From f47591e8f537b953c5c2de08d100633d22ef5faa Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Tue, 12 Dec 2023 13:13:19 +0900 Subject: [PATCH] Fix rendering occured unlimited if window size changed multiple 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 --- automated-tests/src/dali/utc-Dali-Scene.cpp | 51 ++++++++++++++++++++--- dali/integration-api/scene.cpp | 4 +- dali/integration-api/scene.h | 7 ++-- dali/internal/event/common/scene-impl.cpp | 4 +- dali/internal/event/common/scene-impl.h | 4 +- dali/internal/update/common/scene-graph-scene.cpp | 20 ++++----- dali/internal/update/common/scene-graph-scene.h | 10 +++-- 7 files changed, 71 insertions(+), 29 deletions(-) diff --git a/automated-tests/src/dali/utc-Dali-Scene.cpp b/automated-tests/src/dali/utc-Dali-Scene.cpp index 3e6df52..ee5ead4 100644 --- a/automated-tests/src/dali/utc-Dali-Scene.cpp +++ b/automated-tests/src/dali/utc-Dali-Scene.cpp @@ -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 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 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; } diff --git a/dali/integration-api/scene.cpp b/dali/integration-api/scene.cpp index 5bf411f..e0d6c4f 100644 --- a/dali/integration-api/scene.cpp +++ b/dali/integration-api/scene.cpp @@ -198,9 +198,9 @@ const Rect& 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() diff --git a/dali/integration-api/scene.h b/dali/integration-api/scene.h index e0205e3..dbab87d 100644 --- a/dali/integration-api/scene.h +++ b/dali/integration-api/scene.h @@ -360,10 +360,11 @@ public: const Rect& 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. diff --git a/dali/internal/event/common/scene-impl.cpp b/dali/internal/event/common/scene-impl.cpp index 8808e2f..304670d 100644 --- a/dali/internal/event/common/scene-impl.cpp +++ b/dali/internal/event/common/scene-impl.cpp @@ -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 diff --git a/dali/internal/event/common/scene-impl.h b/dali/internal/event/common/scene-impl.h index 56b2f7b..edd9c5f 100644 --- a/dali/internal/event/common/scene-impl.h +++ b/dali/internal/event/common/scene-impl.h @@ -233,9 +233,9 @@ public: const Rect& GetCurrentSurfaceRect() const; /** - * @copydoc Dali::Integration::Scene::IsSurfaceRectChanged + * @copydoc Dali::Integration::Scene::GetSurfaceRectChangedCount */ - bool IsSurfaceRectChanged() const; + uint32_t GetSurfaceRectChangedCount() const; /** * @copydoc Dali::Integration::Scene::SetSurfaceRenderTarget diff --git a/dali/internal/update/common/scene-graph-scene.cpp b/dali/internal/update/common/scene-graph-scene.cpp index 7f195af..d30b192 100644 --- a/dali/internal/update/common/scene-graph-scene.cpp +++ b/dali/internal/update/common/scene-graph-scene.cpp @@ -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& 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& 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 diff --git a/dali/internal/update/common/scene-graph-scene.h b/dali/internal/update/common/scene-graph-scene.h index f857467..0e9fab0 100644 --- a/dali/internal/update/common/scene-graph-scene.h +++ b/dali/internal/update/common/scene-graph-scene.h @@ -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 -- 2.7.4