From 1e1e7f8cfd444b96ee5605daa2625a6f9212f76f Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Tue, 12 Dec 2023 13:13:19 +0900 Subject: [PATCH] [Tizen] 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 | 21 +++++----- dali/internal/update/common/scene-graph-scene.h | 9 ++-- 7 files changed, 70 insertions(+), 30 deletions(-) diff --git a/automated-tests/src/dali/utc-Dali-Scene.cpp b/automated-tests/src/dali/utc-Dali-Scene.cpp index 959e5ee..b353486 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 b1781a9..dc47c6e 100644 --- a/dali/integration-api/scene.cpp +++ b/dali/integration-api/scene.cpp @@ -194,9 +194,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 5e4a3e4..26f85c8 100644 --- a/dali/integration-api/scene.h +++ b/dali/integration-api/scene.h @@ -345,10 +345,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 d60e48b..f0af146 100644 --- a/dali/internal/event/common/scene-impl.cpp +++ b/dali/internal/event/common/scene-impl.cpp @@ -375,9 +375,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 c431fee..f181a3c 100644 --- a/dali/internal/event/common/scene-impl.h +++ b/dali/internal/event/common/scene-impl.h @@ -227,9 +227,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 198299a..6f6510f 100644 --- a/dali/internal/update/common/scene-graph-scene.cpp +++ b/dali/internal/update/common/scene-graph-scene.cpp @@ -34,8 +34,7 @@ Scene::Scene() mSurfaceRect(), mSurfaceOrientation(0), mScreenOrientation(0), - mSurfaceRectChanged(false), - mRotationCompletedAcknowledgement(false) + mSurfaceRectChangedCount(0u) { } @@ -149,10 +148,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) { @@ -165,16 +164,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; @@ -182,8 +183,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 278d3f8..9cde999 100644 --- a/dali/internal/update/common/scene-graph-scene.h +++ b/dali/internal/update/common/scene-graph-scene.h @@ -195,10 +195,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. @@ -306,8 +307,8 @@ private: Rect mSurfaceRect; ///< The rectangle of surface which is related ot this scene. int32_t mSurfaceOrientation; ///< The orientation of surface which is related of this scene int32_t mScreenOrientation; ///< The orientation of screen - 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. + uint32_t mSurfaceRectChangedCount; ///< The numbero of surface's rectangle is changed when is resized or moved. // Render pass and render target -- 2.7.4