1 #ifndef DALI_INTERNAL_SCENE_GRAPH_NODE_H
2 #define DALI_INTERNAL_SCENE_GRAPH_NODE_H
5 * Copyright (c) 2022 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/rendering/scene-graph-renderer.h>
34 #include <dali/public-api/actors/actor-enumerations.h>
35 #include <dali/public-api/actors/draw-mode.h>
36 #include <dali/public-api/math/math-utils.h>
37 #include <dali/public-api/math/quaternion.h>
38 #include <dali/public-api/math/vector3.h>
44 // Value types used by messages.
46 struct ParameterType<ColorMode> : public BasicType<ColorMode>
50 struct ParameterType<ClippingMode::Type> : public BasicType<ClippingMode::Type>
61 // Flags which require the scene renderable lists to be updated
62 static NodePropertyFlags RenderableUpdateFlags = NodePropertyFlags::TRANSFORM | NodePropertyFlags::CHILD_DELETED;
65 * Node is the base class for all nodes in the Scene Graph.
67 * Each node provides a transformation which applies to the node and
68 * its children. Node data is double-buffered. This allows an update
69 * thread to modify node data, without interferring with another
70 * thread reading the values from the previous update traversal.
72 class Node : public PropertyOwner, public NodeDataProvider
76 static const ColorMode DEFAULT_COLOR_MODE;
81 * Construct a new Node.
88 static void Delete(Node* node);
91 * Called during UpdateManager::DestroyNode shortly before Node is destroyed.
96 * @return the unique ID of the node
98 uint32_t GetId() const;
103 * Query whether the node is a layer.
104 * @return True if the node is a layer.
112 * Convert a node to a layer.
113 * @return A pointer to the layer, or NULL.
115 virtual Layer* GetLayer()
123 * Query whether the node is a camera.
124 * @return True if the node is a camera.
126 bool IsCamera() const
132 * Mark an node and its sub tree according to the updated flag.
133 * @param[in] updated The updated flag
134 * (used for partial rendering to mark an animating sub tree for example).
136 void SetUpdatedTree(bool updated)
140 for(Node* child : mChildren)
142 child->SetUpdatedTree(updated);
147 * This method sets clipping information on the node based on its hierarchy in the scene-graph.
148 * A value is calculated that can be used during sorting to increase sort speed.
149 * @param[in] clippingId The Clipping ID of the node to set
150 * @param[in] clippingDepth The Clipping Depth of the node to set
151 * @param[in] scissorDepth The Scissor Clipping Depth of the node to set
153 void SetClippingInformation(const uint32_t clippingId, const uint32_t clippingDepth, const uint32_t scissorDepth)
155 // We only set up the sort value if we have a stencil clipping depth, IE. At least 1 clipping node has been hit.
156 // If not, if we traverse down a clipping tree and back up, and there is another
157 // node on the parent, this will have a non-zero clipping ID that must be ignored
158 if(clippingDepth > 0u)
160 mClippingDepth = clippingDepth;
162 // Calculate the sort value here on write, as when read (during sort) it may be accessed several times.
163 // The items must be sorted by Clipping ID first (so the ID is kept in the most-significant bits).
164 // For the same ID, the clipping nodes must be first, so we negate the
165 // clipping enabled flag and set it as the least significant bit.
166 mClippingSortModifier = (clippingId << 1u) | (mClippingMode == ClippingMode::DISABLED ? 1u : 0u);
170 // If we do not have a clipping depth, then set this to 0 so we do not have a Clipping ID either.
171 mClippingSortModifier = 0u;
174 // The scissor depth does not modify the clipping sort modifier (as scissor clips are 2D only).
175 // For this reason we can always update the member variable.
176 mScissorDepth = scissorDepth;
180 * Gets the Clipping ID for this node.
181 * @return The Clipping ID for this node.
183 uint32_t GetClippingId() const
185 return mClippingSortModifier >> 1u;
189 * Gets the Clipping Depth for this node.
190 * @return The Clipping Depth for this node.
192 uint32_t GetClippingDepth() const
194 return mClippingDepth;
198 * Gets the Scissor Clipping Depth for this node.
199 * @return The Scissor Clipping Depth for this node.
201 uint32_t GetScissorDepth() const
203 return mScissorDepth;
207 * Sets the clipping mode for this node.
208 * @param[in] clippingMode The ClippingMode to set
210 void SetClippingMode(const ClippingMode::Type clippingMode)
212 mClippingMode = clippingMode;
216 * Gets the Clipping Mode for this node.
217 * @return The ClippingMode of this node
219 ClippingMode::Type GetClippingMode() const
221 return mClippingMode;
225 * Add a renderer to the node
226 * @param[in] renderer The renderer added to the node
228 void AddRenderer(Renderer* renderer);
231 * Remove a renderer from the node
232 * @param[in] renderer The renderer to be removed
234 void RemoveRenderer(const Renderer* renderer);
237 * Get the renderer at the given index
240 Renderer* GetRendererAt(uint32_t index) const
242 return mRenderer[index];
246 * Retrieve the number of renderers for the node
248 uint32_t GetRendererCount() const
250 return static_cast<uint32_t>(mRenderer.Size());
253 // Containment methods
256 * Query whether a node is the root node. Root nodes cannot have a parent node.
257 * A node becomes a root node, when it is installed by UpdateManager.
258 * @return True if the node is a root node.
266 * Set whether a node is the root node. Root nodes cannot have a parent node.
267 * This method should only be called by UpdateManager.
268 * @pre When isRoot is true, the node must not have a parent.
269 * @param[in] isRoot Whether the node is now a root node.
271 void SetRoot(bool isRoot);
274 * Retrieve the parent of a Node.
275 * @return The parent node, or NULL if the Node has not been added to the scene-graph.
283 * Retrieve the parent of a Node.
284 * @return The parent node, or NULL if the Node has not been added to the scene-graph.
286 const Node* GetParent() const
292 * @return true if the node is connected to SceneGraph
294 bool ConnectedToScene()
296 return IsRoot() || GetParent();
300 * Connect a node to the scene-graph.
301 * @pre A node cannot be added to itself.
302 * @pre The parent node is connected to the scene-graph.
303 * @pre The childNode does not already have a parent.
304 * @pre The childNode is not a root node.
305 * @param[in] childNode The child to add.
307 void ConnectChild(Node* childNode);
310 * Disconnect a child (& its children) from the scene-graph.
311 * @pre childNode is a child of this Node.
312 * @param[in] updateBufferIndex The current update buffer index.
313 * @param[in] childNode The node to disconnect.
315 void DisconnectChild(BufferIndex updateBufferIndex, Node& childNode);
318 * Retrieve the children a Node.
319 * @return The container of children.
321 const NodeContainer& GetChildren() const
327 * Retrieve the children a Node.
328 * @return The container of children.
330 NodeContainer& GetChildren()
338 * Flag that one of the node values has changed in the current frame.
339 * @param[in] flag The flag to set.
341 void SetDirtyFlag(NodePropertyFlags flag)
347 * Flag that all of the node values are dirty.
349 void SetAllDirtyFlags()
351 mDirtyFlags = NodePropertyFlags::ALL;
355 * Query whether a node is dirty.
356 * @return The dirty flags
358 NodePropertyFlags GetDirtyFlags() const;
361 * Query inherited dirty flags.
363 * @param The parentFlags to or with
364 * @return The inherited dirty flags
366 NodePropertyFlags GetInheritedDirtyFlags(NodePropertyFlags parentFlags) const;
369 * Retrieve the parent-origin of the node.
370 * @return The parent-origin.
372 const Vector3& GetParentOrigin() const
374 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
376 return mParentOrigin.Get(0);
379 return Vector3::ZERO;
383 * Sets both the local & base parent-origins of the node.
384 * @param[in] origin The new local & base parent-origins.
386 void SetParentOrigin(const Vector3& origin)
388 mParentOrigin.Set(0, origin);
392 * Retrieve the anchor-point of the node.
393 * @return The anchor-point.
395 const Vector3& GetAnchorPoint() const
397 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
399 return mAnchorPoint.Get(0);
402 return Vector3::ZERO;
406 * Sets both the local & base anchor-points of the node.
407 * @param[in] anchor The new local & base anchor-points.
409 void SetAnchorPoint(const Vector3& anchor)
411 mAnchorPoint.Set(0, anchor);
415 * Retrieve the local position of the node, relative to its parent.
416 * @param[in] bufferIndex The buffer to read from.
417 * @return The local position.
419 const Vector3& GetPosition(BufferIndex bufferIndex) const
421 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
423 return mPosition.Get(bufferIndex);
426 return Vector3::ZERO;
430 * Retrieve the position of the node derived from the position of all its parents.
431 * @return The world position.
433 const Vector3& GetWorldPosition(BufferIndex bufferIndex) const
435 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
437 return mWorldPosition.Get(bufferIndex);
439 return Vector3::ZERO;
443 * Set whether the Node inherits position.
444 * @param[in] inherit True if the parent position is inherited.
446 void SetInheritPosition(bool inherit)
448 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
450 mTransformManagerData.Manager()->SetInheritPosition(mTransformManagerData.Id(), inherit);
455 * Retrieve the local orientation of the node, relative to its parent.
456 * @param[in] bufferIndex The buffer to read from.
457 * @return The local orientation.
459 const Quaternion& GetOrientation(BufferIndex bufferIndex) const
461 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
463 return mOrientation.Get(0);
466 return Quaternion::IDENTITY;
470 * Retrieve the orientation of the node derived from the rotation of all its parents.
471 * @param[in] bufferIndex The buffer to read from.
472 * @return The world rotation.
474 const Quaternion& GetWorldOrientation(BufferIndex bufferIndex) const
476 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
478 return mWorldOrientation.Get(0);
480 return Quaternion::IDENTITY;
484 * Set whether the Node inherits orientation.
485 * @param[in] inherit True if the parent orientation is inherited.
487 void SetInheritOrientation(bool inherit)
489 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
491 mTransformManagerData.Manager()->SetInheritOrientation(mTransformManagerData.Id(), inherit);
496 * Retrieve the local scale of the node, relative to its parent.
497 * @param[in] bufferIndex The buffer to read from.
498 * @return The local scale.
500 const Vector3& GetScale(BufferIndex bufferIndex) const
502 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
504 return mScale.Get(0);
511 * Retrieve the scale of the node derived from the scale of all its parents.
512 * @param[in] bufferIndex The buffer to read from.
513 * @return The world scale.
515 const Vector3& GetWorldScale(BufferIndex bufferIndex) const
517 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
519 return mWorldScale.Get(0);
525 * Set whether the Node inherits scale.
526 * @param inherit True if the Node inherits scale.
528 void SetInheritScale(bool inherit)
530 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
532 mTransformManagerData.Manager()->SetInheritScale(mTransformManagerData.Id(), inherit);
537 * Retrieve the visibility of the node.
538 * @param[in] bufferIndex The buffer to read from.
539 * @return True if the node is visible.
541 bool IsVisible(BufferIndex bufferIndex) const
543 return mVisible[bufferIndex];
547 * Retrieve the opacity of the node.
548 * @param[in] bufferIndex The buffer to read from.
549 * @return The opacity.
551 float GetOpacity(BufferIndex bufferIndex) const
553 return mColor[bufferIndex].a;
557 * Retrieve the color of the node.
558 * @param[in] bufferIndex The buffer to read from.
561 const Vector4& GetColor(BufferIndex bufferIndex) const
563 return mColor[bufferIndex];
567 * Sets the color of the node derived from the color of all its parents.
568 * @param[in] color The world color.
569 * @param[in] updateBufferIndex The current update buffer index.
571 void SetWorldColor(const Vector4& color, BufferIndex updateBufferIndex)
573 mWorldColor.Set(updateBufferIndex, color);
577 * Sets the color of the node derived from the color of all its parents.
578 * This method should only be called when the parents world color is up-to-date.
579 * @pre The node has a parent.
580 * @param[in] updateBufferIndex The current update buffer index.
582 void InheritWorldColor(BufferIndex updateBufferIndex)
584 DALI_ASSERT_DEBUG(mParent != NULL);
587 if(mColorMode == USE_OWN_MULTIPLY_PARENT_ALPHA)
589 const Vector4& ownColor = mColor[updateBufferIndex];
590 mWorldColor.Set(updateBufferIndex, ownColor.r, ownColor.g, ownColor.b, ownColor.a * mParent->GetWorldColor(updateBufferIndex).a);
592 else if(mColorMode == USE_OWN_MULTIPLY_PARENT_COLOR)
594 mWorldColor.Set(updateBufferIndex, mParent->GetWorldColor(updateBufferIndex) * mColor[updateBufferIndex]);
596 else if(mColorMode == USE_PARENT_COLOR)
598 mWorldColor.Set(updateBufferIndex, mParent->GetWorldColor(updateBufferIndex));
600 else // USE_OWN_COLOR
602 mWorldColor.Set(updateBufferIndex, mColor[updateBufferIndex]);
607 * Copies the previous inherited scale, if this changed in the previous frame.
608 * This method should be called instead of InheritWorldScale i.e. if the inherited scale
609 * does not need to be recalculated in the current frame.
610 * @param[in] updateBufferIndex The current update buffer index.
612 void CopyPreviousWorldColor(BufferIndex updateBufferIndex)
614 mWorldColor.CopyPrevious(updateBufferIndex);
618 * Retrieve the color of the node, possibly derived from the color
619 * of all its parents, depending on the value of mColorMode.
620 * @param[in] bufferIndex The buffer to read from.
621 * @return The world color.
623 const Vector4& GetWorldColor(BufferIndex bufferIndex) const
625 return mWorldColor[bufferIndex];
629 * Set the color mode. This specifies whether the Node uses its own color,
630 * or inherits its parent color.
631 * @param[in] colorMode The new color mode.
633 void SetColorMode(ColorMode colorMode)
635 mColorMode = colorMode;
637 SetDirtyFlag(NodePropertyFlags::COLOR);
641 * Retrieve the color mode.
642 * @return The color mode.
644 ColorMode GetColorMode() const
650 * Retrieve the size of the node.
651 * @param[in] bufferIndex The buffer to read from.
654 const Vector3& GetSize(BufferIndex bufferIndex) const
656 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
661 return Vector3::ZERO;
665 * Retrieve the update area hint of the node.
666 * @return The update area hint.
668 const Vector4& GetUpdateAreaHint() const
670 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
672 return mUpdateAreaHint.Get(0);
675 return Vector4::ZERO;
679 * Retrieve the bounding sphere of the node
680 * @return A vector4 describing the bounding sphere. XYZ is the center and W is the radius
682 const Vector4& GetBoundingSphere() const
684 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
686 return mTransformManagerData.Manager()->GetBoundingSphere(mTransformManagerData.Id());
689 return Vector4::ZERO;
693 * Retrieve world matrix and size of the node
694 * @param[out] The local to world matrix of the node
695 * @param[out] size The current size of the node
697 void GetWorldMatrixAndSize(Matrix& worldMatrix, Vector3& size) const
699 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
701 mTransformManagerData.Manager()->GetWorldMatrixAndSize(mTransformManagerData.Id(), worldMatrix, size);
706 * Checks if local matrix has changed since last update
707 * @return true if local matrix has changed, false otherwise
709 bool IsLocalMatrixDirty() const
711 return (mTransformManagerData.Id() != INVALID_TRANSFORM_ID) &&
712 (mTransformManagerData.Manager()->IsLocalMatrixDirty(mTransformManagerData.Id()));
716 * Retrieve the cached world-matrix of a node.
717 * @param[in] bufferIndex The buffer to read from.
718 * @return The world-matrix.
720 const Matrix& GetWorldMatrix(BufferIndex bufferIndex) const
722 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
724 return mWorldMatrix.Get(bufferIndex);
727 return Matrix::IDENTITY;
731 * Mark the node as exclusive to a single RenderTask.
732 * @param[in] renderTask The render-task, or NULL if the Node is not exclusive to a single RenderTask.
734 void SetExclusiveRenderTask(RenderTask* renderTask)
736 mExclusiveRenderTask = renderTask;
740 * Query whether the node is exclusive to a single RenderTask.
741 * @return The render-task, or NULL if the Node is not exclusive to a single RenderTask.
743 RenderTask* GetExclusiveRenderTask() const
745 return mExclusiveRenderTask;
749 * Set how the Node and its children should be drawn; see Dali::Actor::SetDrawMode() for more details.
750 * @param[in] drawMode The new draw-mode to use.
752 void SetDrawMode(const DrawMode::Type& drawMode)
754 mDrawMode = drawMode;
758 * Returns whether node is an overlay or not.
759 * @return True if node is an overlay, false otherwise.
761 DrawMode::Type GetDrawMode() const
766 void SetTransparent(bool transparent)
768 mTransparent = transparent;
771 bool IsTransparent() const
777 * Returns the transform id of the node
778 * @return The transform component id of the node
780 TransformId GetTransformId() const
782 return mTransformManagerData.Id();
786 * Equality operator, checks for identity, not values.
789 bool operator==(const Node* rhs) const
791 return (this == rhs);
795 * @brief Sets the sibling order of the node
796 * @param[in] order The new order
798 void SetDepthIndex(uint32_t depthIndex)
800 if(depthIndex != mDepthIndex)
802 SetDirtyFlag(NodePropertyFlags::DEPTH_INDEX);
803 mDepthIndex = depthIndex;
808 * @brief Get the depth index of the node
809 * @return Current depth index
811 uint32_t GetDepthIndex() const
817 * @brief Sets the boolean which states whether the position should use the anchor-point.
818 * @param[in] positionUsesAnchorPoint True if the position should use the anchor-point
820 void SetPositionUsesAnchorPoint(bool positionUsesAnchorPoint)
822 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID && mPositionUsesAnchorPoint != positionUsesAnchorPoint)
824 mPositionUsesAnchorPoint = positionUsesAnchorPoint;
825 mTransformManagerData.Manager()->SetPositionUsesAnchorPoint(mTransformManagerData.Id(), mPositionUsesAnchorPoint);
830 * @brief Sets whether the node is culled or not.
831 * @param[in] bufferIndex The buffer to read from.
832 * @param[in] culled True if the node is culled.
834 void SetCulled(BufferIndex bufferIndex, bool culled)
836 mCulled[bufferIndex] = culled;
840 * @brief Retrieves whether the node is culled or not.
841 * @param[in] bufferIndex The buffer to read from.
842 * @return True if the node is culled.
844 bool IsCulled(BufferIndex bufferIndex) const
846 return mCulled[bufferIndex];
851 * @copydoc Dali::Internal::SceneGraph::PropertyOwner::IsAnimationPossible
853 bool IsAnimationPossible() const override;
856 * Called by UpdateManager when the node is added.
857 * Creates a new transform component in the transform manager and initialize all the properties
858 * related to the transformation
859 * @param[in] transformManager A pointer to the trnasform manager (Owned by UpdateManager)
861 void CreateTransform(SceneGraph::TransformManager* transformManager);
866 void ResetDirtyFlags(BufferIndex updateBufferIndex);
870 * Set the parent of a Node.
871 * @param[in] parentNode the new parent.
873 void SetParent(Node& parentNode);
877 * Protected constructor; See also Node::New()
882 * Protected virtual destructor; See also Node::Delete( Node* )
883 * Kept protected to allow destructor chaining from layer
887 private: // from NodeDataProvider
889 * @copydoc NodeDataProvider::GetModelMatrix
891 const Matrix& GetModelMatrix(BufferIndex bufferIndex) const override
893 return GetWorldMatrix(bufferIndex);
897 * @copydoc NodeDataProvider::GetRenderColor
899 const Vector4& GetRenderColor(BufferIndex bufferIndex) const override
901 return GetWorldColor(bufferIndex);
905 * @copydoc NodeDataProvider::GetNodeUniformMap
907 const UniformMap& GetNodeUniformMap() const override
909 return GetUniformMap();
913 // Delete copy and move
914 Node(const Node&) = delete;
915 Node(Node&&) = delete;
916 Node& operator=(const Node& rhs) = delete;
917 Node& operator=(Node&& rhs) = delete;
920 * Recursive helper to disconnect a Node and its children.
921 * Disconnected Nodes have no parent or children.
922 * @param[in] updateBufferIndex The current update buffer index.
924 void RecursiveDisconnectFromSceneGraph(BufferIndex updateBufferIndex);
926 public: // Default properties
927 using TransformManagerParentsOrigin = TransformManagerPropertyVector3<TRANSFORM_PROPERTY_PARENT_ORIGIN>;
928 using TransformManagerAnchorPoint = TransformManagerPropertyVector3<TRANSFORM_PROPERTY_ANCHOR_POINT>;
929 using TransformManagerSize = TransformManagerPropertyVector3<TRANSFORM_PROPERTY_SIZE>;
930 using TransformManagerPosition = TransformManagerPropertyVector3<TRANSFORM_PROPERTY_POSITION>;
931 using TransformManagerScale = TransformManagerPropertyVector3<TRANSFORM_PROPERTY_SCALE>;
933 TransformManagerData mTransformManagerData;
934 TransformManagerParentsOrigin mParentOrigin; ///< Local transform; the position is relative to this. Sets the Transform flag dirty when changed
935 TransformManagerAnchorPoint mAnchorPoint; ///< Local transform; local center of rotation. Sets the Transform flag dirty when changed
936 TransformManagerSize mSize; ///< Size is provided for layouting
937 TransformManagerPosition mPosition; ///< Local transform; distance between parent-origin & anchor-point
938 TransformManagerScale mScale; ///< Local transform; scale relative to parent node
939 TransformManagerPropertyQuaternion mOrientation; ///< Local transform; rotation relative to parent node
941 AnimatableProperty<bool> mVisible; ///< Visibility can be inherited from the Node hierachy
942 AnimatableProperty<bool> mCulled; ///< True if the node is culled. This is not animatable. It is just double-buffered.
943 AnimatableProperty<Vector4> mColor; ///< Color can be inherited from the Node hierarchy
944 AnimatableProperty<Vector4> mUpdateAreaHint; ///< Update area hint is provided for damaged area calculation. (x, y, width, height)
945 ///< This is not animatable. It is just double-buffered. (Because all these bloody properties are).
947 // Inherited properties; read-only from public API
949 TransformManagerVector3Input mWorldPosition; ///< Full inherited position
950 TransformManagerVector3Input mWorldScale;
951 TransformManagerQuaternionInput mWorldOrientation; ///< Full inherited orientation
952 TransformManagerMatrixInput mWorldMatrix; ///< Full inherited world matrix
953 InheritedColor mWorldColor; ///< Full inherited color
955 uint32_t mClippingSortModifier; ///< Contains bit-packed clipping information for quick access when sorting
956 const uint32_t mId; ///< The Unique ID of the node.
959 static uint32_t mNodeCounter; ///< count of total nodes, used for unique ids
961 Node* mParent; ///< Pointer to parent node (a child is owned by its parent)
962 RenderTask* mExclusiveRenderTask; ///< Nodes can be marked as exclusive to a single RenderTask
964 RendererContainer mRenderer; ///< Container of renderers; not owned
966 NodeContainer mChildren; ///< Container of children; not owned
968 uint32_t mClippingDepth; ///< The number of stencil clipping nodes deep this node is
969 uint32_t mScissorDepth; ///< The number of scissor clipping nodes deep this node is
971 uint32_t mDepthIndex; ///< Depth index of the node
973 // flags, compressed to bitfield
974 NodePropertyFlags mDirtyFlags; ///< Dirty flags for each of the Node properties
975 DrawMode::Type mDrawMode : 3; ///< How the Node and its children should be drawn
976 ColorMode mColorMode : 3; ///< Determines whether mWorldColor is inherited, 2 bits is enough
977 ClippingMode::Type mClippingMode : 3; ///< The clipping mode of this node
978 bool mIsRoot : 1; ///< True if the node cannot have a parent
979 bool mIsLayer : 1; ///< True if the node is a layer
980 bool mIsCamera : 1; ///< True if the node is a camera
981 bool mPositionUsesAnchorPoint : 1; ///< True if the node should use the anchor-point when calculating the position
982 bool mTransparent : 1; ///< True if this node is transparent. This value do not affect children.
984 // Changes scope, should be at end of class
985 DALI_LOG_OBJECT_STRING_DECLARATION;
990 inline void SetInheritOrientationMessage(EventThreadServices& eventThreadServices, const Node& node, bool inherit)
992 using LocalType = MessageValue1<Node, bool>;
994 // Reserve some memory inside the message queue
995 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
997 // Construct message in the message queue memory; note that delete should not be called on the return value
998 new(slot) LocalType(&node, &Node::SetInheritOrientation, inherit);
1001 inline void SetParentOriginMessage(EventThreadServices& eventThreadServices, const Node& node, const Vector3& origin)
1003 using LocalType = MessageValue1<Node, Vector3>;
1005 // Reserve some memory inside the message queue
1006 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1008 // Construct message in the message queue memory; note that delete should not be called on the return value
1009 new(slot) LocalType(&node, &Node::SetParentOrigin, origin);
1012 inline void SetAnchorPointMessage(EventThreadServices& eventThreadServices, const Node& node, const Vector3& anchor)
1014 using LocalType = MessageValue1<Node, Vector3>;
1016 // Reserve some memory inside the message queue
1017 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1019 // Construct message in the message queue memory; note that delete should not be called on the return value
1020 new(slot) LocalType(&node, &Node::SetAnchorPoint, anchor);
1023 inline void SetInheritPositionMessage(EventThreadServices& eventThreadServices, const Node& node, bool inherit)
1025 using LocalType = MessageValue1<Node, bool>;
1027 // Reserve some memory inside the message queue
1028 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1030 // Construct message in the message queue memory; note that delete should not be called on the return value
1031 new(slot) LocalType(&node, &Node::SetInheritPosition, inherit);
1034 inline void SetInheritScaleMessage(EventThreadServices& eventThreadServices, const Node& node, bool inherit)
1036 using LocalType = MessageValue1<Node, bool>;
1038 // Reserve some memory inside the message queue
1039 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1041 // Construct message in the message queue memory; note that delete should not be called on the return value
1042 new(slot) LocalType(&node, &Node::SetInheritScale, inherit);
1045 inline void SetColorModeMessage(EventThreadServices& eventThreadServices, const Node& node, ColorMode colorMode)
1047 using LocalType = MessageValue1<Node, ColorMode>;
1049 // Reserve some memory inside the message queue
1050 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1052 // Construct message in the message queue memory; note that delete should not be called on the return value
1053 new(slot) LocalType(&node, &Node::SetColorMode, colorMode);
1056 inline void SetDrawModeMessage(EventThreadServices& eventThreadServices, const Node& node, DrawMode::Type drawMode)
1058 using LocalType = MessageValue1<Node, DrawMode::Type>;
1060 // Reserve some memory inside the message queue
1061 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1063 // Construct message in the message queue memory; note that delete should not be called on the return value
1064 new(slot) LocalType(&node, &Node::SetDrawMode, drawMode);
1067 inline void SetTransparentMessage(EventThreadServices& eventThreadServices, const Node& node, bool transparent)
1069 using LocalType = MessageValue1<Node, bool>;
1071 // Reserve some memory inside the message queue
1072 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1074 // Construct message in the message queue memory; note that delete should not be called on the return value
1075 new(slot) LocalType(&node, &Node::SetTransparent, transparent);
1078 inline void DetachRendererMessage(EventThreadServices& eventThreadServices, const Node& node, const Renderer& renderer)
1080 using LocalType = MessageValue1<Node, const Renderer*>;
1082 // Reserve some memory inside the message queue
1083 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1085 // Construct message in the message queue memory; note that delete should not be called on the return value
1086 new(slot) LocalType(&node, &Node::RemoveRenderer, &renderer);
1089 inline void SetDepthIndexMessage(EventThreadServices& eventThreadServices, const Node& node, uint32_t depthIndex)
1091 using LocalType = MessageValue1<Node, uint32_t>;
1093 // Reserve some memory inside the message queue
1094 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1096 // Construct message in the message queue memory; note that delete should not be called on the return value
1097 new(slot) LocalType(&node, &Node::SetDepthIndex, depthIndex);
1100 inline void SetClippingModeMessage(EventThreadServices& eventThreadServices, const Node& node, ClippingMode::Type clippingMode)
1102 using LocalType = MessageValue1<Node, ClippingMode::Type>;
1104 // Reserve some memory inside the message queue
1105 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1107 // Construct message in the message queue memory; note that delete should not be called on the return value
1108 new(slot) LocalType(&node, &Node::SetClippingMode, clippingMode);
1111 inline void SetPositionUsesAnchorPointMessage(EventThreadServices& eventThreadServices, const Node& node, bool positionUsesAnchorPoint)
1113 using LocalType = MessageValue1<Node, bool>;
1115 // Reserve some memory inside the message queue
1116 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1118 // Construct message in the message queue memory; note that delete should not be called on the return value
1119 new(slot) LocalType(&node, &Node::SetPositionUsesAnchorPoint, positionUsesAnchorPoint);
1122 } // namespace SceneGraph
1124 // Template specialisation for OwnerPointer<Node>, because delete is protected
1126 inline void OwnerPointer<Dali::Internal::SceneGraph::Node>::Reset()
1128 if(mObject != nullptr)
1130 Dali::Internal::SceneGraph::Node::Delete(mObject);
1134 } // namespace Internal
1136 // Template specialisations for OwnerContainer<Node*>, because delete is protected
1138 inline void OwnerContainer<Dali::Internal::SceneGraph::Node*>::Delete(Dali::Internal::SceneGraph::Node* pointer)
1140 Dali::Internal::SceneGraph::Node::Delete(pointer);
1144 #endif // DALI_INTERNAL_SCENE_GRAPH_NODE_H