1 #ifndef DALI_INTERNAL_SCENE_GRAPH_NODE_H
2 #define DALI_INTERNAL_SCENE_GRAPH_NODE_H
5 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/integration-api/debug.h>
23 #include <dali/internal/common/message.h>
24 #include <dali/internal/event/common/event-thread-services.h>
25 #include <dali/internal/render/data-providers/node-data-provider.h>
26 #include <dali/internal/update/common/animatable-property.h>
27 #include <dali/internal/update/common/inherited-property.h>
28 #include <dali/internal/update/common/property-owner.h>
29 #include <dali/internal/update/common/scene-graph-buffers.h>
30 #include <dali/internal/update/manager/transform-manager-property.h>
31 #include <dali/internal/update/manager/transform-manager.h>
32 #include <dali/internal/update/nodes/node-declarations.h>
33 #include <dali/internal/update/nodes/node-helper.h>
34 #include <dali/internal/update/nodes/partial-rendering-data.h>
35 #include <dali/internal/update/rendering/scene-graph-renderer.h>
36 #include <dali/public-api/actors/actor-enumerations.h>
37 #include <dali/public-api/actors/draw-mode.h>
38 #include <dali/public-api/math/math-utils.h>
39 #include <dali/public-api/math/quaternion.h>
40 #include <dali/public-api/math/vector3.h>
46 // Value types used by messages.
48 struct ParameterType<ColorMode> : public BasicType<ColorMode>
52 struct ParameterType<ClippingMode::Type> : public BasicType<ClippingMode::Type>
63 // Flags which require the scene renderable lists to be updated
64 static NodePropertyFlags RenderableUpdateFlags = NodePropertyFlags::TRANSFORM | NodePropertyFlags::CHILD_DELETED;
67 * Node is the base class for all nodes in the Scene Graph.
69 * Each node provides a transformation which applies to the node and
70 * its children. Node data is double-buffered. This allows an update
71 * thread to modify node data, without interferring with another
72 * thread reading the values from the previous update traversal.
74 class Node : public PropertyOwner, public NodeDataProvider
78 static const ColorMode DEFAULT_COLOR_MODE;
83 * Construct a new Node.
90 static void Delete(Node* node);
93 * Called during UpdateManager::DestroyNode shortly before Node is destroyed.
98 * @return the unique ID of the node
100 uint32_t GetId() const;
105 * Query whether the node is a layer.
106 * @return True if the node is a layer.
114 * Convert a node to a layer.
115 * @return A pointer to the layer, or NULL.
117 virtual Layer* GetLayer()
125 * Query whether the node is a camera.
126 * @return True if the node is a camera.
128 bool IsCamera() const
134 * Mark an node and its sub tree according to the updated flag.
135 * @param[in] updated The updated flag
136 * (used for partial rendering to mark an animating sub tree for example).
138 void SetUpdatedTree(bool updated)
142 for(Node* child : mChildren)
144 child->SetUpdatedTree(updated);
149 * This method sets clipping information on the node based on its hierarchy in the scene-graph.
150 * A value is calculated that can be used during sorting to increase sort speed.
151 * @param[in] clippingId The Clipping ID of the node to set
152 * @param[in] clippingDepth The Clipping Depth of the node to set
153 * @param[in] scissorDepth The Scissor Clipping Depth of the node to set
155 void SetClippingInformation(const uint32_t clippingId, const uint32_t clippingDepth, const uint32_t scissorDepth)
157 // We only set up the sort value if we have a stencil clipping depth, IE. At least 1 clipping node has been hit.
158 // If not, if we traverse down a clipping tree and back up, and there is another
159 // node on the parent, this will have a non-zero clipping ID that must be ignored
160 if(clippingDepth > 0u)
162 mClippingDepth = clippingDepth;
164 // Calculate the sort value here on write, as when read (during sort) it may be accessed several times.
165 // The items must be sorted by Clipping ID first (so the ID is kept in the most-significant bits).
166 // For the same ID, the clipping nodes must be first, so we negate the
167 // clipping enabled flag and set it as the least significant bit.
168 mClippingSortModifier = (clippingId << 1u) | (mClippingMode == ClippingMode::DISABLED ? 1u : 0u);
172 // If we do not have a clipping depth, then set this to 0 so we do not have a Clipping ID either.
173 mClippingSortModifier = 0u;
176 // The scissor depth does not modify the clipping sort modifier (as scissor clips are 2D only).
177 // For this reason we can always update the member variable.
178 mScissorDepth = scissorDepth;
182 * Gets the Clipping ID for this node.
183 * @return The Clipping ID for this node.
185 uint32_t GetClippingId() const
187 return mClippingSortModifier >> 1u;
191 * Gets the Clipping Depth for this node.
192 * @return The Clipping Depth for this node.
194 uint32_t GetClippingDepth() const
196 return mClippingDepth;
200 * Gets the Scissor Clipping Depth for this node.
201 * @return The Scissor Clipping Depth for this node.
203 uint32_t GetScissorDepth() const
205 return mScissorDepth;
209 * Sets the clipping mode for this node.
210 * @param[in] clippingMode The ClippingMode to set
212 void SetClippingMode(const ClippingMode::Type clippingMode)
214 mClippingMode = clippingMode;
215 SetDirtyFlag(NodePropertyFlags::TRANSFORM);
219 * Gets the Clipping Mode for this node.
220 * @return The ClippingMode of this node
222 ClippingMode::Type GetClippingMode() const
224 return mClippingMode;
228 * Add a renderer to the node
229 * @param[in] renderer The renderer to add to the node
231 void AddRenderer(const RendererKey& renderer);
234 * Remove a renderer from the node
235 * @param[in] renderer The renderer to be removed
237 void RemoveRenderer(const RendererKey& renderer);
240 * Get the renderer at the given index
241 * @param[in] index The index of the renderer in the node's renderer container
243 RendererKey GetRendererAt(uint32_t index) const
245 return mRenderers[index];
249 * Retrieve the number of renderers for the node
251 uint32_t GetRendererCount() const
253 return static_cast<uint32_t>(mRenderers.Size());
256 // Containment methods
259 * Query whether a node is the root node. Root nodes cannot have a parent node.
260 * A node becomes a root node, when it is installed by UpdateManager.
261 * @return True if the node is a root node.
269 * Set whether a node is the root node. Root nodes cannot have a parent node.
270 * This method should only be called by UpdateManager.
271 * @pre When isRoot is true, the node must not have a parent.
272 * @param[in] isRoot Whether the node is now a root node.
274 void SetRoot(bool isRoot);
277 * Retrieve the parent of a Node.
278 * @return The parent node, or NULL if the Node has not been added to the scene-graph.
286 * Retrieve the parent of a Node.
287 * @return The parent node, or NULL if the Node has not been added to the scene-graph.
289 const Node* GetParent() const
295 * @return true if the node is connected to SceneGraph
297 bool ConnectedToScene()
299 return IsRoot() || GetParent();
303 * Connect a node to the scene-graph.
304 * @pre A node cannot be added to itself.
305 * @pre The parent node is connected to the scene-graph.
306 * @pre The childNode does not already have a parent.
307 * @pre The childNode is not a root node.
308 * @param[in] childNode The child to add.
310 void ConnectChild(Node* childNode);
313 * Disconnect a child (& its children) from the scene-graph.
314 * @pre childNode is a child of this Node.
315 * @param[in] updateBufferIndex The current update buffer index.
316 * @param[in] childNode The node to disconnect.
318 void DisconnectChild(BufferIndex updateBufferIndex, Node& childNode);
321 * Retrieve the children a Node.
322 * @return The container of children.
324 const NodeContainer& GetChildren() const
330 * Retrieve the children a Node.
331 * @return The container of children.
333 NodeContainer& GetChildren()
341 * Flag that one of the node values has changed in the current frame.
342 * @param[in] flag The flag to set.
344 void SetDirtyFlag(NodePropertyFlags flag)
350 * Flag that all of the node values are dirty.
352 void SetAllDirtyFlags()
354 mDirtyFlags = NodePropertyFlags::ALL;
358 * Query whether a node is dirty.
359 * @return The dirty flags
361 NodePropertyFlags GetDirtyFlags() const;
364 * Query inherited dirty flags.
366 * @param The parentFlags to or with
367 * @return The inherited dirty flags
369 NodePropertyFlags GetInheritedDirtyFlags(NodePropertyFlags parentFlags) const;
372 * Retrieve the parent-origin of the node.
373 * @return The parent-origin.
375 const Vector3& GetParentOrigin() const
377 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
379 return mParentOrigin.Get(0);
382 return Vector3::ZERO;
386 * Sets both the local & base parent-origins of the node.
387 * @param[in] origin The new local & base parent-origins.
389 void SetParentOrigin(const Vector3& origin)
391 mParentOrigin.Set(0, origin);
395 * Retrieve the anchor-point of the node.
396 * @return The anchor-point.
398 const Vector3& GetAnchorPoint() const
400 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
402 return mAnchorPoint.Get(0);
405 return Vector3::ZERO;
409 * Sets both the local & base anchor-points of the node.
410 * @param[in] anchor The new local & base anchor-points.
412 void SetAnchorPoint(const Vector3& anchor)
414 mAnchorPoint.Set(0, anchor);
418 * Retrieve the local position of the node, relative to its parent.
419 * @param[in] bufferIndex The buffer to read from.
420 * @return The local position.
422 const Vector3& GetPosition(BufferIndex bufferIndex) const
424 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
426 return mPosition.Get(bufferIndex);
429 return Vector3::ZERO;
433 * Retrieve the position of the node derived from the position of all its parents.
434 * @return The world position.
436 const Vector3& GetWorldPosition(BufferIndex bufferIndex) const
438 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
440 return mWorldPosition.Get(bufferIndex);
442 return Vector3::ZERO;
446 * Set whether the Node inherits position.
447 * @param[in] inherit True if the parent position is inherited.
449 void SetInheritPosition(bool inherit)
451 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
453 mTransformManagerData.Manager()->SetInheritPosition(mTransformManagerData.Id(), inherit);
458 * Retrieve the local orientation of the node, relative to its parent.
459 * @param[in] bufferIndex The buffer to read from.
460 * @return The local orientation.
462 const Quaternion& GetOrientation(BufferIndex bufferIndex) const
464 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
466 return mOrientation.Get(0);
469 return Quaternion::IDENTITY;
473 * Retrieve the orientation of the node derived from the rotation of all its parents.
474 * @param[in] bufferIndex The buffer to read from.
475 * @return The world rotation.
477 const Quaternion& GetWorldOrientation(BufferIndex bufferIndex) const
479 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
481 return mWorldOrientation.Get(0);
483 return Quaternion::IDENTITY;
487 * Set whether the Node inherits orientation.
488 * @param[in] inherit True if the parent orientation is inherited.
490 void SetInheritOrientation(bool inherit)
492 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
494 mTransformManagerData.Manager()->SetInheritOrientation(mTransformManagerData.Id(), inherit);
499 * Retrieve the local scale of the node, relative to its parent.
500 * @param[in] bufferIndex The buffer to read from.
501 * @return The local scale.
503 const Vector3& GetScale(BufferIndex bufferIndex) const
505 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
507 return mScale.Get(0);
514 * Retrieve the scale of the node derived from the scale of all its parents.
515 * @param[in] bufferIndex The buffer to read from.
516 * @return The world scale.
518 const Vector3& GetWorldScale(BufferIndex bufferIndex) const
520 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
522 return mWorldScale.Get(0);
528 * Set whether the Node inherits scale.
529 * @param inherit True if the Node inherits scale.
531 void SetInheritScale(bool inherit)
533 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
535 mTransformManagerData.Manager()->SetInheritScale(mTransformManagerData.Id(), inherit);
540 * Retrieve the visibility of the node.
541 * @param[in] bufferIndex The buffer to read from.
542 * @return True if the node is visible.
544 bool IsVisible(BufferIndex bufferIndex) const
546 return mVisible[bufferIndex];
550 * Retrieve the opacity of the node.
551 * @param[in] bufferIndex The buffer to read from.
552 * @return The opacity.
554 float GetOpacity(BufferIndex bufferIndex) const
556 return mColor[bufferIndex].a;
560 * Retrieve the color of the node.
561 * @param[in] bufferIndex The buffer to read from.
564 const Vector4& GetColor(BufferIndex bufferIndex) const
566 return mColor[bufferIndex];
570 * Sets the color of the node derived from the color of all its parents.
571 * @param[in] color The world color.
572 * @param[in] updateBufferIndex The current update buffer index.
574 void SetWorldColor(const Vector4& color, BufferIndex updateBufferIndex)
576 mWorldColor.Set(updateBufferIndex, color);
580 * Sets the color of the node derived from the color of all its parents.
581 * This method should only be called when the parents world color is up-to-date.
582 * @pre The node has a parent.
583 * @param[in] updateBufferIndex The current update buffer index.
585 void InheritWorldColor(BufferIndex updateBufferIndex)
587 DALI_ASSERT_DEBUG(mParent != NULL);
590 if(mColorMode == USE_OWN_MULTIPLY_PARENT_ALPHA)
592 const Vector4& ownColor = mColor[updateBufferIndex];
593 mWorldColor.Set(updateBufferIndex, ownColor.r, ownColor.g, ownColor.b, ownColor.a * mParent->GetWorldColor(updateBufferIndex).a);
595 else if(mColorMode == USE_OWN_MULTIPLY_PARENT_COLOR)
597 mWorldColor.Set(updateBufferIndex, mParent->GetWorldColor(updateBufferIndex) * mColor[updateBufferIndex]);
599 else if(mColorMode == USE_PARENT_COLOR)
601 mWorldColor.Set(updateBufferIndex, mParent->GetWorldColor(updateBufferIndex));
603 else // USE_OWN_COLOR
605 mWorldColor.Set(updateBufferIndex, mColor[updateBufferIndex]);
610 * Copies the previous inherited scale, if this changed in the previous frame.
611 * This method should be called instead of InheritWorldScale i.e. if the inherited scale
612 * does not need to be recalculated in the current frame.
613 * @param[in] updateBufferIndex The current update buffer index.
615 void CopyPreviousWorldColor(BufferIndex updateBufferIndex)
617 mWorldColor.CopyPrevious(updateBufferIndex);
621 * Retrieve the color of the node, possibly derived from the color
622 * of all its parents, depending on the value of mColorMode.
623 * @param[in] bufferIndex The buffer to read from.
624 * @return The world color.
626 const Vector4& GetWorldColor(BufferIndex bufferIndex) const
628 return mWorldColor[bufferIndex];
632 * Set the color mode. This specifies whether the Node uses its own color,
633 * or inherits its parent color.
634 * @param[in] colorMode The new color mode.
636 void SetColorMode(ColorMode colorMode)
638 mColorMode = colorMode;
640 SetDirtyFlag(NodePropertyFlags::COLOR);
644 * Retrieve the color mode.
645 * @return The color mode.
647 ColorMode GetColorMode() const
653 * Retrieve the size of the node.
654 * @param[in] bufferIndex The buffer to read from.
657 const Vector3& GetSize(BufferIndex bufferIndex) const
659 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
664 return Vector3::ZERO;
668 * Set the update area hint of the node.
669 * @param[in] updateAreaHint The update area hint.
671 void SetUpdateAreaHint(const Vector4& updateAreaHint)
673 if(mUpdateAreaChanged)
675 // Merge area if the update area is dirty
676 float x = std::min(updateAreaHint.x - updateAreaHint.z / 2.0f, mUpdateAreaHint.x - mUpdateAreaHint.z / 2.0f);
677 float y = std::min(updateAreaHint.y - updateAreaHint.w / 2.0f, mUpdateAreaHint.y - mUpdateAreaHint.w / 2.0f);
678 float width = std::max(updateAreaHint.x + updateAreaHint.z / 2.0f, mUpdateAreaHint.x + mUpdateAreaHint.z / 2.0f) - x;
679 float height = std::max(updateAreaHint.y + updateAreaHint.w / 2.0f, mUpdateAreaHint.y + mUpdateAreaHint.w / 2.0f) - y;
680 mUpdateAreaHint = Vector4(x + width / 2, y + height / 2, width, height);
684 mUpdateAreaHint = updateAreaHint;
685 mUpdateAreaChanged = true;
687 mDirtyFlags |= NodePropertyFlags::TRANSFORM;
691 * Retrieve the update area hint of the node.
692 * @return The update area hint.
694 const Vector4& GetUpdateAreaHint() const
696 return mUpdateAreaHint;
700 * Retrieve the bounding sphere of the node
701 * @return A vector4 describing the bounding sphere. XYZ is the center and W is the radius
703 const Vector4& GetBoundingSphere() const
705 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
707 return mTransformManagerData.Manager()->GetBoundingSphere(mTransformManagerData.Id());
710 return Vector4::ZERO;
714 * Retrieve world matrix and size of the node
715 * @param[out] The local to world matrix of the node
716 * @param[out] size The current size of the node
718 void GetWorldMatrixAndSize(Matrix& worldMatrix, Vector3& size) const
720 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
722 mTransformManagerData.Manager()->GetWorldMatrixAndSize(mTransformManagerData.Id(), worldMatrix, size);
727 * Checks if local matrix has changed since last update
728 * @return true if local matrix has changed, false otherwise
730 bool IsLocalMatrixDirty() const
732 return (mTransformManagerData.Id() != INVALID_TRANSFORM_ID) &&
733 (mTransformManagerData.Manager()->IsLocalMatrixDirty(mTransformManagerData.Id()));
737 * Retrieve the cached world-matrix of a node.
738 * @param[in] bufferIndex The buffer to read from.
739 * @return The world-matrix.
741 const Matrix& GetWorldMatrix(BufferIndex bufferIndex) const
743 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
745 return mWorldMatrix.Get(bufferIndex);
748 return Matrix::IDENTITY;
752 * Mark the node as exclusive to a single RenderTask.
753 * @param[in] renderTask The render-task, or NULL if the Node is not exclusive to a single RenderTask.
755 void SetExclusiveRenderTask(RenderTask* renderTask)
757 mExclusiveRenderTask = renderTask;
761 * Query whether the node is exclusive to a single RenderTask.
762 * @return The render-task, or NULL if the Node is not exclusive to a single RenderTask.
764 RenderTask* GetExclusiveRenderTask() const
766 return mExclusiveRenderTask;
770 * Set how the Node and its children should be drawn; see Dali::Actor::SetDrawMode() for more details.
771 * @param[in] drawMode The new draw-mode to use.
773 void SetDrawMode(const DrawMode::Type& drawMode)
775 mDrawMode = drawMode;
779 * Returns whether node is an overlay or not.
780 * @return True if node is an overlay, false otherwise.
782 DrawMode::Type GetDrawMode() const
787 void SetTransparent(bool transparent)
789 mTransparent = transparent;
792 bool IsTransparent() const
798 * Returns the transform id of the node
799 * @return The transform component id of the node
801 TransformId GetTransformId() const
803 return mTransformManagerData.Id();
807 * Equality operator, checks for identity, not values.
810 bool operator==(const Node* rhs) const
812 return (this == rhs);
816 * @brief Sets the sibling order of the node
817 * @param[in] order The new order
819 void SetDepthIndex(uint32_t depthIndex)
821 if(depthIndex != mDepthIndex)
825 // Send CHILDREN_REORDER dirty flag only if my depth index changed.
826 mParent->SetDirtyFlag(NodePropertyFlags::CHILDREN_REORDER);
829 mDepthIndex = depthIndex;
834 * @brief Get the depth index of the node
835 * @return Current depth index
837 uint32_t GetDepthIndex() const
843 * @brief Get whether children sibiling order need to be changed. s.t. child's depth index changed.
844 * @note It will be reset when mDirtyFlag reseted.
845 * @return True if children sibiling order need to be changed.
847 uint32_t IsChildrenReorderRequired() const
849 return mDirtyFlags & NodePropertyFlags::CHILDREN_REORDER;
853 * @brief Sets the boolean which states whether the position should use the anchor-point.
854 * @param[in] positionUsesAnchorPoint True if the position should use the anchor-point
856 void SetPositionUsesAnchorPoint(bool positionUsesAnchorPoint)
858 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID && mPositionUsesAnchorPoint != positionUsesAnchorPoint)
860 mPositionUsesAnchorPoint = positionUsesAnchorPoint;
861 mTransformManagerData.Manager()->SetPositionUsesAnchorPoint(mTransformManagerData.Id(), mPositionUsesAnchorPoint);
866 * @brief Sets whether the node is culled or not.
867 * @param[in] bufferIndex The buffer to read from.
868 * @param[in] culled True if the node is culled.
870 void SetCulled(BufferIndex bufferIndex, bool culled)
872 mCulled[bufferIndex] = culled;
876 * @brief Retrieves whether the node is culled or not.
877 * @param[in] bufferIndex The buffer to read from.
878 * @return True if the node is culled.
880 bool IsCulled(BufferIndex bufferIndex) const
882 return mCulled[bufferIndex];
886 * @brief Get the total capacity of the memory pools
887 * @return The capacity of the memory pools
889 * @note This is different to the node count.
891 static uint32_t GetMemoryPoolCapacity();
894 * @brief Returns partial rendering data associated with the node.
895 * @return The partial rendering data
897 PartialRenderingData& GetPartialRenderingData()
899 return mPartialRenderingData;
904 * @copydoc Dali::Internal::SceneGraph::PropertyOwner::IsAnimationPossible
906 bool IsAnimationPossible() const override;
909 * Called by UpdateManager when the node is added.
910 * Creates a new transform component in the transform manager and initialize all the properties
911 * related to the transformation
912 * @param[in] transformManager A pointer to the trnasform manager (Owned by UpdateManager)
914 void CreateTransform(SceneGraph::TransformManager* transformManager);
919 void ResetDirtyFlags(BufferIndex updateBufferIndex);
922 * Update uniform hash
923 * @param[in] bufferIndex The buffer to read from.
925 void UpdateUniformHash(BufferIndex bufferIndex);
929 * Set the parent of a Node.
930 * @param[in] parentNode the new parent.
932 void SetParent(Node& parentNode);
936 * Protected constructor; See also Node::New()
941 * Protected virtual destructor; See also Node::Delete( Node* )
942 * Kept protected to allow destructor chaining from layer
946 private: // from NodeDataProvider
948 * @copydoc NodeDataProvider::GetRenderColor
950 const Vector4& GetRenderColor(BufferIndex bufferIndex) const override
952 return GetWorldColor(bufferIndex);
956 * @copydoc NodeDataProvider::GetNodeUniformMap
958 const UniformMap& GetNodeUniformMap() const override
960 return GetUniformMap();
964 // Delete copy and move
965 Node(const Node&) = delete;
966 Node(Node&&) = delete;
967 Node& operator=(const Node& rhs) = delete;
968 Node& operator=(Node&& rhs) = delete;
971 * Recursive helper to disconnect a Node and its children.
972 * Disconnected Nodes have no parent or children.
973 * @param[in] updateBufferIndex The current update buffer index.
975 void RecursiveDisconnectFromSceneGraph(BufferIndex updateBufferIndex);
977 public: // Default properties
978 // Define a base offset for the following wrappers. The wrapper macros calculate offsets from the previous
979 // element such that each wrapper type generates a compile time offset to the transform manager data.
980 BASE(TransformManagerData, mTransformManagerData);
981 PROPERTY_WRAPPER(mTransformManagerData, TransformManagerPropertyVector3, TRANSFORM_PROPERTY_PARENT_ORIGIN,
982 mParentOrigin); // Local transform; the position is relative to this. Sets the Transform flag dirty when changed
984 PROPERTY_WRAPPER(mParentOrigin, TransformManagerPropertyVector3, TRANSFORM_PROPERTY_ANCHOR_POINT,
985 mAnchorPoint); // Local transform; local center of rotation. Sets the Transform flag dirty when changed
987 PROPERTY_WRAPPER(mAnchorPoint, TransformManagerPropertyVector3, TRANSFORM_PROPERTY_SIZE,
988 mSize); // Size is provided for layouting
990 PROPERTY_WRAPPER(mSize, TransformManagerPropertyVector3, TRANSFORM_PROPERTY_POSITION,
991 mPosition); // Local transform; distance between parent-origin & anchor-point
992 PROPERTY_WRAPPER(mPosition, TransformManagerPropertyVector3, TRANSFORM_PROPERTY_SCALE,
993 mScale); // Local transform; scale relative to parent node
995 TEMPLATE_WRAPPER(mScale, TransformManagerPropertyQuaternion,
996 mOrientation); // Local transform; rotation relative to parent node
998 // Inherited properties; read-only from public API
999 TEMPLATE_WRAPPER(mOrientation, TransformManagerVector3Input, mWorldPosition); // Full inherited position
1000 TEMPLATE_WRAPPER(mWorldPosition, TransformManagerVector3Input, mWorldScale); // Full inherited scale
1001 TEMPLATE_WRAPPER(mWorldScale, TransformManagerQuaternionInput, mWorldOrientation); // Full inherited orientation
1002 TEMPLATE_WRAPPER(mWorldOrientation, TransformManagerMatrixInput, mWorldMatrix); // Full inherited world matrix
1004 AnimatableProperty<bool> mVisible; ///< Visibility can be inherited from the Node hierachy
1005 AnimatableProperty<bool> mCulled; ///< True if the node is culled. This is not animatable. It is just double-buffered.
1006 AnimatableProperty<Vector4> mColor; ///< Color can be inherited from the Node hierarchy
1007 InheritedColor mWorldColor; ///< Full inherited color
1008 Vector4 mUpdateAreaHint; ///< Update area hint is provided for damaged area calculation. (x, y, width, height)
1010 uint64_t mUniformsHash{0u}; ///< Hash of uniform map property values
1011 uint32_t mClippingSortModifier; ///< Contains bit-packed clipping information for quick access when sorting
1012 const uint32_t mId; ///< The Unique ID of the node.
1015 static uint32_t mNodeCounter; ///< count of total nodes, used for unique ids
1017 PartialRenderingData mPartialRenderingData; ///< Cache to determine if this should be rendered again
1019 Node* mParent; ///< Pointer to parent node (a child is owned by its parent)
1020 RenderTask* mExclusiveRenderTask; ///< Nodes can be marked as exclusive to a single RenderTask
1022 RendererContainer mRenderers; ///< Container of renderers; not owned
1024 NodeContainer mChildren; ///< Container of children; not owned
1026 uint32_t mClippingDepth; ///< The number of stencil clipping nodes deep this node is
1027 uint32_t mScissorDepth; ///< The number of scissor clipping nodes deep this node is
1028 uint32_t mDepthIndex; ///< Depth index of the node
1030 // flags, compressed to bitfield
1031 NodePropertyFlags mDirtyFlags; ///< Dirty flags for each of the Node properties
1032 DrawMode::Type mDrawMode : 3; ///< How the Node and its children should be drawn
1033 ColorMode mColorMode : 3; ///< Determines whether mWorldColor is inherited, 2 bits is enough
1034 ClippingMode::Type mClippingMode : 3; ///< The clipping mode of this node
1035 bool mIsRoot : 1; ///< True if the node cannot have a parent
1036 bool mIsLayer : 1; ///< True if the node is a layer
1037 bool mIsCamera : 1; ///< True if the node is a camera
1038 bool mPositionUsesAnchorPoint : 1; ///< True if the node should use the anchor-point when calculating the position
1039 bool mTransparent : 1; ///< True if this node is transparent. This value do not affect children.
1040 bool mUpdateAreaChanged : 1; ///< True if the update area of the node is changed.
1042 // Changes scope, should be at end of class
1043 DALI_LOG_OBJECT_STRING_DECLARATION;
1046 // Messages for Node
1048 inline void SetInheritOrientationMessage(EventThreadServices& eventThreadServices, const Node& node, bool inherit)
1050 using LocalType = MessageValue1<Node, bool>;
1052 // Reserve some memory inside the message queue
1053 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1055 // Construct message in the message queue memory; note that delete should not be called on the return value
1056 new(slot) LocalType(&node, &Node::SetInheritOrientation, inherit);
1059 inline void SetParentOriginMessage(EventThreadServices& eventThreadServices, const Node& node, const Vector3& origin)
1061 using LocalType = MessageValue1<Node, Vector3>;
1063 // Reserve some memory inside the message queue
1064 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1066 // Construct message in the message queue memory; note that delete should not be called on the return value
1067 new(slot) LocalType(&node, &Node::SetParentOrigin, origin);
1070 inline void SetAnchorPointMessage(EventThreadServices& eventThreadServices, const Node& node, const Vector3& anchor)
1072 using LocalType = MessageValue1<Node, Vector3>;
1074 // Reserve some memory inside the message queue
1075 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1077 // Construct message in the message queue memory; note that delete should not be called on the return value
1078 new(slot) LocalType(&node, &Node::SetAnchorPoint, anchor);
1081 inline void SetInheritPositionMessage(EventThreadServices& eventThreadServices, const Node& node, bool inherit)
1083 using LocalType = MessageValue1<Node, bool>;
1085 // Reserve some memory inside the message queue
1086 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1088 // Construct message in the message queue memory; note that delete should not be called on the return value
1089 new(slot) LocalType(&node, &Node::SetInheritPosition, inherit);
1092 inline void SetInheritScaleMessage(EventThreadServices& eventThreadServices, const Node& node, bool inherit)
1094 using LocalType = MessageValue1<Node, bool>;
1096 // Reserve some memory inside the message queue
1097 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1099 // Construct message in the message queue memory; note that delete should not be called on the return value
1100 new(slot) LocalType(&node, &Node::SetInheritScale, inherit);
1103 inline void SetColorModeMessage(EventThreadServices& eventThreadServices, const Node& node, ColorMode colorMode)
1105 using LocalType = MessageValue1<Node, ColorMode>;
1107 // Reserve some memory inside the message queue
1108 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1110 // Construct message in the message queue memory; note that delete should not be called on the return value
1111 new(slot) LocalType(&node, &Node::SetColorMode, colorMode);
1114 inline void SetDrawModeMessage(EventThreadServices& eventThreadServices, const Node& node, DrawMode::Type drawMode)
1116 using LocalType = MessageValue1<Node, DrawMode::Type>;
1118 // Reserve some memory inside the message queue
1119 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1121 // Construct message in the message queue memory; note that delete should not be called on the return value
1122 new(slot) LocalType(&node, &Node::SetDrawMode, drawMode);
1125 inline void SetTransparentMessage(EventThreadServices& eventThreadServices, const Node& node, bool transparent)
1127 using LocalType = MessageValue1<Node, bool>;
1129 // Reserve some memory inside the message queue
1130 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1132 // Construct message in the message queue memory; note that delete should not be called on the return value
1133 new(slot) LocalType(&node, &Node::SetTransparent, transparent);
1136 inline void DetachRendererMessage(EventThreadServices& eventThreadServices, const Node& node, const Renderer& renderer)
1138 using LocalType = MessageValue1<Node, RendererKey>;
1140 // Reserve some memory inside the message queue
1141 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1143 // Construct message in the message queue memory; note that delete should not be called on the return value
1144 new(slot) LocalType(&node, &Node::RemoveRenderer, Renderer::GetKey(renderer));
1147 inline void SetDepthIndexMessage(EventThreadServices& eventThreadServices, const Node& node, uint32_t depthIndex)
1149 using LocalType = MessageValue1<Node, uint32_t>;
1151 // Reserve some memory inside the message queue
1152 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1154 // Construct message in the message queue memory; note that delete should not be called on the return value
1155 new(slot) LocalType(&node, &Node::SetDepthIndex, depthIndex);
1158 inline void SetClippingModeMessage(EventThreadServices& eventThreadServices, const Node& node, ClippingMode::Type clippingMode)
1160 using LocalType = MessageValue1<Node, ClippingMode::Type>;
1162 // Reserve some memory inside the message queue
1163 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1165 // Construct message in the message queue memory; note that delete should not be called on the return value
1166 new(slot) LocalType(&node, &Node::SetClippingMode, clippingMode);
1169 inline void SetPositionUsesAnchorPointMessage(EventThreadServices& eventThreadServices, const Node& node, bool positionUsesAnchorPoint)
1171 using LocalType = MessageValue1<Node, bool>;
1173 // Reserve some memory inside the message queue
1174 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1176 // Construct message in the message queue memory; note that delete should not be called on the return value
1177 new(slot) LocalType(&node, &Node::SetPositionUsesAnchorPoint, positionUsesAnchorPoint);
1180 inline void SetUpdateAreaHintMessage(EventThreadServices& eventThreadServices, const Node& node, const Vector4& updateAreaHint)
1182 using LocalType = MessageValue1<Node, Vector4>;
1184 // Reserve some memory inside the message queue
1185 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1187 // Construct message in the message queue memory; note that delete should not be called on the return value
1188 new(slot) LocalType(&node, &Node::SetUpdateAreaHint, updateAreaHint);
1191 } // namespace SceneGraph
1193 // Template specialisation for OwnerPointer<Node>, because delete is protected
1195 inline void OwnerPointer<Dali::Internal::SceneGraph::Node>::Reset()
1197 if(mObject != nullptr)
1199 Dali::Internal::SceneGraph::Node::Delete(mObject);
1203 } // namespace Internal
1205 // Template specialisations for OwnerContainer<Node*>, because delete is protected
1207 inline void OwnerContainer<Dali::Internal::SceneGraph::Node*>::Delete(Dali::Internal::SceneGraph::Node* pointer)
1209 Dali::Internal::SceneGraph::Node::Delete(pointer);
1213 #endif // DALI_INTERNAL_SCENE_GRAPH_NODE_H