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/nodes/partial-rendering-data.h>
34 #include <dali/internal/update/rendering/scene-graph-renderer.h>
35 #include <dali/public-api/actors/actor-enumerations.h>
36 #include <dali/public-api/actors/draw-mode.h>
37 #include <dali/public-api/math/math-utils.h>
38 #include <dali/public-api/math/quaternion.h>
39 #include <dali/public-api/math/vector3.h>
45 // Value types used by messages.
47 struct ParameterType<ColorMode> : public BasicType<ColorMode>
51 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 added to the node
231 void AddRenderer(Renderer* renderer);
234 * Remove a renderer from the node
235 * @param[in] renderer The renderer to be removed
237 void RemoveRenderer(const Renderer* renderer);
240 * Get the renderer at the given index
243 Renderer* GetRendererAt(uint32_t index) const
245 return mRenderer[index];
249 * Retrieve the number of renderers for the node
251 uint32_t GetRendererCount() const
253 return static_cast<uint32_t>(mRenderer.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 * Retrieve the update area hint of the node.
669 * @return The update area hint.
671 const Vector4& GetUpdateAreaHint() const
673 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
675 return mUpdateAreaHint.Get(0);
678 return Vector4::ZERO;
682 * Retrieve the bounding sphere of the node
683 * @return A vector4 describing the bounding sphere. XYZ is the center and W is the radius
685 const Vector4& GetBoundingSphere() const
687 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
689 return mTransformManagerData.Manager()->GetBoundingSphere(mTransformManagerData.Id());
692 return Vector4::ZERO;
696 * Retrieve world matrix and size of the node
697 * @param[out] The local to world matrix of the node
698 * @param[out] size The current size of the node
700 void GetWorldMatrixAndSize(Matrix& worldMatrix, Vector3& size) const
702 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
704 mTransformManagerData.Manager()->GetWorldMatrixAndSize(mTransformManagerData.Id(), worldMatrix, size);
709 * Checks if local matrix has changed since last update
710 * @return true if local matrix has changed, false otherwise
712 bool IsLocalMatrixDirty() const
714 return (mTransformManagerData.Id() != INVALID_TRANSFORM_ID) &&
715 (mTransformManagerData.Manager()->IsLocalMatrixDirty(mTransformManagerData.Id()));
719 * Retrieve the cached world-matrix of a node.
720 * @param[in] bufferIndex The buffer to read from.
721 * @return The world-matrix.
723 const Matrix& GetWorldMatrix(BufferIndex bufferIndex) const
725 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
727 return mWorldMatrix.Get(bufferIndex);
730 return Matrix::IDENTITY;
734 * Mark the node as exclusive to a single RenderTask.
735 * @param[in] renderTask The render-task, or NULL if the Node is not exclusive to a single RenderTask.
737 void SetExclusiveRenderTask(RenderTask* renderTask)
739 mExclusiveRenderTask = renderTask;
743 * Query whether the node is exclusive to a single RenderTask.
744 * @return The render-task, or NULL if the Node is not exclusive to a single RenderTask.
746 RenderTask* GetExclusiveRenderTask() const
748 return mExclusiveRenderTask;
752 * Set how the Node and its children should be drawn; see Dali::Actor::SetDrawMode() for more details.
753 * @param[in] drawMode The new draw-mode to use.
755 void SetDrawMode(const DrawMode::Type& drawMode)
757 mDrawMode = drawMode;
761 * Returns whether node is an overlay or not.
762 * @return True if node is an overlay, false otherwise.
764 DrawMode::Type GetDrawMode() const
769 void SetTransparent(bool transparent)
771 mTransparent = transparent;
774 bool IsTransparent() const
780 * Returns the transform id of the node
781 * @return The transform component id of the node
783 TransformId GetTransformId() const
785 return mTransformManagerData.Id();
789 * Equality operator, checks for identity, not values.
792 bool operator==(const Node* rhs) const
794 return (this == rhs);
798 * @brief Sets the sibling order of the node
799 * @param[in] order The new order
801 void SetDepthIndex(uint32_t depthIndex)
803 if(depthIndex != mDepthIndex)
805 SetDirtyFlag(NodePropertyFlags::DEPTH_INDEX);
806 mDepthIndex = depthIndex;
811 * @brief Get the depth index of the node
812 * @return Current depth index
814 uint32_t GetDepthIndex() const
820 * @brief Sets the boolean which states whether the position should use the anchor-point.
821 * @param[in] positionUsesAnchorPoint True if the position should use the anchor-point
823 void SetPositionUsesAnchorPoint(bool positionUsesAnchorPoint)
825 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID && mPositionUsesAnchorPoint != positionUsesAnchorPoint)
827 mPositionUsesAnchorPoint = positionUsesAnchorPoint;
828 mTransformManagerData.Manager()->SetPositionUsesAnchorPoint(mTransformManagerData.Id(), mPositionUsesAnchorPoint);
833 * @brief Sets whether the node is culled or not.
834 * @param[in] bufferIndex The buffer to read from.
835 * @param[in] culled True if the node is culled.
837 void SetCulled(BufferIndex bufferIndex, bool culled)
839 mCulled[bufferIndex] = culled;
843 * @brief Retrieves whether the node is culled or not.
844 * @param[in] bufferIndex The buffer to read from.
845 * @return True if the node is culled.
847 bool IsCulled(BufferIndex bufferIndex) const
849 return mCulled[bufferIndex];
853 * @brief Returns partial rendering data associated with the node.
854 * @return The partial rendering data
856 PartialRenderingData& GetPartialRenderingData()
858 return mPartialRenderingData;
863 * @copydoc Dali::Internal::SceneGraph::PropertyOwner::IsAnimationPossible
865 bool IsAnimationPossible() const override;
868 * Called by UpdateManager when the node is added.
869 * Creates a new transform component in the transform manager and initialize all the properties
870 * related to the transformation
871 * @param[in] transformManager A pointer to the trnasform manager (Owned by UpdateManager)
873 void CreateTransform(SceneGraph::TransformManager* transformManager);
878 void ResetDirtyFlags(BufferIndex updateBufferIndex);
881 * Update uniform hash
882 * @param[in] bufferIndex The buffer to read from.
884 void UpdateUniformHash(BufferIndex bufferIndex);
888 * Set the parent of a Node.
889 * @param[in] parentNode the new parent.
891 void SetParent(Node& parentNode);
895 * Protected constructor; See also Node::New()
900 * Protected virtual destructor; See also Node::Delete( Node* )
901 * Kept protected to allow destructor chaining from layer
905 private: // from NodeDataProvider
907 * @copydoc NodeDataProvider::GetRenderColor
909 const Vector4& GetRenderColor(BufferIndex bufferIndex) const override
911 return GetWorldColor(bufferIndex);
915 * @copydoc NodeDataProvider::GetNodeUniformMap
917 const UniformMap& GetNodeUniformMap() const override
919 return GetUniformMap();
923 // Delete copy and move
924 Node(const Node&) = delete;
925 Node(Node&&) = delete;
926 Node& operator=(const Node& rhs) = delete;
927 Node& operator=(Node&& rhs) = delete;
930 * Recursive helper to disconnect a Node and its children.
931 * Disconnected Nodes have no parent or children.
932 * @param[in] updateBufferIndex The current update buffer index.
934 void RecursiveDisconnectFromSceneGraph(BufferIndex updateBufferIndex);
936 public: // Default properties
937 using TransformManagerParentsOrigin = TransformManagerPropertyVector3<TRANSFORM_PROPERTY_PARENT_ORIGIN>;
938 using TransformManagerAnchorPoint = TransformManagerPropertyVector3<TRANSFORM_PROPERTY_ANCHOR_POINT>;
939 using TransformManagerSize = TransformManagerPropertyVector3<TRANSFORM_PROPERTY_SIZE>;
940 using TransformManagerPosition = TransformManagerPropertyVector3<TRANSFORM_PROPERTY_POSITION>;
941 using TransformManagerScale = TransformManagerPropertyVector3<TRANSFORM_PROPERTY_SCALE>;
943 TransformManagerData mTransformManagerData;
944 TransformManagerParentsOrigin mParentOrigin; ///< Local transform; the position is relative to this. Sets the Transform flag dirty when changed
945 TransformManagerAnchorPoint mAnchorPoint; ///< Local transform; local center of rotation. Sets the Transform flag dirty when changed
946 TransformManagerSize mSize; ///< Size is provided for layouting
947 TransformManagerPosition mPosition; ///< Local transform; distance between parent-origin & anchor-point
948 TransformManagerScale mScale; ///< Local transform; scale relative to parent node
949 TransformManagerPropertyQuaternion mOrientation; ///< Local transform; rotation relative to parent node
951 AnimatableProperty<bool> mVisible; ///< Visibility can be inherited from the Node hierachy
952 AnimatableProperty<bool> mCulled; ///< True if the node is culled. This is not animatable. It is just double-buffered.
953 AnimatableProperty<Vector4> mColor; ///< Color can be inherited from the Node hierarchy
954 AnimatableProperty<Vector4> mUpdateAreaHint; ///< Update area hint is provided for damaged area calculation. (x, y, width, height)
955 ///< This is not animatable. It is just double-buffered. (Because all these bloody properties are).
957 // Inherited properties; read-only from public API
959 TransformManagerVector3Input mWorldPosition; ///< Full inherited position
960 TransformManagerVector3Input mWorldScale;
961 TransformManagerQuaternionInput mWorldOrientation; ///< Full inherited orientation
962 TransformManagerMatrixInput mWorldMatrix; ///< Full inherited world matrix
963 InheritedColor mWorldColor; ///< Full inherited color
965 uint64_t mUniformsHash{0u}; ///< Hash of uniform map property values
966 uint32_t mClippingSortModifier; ///< Contains bit-packed clipping information for quick access when sorting
967 const uint32_t mId; ///< The Unique ID of the node.
970 static uint32_t mNodeCounter; ///< count of total nodes, used for unique ids
972 PartialRenderingData mPartialRenderingData; ///< Cache to determine if this should be rendered again
974 Node* mParent; ///< Pointer to parent node (a child is owned by its parent)
975 RenderTask* mExclusiveRenderTask; ///< Nodes can be marked as exclusive to a single RenderTask
977 RendererContainer mRenderer; ///< Container of renderers; not owned
979 NodeContainer mChildren; ///< Container of children; not owned
981 uint32_t mClippingDepth; ///< The number of stencil clipping nodes deep this node is
982 uint32_t mScissorDepth; ///< The number of scissor clipping nodes deep this node is
984 uint32_t mDepthIndex; ///< Depth index of the node
986 // flags, compressed to bitfield
987 NodePropertyFlags mDirtyFlags; ///< Dirty flags for each of the Node properties
988 DrawMode::Type mDrawMode : 3; ///< How the Node and its children should be drawn
989 ColorMode mColorMode : 3; ///< Determines whether mWorldColor is inherited, 2 bits is enough
990 ClippingMode::Type mClippingMode : 3; ///< The clipping mode of this node
991 bool mIsRoot : 1; ///< True if the node cannot have a parent
992 bool mIsLayer : 1; ///< True if the node is a layer
993 bool mIsCamera : 1; ///< True if the node is a camera
994 bool mPositionUsesAnchorPoint : 1; ///< True if the node should use the anchor-point when calculating the position
995 bool mTransparent : 1; ///< True if this node is transparent. This value do not affect children.
997 // Changes scope, should be at end of class
998 DALI_LOG_OBJECT_STRING_DECLARATION;
1001 // Messages for Node
1003 inline void SetInheritOrientationMessage(EventThreadServices& eventThreadServices, const Node& node, bool inherit)
1005 using LocalType = MessageValue1<Node, bool>;
1007 // Reserve some memory inside the message queue
1008 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1010 // Construct message in the message queue memory; note that delete should not be called on the return value
1011 new(slot) LocalType(&node, &Node::SetInheritOrientation, inherit);
1014 inline void SetParentOriginMessage(EventThreadServices& eventThreadServices, const Node& node, const Vector3& origin)
1016 using LocalType = MessageValue1<Node, Vector3>;
1018 // Reserve some memory inside the message queue
1019 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1021 // Construct message in the message queue memory; note that delete should not be called on the return value
1022 new(slot) LocalType(&node, &Node::SetParentOrigin, origin);
1025 inline void SetAnchorPointMessage(EventThreadServices& eventThreadServices, const Node& node, const Vector3& anchor)
1027 using LocalType = MessageValue1<Node, Vector3>;
1029 // Reserve some memory inside the message queue
1030 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1032 // Construct message in the message queue memory; note that delete should not be called on the return value
1033 new(slot) LocalType(&node, &Node::SetAnchorPoint, anchor);
1036 inline void SetInheritPositionMessage(EventThreadServices& eventThreadServices, const Node& node, bool inherit)
1038 using LocalType = MessageValue1<Node, bool>;
1040 // Reserve some memory inside the message queue
1041 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1043 // Construct message in the message queue memory; note that delete should not be called on the return value
1044 new(slot) LocalType(&node, &Node::SetInheritPosition, inherit);
1047 inline void SetInheritScaleMessage(EventThreadServices& eventThreadServices, const Node& node, bool inherit)
1049 using LocalType = MessageValue1<Node, bool>;
1051 // Reserve some memory inside the message queue
1052 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1054 // Construct message in the message queue memory; note that delete should not be called on the return value
1055 new(slot) LocalType(&node, &Node::SetInheritScale, inherit);
1058 inline void SetColorModeMessage(EventThreadServices& eventThreadServices, const Node& node, ColorMode colorMode)
1060 using LocalType = MessageValue1<Node, ColorMode>;
1062 // Reserve some memory inside the message queue
1063 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1065 // Construct message in the message queue memory; note that delete should not be called on the return value
1066 new(slot) LocalType(&node, &Node::SetColorMode, colorMode);
1069 inline void SetDrawModeMessage(EventThreadServices& eventThreadServices, const Node& node, DrawMode::Type drawMode)
1071 using LocalType = MessageValue1<Node, DrawMode::Type>;
1073 // Reserve some memory inside the message queue
1074 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1076 // Construct message in the message queue memory; note that delete should not be called on the return value
1077 new(slot) LocalType(&node, &Node::SetDrawMode, drawMode);
1080 inline void SetTransparentMessage(EventThreadServices& eventThreadServices, const Node& node, bool transparent)
1082 using LocalType = MessageValue1<Node, bool>;
1084 // Reserve some memory inside the message queue
1085 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1087 // Construct message in the message queue memory; note that delete should not be called on the return value
1088 new(slot) LocalType(&node, &Node::SetTransparent, transparent);
1091 inline void DetachRendererMessage(EventThreadServices& eventThreadServices, const Node& node, const Renderer& renderer)
1093 using LocalType = MessageValue1<Node, const Renderer*>;
1095 // Reserve some memory inside the message queue
1096 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1098 // Construct message in the message queue memory; note that delete should not be called on the return value
1099 new(slot) LocalType(&node, &Node::RemoveRenderer, &renderer);
1102 inline void SetDepthIndexMessage(EventThreadServices& eventThreadServices, const Node& node, uint32_t depthIndex)
1104 using LocalType = MessageValue1<Node, uint32_t>;
1106 // Reserve some memory inside the message queue
1107 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1109 // Construct message in the message queue memory; note that delete should not be called on the return value
1110 new(slot) LocalType(&node, &Node::SetDepthIndex, depthIndex);
1113 inline void SetClippingModeMessage(EventThreadServices& eventThreadServices, const Node& node, ClippingMode::Type clippingMode)
1115 using LocalType = MessageValue1<Node, ClippingMode::Type>;
1117 // Reserve some memory inside the message queue
1118 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1120 // Construct message in the message queue memory; note that delete should not be called on the return value
1121 new(slot) LocalType(&node, &Node::SetClippingMode, clippingMode);
1124 inline void SetPositionUsesAnchorPointMessage(EventThreadServices& eventThreadServices, const Node& node, bool positionUsesAnchorPoint)
1126 using LocalType = MessageValue1<Node, bool>;
1128 // Reserve some memory inside the message queue
1129 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1131 // Construct message in the message queue memory; note that delete should not be called on the return value
1132 new(slot) LocalType(&node, &Node::SetPositionUsesAnchorPoint, positionUsesAnchorPoint);
1135 } // namespace SceneGraph
1137 // Template specialisation for OwnerPointer<Node>, because delete is protected
1139 inline void OwnerPointer<Dali::Internal::SceneGraph::Node>::Reset()
1141 if(mObject != nullptr)
1143 Dali::Internal::SceneGraph::Node::Delete(mObject);
1147 } // namespace Internal
1149 // Template specialisations for OwnerContainer<Node*>, because delete is protected
1151 inline void OwnerContainer<Dali::Internal::SceneGraph::Node*>::Delete(Dali::Internal::SceneGraph::Node* pointer)
1153 Dali::Internal::SceneGraph::Node::Delete(pointer);
1157 #endif // DALI_INTERNAL_SCENE_GRAPH_NODE_H