}
}
-/**
- * Descends into node's hierarchy and sorts the children of each child according to their depth-index.
- * @param[in] node The node whose hierarchy to descend
- */
-void SortSiblingNodesRecursively(Node& node)
-{
- NodeContainer& container = node.GetChildren();
- std::sort(container.Begin(), container.End(), [](Node* a, Node* b) { return a->GetDepthIndex() < b->GetDepthIndex(); });
-
- // Descend tree and sort as well
- for(auto&& iter : container)
- {
- SortSiblingNodesRecursively(*iter);
- }
-}
-
} // unnamed namespace
/**
void UpdateManager::SetDepthIndices(OwnerPointer<NodeDepths>& nodeDepths)
{
- // note,this vector is already in depth order. It could be used as-is to
- // remove sorting in update algorithm. However, it lacks layer boundary markers.
- for(auto&& iter : nodeDepths->nodeDepths)
- {
- iter.node->SetDepthIndex(iter.sortedDepth);
- }
-
- for(auto&& scene : mImpl->scenes)
+ // 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.
+ for(auto rIter = nodeDepths->nodeDepths.rbegin(), rEndIter = nodeDepths->nodeDepths.rend(); rIter != rEndIter; rIter++)
{
- if(scene)
+ auto* node = rIter->node;
+ node->SetDepthIndex(rIter->sortedDepth);
+ if(node->IsChildrenReorderRequired())
{
- // Go through node hierarchy and rearrange siblings according to depth-index
- SortSiblingNodesRecursively(*scene->root);
+ // Reorder children container only if sibiling order changed.
+ NodeContainer& container = node->GetChildren();
+ std::sort(container.Begin(), container.End(), [](Node* a, Node* b) { return a->GetDepthIndex() < b->GetDepthIndex(); });
}
}
}
#define DALI_INTERNAL_SCENE_GRAPH_NODE_DECLARATIONS_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.
enum class NodePropertyFlags : uint8_t
// 8 bits is enough for 5 flags (compiler will check it)
{
- NOTHING = 0x000,
- TRANSFORM = 0x001,
- VISIBLE = 0x002,
- COLOR = 0x004,
- CHILD_DELETED = 0x008,
- DEPTH_INDEX = 0x010,
- ALL = (DEPTH_INDEX << 1) - 1 // all the flags
+ NOTHING = 0x000,
+ TRANSFORM = 0x001,
+ VISIBLE = 0x002,
+ COLOR = 0x004,
+ CHILD_DELETED = 0x008,
+ CHILDREN_REORDER = 0x010,
+ ALL = (CHILDREN_REORDER << 1) - 1 // all the flags
};
struct NodeDepthPair
#define DALI_INTERNAL_SCENE_GRAPH_NODE_H
/*
- * 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.
{
if(depthIndex != mDepthIndex)
{
- SetDirtyFlag(NodePropertyFlags::DEPTH_INDEX);
+ if(mParent)
+ {
+ // Send CHILDREN_REORDER dirty flag only if my depth index changed.
+ mParent->SetDirtyFlag(NodePropertyFlags::CHILDREN_REORDER);
+ }
SetUpdated(true);
mDepthIndex = depthIndex;
}
return mDepthIndex;
}
+ /**
+ * @brief Get whether children sibiling order need to be changed. s.t. child's depth index changed.
+ * @note It will be reset when mDirtyFlag reseted.
+ * @return True if children sibiling order need to be changed.
+ */
+ uint32_t IsChildrenReorderRequired() const
+ {
+ return mDirtyFlags & NodePropertyFlags::CHILDREN_REORDER;
+ }
+
/**
* @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
private:
// Delete copy and move
- Node(const Node&) = delete;
- Node(Node&&) = delete;
+ Node(const Node&) = delete;
+ Node(Node&&) = delete;
Node& operator=(const Node& rhs) = delete;
- Node& operator=(Node&& rhs) = delete;
+ Node& operator=(Node&& rhs) = delete;
/**
* Recursive helper to disconnect a Node and its children.