From d1be5494b09f4c557390f9087922ebfd9019d531 Mon Sep 17 00:00:00 2001 From: seungho baek Date: Fri, 23 Dec 2022 16:40:31 +0900 Subject: [PATCH] Fix to do not use GetCurrentSize in actor-sizer Change-Id: I75c0502a33dcb67e90092b1a8a92e9cf9f6bbe37 Signed-off-by: seungho baek --- automated-tests/src/dali/utc-Dali-Actor.cpp | 27 +++++++++++++++++++++++++ dali/internal/event/actors/actor-relayouter.cpp | 4 +++- dali/internal/event/actors/actor-relayouter.h | 2 +- dali/internal/event/actors/actor-sizer.cpp | 6 ++++-- dali/internal/event/actors/actor-sizer.h | 11 +++++----- 5 files changed, 41 insertions(+), 9 deletions(-) diff --git a/automated-tests/src/dali/utc-Dali-Actor.cpp b/automated-tests/src/dali/utc-Dali-Actor.cpp index a528eb3..1745226 100644 --- a/automated-tests/src/dali/utc-Dali-Actor.cpp +++ b/automated-tests/src/dali/utc-Dali-Actor.cpp @@ -1155,6 +1155,33 @@ int UtcDaliActorSetSize04(void) END_TEST; } +int UtcDaliActorSetSize05(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + Vector2 vector(200.0f, 200.0f); + DALI_TEST_CHECK(vector != parent.GetCurrentProperty(Actor::Property::SIZE)); + + parent.SetProperty(Actor::Property::SIZE, vector); + Vector2 size = parent.GetProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(size, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + Actor child = Actor::New(); + DALI_TEST_CHECK(vector != child.GetCurrentProperty(Actor::Property::SIZE)); + child.SetProperty(Actor::Property::SIZE, vector); + size = parent.GetProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(size, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(vector == parent.GetCurrentProperty(Actor::Property::SIZE)); + + END_TEST; +} + int UtcDaliActorSetSizeIndividual(void) { TestApplication application; diff --git a/dali/internal/event/actors/actor-relayouter.cpp b/dali/internal/event/actors/actor-relayouter.cpp index 696232d..5f55abe 100644 --- a/dali/internal/event/actors/actor-relayouter.cpp +++ b/dali/internal/event/actors/actor-relayouter.cpp @@ -221,7 +221,7 @@ float ActorSizer::Relayouter::GetMaximumSize(Dimension::Type dimension) const return FLT_MAX; // Default } -void ActorSizer::Relayouter::SetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension, Vector3& targetSize) +void ActorSizer::Relayouter::SetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension, Vector3& targetSize, bool& targetSizeDirtyFlag) { ResizePolicy::Type originalWidthPolicy = GetResizePolicy(Dimension::WIDTH); ResizePolicy::Type originalHeightPolicy = GetResizePolicy(Dimension::HEIGHT); @@ -271,6 +271,7 @@ void ActorSizer::Relayouter::SetResizePolicy(ResizePolicy::Type policy, Dimensio else if(originalWidthPolicy == ResizePolicy::FIXED && policy != ResizePolicy::FIXED) { targetSize.width = preferredSize.width; + targetSizeDirtyFlag = true; } } @@ -283,6 +284,7 @@ void ActorSizer::Relayouter::SetResizePolicy(ResizePolicy::Type policy, Dimensio else if(originalHeightPolicy == ResizePolicy::FIXED && policy != ResizePolicy::FIXED) { targetSize.height = preferredSize.height; + targetSizeDirtyFlag = true; } } } diff --git a/dali/internal/event/actors/actor-relayouter.h b/dali/internal/event/actors/actor-relayouter.h index 73b1f55..716120b 100644 --- a/dali/internal/event/actors/actor-relayouter.h +++ b/dali/internal/event/actors/actor-relayouter.h @@ -70,7 +70,7 @@ struct ActorSizer::Relayouter float GetMaximumSize(Dimension::Type dimension) const; /// @copydoc Actor::SetResizePolicy - void SetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension, Vector3& targetSize); + void SetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension, Vector3& targetSize, bool& targetSizeDirtyFlag); /// @copydoc Actor::GetRelayoutDependentOnDimension bool GetRelayoutDependentOnDimension(Dimension::Type dimension, Dimension::Type dependency); diff --git a/dali/internal/event/actors/actor-sizer.cpp b/dali/internal/event/actors/actor-sizer.cpp index 81e3f4d..93c5216 100644 --- a/dali/internal/event/actors/actor-sizer.cpp +++ b/dali/internal/event/actors/actor-sizer.cpp @@ -78,6 +78,7 @@ ActorSizer::ActorSizer(Internal::Actor& owner) mTargetSize(Vector3::ZERO), mAnimatedSize(Vector3::ZERO), mUseAnimatedSize(AnimatedSizeFlag::CLEAR), + mTargetSizeDirtyFlag(false), mInsideOnSizeSet(false) { } @@ -117,8 +118,9 @@ void ActorSizer::SetSizeInternal(const Vector3& size) // dont allow recursive loop DALI_ASSERT_ALWAYS(!mInsideOnSizeSet && "Cannot call SetSize from OnSizeSet"); // check that we have a node AND the new size width, height or depth is at least a little bit different from the old one - if(mTargetSize != size || mTargetSize != mOwner.GetCurrentSize()) + if(mTargetSize != size || mTargetSizeDirtyFlag) { + mTargetSizeDirtyFlag = false; mTargetSize = size; // Update the preferred size after relayoutting @@ -241,7 +243,7 @@ Vector3 ActorSizer::GetTargetSize() const void ActorSizer::SetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension) { - EnsureRelayouter().SetResizePolicy(policy, dimension, mTargetSize); + EnsureRelayouter().SetResizePolicy(policy, dimension, mTargetSize, mTargetSizeDirtyFlag); mOwner.OnSetResizePolicy(policy, dimension); RelayoutRequest(); } diff --git a/dali/internal/event/actors/actor-sizer.h b/dali/internal/event/actors/actor-sizer.h index 2149694..27ea3f7 100644 --- a/dali/internal/event/actors/actor-sizer.h +++ b/dali/internal/event/actors/actor-sizer.h @@ -355,11 +355,12 @@ private: Vector2 GetPreferredSize() const; private: - Internal::Actor& mOwner; // Owner of this actor sizer - Relayouter* mRelayoutData; ///< Struct to hold optional collection of relayout variables - Dali::Vector3 mTargetSize; ///< Event-side storage for size (not a pointer as most actors will have a size) - Dali::Vector3 mAnimatedSize; ///< Event-side storage for size animation - uint16_t mUseAnimatedSize; ///< Whether the size is animated. + Internal::Actor& mOwner; // Owner of this actor sizer + Relayouter* mRelayoutData; ///< Struct to hold optional collection of relayout variables + Dali::Vector3 mTargetSize; ///< Event-side storage for size (not a pointer as most actors will have a size) + Dali::Vector3 mAnimatedSize; ///< Event-side storage for size animation + uint16_t mUseAnimatedSize; ///< Whether the size is animated. + bool mTargetSizeDirtyFlag; ///< Whether the target size is dirty or not. bool mInsideOnSizeSet : 1; }; -- 2.7.4