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;
218 * Gets the Clipping Mode for this node.
219 * @return The ClippingMode of this node
221 ClippingMode::Type GetClippingMode() const
223 return mClippingMode;
227 * Add a renderer to the node
228 * @param[in] renderer The renderer added to the node
230 void AddRenderer(Renderer* renderer);
233 * Remove a renderer from the node
234 * @param[in] renderer The renderer to be removed
236 void RemoveRenderer(const Renderer* renderer);
239 * Get the renderer at the given index
242 Renderer* GetRendererAt(uint32_t index) const
244 return mRenderer[index];
248 * Retrieve the number of renderers for the node
250 uint32_t GetRendererCount() const
252 return static_cast<uint32_t>(mRenderer.Size());
255 // Containment methods
258 * Query whether a node is the root node. Root nodes cannot have a parent node.
259 * A node becomes a root node, when it is installed by UpdateManager.
260 * @return True if the node is a root node.
268 * Set whether a node is the root node. Root nodes cannot have a parent node.
269 * This method should only be called by UpdateManager.
270 * @pre When isRoot is true, the node must not have a parent.
271 * @param[in] isRoot Whether the node is now a root node.
273 void SetRoot(bool isRoot);
276 * Retrieve the parent of a Node.
277 * @return The parent node, or NULL if the Node has not been added to the scene-graph.
285 * Retrieve the parent of a Node.
286 * @return The parent node, or NULL if the Node has not been added to the scene-graph.
288 const Node* GetParent() const
294 * @return true if the node is connected to SceneGraph
296 bool ConnectedToScene()
298 return IsRoot() || GetParent();
302 * Connect a node to the scene-graph.
303 * @pre A node cannot be added to itself.
304 * @pre The parent node is connected to the scene-graph.
305 * @pre The childNode does not already have a parent.
306 * @pre The childNode is not a root node.
307 * @param[in] childNode The child to add.
309 void ConnectChild(Node* childNode);
312 * Disconnect a child (& its children) from the scene-graph.
313 * @pre childNode is a child of this Node.
314 * @param[in] updateBufferIndex The current update buffer index.
315 * @param[in] childNode The node to disconnect.
317 void DisconnectChild(BufferIndex updateBufferIndex, Node& childNode);
320 * Retrieve the children a Node.
321 * @return The container of children.
323 const NodeContainer& GetChildren() const
329 * Retrieve the children a Node.
330 * @return The container of children.
332 NodeContainer& GetChildren()
340 * Flag that one of the node values has changed in the current frame.
341 * @param[in] flag The flag to set.
343 void SetDirtyFlag(NodePropertyFlags flag)
349 * Flag that all of the node values are dirty.
351 void SetAllDirtyFlags()
353 mDirtyFlags = NodePropertyFlags::ALL;
357 * Query whether a node is dirty.
358 * @return The dirty flags
360 NodePropertyFlags GetDirtyFlags() const;
363 * Query inherited dirty flags.
365 * @param The parentFlags to or with
366 * @return The inherited dirty flags
368 NodePropertyFlags GetInheritedDirtyFlags(NodePropertyFlags parentFlags) const;
371 * Retrieve the parent-origin of the node.
372 * @return The parent-origin.
374 const Vector3& GetParentOrigin() const
376 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
378 return mParentOrigin.Get(0);
381 return Vector3::ZERO;
385 * Sets both the local & base parent-origins of the node.
386 * @param[in] origin The new local & base parent-origins.
388 void SetParentOrigin(const Vector3& origin)
390 mParentOrigin.Set(0, origin);
394 * Retrieve the anchor-point of the node.
395 * @return The anchor-point.
397 const Vector3& GetAnchorPoint() const
399 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
401 return mAnchorPoint.Get(0);
404 return Vector3::ZERO;
408 * Sets both the local & base anchor-points of the node.
409 * @param[in] anchor The new local & base anchor-points.
411 void SetAnchorPoint(const Vector3& anchor)
413 mAnchorPoint.Set(0, anchor);
417 * Retrieve the local position of the node, relative to its parent.
418 * @param[in] bufferIndex The buffer to read from.
419 * @return The local position.
421 const Vector3& GetPosition(BufferIndex bufferIndex) const
423 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
425 return mPosition.Get(bufferIndex);
428 return Vector3::ZERO;
432 * Retrieve the position of the node derived from the position of all its parents.
433 * @return The world position.
435 const Vector3& GetWorldPosition(BufferIndex bufferIndex) const
437 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
439 return mWorldPosition.Get(bufferIndex);
441 return Vector3::ZERO;
445 * Set whether the Node inherits position.
446 * @param[in] inherit True if the parent position is inherited.
448 void SetInheritPosition(bool inherit)
450 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
452 mTransformManagerData.Manager()->SetInheritPosition(mTransformManagerData.Id(), inherit);
457 * Retrieve the local orientation of the node, relative to its parent.
458 * @param[in] bufferIndex The buffer to read from.
459 * @return The local orientation.
461 const Quaternion& GetOrientation(BufferIndex bufferIndex) const
463 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
465 return mOrientation.Get(0);
468 return Quaternion::IDENTITY;
472 * Retrieve the orientation of the node derived from the rotation of all its parents.
473 * @param[in] bufferIndex The buffer to read from.
474 * @return The world rotation.
476 const Quaternion& GetWorldOrientation(BufferIndex bufferIndex) const
478 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
480 return mWorldOrientation.Get(0);
482 return Quaternion::IDENTITY;
486 * Set whether the Node inherits orientation.
487 * @param[in] inherit True if the parent orientation is inherited.
489 void SetInheritOrientation(bool inherit)
491 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
493 mTransformManagerData.Manager()->SetInheritOrientation(mTransformManagerData.Id(), inherit);
498 * Retrieve the local scale of the node, relative to its parent.
499 * @param[in] bufferIndex The buffer to read from.
500 * @return The local scale.
502 const Vector3& GetScale(BufferIndex bufferIndex) const
504 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
506 return mScale.Get(0);
513 * Retrieve the scale of the node derived from the scale of all its parents.
514 * @param[in] bufferIndex The buffer to read from.
515 * @return The world scale.
517 const Vector3& GetWorldScale(BufferIndex bufferIndex) const
519 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
521 return mWorldScale.Get(0);
527 * Set whether the Node inherits scale.
528 * @param inherit True if the Node inherits scale.
530 void SetInheritScale(bool inherit)
532 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
534 mTransformManagerData.Manager()->SetInheritScale(mTransformManagerData.Id(), inherit);
539 * Retrieve the visibility of the node.
540 * @param[in] bufferIndex The buffer to read from.
541 * @return True if the node is visible.
543 bool IsVisible(BufferIndex bufferIndex) const
545 return mVisible[bufferIndex];
549 * Retrieve the opacity of the node.
550 * @param[in] bufferIndex The buffer to read from.
551 * @return The opacity.
553 float GetOpacity(BufferIndex bufferIndex) const
555 return mColor[bufferIndex].a;
559 * Retrieve the color of the node.
560 * @param[in] bufferIndex The buffer to read from.
563 const Vector4& GetColor(BufferIndex bufferIndex) const
565 return mColor[bufferIndex];
569 * Sets the color of the node derived from the color of all its parents.
570 * @param[in] color The world color.
571 * @param[in] updateBufferIndex The current update buffer index.
573 void SetWorldColor(const Vector4& color, BufferIndex updateBufferIndex)
575 mWorldColor.Set(updateBufferIndex, color);
579 * Sets the color of the node derived from the color of all its parents.
580 * This method should only be called when the parents world color is up-to-date.
581 * @pre The node has a parent.
582 * @param[in] updateBufferIndex The current update buffer index.
584 void InheritWorldColor(BufferIndex updateBufferIndex)
586 DALI_ASSERT_DEBUG(mParent != NULL);
589 if(mColorMode == USE_OWN_MULTIPLY_PARENT_ALPHA)
591 const Vector4& ownColor = mColor[updateBufferIndex];
592 mWorldColor.Set(updateBufferIndex, ownColor.r, ownColor.g, ownColor.b, ownColor.a * mParent->GetWorldColor(updateBufferIndex).a);
594 else if(mColorMode == USE_OWN_MULTIPLY_PARENT_COLOR)
596 mWorldColor.Set(updateBufferIndex, mParent->GetWorldColor(updateBufferIndex) * mColor[updateBufferIndex]);
598 else if(mColorMode == USE_PARENT_COLOR)
600 mWorldColor.Set(updateBufferIndex, mParent->GetWorldColor(updateBufferIndex));
602 else // USE_OWN_COLOR
604 mWorldColor.Set(updateBufferIndex, mColor[updateBufferIndex]);
609 * Copies the previous inherited scale, if this changed in the previous frame.
610 * This method should be called instead of InheritWorldScale i.e. if the inherited scale
611 * does not need to be recalculated in the current frame.
612 * @param[in] updateBufferIndex The current update buffer index.
614 void CopyPreviousWorldColor(BufferIndex updateBufferIndex)
616 mWorldColor.CopyPrevious(updateBufferIndex);
620 * Retrieve the color of the node, possibly derived from the color
621 * of all its parents, depending on the value of mColorMode.
622 * @param[in] bufferIndex The buffer to read from.
623 * @return The world color.
625 const Vector4& GetWorldColor(BufferIndex bufferIndex) const
627 return mWorldColor[bufferIndex];
631 * Set the color mode. This specifies whether the Node uses its own color,
632 * or inherits its parent color.
633 * @param[in] colorMode The new color mode.
635 void SetColorMode(ColorMode colorMode)
637 mColorMode = colorMode;
639 SetDirtyFlag(NodePropertyFlags::COLOR);
643 * Retrieve the color mode.
644 * @return The color mode.
646 ColorMode GetColorMode() const
652 * Retrieve the size of the node.
653 * @param[in] bufferIndex The buffer to read from.
656 const Vector3& GetSize(BufferIndex bufferIndex) const
658 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
663 return Vector3::ZERO;
667 * Retrieve the update area hint of the node.
668 * @return The update area hint.
670 const Vector4& GetUpdateAreaHint() const
672 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
674 return mUpdateAreaHint.Get(0);
677 return Vector4::ZERO;
681 * Retrieve the bounding sphere of the node
682 * @return A vector4 describing the bounding sphere. XYZ is the center and W is the radius
684 const Vector4& GetBoundingSphere() const
686 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
688 return mTransformManagerData.Manager()->GetBoundingSphere(mTransformManagerData.Id());
691 return Vector4::ZERO;
695 * Retrieve world matrix and size of the node
696 * @param[out] The local to world matrix of the node
697 * @param[out] size The current size of the node
699 void GetWorldMatrixAndSize(Matrix& worldMatrix, Vector3& size) const
701 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
703 mTransformManagerData.Manager()->GetWorldMatrixAndSize(mTransformManagerData.Id(), worldMatrix, size);
708 * Checks if local matrix has changed since last update
709 * @return true if local matrix has changed, false otherwise
711 bool IsLocalMatrixDirty() const
713 return (mTransformManagerData.Id() != INVALID_TRANSFORM_ID) &&
714 (mTransformManagerData.Manager()->IsLocalMatrixDirty(mTransformManagerData.Id()));
718 * Retrieve the cached world-matrix of a node.
719 * @param[in] bufferIndex The buffer to read from.
720 * @return The world-matrix.
722 const Matrix& GetWorldMatrix(BufferIndex bufferIndex) const
724 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
726 return mWorldMatrix.Get(bufferIndex);
729 return Matrix::IDENTITY;
733 * Mark the node as exclusive to a single RenderTask.
734 * @param[in] renderTask The render-task, or NULL if the Node is not exclusive to a single RenderTask.
736 void SetExclusiveRenderTask(RenderTask* renderTask)
738 mExclusiveRenderTask = renderTask;
742 * Query whether the node is exclusive to a single RenderTask.
743 * @return The render-task, or NULL if the Node is not exclusive to a single RenderTask.
745 RenderTask* GetExclusiveRenderTask() const
747 return mExclusiveRenderTask;
751 * Set how the Node and its children should be drawn; see Dali::Actor::SetDrawMode() for more details.
752 * @param[in] drawMode The new draw-mode to use.
754 void SetDrawMode(const DrawMode::Type& drawMode)
756 mDrawMode = drawMode;
760 * Returns whether node is an overlay or not.
761 * @return True if node is an overlay, false otherwise.
763 DrawMode::Type GetDrawMode() const
768 void SetTransparent(bool transparent)
770 mTransparent = transparent;
773 bool IsTransparent() const
779 * Returns the transform id of the node
780 * @return The transform component id of the node
782 TransformId GetTransformId() const
784 return mTransformManagerData.Id();
788 * Equality operator, checks for identity, not values.
791 bool operator==(const Node* rhs) const
793 return (this == rhs);
797 * @brief Sets the sibling order of the node
798 * @param[in] order The new order
800 void SetDepthIndex(uint32_t depthIndex)
802 if(depthIndex != mDepthIndex)
804 SetDirtyFlag(NodePropertyFlags::DEPTH_INDEX);
805 mDepthIndex = depthIndex;
810 * @brief Get the depth index of the node
811 * @return Current depth index
813 uint32_t GetDepthIndex() const
819 * @brief Sets the boolean which states whether the position should use the anchor-point.
820 * @param[in] positionUsesAnchorPoint True if the position should use the anchor-point
822 void SetPositionUsesAnchorPoint(bool positionUsesAnchorPoint)
824 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID && mPositionUsesAnchorPoint != positionUsesAnchorPoint)
826 mPositionUsesAnchorPoint = positionUsesAnchorPoint;
827 mTransformManagerData.Manager()->SetPositionUsesAnchorPoint(mTransformManagerData.Id(), mPositionUsesAnchorPoint);
832 * @brief Sets whether the node is culled or not.
833 * @param[in] bufferIndex The buffer to read from.
834 * @param[in] culled True if the node is culled.
836 void SetCulled(BufferIndex bufferIndex, bool culled)
838 mCulled[bufferIndex] = culled;
842 * @brief Retrieves whether the node is culled or not.
843 * @param[in] bufferIndex The buffer to read from.
844 * @return True if the node is culled.
846 bool IsCulled(BufferIndex bufferIndex) const
848 return mCulled[bufferIndex];
852 * @brief Returns partial rendering data associated with the node.
853 * @return The partial rendering data
855 PartialRenderingData& GetPartialRenderingData()
857 return mPartialRenderingData;
862 * @copydoc Dali::Internal::SceneGraph::PropertyOwner::IsAnimationPossible
864 bool IsAnimationPossible() const override;
867 * Called by UpdateManager when the node is added.
868 * Creates a new transform component in the transform manager and initialize all the properties
869 * related to the transformation
870 * @param[in] transformManager A pointer to the trnasform manager (Owned by UpdateManager)
872 void CreateTransform(SceneGraph::TransformManager* transformManager);
877 void ResetDirtyFlags(BufferIndex updateBufferIndex);
881 * Set the parent of a Node.
882 * @param[in] parentNode the new parent.
884 void SetParent(Node& parentNode);
888 * Protected constructor; See also Node::New()
893 * Protected virtual destructor; See also Node::Delete( Node* )
894 * Kept protected to allow destructor chaining from layer
898 private: // from NodeDataProvider
900 * @copydoc NodeDataProvider::GetRenderColor
902 const Vector4& GetRenderColor(BufferIndex bufferIndex) const override
904 return GetWorldColor(bufferIndex);
908 * @copydoc NodeDataProvider::GetNodeUniformMap
910 const UniformMap& GetNodeUniformMap() const override
912 return GetUniformMap();
916 // Delete copy and move
917 Node(const Node&) = delete;
918 Node(Node&&) = delete;
919 Node& operator=(const Node& rhs) = delete;
920 Node& operator=(Node&& rhs) = delete;
923 * Recursive helper to disconnect a Node and its children.
924 * Disconnected Nodes have no parent or children.
925 * @param[in] updateBufferIndex The current update buffer index.
927 void RecursiveDisconnectFromSceneGraph(BufferIndex updateBufferIndex);
929 public: // Default properties
930 using TransformManagerParentsOrigin = TransformManagerPropertyVector3<TRANSFORM_PROPERTY_PARENT_ORIGIN>;
931 using TransformManagerAnchorPoint = TransformManagerPropertyVector3<TRANSFORM_PROPERTY_ANCHOR_POINT>;
932 using TransformManagerSize = TransformManagerPropertyVector3<TRANSFORM_PROPERTY_SIZE>;
933 using TransformManagerPosition = TransformManagerPropertyVector3<TRANSFORM_PROPERTY_POSITION>;
934 using TransformManagerScale = TransformManagerPropertyVector3<TRANSFORM_PROPERTY_SCALE>;
936 TransformManagerData mTransformManagerData;
937 TransformManagerParentsOrigin mParentOrigin; ///< Local transform; the position is relative to this. Sets the Transform flag dirty when changed
938 TransformManagerAnchorPoint mAnchorPoint; ///< Local transform; local center of rotation. Sets the Transform flag dirty when changed
939 TransformManagerSize mSize; ///< Size is provided for layouting
940 TransformManagerPosition mPosition; ///< Local transform; distance between parent-origin & anchor-point
941 TransformManagerScale mScale; ///< Local transform; scale relative to parent node
942 TransformManagerPropertyQuaternion mOrientation; ///< Local transform; rotation relative to parent node
944 AnimatableProperty<bool> mVisible; ///< Visibility can be inherited from the Node hierachy
945 AnimatableProperty<bool> mCulled; ///< True if the node is culled. This is not animatable. It is just double-buffered.
946 AnimatableProperty<Vector4> mColor; ///< Color can be inherited from the Node hierarchy
947 AnimatableProperty<Vector4> mUpdateAreaHint; ///< Update area hint is provided for damaged area calculation. (x, y, width, height)
948 ///< This is not animatable. It is just double-buffered. (Because all these bloody properties are).
950 // Inherited properties; read-only from public API
952 TransformManagerVector3Input mWorldPosition; ///< Full inherited position
953 TransformManagerVector3Input mWorldScale;
954 TransformManagerQuaternionInput mWorldOrientation; ///< Full inherited orientation
955 TransformManagerMatrixInput mWorldMatrix; ///< Full inherited world matrix
956 InheritedColor mWorldColor; ///< Full inherited color
958 uint32_t mClippingSortModifier; ///< Contains bit-packed clipping information for quick access when sorting
959 const uint32_t mId; ///< The Unique ID of the node.
962 static uint32_t mNodeCounter; ///< count of total nodes, used for unique ids
964 PartialRenderingData mPartialRenderingData; ///< Cache to determine if this should be rendered again
966 Node* mParent; ///< Pointer to parent node (a child is owned by its parent)
967 RenderTask* mExclusiveRenderTask; ///< Nodes can be marked as exclusive to a single RenderTask
969 RendererContainer mRenderer; ///< Container of renderers; not owned
971 NodeContainer mChildren; ///< Container of children; not owned
973 uint32_t mClippingDepth; ///< The number of stencil clipping nodes deep this node is
974 uint32_t mScissorDepth; ///< The number of scissor clipping nodes deep this node is
976 uint32_t mDepthIndex; ///< Depth index of the node
978 // flags, compressed to bitfield
979 NodePropertyFlags mDirtyFlags; ///< Dirty flags for each of the Node properties
980 DrawMode::Type mDrawMode : 3; ///< How the Node and its children should be drawn
981 ColorMode mColorMode : 3; ///< Determines whether mWorldColor is inherited, 2 bits is enough
982 ClippingMode::Type mClippingMode : 3; ///< The clipping mode of this node
983 bool mIsRoot : 1; ///< True if the node cannot have a parent
984 bool mIsLayer : 1; ///< True if the node is a layer
985 bool mIsCamera : 1; ///< True if the node is a camera
986 bool mPositionUsesAnchorPoint : 1; ///< True if the node should use the anchor-point when calculating the position
987 bool mTransparent : 1; ///< True if this node is transparent. This value do not affect children.
989 // Changes scope, should be at end of class
990 DALI_LOG_OBJECT_STRING_DECLARATION;
995 inline void SetInheritOrientationMessage(EventThreadServices& eventThreadServices, const Node& node, bool inherit)
997 using LocalType = MessageValue1<Node, bool>;
999 // Reserve some memory inside the message queue
1000 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1002 // Construct message in the message queue memory; note that delete should not be called on the return value
1003 new(slot) LocalType(&node, &Node::SetInheritOrientation, inherit);
1006 inline void SetParentOriginMessage(EventThreadServices& eventThreadServices, const Node& node, const Vector3& origin)
1008 using LocalType = MessageValue1<Node, Vector3>;
1010 // Reserve some memory inside the message queue
1011 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1013 // Construct message in the message queue memory; note that delete should not be called on the return value
1014 new(slot) LocalType(&node, &Node::SetParentOrigin, origin);
1017 inline void SetAnchorPointMessage(EventThreadServices& eventThreadServices, const Node& node, const Vector3& anchor)
1019 using LocalType = MessageValue1<Node, Vector3>;
1021 // Reserve some memory inside the message queue
1022 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1024 // Construct message in the message queue memory; note that delete should not be called on the return value
1025 new(slot) LocalType(&node, &Node::SetAnchorPoint, anchor);
1028 inline void SetInheritPositionMessage(EventThreadServices& eventThreadServices, const Node& node, bool inherit)
1030 using LocalType = MessageValue1<Node, bool>;
1032 // Reserve some memory inside the message queue
1033 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1035 // Construct message in the message queue memory; note that delete should not be called on the return value
1036 new(slot) LocalType(&node, &Node::SetInheritPosition, inherit);
1039 inline void SetInheritScaleMessage(EventThreadServices& eventThreadServices, const Node& node, bool inherit)
1041 using LocalType = MessageValue1<Node, bool>;
1043 // Reserve some memory inside the message queue
1044 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1046 // Construct message in the message queue memory; note that delete should not be called on the return value
1047 new(slot) LocalType(&node, &Node::SetInheritScale, inherit);
1050 inline void SetColorModeMessage(EventThreadServices& eventThreadServices, const Node& node, ColorMode colorMode)
1052 using LocalType = MessageValue1<Node, ColorMode>;
1054 // Reserve some memory inside the message queue
1055 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1057 // Construct message in the message queue memory; note that delete should not be called on the return value
1058 new(slot) LocalType(&node, &Node::SetColorMode, colorMode);
1061 inline void SetDrawModeMessage(EventThreadServices& eventThreadServices, const Node& node, DrawMode::Type drawMode)
1063 using LocalType = MessageValue1<Node, DrawMode::Type>;
1065 // Reserve some memory inside the message queue
1066 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1068 // Construct message in the message queue memory; note that delete should not be called on the return value
1069 new(slot) LocalType(&node, &Node::SetDrawMode, drawMode);
1072 inline void SetTransparentMessage(EventThreadServices& eventThreadServices, const Node& node, bool transparent)
1074 using LocalType = MessageValue1<Node, bool>;
1076 // Reserve some memory inside the message queue
1077 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1079 // Construct message in the message queue memory; note that delete should not be called on the return value
1080 new(slot) LocalType(&node, &Node::SetTransparent, transparent);
1083 inline void DetachRendererMessage(EventThreadServices& eventThreadServices, const Node& node, const Renderer& renderer)
1085 using LocalType = MessageValue1<Node, const Renderer*>;
1087 // Reserve some memory inside the message queue
1088 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1090 // Construct message in the message queue memory; note that delete should not be called on the return value
1091 new(slot) LocalType(&node, &Node::RemoveRenderer, &renderer);
1094 inline void SetDepthIndexMessage(EventThreadServices& eventThreadServices, const Node& node, uint32_t depthIndex)
1096 using LocalType = MessageValue1<Node, uint32_t>;
1098 // Reserve some memory inside the message queue
1099 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1101 // Construct message in the message queue memory; note that delete should not be called on the return value
1102 new(slot) LocalType(&node, &Node::SetDepthIndex, depthIndex);
1105 inline void SetClippingModeMessage(EventThreadServices& eventThreadServices, const Node& node, ClippingMode::Type clippingMode)
1107 using LocalType = MessageValue1<Node, ClippingMode::Type>;
1109 // Reserve some memory inside the message queue
1110 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1112 // Construct message in the message queue memory; note that delete should not be called on the return value
1113 new(slot) LocalType(&node, &Node::SetClippingMode, clippingMode);
1116 inline void SetPositionUsesAnchorPointMessage(EventThreadServices& eventThreadServices, const Node& node, bool positionUsesAnchorPoint)
1118 using LocalType = MessageValue1<Node, bool>;
1120 // Reserve some memory inside the message queue
1121 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1123 // Construct message in the message queue memory; note that delete should not be called on the return value
1124 new(slot) LocalType(&node, &Node::SetPositionUsesAnchorPoint, positionUsesAnchorPoint);
1127 } // namespace SceneGraph
1129 // Template specialisation for OwnerPointer<Node>, because delete is protected
1131 inline void OwnerPointer<Dali::Internal::SceneGraph::Node>::Reset()
1133 if(mObject != nullptr)
1135 Dali::Internal::SceneGraph::Node::Delete(mObject);
1139 } // namespace Internal
1141 // Template specialisations for OwnerContainer<Node*>, because delete is protected
1143 inline void OwnerContainer<Dali::Internal::SceneGraph::Node*>::Delete(Dali::Internal::SceneGraph::Node* pointer)
1145 Dali::Internal::SceneGraph::Node::Delete(pointer);
1149 #endif // DALI_INTERNAL_SCENE_GRAPH_NODE_H