From: Eunki Hong Date: Fri, 7 Jun 2024 08:26:06 +0000 (+0900) Subject: [Tizen] Call ResetToBaseValue only 1 times per PropertyBase X-Git-Tag: accepted/tizen/8.0/unified/20240612.161755^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F81%2F312581%2F1;p=platform%2Fcore%2Fuifw%2Fdali-core.git [Tizen] Call ResetToBaseValue only 1 times per PropertyBase If multiple animation try to change single property, the dirty flag of PropertyBase would not be works well. To ensure the dirty flag, let we collect resetter required properties into single container, and call ResetToBaseValue only one times. It will ensure that we call the resetter only 1 times per 1 frame. Change-Id: I1a3792993f2ef681399f72f6f1718731408f2128 Signed-off-by: Eunki Hong --- diff --git a/dali/internal/update/common/node-resetter.h b/dali/internal/update/common/node-resetter.h index f3a4142..6d78d6d 100644 --- a/dali/internal/update/common/node-resetter.h +++ b/dali/internal/update/common/node-resetter.h @@ -70,10 +70,9 @@ public: } /** - * Reset the node properties to their base values if the node is still alive and on stage - * @param[in] updateBufferIndex the current buffer index + * Request to reset the node properties to their base values if the node is still alive and on stage */ - void ResetToBaseValue(BufferIndex updateBufferIndex) + void RequestResetToBaseValues() { if(mNode != nullptr && mActive) { @@ -82,8 +81,8 @@ public: // property values are set appropriately. --mActive; - mNode->mVisible.ResetToBaseValue(updateBufferIndex); - mNode->mColor.ResetToBaseValue(updateBufferIndex); + mNode->mVisible.RequestResetToBaseValue(); + mNode->mColor.RequestResetToBaseValue(); } }; @@ -159,9 +158,10 @@ protected: mNode->mColor.MarkAsDirty(); } - Node* mNode; ///< The node that owns the properties - int8_t mActive; ///< 2 if active, 1 if aging, 0 if stopped - bool mDisconnected; ///< True if the node has been disconnected + Node* mNode; ///< The node that owns the properties + + uint8_t mActive : 2; ///< 2 if active, 1 if aging, 0 if stopped + bool mDisconnected : 1; ///< True if the node has been disconnected }; } // namespace SceneGraph diff --git a/dali/internal/update/common/property-base.cpp b/dali/internal/update/common/property-base.cpp index 3f9b337..99ab4cd 100644 --- a/dali/internal/update/common/property-base.cpp +++ b/dali/internal/update/common/property-base.cpp @@ -18,15 +18,40 @@ // CLASS HEADER #include +// INTERNAL INCLUDES +#include ///< For RequestPropertyBaseResetToBaseValue + namespace Dali { namespace Internal { namespace SceneGraph { -PropertyBase::PropertyBase() = default; +namespace +{ +ResetterManager* gResetterManager = nullptr; +} // unnamed namespace + +void PropertyBase::RegisterResetterManager(ResetterManager& manager) +{ + DALI_ASSERT_ALWAYS(gResetterManager == nullptr && "PropertyBase::RegisterResetterManager called twice!"); + + gResetterManager = &manager; +} + +void PropertyBase::UnregisterResetterManager() +{ + DALI_ASSERT_ALWAYS(gResetterManager && "PropertyBase::RegisterResetterManager not be called before!"); + + gResetterManager = nullptr; +} + +void PropertyBase::RequestResetToBaseValue() +{ + DALI_ASSERT_ALWAYS(gResetterManager && "PropertyBase::RequestResetToBaseValue called without RegisterResetterManager!!"); -PropertyBase::~PropertyBase() = default; + gResetterManager->RequestPropertyBaseResetToBaseValue(this); +} } // namespace SceneGraph diff --git a/dali/internal/update/common/property-base.h b/dali/internal/update/common/property-base.h index f21eb93..7636ae7 100644 --- a/dali/internal/update/common/property-base.h +++ b/dali/internal/update/common/property-base.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_SCENE_GRAPH_PROPERTY_BASE_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -33,6 +33,8 @@ namespace Internal { namespace SceneGraph { +class ResetterManager; + /** * Polymorphic base class for scene-graph properties, held by Nodes etc. */ @@ -42,12 +44,29 @@ public: /** * Default constructor. */ - PropertyBase(); + PropertyBase() = default; /** * Virtual destructor. */ - ~PropertyBase() override; + ~PropertyBase() = default; + + /** + * @brief Registers a resetter manager for whole property bases. + * + * @param [in] manager The manager to register. + */ + static void RegisterResetterManager(ResetterManager& manager); + + /** + * @brief Unregisters a resetter manager. + */ + static void UnregisterResetterManager(); + + /** + * @brief Request to reset the property to a base value to registered ResetterManager. + */ + void RequestResetToBaseValue(); /** * Reset the property to a base value; only required if the property is animated. diff --git a/dali/internal/update/common/property-resetter.h b/dali/internal/update/common/property-resetter.h index 833be60..a850479 100644 --- a/dali/internal/update/common/property-resetter.h +++ b/dali/internal/update/common/property-resetter.h @@ -46,9 +46,12 @@ public: */ ~PropertyResetterBase() override { - if(mPropertyOwner != nullptr) + if(DALI_LIKELY(mInitialized)) { - mPropertyOwner->RemoveObserver(*this); + if(mPropertyOwner != nullptr) + { + mPropertyOwner->RemoveObserver(*this); + } } } @@ -59,15 +62,15 @@ public: */ void Initialize() { + mInitialized = true; mPropertyOwner->AddObserver(*this); mPropertyOwner->SetUpdated(true); } /** - * Reset the property to it's base value if the property owner is still alive and on stage - * @param[in] updateBufferIndex the current buffer index + * Request to reset the property to it's base value if the property owner is still alive and on stage */ - virtual void ResetToBaseValue(BufferIndex updateBufferIndex) + virtual void RequestResetToBaseValues() { if(mPropertyOwner != nullptr && mActive) { @@ -79,7 +82,10 @@ public: --mActive; } - mBaseProperty->ResetToBaseValue(updateBufferIndex); + if(DALI_LIKELY(mBaseProperty)) + { + mBaseProperty->RequestResetToBaseValue(); + } } }; @@ -162,15 +168,18 @@ protected: mBaseProperty(baseProperty), mRunning(ACTIVE), mActive(ACTIVE), + mInitialized(false), mDisconnected(false) { } PropertyOwner* mPropertyOwner; ///< The property owner PropertyBase* mBaseProperty; ///< The base property being animated or constrained - int8_t mRunning; ///< Used to determine if we should finish or not, 2 if running, 1 if aging, 0 if stopped - int8_t mActive; ///< 2 if active, 1 if aging, 0 if stopped - bool mDisconnected; ///< True if the property owner has been disconnected + + int8_t mRunning; ///< Used to determine if we should finish or not, 2 if running, 1 if aging, 0 if stopped + int8_t mActive; ///< 2 if active, 1 if aging, 0 if stopped + bool mInitialized : 1; + bool mDisconnected : 1; ///< True if the property owner has been disconnected }; class BakerResetter : public PropertyResetterBase @@ -218,19 +227,21 @@ public: ~BakerResetter() override = default; /** - * @param updateBufferIndex + * @copydoc Dali::Internal::SceneGraph::PropertyResetterBase::RequestResetToBaseValues */ - void ResetToBaseValue(BufferIndex updateBufferIndex) override + void RequestResetToBaseValues() override { if(mPropertyOwner && mRunning > 0) { - mRunning--; - mBaseProperty->ResetToBaseValue(updateBufferIndex); - + --mRunning; if(mRunning > 0) { mPropertyOwner->SetUpdated(true); } + if(DALI_LIKELY(mBaseProperty)) + { + mBaseProperty->RequestResetToBaseValue(); + } } } }; diff --git a/dali/internal/update/common/renderer-resetter.h b/dali/internal/update/common/renderer-resetter.h index fae6dc5..88a1b4e 100644 --- a/dali/internal/update/common/renderer-resetter.h +++ b/dali/internal/update/common/renderer-resetter.h @@ -70,10 +70,9 @@ public: } /** - * Reset the renderer properties to their base values if the renderer is still alive and on stage - * @param[in] updateBufferIndex the current buffer index + * Request to reset the renderer properties to their base values if the renderer is still alive and on stage */ - void ResetToBaseValue(BufferIndex updateBufferIndex) + void RequestResetToBaseValues() { if(mRenderer != nullptr && mActive) { @@ -82,7 +81,7 @@ public: // initialized case. --mActive; - mRenderer->ResetToBaseValues(updateBufferIndex); + mRenderer->RequestResetToBaseValues(); } }; diff --git a/dali/internal/update/common/resetter-manager.h b/dali/internal/update/common/resetter-manager.h index 66f31f2..e155009 100644 --- a/dali/internal/update/common/resetter-manager.h +++ b/dali/internal/update/common/resetter-manager.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_SCENEGRAPH_RESETTER_MANAGER_H /* - * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -52,6 +52,12 @@ public: */ virtual void AddRendererResetter(const Renderer& renderer) = 0; + /** + * @brief Request to reset base value. + * @param[in] propertyBase The property base to reset. + */ + virtual void RequestPropertyBaseResetToBaseValue(PropertyBase* propertyBase) = 0; + protected: /** * Destructor. Protected as no derived class should ever be deleted diff --git a/dali/internal/update/manager/resetter-container.h b/dali/internal/update/manager/resetter-container.h index 2a88d88..a383975 100644 --- a/dali/internal/update/manager/resetter-container.h +++ b/dali/internal/update/manager/resetter-container.h @@ -154,13 +154,12 @@ public: } /** - * Iterate over the container, resetting all the referenced + * Iterate over the container, request to resetting all the referenced * properties. If a resetter has finished (e.g. it's animation / * constraint has ended, or it's baked 2 values), then it is removed * from the list. - * @param[in] bufferIndex The buffer index of the property to be reset */ - void ResetToBaseValues(BufferIndex bufferIndex) + void RequestResetToBaseValues() { if(!mContainer.empty()) { @@ -168,7 +167,7 @@ public: auto iter = mContainer.begin(); while(iter != end) { - (*iter)->ResetToBaseValue(bufferIndex); + (*iter)->RequestResetToBaseValues(); if((*iter)->IsFinished()) { iter = EraseObject(iter); diff --git a/dali/internal/update/manager/update-manager.cpp b/dali/internal/update/manager/update-manager.cpp index d279c55..b15ed31 100644 --- a/dali/internal/update/manager/update-manager.cpp +++ b/dali/internal/update/manager/update-manager.cpp @@ -18,6 +18,9 @@ // CLASS HEADER #include +// EXTERNAL INCLUDES +#include + // INTERNAL INCLUDES #include #include @@ -291,6 +294,9 @@ struct UpdateManager::Impl ResetterContainer nodeResetters; ///< A container of node resetters ResetterContainer rendererResetters; ///< A container of renderer resetters + using PropertyBaseResetRequestedContainer = std::unordered_set; + PropertyBaseResetRequestedContainer resetRequestedPropertyBases; ///< A container of property base to be resets + OwnerContainer animations; ///< A container of owned animations OwnerContainer propertyNotifications; ///< A container of owner property notifications. OwnerKeyContainer renderers; ///< A container of owned renderers @@ -340,6 +346,8 @@ UpdateManager::UpdateManager(NotificationManager& notificationManager, RenderTaskProcessor& renderTaskProcessor) : mImpl(nullptr) { + PropertyBase::RegisterResetterManager(*this); + mImpl = new Impl(notificationManager, animationFinishedNotifier, propertyNotifier, @@ -353,6 +361,7 @@ UpdateManager::UpdateManager(NotificationManager& notificationManager, UpdateManager::~UpdateManager() { delete mImpl; + PropertyBase::UnregisterResetterManager(); } void UpdateManager::InstallRoot(OwnerPointer& layer) @@ -642,6 +651,11 @@ void UpdateManager::AddRendererResetter(const Renderer& renderer) mImpl->rendererResetters.PushBack(rendererResetter.Release()); } +void UpdateManager::RequestPropertyBaseResetToBaseValue(PropertyBase* propertyBase) +{ + mImpl->resetRequestedPropertyBases.insert(propertyBase); +} + void UpdateManager::AddPropertyNotification(OwnerPointer& propertyNotification) { mImpl->propertyNotifications.PushBack(propertyNotification.Release()); @@ -778,10 +792,16 @@ void UpdateManager::ResetProperties(BufferIndex bufferIndex) // Age down discard animations. mImpl->discardAnimationFinishedAge >>= 1; + // Ensure that their was no request to reset to base values during the previous update + // (Since requested property base doesn't consider the lifecycle of PropertyBase, + // It might be invalid after the previous update finished) + DALI_ASSERT_DEBUG(mImpl->resetRequestedPropertyBases.empty() && "Reset to base values requested during the previous update!"); + mImpl->resetRequestedPropertyBases.clear(); + if(mImpl->nodeResetters.Count() > 0u) { // Reset node properties - mImpl->nodeResetters.ResetToBaseValues(bufferIndex); + mImpl->nodeResetters.RequestResetToBaseValues(); #ifdef TRACE_ENABLED if(gTraceFilter && gTraceFilter->IsTraceEnabled()) { @@ -793,7 +813,7 @@ void UpdateManager::ResetProperties(BufferIndex bufferIndex) if(mImpl->rendererResetters.Count() > 0u) { // Reset renderer properties - mImpl->rendererResetters.ResetToBaseValues(bufferIndex); + mImpl->rendererResetters.RequestResetToBaseValues(); #ifdef TRACE_ENABLED if(gTraceFilter && gTraceFilter->IsTraceEnabled()) { @@ -805,7 +825,7 @@ void UpdateManager::ResetProperties(BufferIndex bufferIndex) if(mImpl->propertyResetters.Count() > 0u) { // Reset all animating / constrained properties - mImpl->propertyResetters.ResetToBaseValues(bufferIndex); + mImpl->propertyResetters.RequestResetToBaseValues(); #ifdef TRACE_ENABLED if(gTraceFilter && gTraceFilter->IsTraceEnabled()) { @@ -814,6 +834,14 @@ void UpdateManager::ResetProperties(BufferIndex bufferIndex) #endif } + // Actual reset to base values here + for(auto&& propertyBase : mImpl->resetRequestedPropertyBases) + { + propertyBase->ResetToBaseValue(bufferIndex); + } + mImpl->resetRequestedPropertyBases.clear(); + mImpl->resetRequestedPropertyBases.rehash(0u); + // Clear all root nodes dirty flags for(auto& scene : mImpl->scenes) { diff --git a/dali/internal/update/manager/update-manager.h b/dali/internal/update/manager/update-manager.h index 1e6231f..c106de8 100644 --- a/dali/internal/update/manager/update-manager.h +++ b/dali/internal/update/manager/update-manager.h @@ -269,6 +269,11 @@ public: */ void AddRendererResetter(const Renderer& renderer) override; + /** + * @copydoc Dali::Internal::SceneGraph::ResetterManager::RequestPropertyBaseResetToBaseValue() + */ + void RequestPropertyBaseResetToBaseValue(PropertyBase* propertyBase) override; + // Property Notification /** diff --git a/dali/internal/update/rendering/scene-graph-renderer.cpp b/dali/internal/update/rendering/scene-graph-renderer.cpp index 3fbc62d..3cc80cb 100644 --- a/dali/internal/update/rendering/scene-graph-renderer.cpp +++ b/dali/internal/update/rendering/scene-graph-renderer.cpp @@ -826,12 +826,12 @@ bool Renderer::IsDirty() const return (Updated() || !mOpacity.IsClean()); } -void Renderer::ResetToBaseValues(BufferIndex updateBufferIndex) +void Renderer::RequestResetToBaseValues() { - mOpacity.ResetToBaseValue(updateBufferIndex); + mOpacity.RequestResetToBaseValue(); if(mVisualProperties) { - mVisualProperties->ResetToBaseValues(updateBufferIndex); + mVisualProperties->RequestResetToBaseValues(); } } diff --git a/dali/internal/update/rendering/scene-graph-renderer.h b/dali/internal/update/rendering/scene-graph-renderer.h index a6ad912..e2753c1 100644 --- a/dali/internal/update/rendering/scene-graph-renderer.h +++ b/dali/internal/update/rendering/scene-graph-renderer.h @@ -488,11 +488,9 @@ public: bool IsDirty() const; /** - * @brief Reset to base values of all animatable properties. - * - * @param[in] updateBufferIndex the current buffer index + * @brief Request to reset to base values of all animatable properties. */ - void ResetToBaseValues(BufferIndex updateBufferIndex); + void RequestResetToBaseValues(); /** * Get the capacity of the memory pools diff --git a/dali/internal/update/rendering/scene-graph-visual-renderer.cpp b/dali/internal/update/rendering/scene-graph-visual-renderer.cpp index 904bb2c..81b5a67 100644 --- a/dali/internal/update/rendering/scene-graph-visual-renderer.cpp +++ b/dali/internal/update/rendering/scene-graph-visual-renderer.cpp @@ -28,20 +28,20 @@ extern Debug::Filter* gSceneGraphRendererLogFilter; ///< Defined at scene-graph- #endif namespace VisualRenderer { -void AnimatableVisualProperties::ResetToBaseValues(BufferIndex updateBufferIndex) +void AnimatableVisualProperties::RequestResetToBaseValues() { - mTransformOffset.ResetToBaseValue(updateBufferIndex); - mTransformSize.ResetToBaseValue(updateBufferIndex); - mTransformOrigin.ResetToBaseValue(updateBufferIndex); - mTransformAnchorPoint.ResetToBaseValue(updateBufferIndex); - mTransformOffsetSizeMode.ResetToBaseValue(updateBufferIndex); - mExtraSize.ResetToBaseValue(updateBufferIndex); - mMixColor.ResetToBaseValue(updateBufferIndex); - mPreMultipliedAlpha.ResetToBaseValue(updateBufferIndex); + mTransformOffset.RequestResetToBaseValue(); + mTransformSize.RequestResetToBaseValue(); + mTransformOrigin.RequestResetToBaseValue(); + mTransformAnchorPoint.RequestResetToBaseValue(); + mTransformOffsetSizeMode.RequestResetToBaseValue(); + mExtraSize.RequestResetToBaseValue(); + mMixColor.RequestResetToBaseValue(); + mPreMultipliedAlpha.RequestResetToBaseValue(); if(mExtendedProperties) { auto* decoratedVisualProperties = static_cast(mExtendedProperties); - decoratedVisualProperties->ResetToBaseValues(updateBufferIndex); + decoratedVisualProperties->RequestResetToBaseValues(); } } @@ -191,14 +191,14 @@ bool AnimatableVisualProperties::PrepareProperties() return rendererUpdated; } -void AnimatableDecoratedVisualProperties::ResetToBaseValues(BufferIndex updateBufferIndex) +void AnimatableDecoratedVisualProperties::RequestResetToBaseValues() { - mCornerRadius.ResetToBaseValue(updateBufferIndex); - mCornerRadiusPolicy.ResetToBaseValue(updateBufferIndex); - mBorderlineWidth.ResetToBaseValue(updateBufferIndex); - mBorderlineColor.ResetToBaseValue(updateBufferIndex); - mBorderlineOffset.ResetToBaseValue(updateBufferIndex); - mBlurRadius.ResetToBaseValue(updateBufferIndex); + mCornerRadius.RequestResetToBaseValue(); + mCornerRadiusPolicy.RequestResetToBaseValue(); + mBorderlineWidth.RequestResetToBaseValue(); + mBorderlineColor.RequestResetToBaseValue(); + mBorderlineOffset.RequestResetToBaseValue(); + mBlurRadius.RequestResetToBaseValue(); } bool AnimatableDecoratedVisualProperties::Updated() const diff --git a/dali/internal/update/rendering/scene-graph-visual-renderer.h b/dali/internal/update/rendering/scene-graph-visual-renderer.h index 02244c7..6ca2d64 100644 --- a/dali/internal/update/rendering/scene-graph-visual-renderer.h +++ b/dali/internal/update/rendering/scene-graph-visual-renderer.h @@ -51,9 +51,9 @@ struct AnimatableVisualProperties public: // Public API /** - * @copydoc Dali::Internal::SceneGraph::Renderer::ResetToBaseValues + * @copydoc Dali::Internal::SceneGraph::Renderer::RequestResetToBaseValues */ - void ResetToBaseValues(BufferIndex updateBufferIndex); + void RequestResetToBaseValues(); /** * @copydoc Dali::Internal::SceneGraph::Renderer::Updated @@ -143,9 +143,9 @@ public: // Public API } /** - * @copydoc Dali::Internal::SceneGraph::Renderer::ResetToBaseValues + * @copydoc Dali::Internal::SceneGraph::Renderer::RequestResetToBaseValues */ - void ResetToBaseValues(BufferIndex updateBufferIndex); + void RequestResetToBaseValues(); /** * @copydoc Dali::Internal::SceneGraph::Renderer::Updated