From be4cd1a0785c30e2daeb783dc4af62598d2cfe45 Mon Sep 17 00:00:00 2001 From: Heeyong Song Date: Fri, 29 Jun 2018 16:56:22 +0900 Subject: [PATCH] Fix flickering issue when the window is resized A viewport is sometimes changed later because event processing is delayed. Change a render surface size when the viewport is really changed. Change-Id: I530a0160669aaae4eb9de05dab2c16f22c0863b1 --- dali/internal/adaptor/common/adaptor-impl.cpp | 1 - .../common/combined-update-render-controller.cpp | 44 +++++++++------------- 2 files changed, 17 insertions(+), 28 deletions(-) diff --git a/dali/internal/adaptor/common/adaptor-impl.cpp b/dali/internal/adaptor/common/adaptor-impl.cpp index 83d91a1..b660e43 100755 --- a/dali/internal/adaptor/common/adaptor-impl.cpp +++ b/dali/internal/adaptor/common/adaptor-impl.cpp @@ -785,7 +785,6 @@ void Adaptor::SurfaceResizeComplete( SurfaceSize surfaceSize ) // to start processing messages for new camera setup etc as soon as possible ProcessCoreEvents(); - // this method blocks until the render thread has completed the resizing. mThreadController->ResizeSurface(); } diff --git a/dali/internal/adaptor/common/combined-update-render-controller.cpp b/dali/internal/adaptor/common/combined-update-render-controller.cpp index 5af0ca1..eb59399 100644 --- a/dali/internal/adaptor/common/combined-update-render-controller.cpp +++ b/dali/internal/adaptor/common/combined-update-render-controller.cpp @@ -292,20 +292,14 @@ void CombinedUpdateRenderController::ResizeSurface() { LOG_EVENT_TRACE; - LOG_EVENT( "Starting to resize the surface, event-thread blocked" ); + LOG_EVENT( "Resize the surface" ); - // Start resizing the surface. { ConditionalWait::ScopedLock lock( mUpdateRenderThreadWaitCondition ); mPostRendering = FALSE; // Clear the post-rendering flag as Update/Render thread will resize the surface now mSurfaceResized = TRUE; mUpdateRenderThreadWaitCondition.Notify( lock ); } - - // Wait until the surface has been resized - sem_wait( &mEventThreadSemaphore ); - - LOG_EVENT( "Surface resized, event-thread continuing" ); } void CombinedUpdateRenderController::SetRenderRefreshRate( unsigned int numberOfFramesPerRender ) @@ -443,22 +437,9 @@ void CombinedUpdateRenderController::UpdateRenderThread() SurfaceReplaced(); } - ////////////////////////////// - // RESIZE SURFACE - ////////////////////////////// - const bool isRenderingToFbo = renderToFboEnabled && ( ( 0u == frameCount ) || ( 0u != frameCount % renderToFboInterval ) ); ++frameCount; - // The resizing will be applied in the next loop - bool surfaceResized = ShouldSurfaceBeResized(); - if( DALI_UNLIKELY( surfaceResized ) ) - { - LOG_UPDATE_RENDER_TRACE_FMT( "Resizing Surface" ); - mRenderHelper.ResizeSurface(); - SurfaceResized(); - } - ////////////////////////////// // UPDATE ////////////////////////////// @@ -497,6 +478,19 @@ void CombinedUpdateRenderController::UpdateRenderThread() LOG_UPDATE_RENDER( "Notification Triggered" ); } + // Check resize + bool surfaceResized = ShouldSurfaceBeResized(); + if( DALI_UNLIKELY( surfaceResized ) ) + { + // RenderHelper::ResizeSurface() should be called right after a viewport is changed. + if( updateStatus.SurfaceRectChanged() ) + { + LOG_UPDATE_RENDER_TRACE_FMT( "Resizing Surface" ); + mRenderHelper.ResizeSurface(); + SurfaceResized(); + } + } + // Optional logging of update/render status mUpdateStatusLogger.Log( keepUpdatingStatus ); @@ -657,17 +651,13 @@ void CombinedUpdateRenderController::SurfaceReplaced() bool CombinedUpdateRenderController::ShouldSurfaceBeResized() { ConditionalWait::ScopedLock lock( mUpdateRenderThreadWaitCondition ); - - bool surfaceSized = mSurfaceResized; - mSurfaceResized = FALSE; - - return surfaceSized; + return mSurfaceResized; } void CombinedUpdateRenderController::SurfaceResized() { - // Just increment the semaphore - sem_post( &mEventThreadSemaphore ); + ConditionalWait::ScopedLock lock( mUpdateRenderThreadWaitCondition ); + mSurfaceResized = FALSE; } /////////////////////////////////////////////////////////////////////////////////////////////////// -- 2.7.4