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/node-helper.h>
34 #include <dali/internal/update/nodes/partial-rendering-data.h>
35 #include <dali/internal/update/rendering/scene-graph-renderer.h>
36 #include <dali/public-api/actors/actor-enumerations.h>
37 #include <dali/public-api/actors/draw-mode.h>
38 #include <dali/public-api/math/math-utils.h>
39 #include <dali/public-api/math/quaternion.h>
40 #include <dali/public-api/math/vector3.h>
46 // Value types used by messages.
48 struct ParameterType<ColorMode> : public BasicType<ColorMode>
52 struct ParameterType<ClippingMode::Type> : public BasicType<ClippingMode::Type>
64 // Flags which require the scene renderable lists to be updated
65 static NodePropertyFlags RenderableUpdateFlags = NodePropertyFlags::TRANSFORM | NodePropertyFlags::CHILD_DELETED;
68 * Node is the base class for all nodes in the Scene Graph.
70 * Each node provides a transformation which applies to the node and
71 * its children. Node data is double-buffered. This allows an update
72 * thread to modify node data, without interferring with another
73 * thread reading the values from the previous update traversal.
75 class Node : public PropertyOwner, public NodeDataProvider
79 static const ColorMode DEFAULT_COLOR_MODE;
84 * Construct a new Node.
91 static void Delete(Node* node);
94 * Called during UpdateManager::DestroyNode shortly before Node is destroyed.
99 * @return the unique ID of the node
101 uint32_t GetId() const;
106 * Query whether the node is a layer.
107 * @return True if the node is a layer.
115 * Convert a node to a layer.
116 * @return A pointer to the layer, or NULL.
118 virtual Layer* GetLayer()
126 * Query whether the node is a camera.
127 * @return True if the node is a camera.
129 bool IsCamera() const
135 * Mark an node and its sub tree according to the updated flag.
136 * @param[in] updated The updated flag
137 * (used for partial rendering to mark an animating sub tree for example).
139 void SetUpdatedTree(bool updated)
143 for(Node* child : mChildren)
145 child->SetUpdatedTree(updated);
150 * This method sets clipping information on the node based on its hierarchy in the scene-graph.
151 * A value is calculated that can be used during sorting to increase sort speed.
152 * @param[in] clippingId The Clipping ID of the node to set
153 * @param[in] clippingDepth The Clipping Depth of the node to set
154 * @param[in] scissorDepth The Scissor Clipping Depth of the node to set
156 void SetClippingInformation(const uint32_t clippingId, const uint32_t clippingDepth, const uint32_t scissorDepth)
158 // We only set up the sort value if we have a stencil clipping depth, IE. At least 1 clipping node has been hit.
159 // If not, if we traverse down a clipping tree and back up, and there is another
160 // node on the parent, this will have a non-zero clipping ID that must be ignored
161 if(clippingDepth > 0u)
163 mClippingDepth = clippingDepth;
165 // Calculate the sort value here on write, as when read (during sort) it may be accessed several times.
166 // The items must be sorted by Clipping ID first (so the ID is kept in the most-significant bits).
167 // For the same ID, the clipping nodes must be first, so we negate the
168 // clipping enabled flag and set it as the least significant bit.
169 mClippingSortModifier = (clippingId << 1u) | (mClippingMode == ClippingMode::DISABLED ? 1u : 0u);
173 // If we do not have a clipping depth, then set this to 0 so we do not have a Clipping ID either.
174 mClippingSortModifier = 0u;
177 // The scissor depth does not modify the clipping sort modifier (as scissor clips are 2D only).
178 // For this reason we can always update the member variable.
179 mScissorDepth = scissorDepth;
183 * Gets the Clipping ID for this node.
184 * @return The Clipping ID for this node.
186 uint32_t GetClippingId() const
188 return mClippingSortModifier >> 1u;
192 * Gets the Clipping Depth for this node.
193 * @return The Clipping Depth for this node.
195 uint32_t GetClippingDepth() const
197 return mClippingDepth;
201 * Gets the Scissor Clipping Depth for this node.
202 * @return The Scissor Clipping Depth for this node.
204 uint32_t GetScissorDepth() const
206 return mScissorDepth;
210 * Sets the clipping mode for this node.
211 * @param[in] clippingMode The ClippingMode to set
213 void SetClippingMode(const ClippingMode::Type clippingMode)
215 mClippingMode = clippingMode;
216 SetDirtyFlag(NodePropertyFlags::TRANSFORM);
220 * Gets the Clipping Mode for this node.
221 * @return The ClippingMode of this node
223 ClippingMode::Type GetClippingMode() const
225 return mClippingMode;
229 * Add a renderer to the node
230 * @param[in] renderer The renderer added to the node
232 void AddRenderer(Renderer* renderer);
235 * Remove a renderer from the node
236 * @param[in] renderer The renderer to be removed
238 void RemoveRenderer(const Renderer* renderer);
241 * Get the renderer at the given index
244 Renderer* GetRendererAt(uint32_t index) const
246 return mRenderer[index];
250 * Retrieve the number of renderers for the node
252 uint32_t GetRendererCount() const
254 return static_cast<uint32_t>(mRenderer.Size());
257 // Containment methods
260 * Query whether a node is the root node. Root nodes cannot have a parent node.
261 * A node becomes a root node, when it is installed by UpdateManager.
262 * @return True if the node is a root node.
270 * Set whether a node is the root node. Root nodes cannot have a parent node.
271 * This method should only be called by UpdateManager.
272 * @pre When isRoot is true, the node must not have a parent.
273 * @param[in] isRoot Whether the node is now a root node.
275 void SetRoot(bool isRoot);
278 * Retrieve the parent of a Node.
279 * @return The parent node, or NULL if the Node has not been added to the scene-graph.
287 * Retrieve the parent of a Node.
288 * @return The parent node, or NULL if the Node has not been added to the scene-graph.
290 const Node* GetParent() const
296 * @return true if the node is connected to SceneGraph
298 bool ConnectedToScene()
300 return IsRoot() || GetParent();
304 * Connect a node to the scene-graph.
305 * @pre A node cannot be added to itself.
306 * @pre The parent node is connected to the scene-graph.
307 * @pre The childNode does not already have a parent.
308 * @pre The childNode is not a root node.
309 * @param[in] childNode The child to add.
311 void ConnectChild(Node* childNode);
314 * Disconnect a child (& its children) from the scene-graph.
315 * @pre childNode is a child of this Node.
316 * @param[in] updateBufferIndex The current update buffer index.
317 * @param[in] childNode The node to disconnect.
319 void DisconnectChild(BufferIndex updateBufferIndex, Node& childNode);
322 * Retrieve the children a Node.
323 * @return The container of children.
325 const NodeContainer& GetChildren() const
331 * Retrieve the children a Node.
332 * @return The container of children.
334 NodeContainer& GetChildren()
342 * Flag that one of the node values has changed in the current frame.
343 * @param[in] flag The flag to set.
345 void SetDirtyFlag(NodePropertyFlags flag)
351 * Flag that all of the node values are dirty.
353 void SetAllDirtyFlags()
355 mDirtyFlags = NodePropertyFlags::ALL;
359 * Query whether a node is dirty.
360 * @return The dirty flags
362 NodePropertyFlags GetDirtyFlags() const;
365 * Query inherited dirty flags.
367 * @param The parentFlags to or with
368 * @return The inherited dirty flags
370 NodePropertyFlags GetInheritedDirtyFlags(NodePropertyFlags parentFlags) const;
373 * Retrieve the parent-origin of the node.
374 * @return The parent-origin.
376 const Vector3& GetParentOrigin() const
378 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
380 return mParentOrigin.Get(0);
383 return Vector3::ZERO;
387 * Sets both the local & base parent-origins of the node.
388 * @param[in] origin The new local & base parent-origins.
390 void SetParentOrigin(const Vector3& origin)
392 mParentOrigin.Set(0, origin);
396 * Retrieve the anchor-point of the node.
397 * @return The anchor-point.
399 const Vector3& GetAnchorPoint() const
401 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
403 return mAnchorPoint.Get(0);
406 return Vector3::ZERO;
410 * Sets both the local & base anchor-points of the node.
411 * @param[in] anchor The new local & base anchor-points.
413 void SetAnchorPoint(const Vector3& anchor)
415 mAnchorPoint.Set(0, anchor);
419 * Retrieve the local position of the node, relative to its parent.
420 * @param[in] bufferIndex The buffer to read from.
421 * @return The local position.
423 const Vector3& GetPosition(BufferIndex bufferIndex) const
425 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
427 return mPosition.Get(bufferIndex);
430 return Vector3::ZERO;
434 * Retrieve the position of the node derived from the position of all its parents.
435 * @return The world position.
437 const Vector3& GetWorldPosition(BufferIndex bufferIndex) const
439 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
441 return mWorldPosition.Get(bufferIndex);
443 return Vector3::ZERO;
447 * Set whether the Node inherits position.
448 * @param[in] inherit True if the parent position is inherited.
450 void SetInheritPosition(bool inherit)
452 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
454 mTransformManagerData.Manager()->SetInheritPosition(mTransformManagerData.Id(), inherit);
459 * Retrieve the local orientation of the node, relative to its parent.
460 * @param[in] bufferIndex The buffer to read from.
461 * @return The local orientation.
463 const Quaternion& GetOrientation(BufferIndex bufferIndex) const
465 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
467 return mOrientation.Get(0);
470 return Quaternion::IDENTITY;
474 * Retrieve the orientation of the node derived from the rotation of all its parents.
475 * @param[in] bufferIndex The buffer to read from.
476 * @return The world rotation.
478 const Quaternion& GetWorldOrientation(BufferIndex bufferIndex) const
480 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
482 return mWorldOrientation.Get(0);
484 return Quaternion::IDENTITY;
488 * Set whether the Node inherits orientation.
489 * @param[in] inherit True if the parent orientation is inherited.
491 void SetInheritOrientation(bool inherit)
493 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
495 mTransformManagerData.Manager()->SetInheritOrientation(mTransformManagerData.Id(), inherit);
500 * Retrieve the local scale of the node, relative to its parent.
501 * @param[in] bufferIndex The buffer to read from.
502 * @return The local scale.
504 const Vector3& GetScale(BufferIndex bufferIndex) const
506 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
508 return mScale.Get(0);
515 * Retrieve the scale of the node derived from the scale of all its parents.
516 * @param[in] bufferIndex The buffer to read from.
517 * @return The world scale.
519 const Vector3& GetWorldScale(BufferIndex bufferIndex) const
521 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
523 return mWorldScale.Get(0);
529 * Set whether the Node inherits scale.
530 * @param inherit True if the Node inherits scale.
532 void SetInheritScale(bool inherit)
534 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
536 mTransformManagerData.Manager()->SetInheritScale(mTransformManagerData.Id(), inherit);
541 * Retrieve the visibility of the node.
542 * @param[in] bufferIndex The buffer to read from.
543 * @return True if the node is visible.
545 bool IsVisible(BufferIndex bufferIndex) const
547 return mVisible[bufferIndex];
551 * Retrieve the opacity of the node.
552 * @param[in] bufferIndex The buffer to read from.
553 * @return The opacity.
555 float GetOpacity(BufferIndex bufferIndex) const
557 return mColor[bufferIndex].a;
561 * Retrieve the color of the node.
562 * @param[in] bufferIndex The buffer to read from.
565 const Vector4& GetColor(BufferIndex bufferIndex) const
567 return mColor[bufferIndex];
571 * Sets the color of the node derived from the color of all its parents.
572 * @param[in] color The world color.
573 * @param[in] updateBufferIndex The current update buffer index.
575 void SetWorldColor(const Vector4& color, BufferIndex updateBufferIndex)
577 mWorldColor.Set(updateBufferIndex, color);
581 * Sets the color of the node derived from the color of all its parents.
582 * This method should only be called when the parents world color is up-to-date.
583 * @pre The node has a parent.
584 * @param[in] updateBufferIndex The current update buffer index.
586 void InheritWorldColor(BufferIndex updateBufferIndex)
588 DALI_ASSERT_DEBUG(mParent != NULL);
591 if(mColorMode == USE_OWN_MULTIPLY_PARENT_ALPHA)
593 const Vector4& ownColor = mColor[updateBufferIndex];
594 mWorldColor.Set(updateBufferIndex, ownColor.r, ownColor.g, ownColor.b, ownColor.a * mParent->GetWorldColor(updateBufferIndex).a);
596 else if(mColorMode == USE_OWN_MULTIPLY_PARENT_COLOR)
598 mWorldColor.Set(updateBufferIndex, mParent->GetWorldColor(updateBufferIndex) * mColor[updateBufferIndex]);
600 else if(mColorMode == USE_PARENT_COLOR)
602 mWorldColor.Set(updateBufferIndex, mParent->GetWorldColor(updateBufferIndex));
604 else // USE_OWN_COLOR
606 mWorldColor.Set(updateBufferIndex, mColor[updateBufferIndex]);
611 * Copies the previous inherited scale, if this changed in the previous frame.
612 * This method should be called instead of InheritWorldScale i.e. if the inherited scale
613 * does not need to be recalculated in the current frame.
614 * @param[in] updateBufferIndex The current update buffer index.
616 void CopyPreviousWorldColor(BufferIndex updateBufferIndex)
618 mWorldColor.CopyPrevious(updateBufferIndex);
622 * Retrieve the color of the node, possibly derived from the color
623 * of all its parents, depending on the value of mColorMode.
624 * @param[in] bufferIndex The buffer to read from.
625 * @return The world color.
627 const Vector4& GetWorldColor(BufferIndex bufferIndex) const
629 return mWorldColor[bufferIndex];
633 * Set the color mode. This specifies whether the Node uses its own color,
634 * or inherits its parent color.
635 * @param[in] colorMode The new color mode.
637 void SetColorMode(ColorMode colorMode)
639 mColorMode = colorMode;
641 SetDirtyFlag(NodePropertyFlags::COLOR);
645 * Retrieve the color mode.
646 * @return The color mode.
648 ColorMode GetColorMode() const
654 * Retrieve the size of the node.
655 * @param[in] bufferIndex The buffer to read from.
658 const Vector3& GetSize(BufferIndex bufferIndex) const
660 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
665 return Vector3::ZERO;
669 * Retrieve the update area hint of the node.
670 * @return The update area hint.
672 const Vector4& GetUpdateAreaHint() const
674 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
676 return mUpdateAreaHint.Get(0);
679 return Vector4::ZERO;
683 * Retrieve the bounding sphere of the node
684 * @return A vector4 describing the bounding sphere. XYZ is the center and W is the radius
686 const Vector4& GetBoundingSphere() const
688 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
690 return mTransformManagerData.Manager()->GetBoundingSphere(mTransformManagerData.Id());
693 return Vector4::ZERO;
697 * Retrieve world matrix and size of the node
698 * @param[out] The local to world matrix of the node
699 * @param[out] size The current size of the node
701 void GetWorldMatrixAndSize(Matrix& worldMatrix, Vector3& size) const
703 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
705 mTransformManagerData.Manager()->GetWorldMatrixAndSize(mTransformManagerData.Id(), worldMatrix, size);
710 * Checks if local matrix has changed since last update
711 * @return true if local matrix has changed, false otherwise
713 bool IsLocalMatrixDirty() const
715 return (mTransformManagerData.Id() != INVALID_TRANSFORM_ID) &&
716 (mTransformManagerData.Manager()->IsLocalMatrixDirty(mTransformManagerData.Id()));
720 * Retrieve the cached world-matrix of a node.
721 * @param[in] bufferIndex The buffer to read from.
722 * @return The world-matrix.
724 const Matrix& GetWorldMatrix(BufferIndex bufferIndex) const
726 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
728 return mWorldMatrix.Get(bufferIndex);
731 return Matrix::IDENTITY;
735 * Mark the node as exclusive to a single RenderTask.
736 * @param[in] renderTask The render-task, or NULL if the Node is not exclusive to a single RenderTask.
738 void SetExclusiveRenderTask(RenderTask* renderTask)
740 mExclusiveRenderTask = renderTask;
744 * Query whether the node is exclusive to a single RenderTask.
745 * @return The render-task, or NULL if the Node is not exclusive to a single RenderTask.
747 RenderTask* GetExclusiveRenderTask() const
749 return mExclusiveRenderTask;
753 * Set how the Node and its children should be drawn; see Dali::Actor::SetDrawMode() for more details.
754 * @param[in] drawMode The new draw-mode to use.
756 void SetDrawMode(const DrawMode::Type& drawMode)
758 mDrawMode = drawMode;
762 * Returns whether node is an overlay or not.
763 * @return True if node is an overlay, false otherwise.
765 DrawMode::Type GetDrawMode() const
770 void SetTransparent(bool transparent)
772 mTransparent = transparent;
775 bool IsTransparent() const
781 * Returns the transform id of the node
782 * @return The transform component id of the node
784 TransformId GetTransformId() const
786 return mTransformManagerData.Id();
790 * Equality operator, checks for identity, not values.
793 bool operator==(const Node* rhs) const
795 return (this == rhs);
799 * @brief Sets the sibling order of the node
800 * @param[in] order The new order
802 void SetDepthIndex(uint32_t depthIndex)
804 if(depthIndex != mDepthIndex)
806 SetDirtyFlag(NodePropertyFlags::DEPTH_INDEX);
808 mDepthIndex = depthIndex;
813 * @brief Get the depth index of the node
814 * @return Current depth index
816 uint32_t GetDepthIndex() const
822 * @brief Sets the boolean which states whether the position should use the anchor-point.
823 * @param[in] positionUsesAnchorPoint True if the position should use the anchor-point
825 void SetPositionUsesAnchorPoint(bool positionUsesAnchorPoint)
827 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID && mPositionUsesAnchorPoint != positionUsesAnchorPoint)
829 mPositionUsesAnchorPoint = positionUsesAnchorPoint;
830 mTransformManagerData.Manager()->SetPositionUsesAnchorPoint(mTransformManagerData.Id(), mPositionUsesAnchorPoint);
835 * @brief Sets whether the node is culled or not.
836 * @param[in] bufferIndex The buffer to read from.
837 * @param[in] culled True if the node is culled.
839 void SetCulled(BufferIndex bufferIndex, bool culled)
841 mCulled[bufferIndex] = culled;
845 * @brief Retrieves whether the node is culled or not.
846 * @param[in] bufferIndex The buffer to read from.
847 * @return True if the node is culled.
849 bool IsCulled(BufferIndex bufferIndex) const
851 return mCulled[bufferIndex];
855 * @brief Get the total capacity of the memory pools
856 * @return The capacity of the memory pools
858 * @note This is different to the node count.
860 static uint32_t GetMemoryPoolCapacity();
863 * @brief Returns partial rendering data associated with the node.
864 * @return The partial rendering data
866 PartialRenderingData& GetPartialRenderingData()
868 return mPartialRenderingData;
873 * @copydoc Dali::Internal::SceneGraph::PropertyOwner::IsAnimationPossible
875 bool IsAnimationPossible() const override;
878 * Called by UpdateManager when the node is added.
879 * Creates a new transform component in the transform manager and initialize all the properties
880 * related to the transformation
881 * @param[in] transformManager A pointer to the trnasform manager (Owned by UpdateManager)
883 void CreateTransform(SceneGraph::TransformManager* transformManager);
888 void ResetDirtyFlags(BufferIndex updateBufferIndex);
891 * Update uniform hash
892 * @param[in] bufferIndex The buffer to read from.
894 void UpdateUniformHash(BufferIndex bufferIndex);
898 * Set the parent of a Node.
899 * @param[in] parentNode the new parent.
901 void SetParent(Node& parentNode);
905 * Protected constructor; See also Node::New()
910 * Protected virtual destructor; See also Node::Delete( Node* )
911 * Kept protected to allow destructor chaining from layer
915 private: // from NodeDataProvider
917 * @copydoc NodeDataProvider::GetRenderColor
919 const Vector4& GetRenderColor(BufferIndex bufferIndex) const override
921 return GetWorldColor(bufferIndex);
925 * @copydoc NodeDataProvider::GetNodeUniformMap
927 const UniformMap& GetNodeUniformMap() const override
929 return GetUniformMap();
933 // Delete copy and move
934 Node(const Node&) = delete;
935 Node(Node&&) = delete;
936 Node& operator=(const Node& rhs) = delete;
937 Node& operator=(Node&& rhs) = delete;
940 * Recursive helper to disconnect a Node and its children.
941 * Disconnected Nodes have no parent or children.
942 * @param[in] updateBufferIndex The current update buffer index.
944 void RecursiveDisconnectFromSceneGraph(BufferIndex updateBufferIndex);
946 public: // Default properties
947 // Define a base offset for the following wrappers. The wrapper macros calculate offsets from the previous
948 // element such that each wrapper type generates a compile time offset to the transform manager data.
949 BASE(TransformManagerData, mTransformManagerData);
950 PROPERTY_WRAPPER(mTransformManagerData, TransformManagerPropertyVector3, TRANSFORM_PROPERTY_PARENT_ORIGIN,
951 mParentOrigin); // Local transform; the position is relative to this. Sets the Transform flag dirty when changed
953 PROPERTY_WRAPPER(mParentOrigin, TransformManagerPropertyVector3, TRANSFORM_PROPERTY_ANCHOR_POINT,
954 mAnchorPoint); // Local transform; local center of rotation. Sets the Transform flag dirty when changed
956 PROPERTY_WRAPPER(mAnchorPoint, TransformManagerPropertyVector3, TRANSFORM_PROPERTY_SIZE,
957 mSize); // Size is provided for layouting
959 PROPERTY_WRAPPER(mSize, TransformManagerPropertyVector3, TRANSFORM_PROPERTY_POSITION,
960 mPosition); // Local transform; distance between parent-origin & anchor-point
961 PROPERTY_WRAPPER(mPosition, TransformManagerPropertyVector3, TRANSFORM_PROPERTY_SCALE,
962 mScale); // Local transform; scale relative to parent node
964 TEMPLATE_WRAPPER(mScale, TransformManagerPropertyQuaternion,
965 mOrientation); // Local transform; rotation relative to parent node
967 // Inherited properties; read-only from public API
968 TEMPLATE_WRAPPER(mOrientation, TransformManagerVector3Input, mWorldPosition); // Full inherited position
969 TEMPLATE_WRAPPER(mWorldPosition, TransformManagerVector3Input, mWorldScale); // Full inherited scale
970 TEMPLATE_WRAPPER(mWorldScale, TransformManagerQuaternionInput, mWorldOrientation); // Full inherited orientation
971 TEMPLATE_WRAPPER(mWorldOrientation, TransformManagerMatrixInput, mWorldMatrix); // Full inherited world matrix
973 AnimatableProperty<bool> mVisible; ///< Visibility can be inherited from the Node hierachy
974 AnimatableProperty<bool> mCulled; ///< True if the node is culled. This is not animatable. It is just double-buffered.
975 AnimatableProperty<Vector4> mColor; ///< Color can be inherited from the Node hierarchy
976 InheritedColor mWorldColor; ///< Full inherited color
977 AnimatableProperty<Vector4> mUpdateAreaHint; ///< Update area hint is provided for damaged area calculation. (x, y, width, height)
978 ///< This is not animatable. It is just double-buffered. (Because all these bloody properties are).
980 uint64_t mUniformsHash{0u}; ///< Hash of uniform map property values
981 uint32_t mClippingSortModifier; ///< Contains bit-packed clipping information for quick access when sorting
982 const uint32_t mId; ///< The Unique ID of the node.
985 static uint32_t mNodeCounter; ///< count of total nodes, used for unique ids
987 PartialRenderingData mPartialRenderingData; ///< Cache to determine if this should be rendered again
989 Node* mParent; ///< Pointer to parent node (a child is owned by its parent)
990 RenderTask* mExclusiveRenderTask; ///< Nodes can be marked as exclusive to a single RenderTask
992 RendererContainer mRenderer; ///< Container of renderers; not owned
994 NodeContainer mChildren; ///< Container of children; not owned
996 uint32_t mClippingDepth; ///< The number of stencil clipping nodes deep this node is
997 uint32_t mScissorDepth; ///< The number of scissor clipping nodes deep this node is
998 uint32_t mDepthIndex; ///< Depth index of the node
1000 // flags, compressed to bitfield
1001 NodePropertyFlags mDirtyFlags; ///< Dirty flags for each of the Node properties
1002 DrawMode::Type mDrawMode : 3; ///< How the Node and its children should be drawn
1003 ColorMode mColorMode : 3; ///< Determines whether mWorldColor is inherited, 2 bits is enough
1004 ClippingMode::Type mClippingMode : 3; ///< The clipping mode of this node
1005 bool mIsRoot : 1; ///< True if the node cannot have a parent
1006 bool mIsLayer : 1; ///< True if the node is a layer
1007 bool mIsCamera : 1; ///< True if the node is a camera
1008 bool mPositionUsesAnchorPoint : 1; ///< True if the node should use the anchor-point when calculating the position
1009 bool mTransparent : 1; ///< True if this node is transparent. This value do not affect children.
1011 // Changes scope, should be at end of class
1012 DALI_LOG_OBJECT_STRING_DECLARATION;
1015 // Messages for Node
1017 inline void SetInheritOrientationMessage(EventThreadServices& eventThreadServices, const Node& node, bool inherit)
1019 using LocalType = MessageValue1<Node, bool>;
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::SetInheritOrientation, inherit);
1028 inline void SetParentOriginMessage(EventThreadServices& eventThreadServices, const Node& node, const Vector3& origin)
1030 using LocalType = MessageValue1<Node, Vector3>;
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::SetParentOrigin, origin);
1039 inline void SetAnchorPointMessage(EventThreadServices& eventThreadServices, const Node& node, const Vector3& anchor)
1041 using LocalType = MessageValue1<Node, Vector3>;
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::SetAnchorPoint, anchor);
1050 inline void SetInheritPositionMessage(EventThreadServices& eventThreadServices, const Node& node, bool inherit)
1052 using LocalType = MessageValue1<Node, bool>;
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::SetInheritPosition, inherit);
1061 inline void SetInheritScaleMessage(EventThreadServices& eventThreadServices, const Node& node, bool inherit)
1063 using LocalType = MessageValue1<Node, bool>;
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::SetInheritScale, inherit);
1072 inline void SetColorModeMessage(EventThreadServices& eventThreadServices, const Node& node, ColorMode colorMode)
1074 using LocalType = MessageValue1<Node, ColorMode>;
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::SetColorMode, colorMode);
1083 inline void SetDrawModeMessage(EventThreadServices& eventThreadServices, const Node& node, DrawMode::Type drawMode)
1085 using LocalType = MessageValue1<Node, DrawMode::Type>;
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::SetDrawMode, drawMode);
1094 inline void SetTransparentMessage(EventThreadServices& eventThreadServices, const Node& node, bool transparent)
1096 using LocalType = MessageValue1<Node, bool>;
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::SetTransparent, transparent);
1105 inline void DetachRendererMessage(EventThreadServices& eventThreadServices, const Node& node, const Renderer& renderer)
1107 using LocalType = MessageValue1<Node, const Renderer*>;
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::RemoveRenderer, &renderer);
1116 inline void SetDepthIndexMessage(EventThreadServices& eventThreadServices, const Node& node, uint32_t depthIndex)
1118 using LocalType = MessageValue1<Node, uint32_t>;
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::SetDepthIndex, depthIndex);
1127 inline void SetClippingModeMessage(EventThreadServices& eventThreadServices, const Node& node, ClippingMode::Type clippingMode)
1129 using LocalType = MessageValue1<Node, ClippingMode::Type>;
1131 // Reserve some memory inside the message queue
1132 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1134 // Construct message in the message queue memory; note that delete should not be called on the return value
1135 new(slot) LocalType(&node, &Node::SetClippingMode, clippingMode);
1138 inline void SetPositionUsesAnchorPointMessage(EventThreadServices& eventThreadServices, const Node& node, bool positionUsesAnchorPoint)
1140 using LocalType = MessageValue1<Node, bool>;
1142 // Reserve some memory inside the message queue
1143 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1145 // Construct message in the message queue memory; note that delete should not be called on the return value
1146 new(slot) LocalType(&node, &Node::SetPositionUsesAnchorPoint, positionUsesAnchorPoint);
1149 } // namespace SceneGraph
1151 // Template specialisation for OwnerPointer<Node>, because delete is protected
1153 inline void OwnerPointer<Dali::Internal::SceneGraph::Node>::Reset()
1155 if(mObject != nullptr)
1157 Dali::Internal::SceneGraph::Node::Delete(mObject);
1161 } // namespace Internal
1163 // Template specialisations for OwnerContainer<Node*>, because delete is protected
1165 inline void OwnerContainer<Dali::Internal::SceneGraph::Node*>::Delete(Dali::Internal::SceneGraph::Node* pointer)
1167 Dali::Internal::SceneGraph::Node::Delete(pointer);
1171 #endif // DALI_INTERNAL_SCENE_GRAPH_NODE_H