mPendingRequestUpdate( FALSE ),
mUseElapsedTimeAfterWait( FALSE ),
mNewSurface( NULL ),
- mDeletedSurface( nullptr ),
mPostRendering( FALSE ),
mSurfaceResized( FALSE ),
mForceClear( FALSE ),
mUploadWithoutRendering( FALSE ),
- mFirstFrameAfterResume( FALSE )
+ mFirstFrameAfterResume( FALSE ),
+ mIsRenderingWindows( false )
{
LOG_EVENT_TRACE;
}
}
-void CombinedUpdateRenderController::DeleteSurface( Dali::RenderSurfaceInterface* surface )
-{
- LOG_EVENT_TRACE;
-
- if( mUpdateRenderThread )
- {
- LOG_EVENT( "Starting to delete the surface, event-thread blocked" );
-
- // Start replacing the surface.
- {
- ConditionalWait::ScopedLock lock( mUpdateRenderThreadWaitCondition );
- mPostRendering = FALSE; // Clear the post-rendering flag as Update/Render thread will delete the surface now
- mDeletedSurface = surface;
- mUpdateRenderThreadWaitCondition.Notify( lock );
- }
-
- // Wait until the surface has been deleted
- sem_wait( &mEventThreadSemaphore );
-
- LOG_EVENT( "Surface deleted, event-thread continuing" );
- }
-}
-
void CombinedUpdateRenderController::WaitForGraphicsInitialization()
{
LOG_EVENT_TRACE;
AddPerformanceMarker( PerformanceInterface::RENDER_START );
+ mIsRenderingWindows = true;
+
// Upload shared resources
mCore.PreRender( renderStatus, mForceClear, mUploadWithoutRendering );
for( auto&& window : windows )
{
- Dali::Integration::Scene scene = window->GetScene();
- Dali::RenderSurfaceInterface* windowSurface = window->GetSurface();
-
- if ( scene && windowSurface )
+ if ( window && !window->IsBeingDeleted() )
{
- windowSurface->InitializeGraphics();
+ Dali::Integration::Scene scene = window->GetScene();
+ Dali::RenderSurfaceInterface* windowSurface = window->GetSurface();
- // Render off-screen frame buffers first if any
- mCore.RenderScene( scene, true );
+ if ( scene && windowSurface )
+ {
+ windowSurface->InitializeGraphics();
- // Switch to the EGL context of the surface
- windowSurface->PreRender( surfaceResized ); // Switch GL context
+ // Render off-screen frame buffers first if any
+ mCore.RenderScene( scene, true );
- // Render the surface
- mCore.RenderScene( scene, false );
+ // Switch to the EGL context of the surface
+ windowSurface->PreRender( surfaceResized ); // Switch GL context
- windowSurface->PostRender( false, false, surfaceResized ); // Swap Buffer
+ // Render the surface
+ mCore.RenderScene( scene, false );
+
+ windowSurface->PostRender( false, false, surfaceResized ); // Swap Buffer
+ }
}
}
}
mCore.PostRender( mUploadWithoutRendering );
- //////////////////////////////
- // DELETE SURFACE
- //////////////////////////////
-
- Dali::RenderSurfaceInterface* deletedSurface = ShouldSurfaceBeDeleted();
- if( DALI_UNLIKELY( deletedSurface ) )
- {
- LOG_UPDATE_RENDER_TRACE_FMT( "Deleting Surface" );
-
- deletedSurface->DestroySurface();
-
- SurfaceDeleted();
- }
+ mIsRenderingWindows = false;
AddPerformanceMarker( PerformanceInterface::RENDER_END );
( mUpdateRenderThreadCanSleep && ! updateRequired && ! mPendingRequestUpdate ) ) && // Ensure we wait if we're supposed to be sleeping AND do not require another update
! mDestroyUpdateRenderThread && // Ensure we don't wait if the update-render-thread is supposed to be destroyed
! mNewSurface && // Ensure we don't wait if we need to replace the surface
- ! mDeletedSurface && // Ensure we don't wait if we need to delete the surface
! mSurfaceResized ) // Ensure we don't wait if we need to resize the surface
{
LOG_UPDATE_RENDER( "WAIT: mUpdateRenderRunCount: %d", mUpdateRenderRunCount );
LOG_UPDATE_RENDER( " mUpdateRenderThreadCanSleep: %d, updateRequired: %d, mPendingRequestUpdate: %d", mUpdateRenderThreadCanSleep, updateRequired, mPendingRequestUpdate );
LOG_UPDATE_RENDER( " mDestroyUpdateRenderThread: %d", mDestroyUpdateRenderThread );
LOG_UPDATE_RENDER( " mNewSurface: %d", mNewSurface );
- LOG_UPDATE_RENDER( " mDeletedSurface: %d", mDeletedSurface );
LOG_UPDATE_RENDER( " mSurfaceResized: %d", mSurfaceResized );
// Reset the time when the thread is waiting, so the sleep-until time for
LOG_COUNTER_UPDATE_RENDER( "mUpdateRenderThreadCanSleep: %d, updateRequired: %d, mPendingRequestUpdate: %d", mUpdateRenderThreadCanSleep, updateRequired, mPendingRequestUpdate );
LOG_COUNTER_UPDATE_RENDER( "mDestroyUpdateRenderThread: %d", mDestroyUpdateRenderThread );
LOG_COUNTER_UPDATE_RENDER( "mNewSurface: %d", mNewSurface );
- LOG_COUNTER_UPDATE_RENDER( "mDeletedSurface: %d", mDeletedSurface );
LOG_COUNTER_UPDATE_RENDER( "mSurfaceResized: %d", mSurfaceResized );
mUseElapsedTimeAfterWait = FALSE;
sem_post( &mEventThreadSemaphore );
}
-Dali::RenderSurfaceInterface* CombinedUpdateRenderController::ShouldSurfaceBeDeleted()
-{
- ConditionalWait::ScopedLock lock( mUpdateRenderThreadWaitCondition );
-
- Dali::RenderSurfaceInterface* deletedSurface = mDeletedSurface;
- mDeletedSurface = NULL;
-
- return deletedSurface;
-}
-
-void CombinedUpdateRenderController::SurfaceDeleted()
-{
- // Just increment the semaphore
- sem_post( &mEventThreadSemaphore );
-}
-
bool CombinedUpdateRenderController::ShouldSurfaceBeResized()
{
ConditionalWait::ScopedLock lock( mUpdateRenderThreadWaitCondition );
ConditionalWait::ScopedLock lock( mUpdateRenderThreadWaitCondition );
while( mPostRendering &&
! mNewSurface && // We should NOT wait if we're replacing the surface
- ! mDeletedSurface && // We should NOT wait if we're deleting the surface
! mDestroyUpdateRenderThread )
{
mUpdateRenderThreadWaitCondition.Wait( lock );
virtual void ReplaceSurface( Dali::RenderSurfaceInterface* surface );
/**
- * @copydoc ThreadControllerInterface::DeleteSurface()
- */
- virtual void DeleteSurface( Dali::RenderSurfaceInterface* surface );
-
- /**
* @copydoc ThreadControllerInterface::ResizeSurface()
*/
virtual void ResizeSurface();
*/
virtual void AddSurface( Dali::RenderSurfaceInterface* surface );
+ /**
+ * @copydoc ThreadControllerInterface::IsRenderingWindows()
+ */
+ bool IsRenderingWindows() const override { return mIsRenderingWindows; }
+
private:
// Undefined copy constructor.
void SurfaceReplaced();
/**
- * Checks to see if the surface needs to be deleted.
- * This will lock the mutex in mUpdateRenderThreadWaitCondition.
- *
- * @return Pointer to the deleted surface, nullptr otherwise
- */
- Dali::RenderSurfaceInterface* ShouldSurfaceBeDeleted();
-
- /**
- * Called by the Update/Render thread after a surface has been deleted.
- *
- * This will lock the mutex in mEventThreadWaitCondition
- */
- void SurfaceDeleted();
-
- /**
* Checks to see if the surface needs to be resized.
* This will lock the mutex in mUpdateRenderThreadWaitCondition.
*
volatile unsigned int mUseElapsedTimeAfterWait; ///< Whether we should use the elapsed time after waiting (set by the event-thread, read by the update-render-thread).
Dali::RenderSurfaceInterface* volatile mNewSurface; ///< Will be set to the new-surface if requested (set by the event-thread, read & cleared by the update-render thread).
- Dali::RenderSurfaceInterface* volatile mDeletedSurface; ///< Will be set to the deleted surface if requested (set by the event-thread, read & cleared by the update-render thread).
volatile unsigned int mPostRendering; ///< Whether post-rendering is taking place (set by the event & render threads, read by the render-thread).
volatile unsigned int mSurfaceResized; ///< Will be set to resize the surface (set by the event-thread, read & cleared by the update-render thread).
volatile unsigned int mUploadWithoutRendering; ///< Will be set to upload the resource only (with no rendering)
volatile unsigned int mFirstFrameAfterResume; ///< Will be set to check the first frame after resume (for log)
+
+ std::atomic<bool> mIsRenderingWindows; ///< This is set only from the render thread and read only from the event thread
};
} // namespace Adaptor