From d28979e5a4966c85c3fb6cf1d9f39c942e487fe8 Mon Sep 17 00:00:00 2001 From: Richard Huang Date: Fri, 5 Nov 2021 15:47:28 +0000 Subject: [PATCH] Reset node animatable properties for two frames after removing the frame callback Change-Id: I67e0ee42b2da8076fa47cadf2af1435c89a4a431 --- dali/internal/update/common/animatable-property.h | 11 +++++++++++ dali/internal/update/common/node-resetter.h | 12 ++++++------ .../internal/update/manager/scene-graph-frame-callback.cpp | 1 + dali/internal/update/manager/update-manager.cpp | 9 ++++----- dali/internal/update/manager/update-manager.h | 2 +- dali/internal/update/manager/update-proxy-impl.cpp | 14 ++++++++++++++ dali/internal/update/manager/update-proxy-impl.h | 6 ++++++ 7 files changed, 43 insertions(+), 12 deletions(-) diff --git a/dali/internal/update/common/animatable-property.h b/dali/internal/update/common/animatable-property.h index d1f97d6..ebc2c82 100644 --- a/dali/internal/update/common/animatable-property.h +++ b/dali/internal/update/common/animatable-property.h @@ -52,6 +52,7 @@ namespace SceneGraph static const uint32_t CLEAN_FLAG = 0x00; ///< Indicates that the value did not change in this, or the previous frame static const uint32_t BAKED_FLAG = 0x01; ///< Indicates that the value was Baked during the previous frame static const uint32_t SET_FLAG = 0x02; ///< Indicates that the value was Set during the previous frame +static const uint32_t RESET_FLAG = 0x02; ///< Indicates that the value should be reset to the base value in the next two frames template class AnimatableProperty; @@ -93,6 +94,16 @@ protected: // for derived classes mDirtyFlags = BAKED_FLAG; } +public: + + /** + * Mark the property as dirty so that it will be reset to the base value in the next two frames. + */ + void MarkAsDirty() + { + mDirtyFlags = RESET_FLAG; + } + public: // From PropertyBase /** * @copydoc Dali::Internal::SceneGraph::PropertyBase::IsClean() diff --git a/dali/internal/update/common/node-resetter.h b/dali/internal/update/common/node-resetter.h index 7e73a6b..6d31da5 100644 --- a/dali/internal/update/common/node-resetter.h +++ b/dali/internal/update/common/node-resetter.h @@ -80,15 +80,10 @@ public: // Start aging the node properties. // We need to reset the node properties for two frames to ensure both // property values are set appropriately. - // if(mDisconnected) - { - --mActive; - } + --mActive; mNode->mVisible.ResetToBaseValue(updateBufferIndex); - mNode->mCulled.ResetToBaseValue(updateBufferIndex); mNode->mColor.ResetToBaseValue(updateBufferIndex); - mNode->mUpdateSizeHint.ResetToBaseValue(updateBufferIndex); } }; @@ -104,6 +99,9 @@ public: { mDisconnected = false; mActive = ACTIVE; + + mNode->mVisible.MarkAsDirty(); + mNode->mColor.MarkAsDirty(); } /** @@ -157,6 +155,8 @@ protected: mActive(ACTIVE), mDisconnected(false) { + mNode->mVisible.MarkAsDirty(); + mNode->mColor.MarkAsDirty(); } Node* mNode; ///< The node that owns the properties diff --git a/dali/internal/update/manager/scene-graph-frame-callback.cpp b/dali/internal/update/manager/scene-graph-frame-callback.cpp index 6e1bd5e..1f8aa62 100644 --- a/dali/internal/update/manager/scene-graph-frame-callback.cpp +++ b/dali/internal/update/manager/scene-graph-frame-callback.cpp @@ -40,6 +40,7 @@ FrameCallback::~FrameCallback() if(mUpdateProxy) { mUpdateProxy->GetRootNode().RemoveObserver(*this); + mUpdateProxy->AddNodeResetters(); } Invalidate(); diff --git a/dali/internal/update/manager/update-manager.cpp b/dali/internal/update/manager/update-manager.cpp index 86db620..c231eb8 100644 --- a/dali/internal/update/manager/update-manager.cpp +++ b/dali/internal/update/manager/update-manager.cpp @@ -341,8 +341,7 @@ void UpdateManager::InstallRoot(OwnerPointer& layer) rootLayer->CreateTransform(&mImpl->transformManager); rootLayer->SetRoot(true); - OwnerPointer nodeResetter = SceneGraph::NodeResetter::New(*rootLayer); - AddNodeResetter(nodeResetter); + AddNodeResetter(*rootLayer); mImpl->scenes.emplace_back(new Impl::SceneInfo(rootLayer)); } @@ -388,8 +387,7 @@ void UpdateManager::ConnectNode(Node* parent, Node* node) parent->ConnectChild(node); - OwnerPointer nodeResetter = SceneGraph::NodeResetter::New(*node); - AddNodeResetter(nodeResetter); + AddNodeResetter(*node); // Inform the frame-callback-processor, if set, about the node-hierarchy changing if(mImpl->frameCallbackProcessor) @@ -562,8 +560,9 @@ void UpdateManager::AddPropertyResetter(OwnerPointer& prop mImpl->propertyResetters.PushBack(propertyResetter.Release()); } -void UpdateManager::AddNodeResetter(OwnerPointer& nodeResetter) +void UpdateManager::AddNodeResetter(const Node& node) { + OwnerPointer nodeResetter = SceneGraph::NodeResetter::New(node); nodeResetter->Initialize(); mImpl->nodeResetters.PushBack(nodeResetter.Release()); } diff --git a/dali/internal/update/manager/update-manager.h b/dali/internal/update/manager/update-manager.h index da66ea4..410d74c 100644 --- a/dali/internal/update/manager/update-manager.h +++ b/dali/internal/update/manager/update-manager.h @@ -265,7 +265,7 @@ public: * It will be killed by UpdateManager when the node is disconnected from the scene graph; * or when the node is destroyed. */ - void AddNodeResetter(OwnerPointer& nodeResetter); + void AddNodeResetter(const Node& node); // Property Notification diff --git a/dali/internal/update/manager/update-proxy-impl.cpp b/dali/internal/update/manager/update-proxy-impl.cpp index 76206b6..f5a387e 100644 --- a/dali/internal/update/manager/update-proxy-impl.cpp +++ b/dali/internal/update/manager/update-proxy-impl.cpp @@ -55,6 +55,7 @@ SceneGraph::Node* FindNodeInSceneGraph(uint32_t id, SceneGraph::Node& node) UpdateProxy::UpdateProxy(SceneGraph::UpdateManager& updateManager, SceneGraph::TransformManager& transformManager, SceneGraph::Node& rootNode) : mNodeContainer(), mLastCachedIdNodePair({0u, nullptr}), + mDirtyNodes(), mCurrentBufferIndex(0u), mUpdateManager(updateManager), mTransformManager(transformManager), @@ -212,6 +213,7 @@ bool UpdateProxy::SetColor(uint32_t id, const Vector4& color) { node->mColor.Set(mCurrentBufferIndex, color); node->SetDirtyFlag(SceneGraph::NodePropertyFlags::COLOR); + mDirtyNodes.push_back(id); AddResetter(*node, node->mColor); success = true; } @@ -283,6 +285,18 @@ void UpdateProxy::AddResetter(SceneGraph::Node& node, SceneGraph::PropertyBase& mPropertyModifier->AddResetter(node, propertyBase); } +void UpdateProxy::AddNodeResetters() +{ + for(auto&& id : mDirtyNodes) + { + SceneGraph::Node* node = FindNodeInSceneGraph(id, mRootNode); + if(node) + { + mUpdateManager.AddNodeResetter(*node); + } + } +} + } // namespace Internal } // namespace Dali diff --git a/dali/internal/update/manager/update-proxy-impl.h b/dali/internal/update/manager/update-proxy-impl.h index 8294071..9a45c9f 100644 --- a/dali/internal/update/manager/update-proxy-impl.h +++ b/dali/internal/update/manager/update-proxy-impl.h @@ -157,6 +157,11 @@ public: */ void NodeHierarchyChanged(); + /** + * @brief Adds node resetter for each dirty node whose animatable properties have been changed. + */ + void AddNodeResetters(); + private: /** * @brief Retrieves the node with the specified ID. @@ -188,6 +193,7 @@ private: mutable std::vector mNodeContainer; ///< Used to store cached pointers to already searched for Nodes. mutable IdNodePair mLastCachedIdNodePair; ///< Used to cache the last retrieved id-node pair. + mutable std::vector mDirtyNodes; ///< Used to store the ID of the dirty nodes with non-transform property modifications. BufferIndex mCurrentBufferIndex; SceneGraph::UpdateManager& mUpdateManager; ///< Reference to the Update Manager. -- 2.7.4