X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fadaptor%2Fcommon%2Fcombined-update-render-controller.cpp;h=4b794ce41a4bbf66a28a0c04d6d0c3b818486cea;hb=3382101c1ce68b0b4f1a3398d977b210bcb58e2f;hp=94693d2056cb1d6c58469dbec3286d648b358333;hpb=7b429f21ec5d2da166967ff07f2cfde4ce4f19e6;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/internal/adaptor/common/combined-update-render-controller.cpp b/dali/internal/adaptor/common/combined-update-render-controller.cpp index 94693d2..4b794ce 100644 --- a/dali/internal/adaptor/common/combined-update-render-controller.cpp +++ b/dali/internal/adaptor/common/combined-update-render-controller.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,15 +23,15 @@ #include // INTERNAL INCLUDES -#include -#include -#include -#include -#include +#include #include +#include +#include #include #include #include +#include +#include namespace Dali { @@ -91,6 +91,7 @@ CombinedUpdateRenderController::CombinedUpdateRenderController( AdaptorInternalS : mFpsTracker( environmentOptions ), mUpdateStatusLogger( environmentOptions ), mEventThreadSemaphore(), + mGraphicsInitializeSemaphore(), mUpdateRenderThreadWaitCondition(), mAdaptorInterfaces( adaptorInterfaces ), mPerformanceInterface( adaptorInterfaces.GetPerformanceInterface() ), @@ -115,7 +116,9 @@ CombinedUpdateRenderController::CombinedUpdateRenderController( AdaptorInternalS mDeletedSurface( nullptr ), mPostRendering( FALSE ), mSurfaceResized( FALSE ), - mForceClear( FALSE ) + mForceClear( FALSE ), + mUploadWithoutRendering( FALSE ), + mFirstFrameAfterResume( FALSE ) { LOG_EVENT_TRACE; @@ -132,7 +135,9 @@ CombinedUpdateRenderController::CombinedUpdateRenderController( AdaptorInternalS TriggerEventFactoryInterface& triggerFactory = mAdaptorInterfaces.GetTriggerEventFactoryInterface(); mSleepTrigger = triggerFactory.CreateTriggerEvent( MakeCallback( this, &CombinedUpdateRenderController::ProcessSleepRequest ), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER ); - sem_init( &mEventThreadSemaphore, 0, 0 ); // Initialize to 0 so that it just waits if sem_post has not been called + // Initialize to 0 so that it just waits if sem_post has not been called + sem_init( &mEventThreadSemaphore, 0, 0 ); + sem_init( &mGraphicsInitializeSemaphore, 0, 0 ); } CombinedUpdateRenderController::~CombinedUpdateRenderController() @@ -183,7 +188,7 @@ void CombinedUpdateRenderController::Start() LOG_EVENT( "Startup Complete, starting Update/Render Thread" ); - RunUpdateRenderThread( CONTINUOUS, false /* No animation progression */ ); + RunUpdateRenderThread( CONTINUOUS, AnimationProgression::NONE, UpdateMode::NORMAL ); DALI_LOG_RELEASE_INFO( "CombinedUpdateRenderController::Start\n" ); } @@ -209,12 +214,13 @@ void CombinedUpdateRenderController::Resume() { LOG_EVENT( "Resuming" ); - RunUpdateRenderThread( CONTINUOUS, true /* Animation progression required while we were paused */ ); + RunUpdateRenderThread( CONTINUOUS, AnimationProgression::USE_ELAPSED_TIME, UpdateMode::NORMAL ); AddPerformanceMarker( PerformanceInterface::RESUME ); mRunning = TRUE; mForceClear = TRUE; + mFirstFrameAfterResume = TRUE; DALI_LOG_RELEASE_INFO( "CombinedUpdateRenderController::Resume\n" ); } @@ -267,14 +273,14 @@ void CombinedUpdateRenderController::RequestUpdate() { LOG_EVENT( "Processing" ); - RunUpdateRenderThread( CONTINUOUS, false /* No animation progression */ ); + RunUpdateRenderThread( CONTINUOUS, AnimationProgression::NONE, UpdateMode::NORMAL ); } ConditionalWait::ScopedLock updateLock( mUpdateRenderThreadWaitCondition ); mPendingRequestUpdate = TRUE; } -void CombinedUpdateRenderController::RequestUpdateOnce() +void CombinedUpdateRenderController::RequestUpdateOnce( UpdateMode updateMode ) { // Increment the update-request count to the maximum if( mUpdateRequestCount < MAXIMUM_UPDATE_REQUESTS ) @@ -287,7 +293,7 @@ void CombinedUpdateRenderController::RequestUpdateOnce() LOG_EVENT_TRACE; // Run Update/Render once - RunUpdateRenderThread( ONCE, false /* No animation progression */ ); + RunUpdateRenderThread( ONCE, AnimationProgression::NONE, updateMode ); } } @@ -340,6 +346,21 @@ void CombinedUpdateRenderController::DeleteSurface( Dali::RenderSurfaceInterface } } +void CombinedUpdateRenderController::WaitForGraphicsInitialization() +{ + LOG_EVENT_TRACE; + + if( mUpdateRenderThread ) + { + LOG_EVENT( "Waiting for graphics initialisation, event-thread blocked" ); + + // Wait until the graphics has been initialised + sem_wait( &mGraphicsInitializeSemaphore ); + + LOG_EVENT( "graphics initialised, event-thread continuing" ); + } +} + void CombinedUpdateRenderController::ResizeSurface() { LOG_EVENT_TRACE; @@ -382,12 +403,13 @@ void CombinedUpdateRenderController::SetPreRenderCallback( CallbackBase* callbac // EVENT THREAD /////////////////////////////////////////////////////////////////////////////////////////////////// -void CombinedUpdateRenderController::RunUpdateRenderThread( int numberOfCycles, bool useElapsedTime ) +void CombinedUpdateRenderController::RunUpdateRenderThread( int numberOfCycles, AnimationProgression animationProgression, UpdateMode updateMode ) { ConditionalWait::ScopedLock lock( mUpdateRenderThreadWaitCondition ); mUpdateRenderRunCount = numberOfCycles; mUpdateRenderThreadCanSleep = FALSE; - mUseElapsedTimeAfterWait = useElapsedTime; + mUseElapsedTimeAfterWait = ( animationProgression == AnimationProgression::USE_ELAPSED_TIME ); + mUploadWithoutRendering = ( updateMode == UpdateMode::SKIP_RENDER ); LOG_COUNTER_EVENT( "mUpdateRenderRunCount: %d, mUseElapsedTimeAfterWait: %d", mUpdateRenderRunCount, mUseElapsedTimeAfterWait ); mUpdateRenderThreadWaitCondition.Notify( lock ); } @@ -453,6 +475,9 @@ void CombinedUpdateRenderController::UpdateRenderThread() Dali::DisplayConnection& displayConnection = mAdaptorInterfaces.GetDisplayConnectionInterface(); displayConnection.Initialize(); + // EGL has been initialised at this point + NotifyGraphicsInitialised(); + RenderSurfaceInterface* currentSurface = nullptr; GraphicsInterface& graphics = mAdaptorInterfaces.GetGraphicsInterface(); @@ -544,15 +569,17 @@ void CombinedUpdateRenderController::UpdateRenderThread() if( DALI_UNLIKELY( newSurface ) ) { LOG_UPDATE_RENDER_TRACE_FMT( "Replacing Surface" ); - // This is designed for replacing pixmap surfaces, but should work for window as well // we need to delete the surface and renderable (pixmap / window) // Then create a new pixmap/window and new surface // If the new surface has a different display connection, then the context will be lost - mAdaptorInterfaces.GetDisplayConnectionInterface().Initialize(); newSurface->InitializeGraphics(); - newSurface->ReplaceGraphicsSurface(); + newSurface->MakeContextCurrent(); + // TODO: ReplaceGraphicsSurface doesn't work, InitializeGraphics() + // already creates new surface window, the surface and the context. + // We probably don't need ReplaceGraphicsSurface at all. + // newSurface->ReplaceGraphicsSurface(); SurfaceReplaced(); } @@ -633,10 +660,18 @@ void CombinedUpdateRenderController::UpdateRenderThread() eglImpl.MakeContextCurrent( EGL_NO_SURFACE, eglImpl.GetContext() ); } + if( mFirstFrameAfterResume ) + { + // mFirstFrameAfterResume is set to true when the thread is resumed + // Let eglImplementation know the first frame after thread initialized or resumed. + eglImpl.SetFirstFrameAfterResume(); + mFirstFrameAfterResume = FALSE; + } + Integration::RenderStatus renderStatus; AddPerformanceMarker( PerformanceInterface::RENDER_START ); - mCore.Render( renderStatus, mForceClear ); + mCore.Render( renderStatus, mForceClear, mUploadWithoutRendering ); ////////////////////////////// // DELETE SURFACE @@ -835,6 +870,11 @@ void CombinedUpdateRenderController::NotifyThreadInitialised() sem_post( &mEventThreadSemaphore ); } +void CombinedUpdateRenderController::NotifyGraphicsInitialised() +{ + sem_post( &mGraphicsInitializeSemaphore ); +} + void CombinedUpdateRenderController::AddPerformanceMarker( PerformanceInterface::MarkerType type ) { if( mPerformanceInterface ) @@ -870,7 +910,6 @@ void CombinedUpdateRenderController::PostRenderWaitForCompletion() while( mPostRendering && ! mNewSurface && // We should NOT wait if we're replacing the surface ! mDeletedSurface && // We should NOT wait if we're deleting the surface - ! mSurfaceResized && // We should NOT wait if we're resizing the surface ! mDestroyUpdateRenderThread ) { mUpdateRenderThreadWaitCondition.Wait( lock );