Fix the synchronization issue when window is resized or rotated 38/249438/8
authorWonsik Jung <sidein@samsung.com>
Fri, 11 Dec 2020 11:43:33 +0000 (20:43 +0900)
committerWonsik Jung <sidein@samsung.com>
Sat, 23 Jan 2021 23:25:38 +0000 (08:25 +0900)
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

dali/internal/adaptor/common/combined-update-render-controller.cpp
dali/internal/adaptor/common/combined-update-render-controller.h

index 2076d17..2f970cb 100644 (file)
@@ -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<int> 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--;
+  }
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
index 8c2da95..612967f 100644 (file)
@@ -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