Fix rendering occured unlimited if window size changed multiple 81/302681/4
authorEunki, Hong <eunkiki.hong@samsung.com>
Tue, 12 Dec 2023 04:13:19 +0000 (13:13 +0900)
committerEunki Hong <eunkiki.hong@samsung.com>
Thu, 14 Dec 2023 03:52:46 +0000 (03:52 +0000)
To support multi window cases, dali-adaptor count how many times
the window resize event occured.

But in dali-core scene has only bool flag.

So if scene changed multiple times during 1 render time,
surface resized count never be reduced as zero.
So it will keep rendering unlimited.

This patch make we return the number of surface rect changed,
so dali-adaptor can control the scene changed count well.

Change-Id: I35d0bcef3ff33c67f106b276848a2b5a26ccc67c
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
automated-tests/src/dali/utc-Dali-Scene.cpp
dali/integration-api/scene.cpp
dali/integration-api/scene.h
dali/internal/event/common/scene-impl.cpp
dali/internal/event/common/scene-impl.h
dali/internal/update/common/scene-graph-scene.cpp
dali/internal/update/common/scene-graph-scene.h

index 3e6df52..ee5ead4 100644 (file)
@@ -980,7 +980,7 @@ int UtcDaliSceneSurfaceResizedDefaultSceneViewport(void)
   DALI_TEST_CHECK(defaultScene);
 
   // consume the resize flag by first rendering
-  defaultScene.IsSurfaceRectChanged();
+  defaultScene.GetSurfaceRectChangedCount();
 
   // Ensure stage size matches the scene size
   auto stage = Stage::GetCurrent();
@@ -988,10 +988,10 @@ int UtcDaliSceneSurfaceResizedDefaultSceneViewport(void)
 
   Rect<int32_t> surfaceRect = defaultScene.GetCurrentSurfaceRect();
 
-  bool surfaceResized;
+  uint32_t surfaceResized;
   // check resized flag before surface is resized.
-  surfaceResized = defaultScene.IsSurfaceRectChanged();
-  DALI_TEST_EQUALS(surfaceResized, false, TEST_LOCATION);
+  surfaceResized = defaultScene.GetSurfaceRectChangedCount();
+  DALI_TEST_EQUALS(surfaceResized, 0u, TEST_LOCATION);
 
   // Resize the scene
   Vector2     newSize(1000.0f, 2000.0f);
@@ -1012,8 +1012,8 @@ int UtcDaliSceneSurfaceResizedDefaultSceneViewport(void)
   application.SendNotification();
   application.Render(0);
 
-  surfaceResized = defaultScene.IsSurfaceRectChanged();
-  DALI_TEST_EQUALS(surfaceResized, true, TEST_LOCATION);
+  surfaceResized = defaultScene.GetSurfaceRectChangedCount();
+  DALI_TEST_EQUALS(surfaceResized, 1u, TEST_LOCATION);
 
   // Check that the viewport is handled properly
   DALI_TEST_CHECK(callStack.FindIndexFromMethodAndParams("Viewport", viewportParams) >= 0);
@@ -1027,6 +1027,45 @@ int UtcDaliSceneSurfaceResizedDefaultSceneViewport(void)
   DALI_TEST_EQUALS(newSurfaceRect.width, 1000, TEST_LOCATION);
   DALI_TEST_EQUALS(newSurfaceRect.height, 2000, TEST_LOCATION);
 
+  // SurfaceRect should be changed.
+  surfaceRect = newSurfaceRect;
+
+  // Resize the scene multiple times
+  uint32_t resizeCount = 10u;
+
+  for(uint32_t i = 0u; i < resizeCount; ++i)
+  {
+    Vector2 newSize(1000.0f, 2100.0f + i);
+    DALI_TEST_CHECK(stage.GetSize() != newSize);
+    defaultScene.SurfaceResized(newSize.width, newSize.height);
+
+    DALI_TEST_EQUALS(stage.GetSize(), newSize, TEST_LOCATION);
+    DALI_TEST_EQUALS(defaultScene.GetSize(), newSize, TEST_LOCATION);
+
+    // Check current surface rect
+    Rect<int32_t> newSurfaceRect = defaultScene.GetCurrentSurfaceRect();
+
+    // It should not be changed yet.
+    DALI_TEST_CHECK(surfaceRect == newSurfaceRect);
+  }
+
+  // Render after resizing surface
+  application.SendNotification();
+  application.Render(0);
+
+  // Check whether the number of surface resized count get well.
+  surfaceResized = defaultScene.GetSurfaceRectChangedCount();
+  DALI_TEST_EQUALS(surfaceResized, resizeCount, TEST_LOCATION);
+
+  // Check current surface rect
+  newSurfaceRect = defaultScene.GetCurrentSurfaceRect();
+
+  // It should be changed
+  DALI_TEST_EQUALS(newSurfaceRect.x, 0, TEST_LOCATION);
+  DALI_TEST_EQUALS(newSurfaceRect.y, 0, TEST_LOCATION);
+  DALI_TEST_EQUALS(newSurfaceRect.width, 1000, TEST_LOCATION);
+  DALI_TEST_EQUALS(newSurfaceRect.height, 2100 + (resizeCount - 1), TEST_LOCATION);
+
   END_TEST;
 }
 
index 5bf411f..e0d6c4f 100644 (file)
@@ -198,9 +198,9 @@ const Rect<int32_t>& Scene::GetCurrentSurfaceRect() const
   return GetImplementation(*this).GetCurrentSurfaceRect();
 }
 
-bool Scene::IsSurfaceRectChanged() const
+uint32_t Scene::GetSurfaceRectChangedCount() const
 {
-  return GetImplementation(*this).IsSurfaceRectChanged();
+  return GetImplementation(*this).GetSurfaceRectChangedCount();
 }
 
 void Scene::SetRotationCompletedAcknowledgement()
index e0205e3..dbab87d 100644 (file)
@@ -360,10 +360,11 @@ public:
   const Rect<int32_t>& GetCurrentSurfaceRect() const;
 
   /**
-   * Query wheter the surface rect is changed or not.
-   * @return true if the surface rect is changed.
+   * Query how many times the surface rect changed.
+   * @note It will reset surface rect changed count.
+   * @return The count of the surface rect changed.
    */
-  bool IsSurfaceRectChanged() const;
+  uint32_t GetSurfaceRectChangedCount() const;
 
   /**
    * @brief Send message to acknowledge for completing window rotation with current window orientation.
index 8808e2f..304670d 100644 (file)
@@ -382,9 +382,9 @@ void Scene::ChangedSurface(float width, float height, int32_t windowOrientation,
   }
 }
 
-bool Scene::IsSurfaceRectChanged() const
+uint32_t Scene::GetSurfaceRectChangedCount() const
 {
-  return mSceneObject ? mSceneObject->IsSurfaceRectChanged() : false;
+  return mSceneObject ? mSceneObject->GetSurfaceRectChangedCount() : 0u;
 }
 
 bool Scene::IsRotationCompletedAcknowledgementSet() const
index 56b2f7b..edd9c5f 100644 (file)
@@ -233,9 +233,9 @@ public:
   const Rect<int32_t>& GetCurrentSurfaceRect() const;
 
   /**
-   * @copydoc Dali::Integration::Scene::IsSurfaceRectChanged
+   * @copydoc Dali::Integration::Scene::GetSurfaceRectChangedCount
    */
-  bool IsSurfaceRectChanged() const;
+  uint32_t GetSurfaceRectChangedCount() const;
 
   /**
    * @copydoc Dali::Integration::Scene::SetSurfaceRenderTarget
index 7f195af..d30b192 100644 (file)
@@ -33,7 +33,7 @@ Scene::Scene()
   mSurfaceRect(),
   mSurfaceOrientation(0),
   mScreenOrientation(0),
-  mSurfaceRectChanged(false),
+  mSurfaceRectChangedCount(0u),
   mRotationCompletedAcknowledgement(false),
   mSkipRendering(false),
   mNeedFullUpdate(false),
@@ -151,10 +151,10 @@ bool Scene::IsRenderingSkipped() const
 
 void Scene::SetSurfaceRect(const Rect<int32_t>& rect)
 {
-  mSurfaceRect        = rect;
-  mSurfaceRectChanged = true;
+  DALI_LOG_RELEASE_INFO("update surfce rect in scene-graph, from width[%d], height[%d], to width[%d], height[%d]. Changed count [%d]\n", mSurfaceRect.width, mSurfaceRect.height, rect.width, rect.height, mSurfaceRectChangedCount + 1u);
 
-  DALI_LOG_RELEASE_INFO("update surfce rect in scene-graph, width[%d], height[%d]\n", mSurfaceRect.width, mSurfaceRect.height);
+  mSurfaceRect = rect;
+  ++mSurfaceRectChangedCount;
 
   if(mRoot)
   {
@@ -167,16 +167,18 @@ const Rect<int32_t>& Scene::GetSurfaceRect() const
   return mSurfaceRect;
 }
 
-bool Scene::IsSurfaceRectChanged()
+uint32_t Scene::GetSurfaceRectChangedCount()
 {
-  bool surfaceRectChanged = mSurfaceRectChanged;
-  mSurfaceRectChanged     = false;
+  uint32_t surfaceRectChangedCount = mSurfaceRectChangedCount;
+  mSurfaceRectChangedCount         = 0u;
 
-  return surfaceRectChanged;
+  return surfaceRectChangedCount;
 }
 
 void Scene::SetSurfaceOrientations(int32_t windowOrientation, int32_t screenOrienation)
 {
+  DALI_LOG_RELEASE_INFO("update orientation in scene-graph, from surface [%d], screen[%d], to surface [%d], screen[%d]\n", mSurfaceOrientation, mScreenOrientation, windowOrientation, screenOrienation);
+
   mSurfaceOrientation = windowOrientation;
   mScreenOrientation  = screenOrienation;
 
@@ -184,8 +186,6 @@ void Scene::SetSurfaceOrientations(int32_t windowOrientation, int32_t screenOrie
   {
     mRoot->SetUpdated(true);
   }
-
-  DALI_LOG_RELEASE_INFO("update orientation in scene-graph, surface [%d], screen[%d]\n", mSurfaceOrientation, mScreenOrientation);
 }
 
 int32_t Scene::GetSurfaceOrientation() const
index f857467..0e9fab0 100644 (file)
@@ -216,10 +216,11 @@ public:
   int32_t GetScreenOrientation() const;
 
   /**
-   * Query wheter the surface rect is changed or not.
-   * @return true if the surface rect is changed.
+   * Query how many times the surface rect changed.
+   * @note It will reset surface rect changed count.
+   * @return The count of the surface rect changed.
    */
-  bool IsSurfaceRectChanged();
+  uint32_t GetSurfaceRectChangedCount();
 
   /**
    * @brief Set the internal flag to acknowledge surface rotation.
@@ -366,9 +367,10 @@ private:
   int32_t       mSurfaceOrientation; ///< The orientation of surface which is related of this scene
   int32_t       mScreenOrientation;  ///< The orientation of screen
 
+  uint32_t mSurfaceRectChangedCount; ///< The numbero of surface's rectangle is changed when is resized or moved.
+
   float mKeepRenderingSeconds{0.0f}; ///< Time to keep rendering
 
-  bool mSurfaceRectChanged;               ///< The flag of surface's rectangle is changed when is resized or moved.
   bool mRotationCompletedAcknowledgement; ///< The flag of sending the acknowledgement to complete window rotation.
   bool mSkipRendering;                    ///< A flag to skip rendering
   bool mNeedFullUpdate;                   ///< A flag to update full area