Reset UpdateProxy traveler only if descendent hierarchy changed 26/300926/2
authorEunki, Hong <eunkiki.hong@samsung.com>
Mon, 6 Nov 2023 06:00:02 +0000 (15:00 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Tue, 7 Nov 2023 01:41:28 +0000 (10:41 +0900)
Add new dirty flags about descendent hierarchy changed.
It will be useful when we want to know that given node's traveler
need to reset cache or not.

Change-Id: I62cebb40b92e808bcf5fd446517da32442463b42
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali/internal/update/manager/frame-callback-processor.cpp
dali/internal/update/manager/update-manager.cpp
dali/internal/update/nodes/node-declarations.h
dali/internal/update/nodes/node.h

index afa480e..8e02e21 100644 (file)
@@ -95,7 +95,11 @@ bool FrameCallbackProcessor::Update(BufferIndex bufferIndex, float elapsedSecond
       }
       else
       {
-        (iter++)->second->NodeHierarchyChanged();
+        if(iter->first->IsDescendentHierarchyChanged())
+        {
+          iter->second->NodeHierarchyChanged();
+        }
+        ++iter;
       }
     }
   }
index 484687a..098c0a9 100644 (file)
@@ -408,6 +408,7 @@ void UpdateManager::ConnectNode(Node* parent, Node* node)
 
   DALI_LOG_INFO(gLogFilter, Debug::General, "[%x] ConnectNode\n", node);
 
+  parent->SetDirtyFlag(NodePropertyFlags::DESCENDENT_HIERARCHY_CHANGED); // make parent dirty so that render items dont get reused
   parent->ConnectChild(node);
 
   node->AddInitializeResetter(*this);
@@ -425,7 +426,7 @@ void UpdateManager::DisconnectNode(Node* node)
 
   Node* parent = node->GetParent();
   DALI_ASSERT_ALWAYS(nullptr != parent);
-  parent->SetDirtyFlag(NodePropertyFlags::CHILD_DELETED); // make parent dirty so that render items dont get reused
+  parent->SetDirtyFlag(NodePropertyFlags::CHILD_DELETED | NodePropertyFlags::DESCENDENT_HIERARCHY_CHANGED); // make parent dirty so that render items dont get reused
 
   parent->DisconnectChild(mSceneGraphBuffers.GetUpdateBufferIndex(), *node);
 
@@ -1315,9 +1316,13 @@ void UpdateManager::SetDepthIndices(OwnerPointer<NodeDepths>& nodeDepths)
   // note, this vector is already in depth order.
   // So if we reverse iterate, we can assume that
   // my descendant node's depth index are updated.
+
+  // And also, This API is the last flushed message.
+  // We can now setup the DESCENDENT_HIERARCHY_CHANGED flag here.
   for(auto rIter = nodeDepths->nodeDepths.rbegin(), rEndIter = nodeDepths->nodeDepths.rend(); rIter != rEndIter; rIter++)
   {
     auto* node = rIter->node;
+    node->PropagateDescendentFlags();
     node->SetDepthIndex(rIter->sortedDepth);
     if(node->IsChildrenReorderRequired())
     {
index c6fb7aa..6a66d30 100644 (file)
@@ -41,15 +41,16 @@ using NodeConstIter = NodeContainer::ConstIterator;
  * Flag whether property has changed, during the Update phase.
  */
 enum class NodePropertyFlags : uint8_t
-// 8 bits is enough for 5 flags (compiler will check it)
+// 8 bits is enough for 6 flags (compiler will check it)
 {
-  NOTHING          = 0x000,
-  TRANSFORM        = 0x001,
-  VISIBLE          = 0x002,
-  COLOR            = 0x004,
-  CHILD_DELETED    = 0x008,
-  CHILDREN_REORDER = 0x010,
-  ALL              = (CHILDREN_REORDER << 1) - 1 // all the flags
+  NOTHING                      = 0x000,
+  TRANSFORM                    = 0x001,
+  VISIBLE                      = 0x002,
+  COLOR                        = 0x004,
+  CHILD_DELETED                = 0x008,
+  CHILDREN_REORDER             = 0x010,
+  DESCENDENT_HIERARCHY_CHANGED = 0x020,
+  ALL                          = (DESCENDENT_HIERARCHY_CHANGED << 1) - 1 // all the flags
 };
 
 struct NodeDepthPair
index 2af3568..52f76bb 100644 (file)
@@ -889,12 +889,34 @@ public:
    * @note It will be reset when mDirtyFlag reseted.
    * @return True if children sibiling order need to be changed.
    */
-  uint32_t IsChildrenReorderRequired() const
+  bool IsChildrenReorderRequired() const
   {
     return mDirtyFlags & NodePropertyFlags::CHILDREN_REORDER;
   }
 
   /**
+   * @brief Get whether descendent hierarchy was changed.
+   * @pre The flag will be propagate at UpdateManager::SetDepthIndices().
+   * @note It will be reset when mDirtyFlag reseted.
+   * @return True if children sibiling order need to be changed.
+   */
+  bool IsDescendentHierarchyChanged() const
+  {
+    return mDirtyFlags & NodePropertyFlags::DESCENDENT_HIERARCHY_CHANGED;
+  }
+
+  /**
+   * @brief Propagate the heirarchy changeness flag to it's parent node.
+   */
+  void PropagateDescendentFlags()
+  {
+    if(IsDescendentHierarchyChanged() && mParent)
+    {
+      mParent->SetDirtyFlag(NodePropertyFlags::DESCENDENT_HIERARCHY_CHANGED);
+    }
+  }
+
+  /**
    * @brief Sets the boolean which states whether the position should use the anchor-point.
    * @param[in] positionUsesAnchorPoint True if the position should use the anchor-point
    */