1 #ifndef DALI_INTERNAL_SCENE_GRAPH_NODE_H
2 #define DALI_INTERNAL_SCENE_GRAPH_NODE_H
5 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/integration-api/debug.h>
23 #include <dali/internal/common/message.h>
24 #include <dali/internal/event/common/event-thread-services.h>
25 #include <dali/internal/render/data-providers/node-data-provider.h>
26 #include <dali/internal/update/common/animatable-property.h>
27 #include <dali/internal/update/common/inherited-property.h>
28 #include <dali/internal/update/common/property-owner.h>
29 #include <dali/internal/update/common/scene-graph-buffers.h>
30 #include <dali/internal/update/manager/transform-manager-property.h>
31 #include <dali/internal/update/manager/transform-manager.h>
32 #include <dali/internal/update/nodes/node-declarations.h>
33 #include <dali/internal/update/nodes/node-helper.h>
34 #include <dali/internal/update/nodes/partial-rendering-data.h>
35 #include <dali/internal/update/rendering/scene-graph-renderer.h>
36 #include <dali/public-api/actors/actor-enumerations.h>
37 #include <dali/public-api/actors/draw-mode.h>
38 #include <dali/public-api/math/math-utils.h>
39 #include <dali/public-api/math/quaternion.h>
40 #include <dali/public-api/math/vector3.h>
46 // Value types used by messages.
48 struct ParameterType<ColorMode> : public BasicType<ColorMode>
52 struct ParameterType<ClippingMode::Type> : public BasicType<ClippingMode::Type>
61 class ResetterManager;
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 to add to the node
232 void AddRenderer(const RendererKey& renderer);
235 * Remove a renderer from the node
236 * @param[in] renderer The renderer to be removed
238 void RemoveRenderer(const RendererKey& renderer);
241 * Get the renderer at the given index
242 * @param[in] index The index of the renderer in the node's renderer container
244 RendererKey GetRendererAt(uint32_t index) const
246 return mRenderers[index];
250 * Retrieve the number of renderers for the node
252 uint32_t GetRendererCount() const
254 return static_cast<uint32_t>(mRenderers.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 * Set the update area hint of the node.
670 * @param[in] updateAreaHint The update area hint.
672 void SetUpdateAreaHint(const Vector4& updateAreaHint)
674 if(mUpdateAreaChanged)
676 // Merge area if the update area is dirty
677 float x = std::min(updateAreaHint.x - updateAreaHint.z / 2.0f, mUpdateAreaHint.x - mUpdateAreaHint.z / 2.0f);
678 float y = std::min(updateAreaHint.y - updateAreaHint.w / 2.0f, mUpdateAreaHint.y - mUpdateAreaHint.w / 2.0f);
679 float width = std::max(updateAreaHint.x + updateAreaHint.z / 2.0f, mUpdateAreaHint.x + mUpdateAreaHint.z / 2.0f) - x;
680 float height = std::max(updateAreaHint.y + updateAreaHint.w / 2.0f, mUpdateAreaHint.y + mUpdateAreaHint.w / 2.0f) - y;
681 mUpdateAreaHint = Vector4(x + width / 2, y + height / 2, width, height);
685 mUpdateAreaHint = updateAreaHint;
686 mUpdateAreaChanged = true;
688 mDirtyFlags |= NodePropertyFlags::TRANSFORM;
692 * Retrieve the update area hint of the node.
693 * @return The update area hint.
695 const Vector4& GetUpdateAreaHint() const
697 return mUpdateAreaHint;
701 * Retrieve the bounding sphere of the node
702 * @return A vector4 describing the bounding sphere. XYZ is the center and W is the radius
704 const Vector4& GetBoundingSphere() const
706 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
708 return mTransformManagerData.Manager()->GetBoundingSphere(mTransformManagerData.Id());
711 return Vector4::ZERO;
715 * Retrieve world matrix and size of the node
716 * @param[out] The local to world matrix of the node
717 * @param[out] size The current size of the node
719 void GetWorldMatrixAndSize(Matrix& worldMatrix, Vector3& size) const
721 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
723 mTransformManagerData.Manager()->GetWorldMatrixAndSize(mTransformManagerData.Id(), worldMatrix, size);
728 * Checks if local matrix has changed since last update
729 * @return true if local matrix has changed, false otherwise
731 bool IsLocalMatrixDirty() const
733 return (mTransformManagerData.Id() != INVALID_TRANSFORM_ID) &&
734 (mTransformManagerData.Manager()->IsLocalMatrixDirty(mTransformManagerData.Id()));
738 * Retrieve the cached world-matrix of a node.
739 * @param[in] bufferIndex The buffer to read from.
740 * @return The world-matrix.
742 const Matrix& GetWorldMatrix(BufferIndex bufferIndex) const
744 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
746 return mWorldMatrix.Get(bufferIndex);
749 return Matrix::IDENTITY;
753 * Mark the node as exclusive to a single RenderTask.
754 * @param[in] renderTask The render-task, or NULL if the Node is not exclusive to a single RenderTask.
756 void SetExclusiveRenderTask(RenderTask* renderTask)
758 mExclusiveRenderTask = renderTask;
762 * Query whether the node is exclusive to a single RenderTask.
763 * @return The render-task, or NULL if the Node is not exclusive to a single RenderTask.
765 RenderTask* GetExclusiveRenderTask() const
767 return mExclusiveRenderTask;
771 * Set how the Node and its children should be drawn; see Dali::Actor::SetDrawMode() for more details.
772 * @param[in] drawMode The new draw-mode to use.
774 void SetDrawMode(const DrawMode::Type& drawMode)
776 mDrawMode = drawMode;
780 * Returns whether node is an overlay or not.
781 * @return True if node is an overlay, false otherwise.
783 DrawMode::Type GetDrawMode() const
788 void SetTransparent(bool transparent)
790 mTransparent = transparent;
793 bool IsTransparent() const
799 * Returns the transform id of the node
800 * @return The transform component id of the node
802 TransformId GetTransformId() const
804 return mTransformManagerData.Id();
808 * Equality operator, checks for identity, not values.
811 bool operator==(const Node* rhs) const
813 return (this == rhs);
817 * @brief Sets the sibling order of the node
818 * @param[in] order The new order
820 void SetDepthIndex(uint32_t depthIndex)
822 if(depthIndex != mDepthIndex)
826 // Send CHILDREN_REORDER dirty flag only if my depth index changed.
827 mParent->SetDirtyFlag(NodePropertyFlags::CHILDREN_REORDER);
830 mDepthIndex = depthIndex;
835 * @brief Get the depth index of the node
836 * @return Current depth index
838 uint32_t GetDepthIndex() const
844 * @brief Get whether children sibiling order need to be changed. s.t. child's depth index changed.
845 * @note It will be reset when mDirtyFlag reseted.
846 * @return True if children sibiling order need to be changed.
848 uint32_t IsChildrenReorderRequired() const
850 return mDirtyFlags & NodePropertyFlags::CHILDREN_REORDER;
854 * @brief Sets the boolean which states whether the position should use the anchor-point.
855 * @param[in] positionUsesAnchorPoint True if the position should use the anchor-point
857 void SetPositionUsesAnchorPoint(bool positionUsesAnchorPoint)
859 if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID && mPositionUsesAnchorPoint != positionUsesAnchorPoint)
861 mPositionUsesAnchorPoint = positionUsesAnchorPoint;
862 mTransformManagerData.Manager()->SetPositionUsesAnchorPoint(mTransformManagerData.Id(), mPositionUsesAnchorPoint);
867 * @brief Sets whether the node is culled or not.
868 * @param[in] bufferIndex The buffer to read from.
869 * @param[in] culled True if the node is culled.
871 void SetCulled(BufferIndex bufferIndex, bool culled)
873 mCulled[bufferIndex] = culled;
877 * @brief Retrieves whether the node is culled or not.
878 * @param[in] bufferIndex The buffer to read from.
879 * @return True if the node is culled.
881 bool IsCulled(BufferIndex bufferIndex) const
883 return mCulled[bufferIndex];
887 * @brief Get the total capacity of the memory pools
888 * @return The capacity of the memory pools
890 * @note This is different to the node count.
892 static uint32_t GetMemoryPoolCapacity();
895 * @brief Returns partial rendering data associated with the node.
896 * @return The partial rendering data
898 PartialRenderingData& GetPartialRenderingData()
900 return mPartialRenderingData;
905 * @copydoc Dali::Internal::SceneGraph::PropertyOwner::IsAnimationPossible
907 bool IsAnimationPossible() const override;
910 * @copydoc Dali::Internal::SceneGraph::PropertyOwner::AddInitializeResetter
912 void AddInitializeResetter(ResetterManager& manager) const override;
915 * Called by UpdateManager when the node is added.
916 * Creates a new transform component in the transform manager and initialize all the properties
917 * related to the transformation
918 * @param[in] transformManager A pointer to the trnasform manager (Owned by UpdateManager)
920 void CreateTransform(SceneGraph::TransformManager* transformManager);
925 void ResetDirtyFlags(BufferIndex updateBufferIndex);
929 * Set the parent of a Node.
930 * @param[in] parentNode the new parent.
932 void SetParent(Node& parentNode);
936 * Protected constructor; See also Node::New()
941 * Protected virtual destructor; See also Node::Delete( Node* )
942 * Kept protected to allow destructor chaining from layer
946 private: // from NodeDataProvider
948 * @copydoc NodeDataProvider::GetRenderColor
950 const Vector4& GetRenderColor(BufferIndex bufferIndex) const override
952 return GetWorldColor(bufferIndex);
956 * @copydoc NodeDataProvider::GetNodeUniformMap
958 const UniformMap& GetNodeUniformMap() const override
960 return GetUniformMap();
964 // Delete copy and move
965 Node(const Node&) = delete;
966 Node(Node&&) = delete;
967 Node& operator=(const Node& rhs) = delete;
968 Node& operator=(Node&& rhs) = delete;
971 * Recursive helper to disconnect a Node and its children.
972 * Disconnected Nodes have no parent or children.
973 * @param[in] updateBufferIndex The current update buffer index.
975 void RecursiveDisconnectFromSceneGraph(BufferIndex updateBufferIndex);
977 public: // Default properties
978 // Define a base offset for the following wrappers. The wrapper macros calculate offsets from the previous
979 // element such that each wrapper type generates a compile time offset to the transform manager data.
980 BASE(TransformManagerData, mTransformManagerData);
981 PROPERTY_WRAPPER(mTransformManagerData, TransformManagerPropertyVector3, TRANSFORM_PROPERTY_PARENT_ORIGIN,
982 mParentOrigin); // Local transform; the position is relative to this. Sets the Transform flag dirty when changed
984 PROPERTY_WRAPPER(mParentOrigin, TransformManagerPropertyVector3, TRANSFORM_PROPERTY_ANCHOR_POINT,
985 mAnchorPoint); // Local transform; local center of rotation. Sets the Transform flag dirty when changed
987 PROPERTY_WRAPPER(mAnchorPoint, TransformManagerPropertyVector3, TRANSFORM_PROPERTY_SIZE,
988 mSize); // Size is provided for layouting
990 PROPERTY_WRAPPER(mSize, TransformManagerPropertyVector3, TRANSFORM_PROPERTY_POSITION,
991 mPosition); // Local transform; distance between parent-origin & anchor-point
992 PROPERTY_WRAPPER(mPosition, TransformManagerPropertyVector3, TRANSFORM_PROPERTY_SCALE,
993 mScale); // Local transform; scale relative to parent node
995 TEMPLATE_WRAPPER(mScale, TransformManagerPropertyQuaternion,
996 mOrientation); // Local transform; rotation relative to parent node
998 // Inherited properties; read-only from public API
999 TEMPLATE_WRAPPER(mOrientation, TransformManagerVector3Input, mWorldPosition); // Full inherited position
1000 TEMPLATE_WRAPPER(mWorldPosition, TransformManagerVector3Input, mWorldScale); // Full inherited scale
1001 TEMPLATE_WRAPPER(mWorldScale, TransformManagerQuaternionInput, mWorldOrientation); // Full inherited orientation
1002 TEMPLATE_WRAPPER(mWorldOrientation, TransformManagerMatrixInput, mWorldMatrix); // Full inherited world matrix
1004 AnimatableProperty<bool> mVisible; ///< Visibility can be inherited from the Node hierachy
1005 AnimatableProperty<bool> mCulled; ///< True if the node is culled. This is not animatable. It is just double-buffered.
1006 AnimatableProperty<Vector4> mColor; ///< Color can be inherited from the Node hierarchy
1007 InheritedColor mWorldColor; ///< Full inherited color
1008 Vector4 mUpdateAreaHint; ///< Update area hint is provided for damaged area calculation. (x, y, width, height)
1010 uint32_t mClippingSortModifier; ///< Contains bit-packed clipping information for quick access when sorting
1011 const uint32_t mId; ///< The Unique ID of the node.
1014 static uint32_t mNodeCounter; ///< count of total nodes, used for unique ids
1016 PartialRenderingData mPartialRenderingData; ///< Cache to determine if this should be rendered again
1018 Node* mParent; ///< Pointer to parent node (a child is owned by its parent)
1019 RenderTask* mExclusiveRenderTask; ///< Nodes can be marked as exclusive to a single RenderTask
1021 RendererContainer mRenderers; ///< Container of renderers; not owned
1023 NodeContainer mChildren; ///< Container of children; not owned
1025 uint32_t mClippingDepth; ///< The number of stencil clipping nodes deep this node is
1026 uint32_t mScissorDepth; ///< The number of scissor clipping nodes deep this node is
1027 uint32_t mDepthIndex; ///< Depth index of the node
1029 // flags, compressed to bitfield
1030 NodePropertyFlags mDirtyFlags; ///< Dirty flags for each of the Node properties
1031 DrawMode::Type mDrawMode : 3; ///< How the Node and its children should be drawn
1032 ColorMode mColorMode : 3; ///< Determines whether mWorldColor is inherited, 2 bits is enough
1033 ClippingMode::Type mClippingMode : 3; ///< The clipping mode of this node
1034 bool mIsRoot : 1; ///< True if the node cannot have a parent
1035 bool mIsLayer : 1; ///< True if the node is a layer
1036 bool mIsCamera : 1; ///< True if the node is a camera
1037 bool mPositionUsesAnchorPoint : 1; ///< True if the node should use the anchor-point when calculating the position
1038 bool mTransparent : 1; ///< True if this node is transparent. This value do not affect children.
1039 bool mUpdateAreaChanged : 1; ///< True if the update area of the node is changed.
1041 // Changes scope, should be at end of class
1042 DALI_LOG_OBJECT_STRING_DECLARATION;
1045 // Messages for Node
1047 inline void SetInheritOrientationMessage(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::SetInheritOrientation, inherit);
1058 inline void SetParentOriginMessage(EventThreadServices& eventThreadServices, const Node& node, const Vector3& origin)
1060 using LocalType = MessageValue1<Node, Vector3>;
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::SetParentOrigin, origin);
1069 inline void SetAnchorPointMessage(EventThreadServices& eventThreadServices, const Node& node, const Vector3& anchor)
1071 using LocalType = MessageValue1<Node, Vector3>;
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::SetAnchorPoint, anchor);
1080 inline void SetInheritPositionMessage(EventThreadServices& eventThreadServices, const Node& node, bool inherit)
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::SetInheritPosition, inherit);
1091 inline void SetInheritScaleMessage(EventThreadServices& eventThreadServices, const Node& node, bool inherit)
1093 using LocalType = MessageValue1<Node, bool>;
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::SetInheritScale, inherit);
1102 inline void SetColorModeMessage(EventThreadServices& eventThreadServices, const Node& node, ColorMode colorMode)
1104 using LocalType = MessageValue1<Node, ColorMode>;
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::SetColorMode, colorMode);
1113 inline void SetDrawModeMessage(EventThreadServices& eventThreadServices, const Node& node, DrawMode::Type drawMode)
1115 using LocalType = MessageValue1<Node, DrawMode::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::SetDrawMode, drawMode);
1124 inline void SetTransparentMessage(EventThreadServices& eventThreadServices, const Node& node, bool transparent)
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::SetTransparent, transparent);
1135 inline void DetachRendererMessage(EventThreadServices& eventThreadServices, const Node& node, const Renderer& renderer)
1137 using LocalType = MessageValue1<Node, RendererKey>;
1139 // Reserve some memory inside the message queue
1140 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1142 // Construct message in the message queue memory; note that delete should not be called on the return value
1143 new(slot) LocalType(&node, &Node::RemoveRenderer, Renderer::GetKey(renderer));
1146 inline void SetDepthIndexMessage(EventThreadServices& eventThreadServices, const Node& node, uint32_t depthIndex)
1148 using LocalType = MessageValue1<Node, uint32_t>;
1150 // Reserve some memory inside the message queue
1151 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1153 // Construct message in the message queue memory; note that delete should not be called on the return value
1154 new(slot) LocalType(&node, &Node::SetDepthIndex, depthIndex);
1157 inline void SetClippingModeMessage(EventThreadServices& eventThreadServices, const Node& node, ClippingMode::Type clippingMode)
1159 using LocalType = MessageValue1<Node, ClippingMode::Type>;
1161 // Reserve some memory inside the message queue
1162 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1164 // Construct message in the message queue memory; note that delete should not be called on the return value
1165 new(slot) LocalType(&node, &Node::SetClippingMode, clippingMode);
1168 inline void SetPositionUsesAnchorPointMessage(EventThreadServices& eventThreadServices, const Node& node, bool positionUsesAnchorPoint)
1170 using LocalType = MessageValue1<Node, bool>;
1172 // Reserve some memory inside the message queue
1173 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1175 // Construct message in the message queue memory; note that delete should not be called on the return value
1176 new(slot) LocalType(&node, &Node::SetPositionUsesAnchorPoint, positionUsesAnchorPoint);
1179 inline void SetUpdateAreaHintMessage(EventThreadServices& eventThreadServices, const Node& node, const Vector4& updateAreaHint)
1181 using LocalType = MessageValue1<Node, Vector4>;
1183 // Reserve some memory inside the message queue
1184 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
1186 // Construct message in the message queue memory; note that delete should not be called on the return value
1187 new(slot) LocalType(&node, &Node::SetUpdateAreaHint, updateAreaHint);
1190 } // namespace SceneGraph
1192 // Template specialisation for OwnerPointer<Node>, because delete is protected
1194 inline void OwnerPointer<Dali::Internal::SceneGraph::Node>::Reset()
1196 if(mObject != nullptr)
1198 Dali::Internal::SceneGraph::Node::Delete(mObject);
1202 } // namespace Internal
1204 // Template specialisations for OwnerContainer<Node*>, because delete is protected
1206 inline void OwnerContainer<Dali::Internal::SceneGraph::Node*>::Delete(Dali::Internal::SceneGraph::Node* pointer)
1208 Dali::Internal::SceneGraph::Node::Delete(pointer);
1212 #endif // DALI_INTERNAL_SCENE_GRAPH_NODE_H