1 #ifndef DALI_INTERNAL_SCENE_GRAPH_NODE_H
2 #define DALI_INTERNAL_SCENE_GRAPH_NODE_H
5 * Copyright (c) 2018 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/public-api/actors/actor-enumerations.h>
23 #include <dali/public-api/actors/draw-mode.h>
24 #include <dali/public-api/math/quaternion.h>
25 #include <dali/public-api/math/math-utils.h>
26 #include <dali/public-api/math/vector3.h>
27 #include <dali/integration-api/debug.h>
28 #include <dali/internal/common/message.h>
29 #include <dali/internal/event/common/event-thread-services.h>
30 #include <dali/internal/render/data-providers/node-data-provider.h>
31 #include <dali/internal/update/common/animatable-property.h>
32 #include <dali/internal/update/common/property-owner.h>
33 #include <dali/internal/update/common/scene-graph-buffers.h>
34 #include <dali/internal/update/common/inherited-property.h>
35 #include <dali/internal/update/manager/transform-manager.h>
36 #include <dali/internal/update/manager/transform-manager-property.h>
37 #include <dali/internal/update/nodes/node-declarations.h>
38 #include <dali/internal/update/rendering/scene-graph-renderer.h>
46 // Value types used by messages.
47 template <> struct ParameterType< ColorMode > : public BasicType< ColorMode > {};
48 template <> struct ParameterType< ClippingMode::Type > : public BasicType< ClippingMode::Type > {};
59 // Flags which require the scene renderable lists to be updated
60 static NodePropertyFlags RenderableUpdateFlags = NodePropertyFlags::TRANSFORM | NodePropertyFlags::CHILD_DELETED;
63 * Node is the base class for all nodes in the Scene Graph.
65 * Each node provides a transformation which applies to the node and
66 * its children. Node data is double-buffered. This allows an update
67 * thread to modify node data, without interferring with another
68 * thread reading the values from the previous update traversal.
70 class Node : public PropertyOwner, public NodeDataProvider
75 static const ColorMode DEFAULT_COLOR_MODE;
80 * Construct a new Node.
87 static void Delete( Node* node );
90 * Called during UpdateManager::DestroyNode shortly before Node is destroyed.
95 * @return the unique ID of the node
97 uint32_t GetId() const;
102 * Query whether the node is a layer.
103 * @return True if the node is a layer.
111 * Convert a node to a layer.
112 * @return A pointer to the layer, or NULL.
114 virtual Layer* GetLayer()
120 * Mark an node and its sub tree according to the updated flag.
121 * @param[in] updated The updated flag
122 * (used for partial rendering to mark an animating sub tree for example).
124 void SetUpdated(bool updated) override
128 for (Node* child : mChildren)
130 child->SetUpdated(updated);
135 * This method sets clipping information on the node based on its hierarchy in the scene-graph.
136 * A value is calculated that can be used during sorting to increase sort speed.
137 * @param[in] clippingId The Clipping ID of the node to set
138 * @param[in] clippingDepth The Clipping Depth of the node to set
139 * @param[in] scissorDepth The Scissor Clipping Depth of the node to set
141 void SetClippingInformation( const uint32_t clippingId, const uint32_t clippingDepth, const uint32_t scissorDepth )
143 // We only set up the sort value if we have a stencil clipping depth, IE. At least 1 clipping node has been hit.
144 // If not, if we traverse down a clipping tree and back up, and there is another
145 // node on the parent, this will have a non-zero clipping ID that must be ignored
146 if( clippingDepth > 0u )
148 mClippingDepth = clippingDepth;
150 // Calculate the sort value here on write, as when read (during sort) it may be accessed several times.
151 // The items must be sorted by Clipping ID first (so the ID is kept in the most-significant bits).
152 // For the same ID, the clipping nodes must be first, so we negate the
153 // clipping enabled flag and set it as the least significant bit.
154 mClippingSortModifier = ( clippingId << 1u ) | ( mClippingMode == ClippingMode::DISABLED ? 1u : 0u );
158 // If we do not have a clipping depth, then set this to 0 so we do not have a Clipping ID either.
159 mClippingSortModifier = 0u;
162 // The scissor depth does not modify the clipping sort modifier (as scissor clips are 2D only).
163 // For this reason we can always update the member variable.
164 mScissorDepth = scissorDepth;
168 * Gets the Clipping ID for this node.
169 * @return The Clipping ID for this node.
171 uint32_t GetClippingId() const
173 return mClippingSortModifier >> 1u;
177 * Gets the Clipping Depth for this node.
178 * @return The Clipping Depth for this node.
180 uint32_t GetClippingDepth() const
182 return mClippingDepth;
186 * Gets the Scissor Clipping Depth for this node.
187 * @return The Scissor Clipping Depth for this node.
189 uint32_t GetScissorDepth() const
191 return mScissorDepth;
195 * Sets the clipping mode for this node.
196 * @param[in] clippingMode The ClippingMode to set
198 void SetClippingMode( const ClippingMode::Type clippingMode )
200 mClippingMode = clippingMode;
204 * Gets the Clipping Mode for this node.
205 * @return The ClippingMode of this node
207 ClippingMode::Type GetClippingMode() const
209 return mClippingMode;
213 * Add a renderer to the node
214 * @param[in] renderer The renderer added to the node
216 void AddRenderer( Renderer* renderer );
219 * Remove a renderer from the node
220 * @param[in] renderer The renderer to be removed
222 void RemoveRenderer( const Renderer* renderer );
225 * Get the renderer at the given index
228 Renderer* GetRendererAt( uint32_t index ) const
230 return mRenderer[index];
234 * Retrieve the number of renderers for the node
236 uint32_t GetRendererCount() const
238 return static_cast<uint32_t>( mRenderer.Size() );
241 // Containment methods
244 * Query whether a node is the root node. Root nodes cannot have a parent node.
245 * A node becomes a root node, when it is installed by UpdateManager.
246 * @return True if the node is a root node.
254 * Set whether a node is the root node. Root nodes cannot have a parent node.
255 * This method should only be called by UpdateManager.
256 * @pre When isRoot is true, the node must not have a parent.
257 * @param[in] isRoot Whether the node is now a root node.
259 void SetRoot(bool isRoot);
262 * Retrieve the parent of a Node.
263 * @return The parent node, or NULL if the Node has not been added to the scene-graph.
271 * Retrieve the parent of a Node.
272 * @return The parent node, or NULL if the Node has not been added to the scene-graph.
274 const Node* GetParent() const
280 * @return true if the node is connected to SceneGraph
282 bool ConnectedToScene()
284 return IsRoot() || GetParent();
288 * Connect a node to the scene-graph.
289 * @pre A node cannot be added to itself.
290 * @pre The parent node is connected to the scene-graph.
291 * @pre The childNode does not already have a parent.
292 * @pre The childNode is not a root node.
293 * @param[in] childNode The child to add.
295 void ConnectChild( Node* childNode );
298 * Disconnect a child (& its children) from the scene-graph.
299 * @pre childNode is a child of this Node.
300 * @param[in] updateBufferIndex The current update buffer index.
301 * @param[in] childNode The node to disconnect.
303 void DisconnectChild( BufferIndex updateBufferIndex, Node& childNode );
306 * Retrieve the children a Node.
307 * @return The container of children.
309 const NodeContainer& GetChildren() const
315 * Retrieve the children a Node.
316 * @return The container of children.
318 NodeContainer& GetChildren()
326 * Flag that one of the node values has changed in the current frame.
327 * @param[in] flag The flag to set.
329 void SetDirtyFlag( NodePropertyFlags flag )
335 * Flag that all of the node values are dirty.
337 void SetAllDirtyFlags()
339 mDirtyFlags = NodePropertyFlags::ALL;
343 * Query whether a node is dirty.
344 * @return The dirty flags
346 NodePropertyFlags GetDirtyFlags() const;
349 * Query inherited dirty flags.
351 * @param The parentFlags to or with
352 * @return The inherited dirty flags
354 NodePropertyFlags GetInheritedDirtyFlags( NodePropertyFlags parentFlags ) const;
357 * Retrieve the parent-origin of the node.
358 * @return The parent-origin.
360 const Vector3& GetParentOrigin() const
362 return mParentOrigin.Get(0);
366 * Sets both the local & base parent-origins of the node.
367 * @param[in] origin The new local & base parent-origins.
369 void SetParentOrigin(const Vector3& origin)
371 mParentOrigin.Set(0,origin );
375 * Retrieve the anchor-point of the node.
376 * @return The anchor-point.
378 const Vector3& GetAnchorPoint() const
380 return mAnchorPoint.Get(0);
384 * Sets both the local & base anchor-points of the node.
385 * @param[in] anchor The new local & base anchor-points.
387 void SetAnchorPoint(const Vector3& anchor)
389 mAnchorPoint.Set(0, anchor );
393 * Retrieve the local position of the node, relative to its parent.
394 * @param[in] bufferIndex The buffer to read from.
395 * @return The local position.
397 const Vector3& GetPosition(BufferIndex bufferIndex) const
399 if( mTransformManagerData.Id() != INVALID_TRANSFORM_ID )
401 return mPosition.Get(bufferIndex);
404 return Vector3::ZERO;
408 * Retrieve the position of the node derived from the position of all its parents.
409 * @return The world position.
411 const Vector3& GetWorldPosition( BufferIndex bufferIndex ) const
413 return mWorldPosition.Get(bufferIndex);
417 * Set whether the Node inherits position.
418 * @param[in] inherit True if the parent position is inherited.
420 void SetInheritPosition(bool inherit)
422 if( mTransformManagerData.Id() != INVALID_TRANSFORM_ID )
424 mTransformManagerData.Manager()->SetInheritPosition( mTransformManagerData.Id(), inherit );
429 * Retrieve the local orientation of the node, relative to its parent.
430 * @param[in] bufferIndex The buffer to read from.
431 * @return The local orientation.
433 const Quaternion& GetOrientation(BufferIndex bufferIndex) const
435 if( mTransformManagerData.Id() != INVALID_TRANSFORM_ID )
437 return mOrientation.Get(0);
440 return Quaternion::IDENTITY;
444 * Retrieve the orientation of the node derived from the rotation of all its parents.
445 * @param[in] bufferIndex The buffer to read from.
446 * @return The world rotation.
448 const Quaternion& GetWorldOrientation( BufferIndex bufferIndex ) const
450 return mWorldOrientation.Get(0);
454 * Set whether the Node inherits orientation.
455 * @param[in] inherit True if the parent orientation is inherited.
457 void SetInheritOrientation(bool inherit)
459 if( mTransformManagerData.Id() != INVALID_TRANSFORM_ID )
461 mTransformManagerData.Manager()->SetInheritOrientation(mTransformManagerData.Id(), inherit );
466 * Retrieve the local scale of the node, relative to its parent.
467 * @param[in] bufferIndex The buffer to read from.
468 * @return The local scale.
470 const Vector3& GetScale(BufferIndex bufferIndex) const
472 if( mTransformManagerData.Id() != INVALID_TRANSFORM_ID )
474 return mScale.Get(0);
482 * Retrieve the scale of the node derived from the scale of all its parents.
483 * @param[in] bufferIndex The buffer to read from.
484 * @return The world scale.
486 const Vector3& GetWorldScale( BufferIndex bufferIndex ) const
488 return mWorldScale.Get(0);
492 * Set whether the Node inherits scale.
493 * @param inherit True if the Node inherits scale.
495 void SetInheritScale( bool inherit )
497 if( mTransformManagerData.Id() != INVALID_TRANSFORM_ID )
499 mTransformManagerData.Manager()->SetInheritScale(mTransformManagerData.Id(), inherit );
504 * Retrieve the visibility of the node.
505 * @param[in] bufferIndex The buffer to read from.
506 * @return True if the node is visible.
508 bool IsVisible(BufferIndex bufferIndex) const
510 return mVisible[bufferIndex];
514 * Retrieve the opacity of the node.
515 * @param[in] bufferIndex The buffer to read from.
516 * @return The opacity.
518 float GetOpacity(BufferIndex bufferIndex) const
520 return mColor[bufferIndex].a;
524 * Retrieve the color of the node.
525 * @param[in] bufferIndex The buffer to read from.
528 const Vector4& GetColor(BufferIndex bufferIndex) const
530 return mColor[bufferIndex];
534 * Sets the color of the node derived from the color of all its parents.
535 * @param[in] color The world color.
536 * @param[in] updateBufferIndex The current update buffer index.
538 void SetWorldColor(const Vector4& color, BufferIndex updateBufferIndex)
540 mWorldColor.Set( updateBufferIndex, color );
544 * Sets the color of the node derived from the color of all its parents.
545 * This method should only be called when the parents world color is up-to-date.
546 * @pre The node has a parent.
547 * @param[in] updateBufferIndex The current update buffer index.
549 void InheritWorldColor( BufferIndex updateBufferIndex )
551 DALI_ASSERT_DEBUG(mParent != NULL);
554 if( mColorMode == USE_OWN_MULTIPLY_PARENT_ALPHA )
556 const Vector4& ownColor = mColor[updateBufferIndex];
557 mWorldColor.Set( updateBufferIndex, ownColor.r, ownColor.g, ownColor.b, ownColor.a * mParent->GetWorldColor(updateBufferIndex).a );
559 else if( mColorMode == USE_OWN_MULTIPLY_PARENT_COLOR )
561 mWorldColor.Set( updateBufferIndex, mParent->GetWorldColor(updateBufferIndex) * mColor[updateBufferIndex] );
563 else if( mColorMode == USE_PARENT_COLOR )
565 mWorldColor.Set( updateBufferIndex, mParent->GetWorldColor(updateBufferIndex) );
567 else // USE_OWN_COLOR
569 mWorldColor.Set( updateBufferIndex, mColor[updateBufferIndex] );
574 * Copies the previous inherited scale, if this changed in the previous frame.
575 * This method should be called instead of InheritWorldScale i.e. if the inherited scale
576 * does not need to be recalculated in the current frame.
577 * @param[in] updateBufferIndex The current update buffer index.
579 void CopyPreviousWorldColor( BufferIndex updateBufferIndex )
581 mWorldColor.CopyPrevious( updateBufferIndex );
585 * Retrieve the color of the node, possibly derived from the color
586 * of all its parents, depending on the value of mColorMode.
587 * @param[in] bufferIndex The buffer to read from.
588 * @return The world color.
590 const Vector4& GetWorldColor(BufferIndex bufferIndex) const
592 return mWorldColor[bufferIndex];
596 * Set the color mode. This specifies whether the Node uses its own color,
597 * or inherits its parent color.
598 * @param[in] colorMode The new color mode.
600 void SetColorMode( ColorMode colorMode )
602 mColorMode = colorMode;
604 SetDirtyFlag( NodePropertyFlags::COLOR );
608 * Retrieve the color mode.
609 * @return The color mode.
611 ColorMode GetColorMode() const
617 * Retrieve the size of the node.
618 * @param[in] bufferIndex The buffer to read from.
621 const Vector3& GetSize(BufferIndex bufferIndex) const
623 if( mTransformManagerData.Id() != INVALID_TRANSFORM_ID )
628 return Vector3::ZERO;
632 * Retrieve the update size hint of the node.
633 * @return The update size hint.
635 const Vector3& GetUpdateSizeHint() const
637 if( mTransformManagerData.Id() != INVALID_TRANSFORM_ID )
639 return mUpdateSizeHint.Get(0);
642 return Vector3::ZERO;
646 * Retrieve the bounding sphere of the node
647 * @return A vector4 describing the bounding sphere. XYZ is the center and W is the radius
649 const Vector4& GetBoundingSphere() const
651 if( mTransformManagerData.Id() != INVALID_TRANSFORM_ID )
653 return mTransformManagerData.Manager()->GetBoundingSphere( mTransformManagerData.Id() );
656 return Vector4::ZERO;
660 * Retrieve world matrix and size of the node
661 * @param[out] The local to world matrix of the node
662 * @param[out] size The current size of the node
664 void GetWorldMatrixAndSize( Matrix& worldMatrix, Vector3& size ) const
666 if( mTransformManagerData.Id() != INVALID_TRANSFORM_ID )
668 mTransformManagerData.Manager()->GetWorldMatrixAndSize( mTransformManagerData.Id(), worldMatrix, size );
673 * Checks if local matrix has changed since last update
674 * @return true if local matrix has changed, false otherwise
676 bool IsLocalMatrixDirty() const
678 return (mTransformManagerData.Id() != INVALID_TRANSFORM_ID) &&
679 (mTransformManagerData.Manager()->IsLocalMatrixDirty( mTransformManagerData.Id() ));
683 * Retrieve the cached world-matrix of a node.
684 * @param[in] bufferIndex The buffer to read from.
685 * @return The world-matrix.
687 const Matrix& GetWorldMatrix( BufferIndex bufferIndex ) const
689 return mWorldMatrix.Get(bufferIndex);
693 * Mark the node as exclusive to a single RenderTask.
694 * @param[in] renderTask The render-task, or NULL if the Node is not exclusive to a single RenderTask.
696 void SetExclusiveRenderTask( RenderTask* renderTask )
698 mExclusiveRenderTask = renderTask;
702 * Query whether the node is exclusive to a single RenderTask.
703 * @return The render-task, or NULL if the Node is not exclusive to a single RenderTask.
705 RenderTask* GetExclusiveRenderTask() const
707 return mExclusiveRenderTask;
711 * Set how the Node and its children should be drawn; see Dali::Actor::SetDrawMode() for more details.
712 * @param[in] drawMode The new draw-mode to use.
714 void SetDrawMode( const DrawMode::Type& drawMode )
716 mDrawMode = drawMode;
720 * Returns whether node is an overlay or not.
721 * @return True if node is an overlay, false otherwise.
723 DrawMode::Type GetDrawMode() const
729 * Returns the transform id of the node
730 * @return The transform component id of the node
732 TransformId GetTransformId() const
734 return mTransformManagerData.Id();
738 * Equality operator, checks for identity, not values.
741 bool operator==( const Node* rhs ) const
743 return ( this == rhs );
747 * @brief Sets the sibling order of the node
748 * @param[in] order The new order
750 void SetDepthIndex( uint32_t depthIndex )
752 mDepthIndex = depthIndex;
756 * @brief Get the depth index of the node
757 * @return Current depth index
759 uint32_t GetDepthIndex() const
765 * @brief Sets the boolean which states whether the position should use the anchor-point.
766 * @param[in] positionUsesAnchorPoint True if the position should use the anchor-point
768 void SetPositionUsesAnchorPoint( bool positionUsesAnchorPoint )
770 if( mTransformManagerData.Id() != INVALID_TRANSFORM_ID && mPositionUsesAnchorPoint != positionUsesAnchorPoint )
772 mPositionUsesAnchorPoint = positionUsesAnchorPoint;
773 mTransformManagerData.Manager()->SetPositionUsesAnchorPoint( mTransformManagerData.Id(), mPositionUsesAnchorPoint );
778 * @brief Sets whether the node is culled or not.
779 * @param[in] bufferIndex The buffer to read from.
780 * @param[in] culled True if the node is culled.
782 void SetCulled( BufferIndex bufferIndex, bool culled )
784 mCulled[bufferIndex] = culled;
788 * @brief Retrieves whether the node is culled or not.
789 * @param[in] bufferIndex The buffer to read from.
790 * @return True if the node is culled.
792 bool IsCulled( BufferIndex bufferIndex ) const
794 return mCulled[bufferIndex];
799 * @copydoc UniformMap::Add
801 void AddUniformMapping(const UniformPropertyMapping& map) override;
804 * @copydoc UniformMap::Remove
806 void RemoveUniformMapping( const ConstString& uniformName ) override;
809 * @copydoc Dali::Internal::SceneGraph::PropertyOwner::IsAnimationPossible
811 bool IsAnimationPossible() const override;
814 * Prepare the node for rendering.
815 * This is called by the UpdateManager when an object is due to be rendered in the current frame.
816 * @param[in] updateBufferIndex The current update buffer index.
818 void PrepareRender( BufferIndex bufferIndex );
821 * Called by UpdateManager when the node is added.
822 * Creates a new transform component in the transform manager and initialize all the properties
823 * related to the transformation
824 * @param[in] transformManager A pointer to the trnasform manager (Owned by UpdateManager)
826 void CreateTransform( SceneGraph::TransformManager* transformManager );
831 void ResetDirtyFlags( BufferIndex updateBufferIndex );
836 * Set the parent of a Node.
837 * @param[in] parentNode the new parent.
839 void SetParent( Node& parentNode );
844 * Protected constructor; See also Node::New()
849 * Protected virtual destructor; See also Node::Delete( Node* )
850 * Kept protected to allow destructor chaining from layer
854 private: // from NodeDataProvider
857 * @copydoc NodeDataProvider::GetModelMatrix
859 const Matrix& GetModelMatrix( BufferIndex bufferIndex ) const override
861 return GetWorldMatrix( bufferIndex );
865 * @copydoc NodeDataProvider::GetRenderColor
867 const Vector4& GetRenderColor( BufferIndex bufferIndex ) const override
869 return GetWorldColor( bufferIndex );
872 public: // From UniformMapDataProvider
874 * @copydoc UniformMapDataProvider::GetUniformMapChanged
876 bool GetUniformMapChanged( BufferIndex bufferIndex ) const override
878 return mUniformMapChanged[bufferIndex];
882 * @copydoc UniformMapDataProvider::GetUniformMap
884 const CollectedUniformMap& GetUniformMap( BufferIndex bufferIndex ) const override
886 return mCollectedUniformMap[bufferIndex];
895 Node& operator=(const Node& rhs);
898 * Recursive helper to disconnect a Node and its children.
899 * Disconnected Nodes have no parent or children.
900 * @param[in] updateBufferIndex The current update buffer index.
902 void RecursiveDisconnectFromSceneGraph( BufferIndex updateBufferIndex );
904 public: // Default properties
905 using TransformManagerParentsOrigin = TransformManagerPropertyVector3<TRANSFORM_PROPERTY_PARENT_ORIGIN>;
906 using TransformManagerAnchorPoint = TransformManagerPropertyVector3<TRANSFORM_PROPERTY_ANCHOR_POINT>;
907 using TransformManagerSize = TransformManagerPropertyVector3<TRANSFORM_PROPERTY_SIZE>;
908 using TransformManagerPosition = TransformManagerPropertyVector3<TRANSFORM_PROPERTY_POSITION>;
909 using TransformManagerScale = TransformManagerPropertyVector3<TRANSFORM_PROPERTY_SCALE>;
912 TransformManagerData mTransformManagerData;
913 TransformManagerParentsOrigin mParentOrigin; ///< Local transform; the position is relative to this. Sets the Transform flag dirty when changed
914 TransformManagerAnchorPoint mAnchorPoint; ///< Local transform; local center of rotation. Sets the Transform flag dirty when changed
915 TransformManagerSize mSize; ///< Size is provided for layouting
916 TransformManagerPosition mPosition; ///< Local transform; distance between parent-origin & anchor-point
917 TransformManagerScale mScale; ///< Local transform; scale relative to parent node
918 TransformManagerPropertyQuaternion mOrientation; ///< Local transform; rotation relative to parent node
920 AnimatableProperty<bool> mVisible; ///< Visibility can be inherited from the Node hierachy
921 AnimatableProperty<bool> mCulled; ///< True if the node is culled. This is not animatable. It is just double-buffered.
922 AnimatableProperty<Vector4> mColor; ///< Color can be inherited from the Node hierarchy
923 AnimatableProperty<Vector3> mUpdateSizeHint; ///< Update size hint is provided for damaged area calculation. This is not animatable. It is just double-buffered. (Because all these bloody properties are).
926 // Inherited properties; read-only from public API
928 TransformManagerVector3Input mWorldPosition; ///< Full inherited position
929 TransformManagerVector3Input mWorldScale;
930 TransformManagerQuaternionInput mWorldOrientation; ///< Full inherited orientation
931 TransformManagerMatrixInput mWorldMatrix; ///< Full inherited world matrix
932 InheritedColor mWorldColor; ///< Full inherited color
934 uint32_t mClippingSortModifier; ///< Contains bit-packed clipping information for quick access when sorting
935 const uint32_t mId; ///< The Unique ID of the node.
939 static uint32_t mNodeCounter; ///< count of total nodes, used for unique ids
941 Node* mParent; ///< Pointer to parent node (a child is owned by its parent)
942 RenderTask* mExclusiveRenderTask; ///< Nodes can be marked as exclusive to a single RenderTask
944 RendererContainer mRenderer; ///< Container of renderers; not owned
946 NodeContainer mChildren; ///< Container of children; not owned
948 CollectedUniformMap mCollectedUniformMap[2]; ///< Uniform maps of the node
949 uint32_t mUniformMapChanged[2]; ///< Records if the uniform map has been altered this frame
950 uint32_t mClippingDepth; ///< The number of stencil clipping nodes deep this node is
951 uint32_t mScissorDepth; ///< The number of scissor clipping nodes deep this node is
953 uint32_t mDepthIndex; ///< Depth index of the node
955 // flags, compressed to bitfield
956 NodePropertyFlags mDirtyFlags; ///< Dirty flags for each of the Node properties
957 uint32_t mRegenerateUniformMap:2; ///< Indicate if the uniform map has to be regenerated this frame
958 DrawMode::Type mDrawMode:3; ///< How the Node and its children should be drawn
959 ColorMode mColorMode:3; ///< Determines whether mWorldColor is inherited, 2 bits is enough
960 ClippingMode::Type mClippingMode:3; ///< The clipping mode of this node
961 bool mIsRoot:1; ///< True if the node cannot have a parent
962 bool mIsLayer:1; ///< True if the node is a layer
963 bool mPositionUsesAnchorPoint:1; ///< True if the node should use the anchor-point when calculating the position
965 // Changes scope, should be at end of class
966 DALI_LOG_OBJECT_STRING_DECLARATION;
971 inline void SetInheritOrientationMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
973 using LocalType = MessageValue1<Node, bool>;
975 // Reserve some memory inside the message queue
976 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
978 // Construct message in the message queue memory; note that delete should not be called on the return value
979 new (slot) LocalType( &node, &Node::SetInheritOrientation, inherit );
982 inline void SetParentOriginMessage( EventThreadServices& eventThreadServices, const Node& node, const Vector3& origin )
984 using LocalType = MessageValue1<Node, Vector3>;
986 // Reserve some memory inside the message queue
987 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
989 // Construct message in the message queue memory; note that delete should not be called on the return value
990 new (slot) LocalType( &node, &Node::SetParentOrigin, origin );
993 inline void SetAnchorPointMessage( EventThreadServices& eventThreadServices, const Node& node, const Vector3& anchor )
995 using LocalType = MessageValue1<Node, Vector3>;
997 // Reserve some memory inside the message queue
998 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1000 // Construct message in the message queue memory; note that delete should not be called on the return value
1001 new (slot) LocalType( &node, &Node::SetAnchorPoint, anchor );
1004 inline void SetInheritPositionMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
1006 using LocalType = MessageValue1<Node, bool>;
1008 // Reserve some memory inside the message queue
1009 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1011 // Construct message in the message queue memory; note that delete should not be called on the return value
1012 new (slot) LocalType( &node, &Node::SetInheritPosition, inherit );
1015 inline void SetInheritScaleMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
1017 using LocalType = MessageValue1<Node, bool>;
1019 // Reserve some memory inside the message queue
1020 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1022 // Construct message in the message queue memory; note that delete should not be called on the return value
1023 new (slot) LocalType( &node, &Node::SetInheritScale, inherit );
1026 inline void SetColorModeMessage( EventThreadServices& eventThreadServices, const Node& node, ColorMode colorMode )
1028 using LocalType = MessageValue1<Node, ColorMode>;
1030 // Reserve some memory inside the message queue
1031 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1033 // Construct message in the message queue memory; note that delete should not be called on the return value
1034 new (slot) LocalType( &node, &Node::SetColorMode, colorMode );
1037 inline void SetDrawModeMessage( EventThreadServices& eventThreadServices, const Node& node, DrawMode::Type drawMode )
1039 using LocalType = MessageValue1<Node, DrawMode::Type>;
1041 // Reserve some memory inside the message queue
1042 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1044 // Construct message in the message queue memory; note that delete should not be called on the return value
1045 new (slot) LocalType( &node, &Node::SetDrawMode, drawMode );
1048 inline void AttachRendererMessage( EventThreadServices& eventThreadServices, const Node& node, const Renderer& renderer )
1050 using LocalType = MessageValue1<Node, Renderer*>;
1052 // Reserve some memory inside the message queue
1053 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1055 // Construct message in the message queue memory; note that delete should not be called on the return value
1056 new (slot) LocalType( &node, &Node::AddRenderer, const_cast<Renderer*>( &renderer ) );
1059 inline void DetachRendererMessage( EventThreadServices& eventThreadServices, const Node& node, const Renderer& renderer )
1061 using LocalType = MessageValue1<Node, const Renderer*>;
1063 // Reserve some memory inside the message queue
1064 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1066 // Construct message in the message queue memory; note that delete should not be called on the return value
1067 new (slot) LocalType( &node, &Node::RemoveRenderer, &renderer );
1070 inline void SetDepthIndexMessage( EventThreadServices& eventThreadServices, const Node& node, uint32_t depthIndex )
1072 using LocalType = MessageValue1<Node, uint32_t>;
1074 // Reserve some memory inside the message queue
1075 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1077 // Construct message in the message queue memory; note that delete should not be called on the return value
1078 new (slot) LocalType( &node, &Node::SetDepthIndex, depthIndex );
1081 inline void SetClippingModeMessage( EventThreadServices& eventThreadServices, const Node& node, ClippingMode::Type clippingMode )
1083 using LocalType = MessageValue1<Node, ClippingMode::Type>;
1085 // Reserve some memory inside the message queue
1086 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1088 // Construct message in the message queue memory; note that delete should not be called on the return value
1089 new (slot) LocalType( &node, &Node::SetClippingMode, clippingMode );
1092 inline void SetPositionUsesAnchorPointMessage( EventThreadServices& eventThreadServices, const Node& node, bool positionUsesAnchorPoint )
1094 using LocalType = MessageValue1<Node, bool>;
1096 // Reserve some memory inside the message queue
1097 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1099 // Construct message in the message queue memory; note that delete should not be called on the return value
1100 new (slot) LocalType( &node, &Node::SetPositionUsesAnchorPoint, positionUsesAnchorPoint );
1103 } // namespace SceneGraph
1105 // Template specialisation for OwnerPointer<Node>, because delete is protected
1107 inline void OwnerPointer<Dali::Internal::SceneGraph::Node>::Reset()
1109 if (mObject != nullptr)
1111 Dali::Internal::SceneGraph::Node::Delete(mObject);
1115 } // namespace Internal
1117 // Template specialisations for OwnerContainer<Node*>, because delete is protected
1119 inline void OwnerContainer<Dali::Internal::SceneGraph::Node*>::Delete( Dali::Internal::SceneGraph::Node* pointer )
1121 Dali::Internal::SceneGraph::Node::Delete(pointer);
1125 #endif // DALI_INTERNAL_SCENE_GRAPH_NODE_H