From d6f00e49197d6afa320764f49eebd4e6e4f15771 Mon Sep 17 00:00:00 2001 From: Wonsik Jung Date: Fri, 11 Dec 2020 20:43:33 +0900 Subject: [PATCH] Fix the synchronization issue when window is resized or rotated Window position, size and rotaton angle information are in both main and update thread. To complete the works, the information should be synchronized in both main and update thread. In addition, when multiple windows works and one of them resized or rotated, all windows are resized or rotated. For fixing them, this patch has the informations are in the related modules (as Intergration::Scene, SceneGraph::Scene ... ) and are compared. Change-Id: I03a25da7e42b0ab1133401017346e823e019e160 --- .../common/combined-update-render-controller.cpp | 46 ++++++++++------------ .../common/combined-update-render-controller.h | 8 ---- 2 files changed, 21 insertions(+), 33 deletions(-) diff --git a/dali/internal/adaptor/common/combined-update-render-controller.cpp b/dali/internal/adaptor/common/combined-update-render-controller.cpp index 2076d17..2f970cb 100644 --- a/dali/internal/adaptor/common/combined-update-render-controller.cpp +++ b/dali/internal/adaptor/common/combined-update-render-controller.cpp @@ -115,7 +115,7 @@ CombinedUpdateRenderController::CombinedUpdateRenderController(AdaptorInternalSe mNewSurface(NULL), mDeletedSurface(nullptr), mPostRendering(FALSE), - mSurfaceResized(FALSE), + mSurfaceResized(0), mForceClear(FALSE), mUploadWithoutRendering(FALSE), mFirstFrameAfterResume(FALSE) @@ -366,8 +366,9 @@ void CombinedUpdateRenderController::ResizeSurface() { ConditionalWait::ScopedLock lock(mUpdateRenderThreadWaitCondition); - mPostRendering = FALSE; // Clear the post-rendering flag as Update/Render thread will resize the surface now - mSurfaceResized = TRUE; + mPostRendering = FALSE; // Clear the post-rendering flag as Update/Render thread will resize the surface now + // Surface is resized and the surface resized count is increased. + mSurfaceResized++; mUpdateRenderThreadWaitCondition.Notify(lock); } } @@ -633,19 +634,6 @@ void CombinedUpdateRenderController::UpdateRenderThread() LOG_UPDATE_RENDER("Notification Triggered"); } - // Check resize - bool surfaceResized = false; - bool shouldSurfaceBeResized = ShouldSurfaceBeResized(); - if(DALI_UNLIKELY(shouldSurfaceBeResized)) - { - if(updateStatus.SurfaceRectChanged()) - { - LOG_UPDATE_RENDER_TRACE_FMT("Resizing Surface"); - SurfaceResized(); - surfaceResized = true; - } - } - // Optional logging of update/render status mUpdateStatusLogger.Log(keepUpdatingStatus); @@ -688,6 +676,8 @@ void CombinedUpdateRenderController::UpdateRenderThread() WindowContainer windows; mAdaptorInterfaces.GetWindowContainerInterface(windows); + bool sceneSurfaceResized; + for(auto&& window : windows) { Dali::Integration::Scene scene = window->GetScene(); @@ -697,6 +687,9 @@ void CombinedUpdateRenderController::UpdateRenderThread() { Integration::RenderStatus windowRenderStatus; + // Get Surface Resized flag + sceneSurfaceResized = scene.IsSurfaceRectChanged(); + windowSurface->InitializeGraphics(); // clear previous frame damaged render items rects, buffer history is tracked on surface level @@ -711,7 +704,7 @@ void CombinedUpdateRenderController::UpdateRenderThread() Rect clippingRect; // Empty for fbo rendering // Switch to the context of the surface, merge damaged areas for previous frames - windowSurface->PreRender(surfaceResized, mDamagedRects, clippingRect); // Switch GL context + windowSurface->PreRender(sceneSurfaceResized, mDamagedRects, clippingRect); // Switch GL context if(clippingRect.IsEmpty()) { @@ -723,7 +716,13 @@ void CombinedUpdateRenderController::UpdateRenderThread() if(windowRenderStatus.NeedsPostRender()) { - windowSurface->PostRender(false, false, surfaceResized, mDamagedRects); // Swap Buffer with damage + windowSurface->PostRender(false, false, sceneSurfaceResized, mDamagedRects); // Swap Buffer with damage + } + + // If surface is resized, the surface resized count is decreased. + if(DALI_UNLIKELY(sceneSurfaceResized)) + { + SurfaceResized(); } } } @@ -912,16 +911,13 @@ void CombinedUpdateRenderController::SurfaceDeleted() mSurfaceSemaphore.Release(1); } -bool CombinedUpdateRenderController::ShouldSurfaceBeResized() -{ - ConditionalWait::ScopedLock lock(mUpdateRenderThreadWaitCondition); - return mSurfaceResized; -} - void CombinedUpdateRenderController::SurfaceResized() { ConditionalWait::ScopedLock lock(mUpdateRenderThreadWaitCondition); - mSurfaceResized = FALSE; + if(mSurfaceResized) + { + mSurfaceResized--; + } } /////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/dali/internal/adaptor/common/combined-update-render-controller.h b/dali/internal/adaptor/common/combined-update-render-controller.h index 8c2da95..612967f 100644 --- a/dali/internal/adaptor/common/combined-update-render-controller.h +++ b/dali/internal/adaptor/common/combined-update-render-controller.h @@ -266,14 +266,6 @@ private: void SurfaceDeleted(); /** - * Checks to see if the surface needs to be resized. - * This will lock the mutex in mUpdateRenderThreadWaitCondition. - * - * @return true if the surface should be resized, false otherwise - */ - bool ShouldSurfaceBeResized(); - - /** * Called by the Update/Render thread after a surface has been resized. * * This will lock the mutex in mEventThreadWaitCondition -- 2.7.4