From 9a0644d6e10782ab0a8a1627e2668aabb3739b80 Mon Sep 17 00:00:00 2001 From: seungho baek Date: Fri, 23 Dec 2022 16:40:31 +0900 Subject: [PATCH] [Tizen] 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 | 29 +++++++++++++++++++++++- dali/internal/event/actors/actor-relayouter.cpp | 10 +++++---- dali/internal/event/actors/actor-relayouter.h | 4 ++-- dali/internal/event/actors/actor-sizer.cpp | 30 +++++-------------------- dali/internal/event/actors/actor-sizer.h | 13 ++++++----- 5 files changed, 49 insertions(+), 37 deletions(-) diff --git a/automated-tests/src/dali/utc-Dali-Actor.cpp b/automated-tests/src/dali/utc-Dali-Actor.cpp index 09ec1a6..969f802 100644 --- a/automated-tests/src/dali/utc-Dali-Actor.cpp +++ b/automated-tests/src/dali/utc-Dali-Actor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -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..bd11187 100644 --- a/dali/internal/event/actors/actor-relayouter.cpp +++ b/dali/internal/event/actors/actor-relayouter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -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); @@ -270,7 +270,8 @@ void ActorSizer::Relayouter::SetResizePolicy(ResizePolicy::Type policy, Dimensio } else if(originalWidthPolicy == ResizePolicy::FIXED && policy != ResizePolicy::FIXED) { - targetSize.width = preferredSize.width; + targetSize.width = preferredSize.width; + targetSizeDirtyFlag = true; } } @@ -282,7 +283,8 @@ void ActorSizer::Relayouter::SetResizePolicy(ResizePolicy::Type policy, Dimensio } else if(originalHeightPolicy == ResizePolicy::FIXED && policy != ResizePolicy::FIXED) { - targetSize.height = preferredSize.height; + 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..2912058 100644 --- a/dali/internal/event/actors/actor-relayouter.h +++ b/dali/internal/event/actors/actor-relayouter.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_ACTOR_RELAYOUTER_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -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 0c06f60..eeee644 100644 --- a/dali/internal/event/actors/actor-sizer.cpp +++ b/dali/internal/event/actors/actor-sizer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -78,6 +78,7 @@ ActorSizer::ActorSizer(Internal::Actor& owner) mTargetSize(Vector3::ZERO), mAnimatedSize(Vector3::ZERO), mUseAnimatedSize(AnimatedSizeFlag::CLEAR), + mTargetSizeDirtyFlag(false), mInsideOnSizeSet(false) { } @@ -117,29 +118,10 @@ 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 - bool changeTargetSize = false; - - if((fabsf(mTargetSize.width - size.width) > Math::MACHINE_EPSILON_1) || - (fabsf(mTargetSize.height - size.height) > Math::MACHINE_EPSILON_1) || - (fabsf(mTargetSize.depth - size.depth) > Math::MACHINE_EPSILON_1)) - { - changeTargetSize = true; - } - else - { - // Check if currentSize it difference with target size. - Vector3 currentSize = mOwner.GetCurrentSize(); - if((fabsf(mTargetSize.width - currentSize.width) > Math::MACHINE_EPSILON_1) || - (fabsf(mTargetSize.height - currentSize.height) > Math::MACHINE_EPSILON_1) || - (fabsf(mTargetSize.depth - currentSize.depth) > Math::MACHINE_EPSILON_1)) - { - changeTargetSize = true; - } - } - - if(changeTargetSize) + if(mTargetSize != size || mTargetSizeDirtyFlag) { - mTargetSize = size; + mTargetSizeDirtyFlag = false; + mTargetSize = size; // Update the preferred size after relayoutting // It should be used in the next relayoutting @@ -261,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..987ce14 100644 --- a/dali/internal/event/actors/actor-sizer.h +++ b/dali/internal/event/actors/actor-sizer.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_ACTOR_SIZER_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -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