Reset node animatable properties for two frames after removing the frame callback 94/266094/4
authorRichard Huang <r.huang@samsung.com>
Fri, 5 Nov 2021 15:47:28 +0000 (15:47 +0000)
committerRichard <r.huang@samsung.com>
Thu, 18 Nov 2021 16:11:06 +0000 (16:11 +0000)
Change-Id: I67e0ee42b2da8076fa47cadf2af1435c89a4a431

dali/internal/update/common/animatable-property.h
dali/internal/update/common/node-resetter.h
dali/internal/update/manager/scene-graph-frame-callback.cpp
dali/internal/update/manager/update-manager.cpp
dali/internal/update/manager/update-manager.h
dali/internal/update/manager/update-proxy-impl.cpp
dali/internal/update/manager/update-proxy-impl.h

index d1f97d6..ebc2c82 100644 (file)
@@ -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 T>
 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()
index 7e73a6b..6d31da5 100644 (file)
@@ -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
index 6e1bd5e..1f8aa62 100644 (file)
@@ -40,6 +40,7 @@ FrameCallback::~FrameCallback()
   if(mUpdateProxy)
   {
     mUpdateProxy->GetRootNode().RemoveObserver(*this);
+    mUpdateProxy->AddNodeResetters();
   }
 
   Invalidate();
index 86db620..c231eb8 100644 (file)
@@ -341,8 +341,7 @@ void UpdateManager::InstallRoot(OwnerPointer<Layer>& layer)
   rootLayer->CreateTransform(&mImpl->transformManager);
   rootLayer->SetRoot(true);
 
-  OwnerPointer<SceneGraph::NodeResetter> 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<SceneGraph::NodeResetter> 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<PropertyResetterBase>& prop
   mImpl->propertyResetters.PushBack(propertyResetter.Release());
 }
 
-void UpdateManager::AddNodeResetter(OwnerPointer<NodeResetter>& nodeResetter)
+void UpdateManager::AddNodeResetter(const Node& node)
 {
+  OwnerPointer<SceneGraph::NodeResetter> nodeResetter = SceneGraph::NodeResetter::New(node);
   nodeResetter->Initialize();
   mImpl->nodeResetters.PushBack(nodeResetter.Release());
 }
index da66ea4..410d74c 100644 (file)
@@ -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>& nodeResetter);
+  void AddNodeResetter(const Node& node);
 
   // Property Notification
 
index 76206b6..f5a387e 100644 (file)
@@ -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
index 8294071..9a45c9f 100644 (file)
@@ -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<IdNodePair> 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<uint32_t>   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.