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( mTransformId != 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( mTransformId != INVALID_TRANSFORM_ID )
424 mTransformManager->SetInheritPosition( mTransformId, 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( mTransformId != 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( mTransformId != INVALID_TRANSFORM_ID )
461 mTransformManager->SetInheritOrientation(mTransformId, 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( mTransformId != 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( mTransformId != INVALID_TRANSFORM_ID )
499 mTransformManager->SetInheritScale(mTransformId, 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( mTransformId != 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( mTransformId != 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( mTransformId != INVALID_TRANSFORM_ID )
653 return mTransformManager->GetBoundingSphere( mTransformId );
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( mTransformId != INVALID_TRANSFORM_ID )
668 mTransformManager->GetWorldMatrixAndSize( mTransformId, 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 (mTransformId != INVALID_TRANSFORM_ID) &&
679 (mTransformManager->IsLocalMatrixDirty( mTransformId ));
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
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( mTransformId != INVALID_TRANSFORM_ID && mPositionUsesAnchorPoint != positionUsesAnchorPoint )
772 mPositionUsesAnchorPoint = positionUsesAnchorPoint;
773 mTransformManager->SetPositionUsesAnchorPoint( mTransformId, 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( OwnerPointer< 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
906 TransformManager* mTransformManager;
907 TransformId mTransformId;
908 TransformManagerPropertyVector3 mParentOrigin; ///< Local transform; the position is relative to this. Sets the Transform flag dirty when changed
909 TransformManagerPropertyVector3 mAnchorPoint; ///< Local transform; local center of rotation. Sets the Transform flag dirty when changed
910 TransformManagerPropertyVector3 mSize; ///< Size is provided for layouting
911 TransformManagerPropertyVector3 mPosition; ///< Local transform; distance between parent-origin & anchor-point
912 TransformManagerPropertyQuaternion mOrientation; ///< Local transform; rotation relative to parent node
913 TransformManagerPropertyVector3 mScale; ///< Local transform; scale relative to parent node
915 AnimatableProperty<bool> mVisible; ///< Visibility can be inherited from the Node hierachy
916 AnimatableProperty<bool> mCulled; ///< True if the node is culled. This is not animatable. It is just double-buffered.
917 AnimatableProperty<Vector4> mColor; ///< Color can be inherited from the Node hierarchy
918 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).
921 // Inherited properties; read-only from public API
923 TransformManagerVector3Input mWorldPosition; ///< Full inherited position
924 TransformManagerVector3Input mWorldScale;
925 TransformManagerQuaternionInput mWorldOrientation; ///< Full inherited orientation
926 TransformManagerMatrixInput mWorldMatrix; ///< Full inherited world matrix
927 InheritedColor mWorldColor; ///< Full inherited color
929 uint32_t mClippingSortModifier; ///< Contains bit-packed clipping information for quick access when sorting
930 const uint32_t mId; ///< The Unique ID of the node.
934 static uint32_t mNodeCounter; ///< count of total nodes, used for unique ids
936 Node* mParent; ///< Pointer to parent node (a child is owned by its parent)
937 RenderTask* mExclusiveRenderTask; ///< Nodes can be marked as exclusive to a single RenderTask
939 RendererContainer mRenderer; ///< Container of renderers; not owned
941 NodeContainer mChildren; ///< Container of children; not owned
943 CollectedUniformMap mCollectedUniformMap[2]; ///< Uniform maps of the node
944 uint32_t mUniformMapChanged[2]; ///< Records if the uniform map has been altered this frame
945 uint32_t mClippingDepth; ///< The number of stencil clipping nodes deep this node is
946 uint32_t mScissorDepth; ///< The number of scissor clipping nodes deep this node is
948 uint32_t mDepthIndex; ///< Depth index of the node
950 // flags, compressed to bitfield
951 NodePropertyFlags mDirtyFlags; ///< Dirty flags for each of the Node properties
952 uint32_t mRegenerateUniformMap:2; ///< Indicate if the uniform map has to be regenerated this frame
953 DrawMode::Type mDrawMode:3; ///< How the Node and its children should be drawn
954 ColorMode mColorMode:3; ///< Determines whether mWorldColor is inherited, 2 bits is enough
955 ClippingMode::Type mClippingMode:3; ///< The clipping mode of this node
956 bool mIsRoot:1; ///< True if the node cannot have a parent
957 bool mIsLayer:1; ///< True if the node is a layer
958 bool mPositionUsesAnchorPoint:1; ///< True if the node should use the anchor-point when calculating the position
960 // Changes scope, should be at end of class
961 DALI_LOG_OBJECT_STRING_DECLARATION;
966 inline void SetInheritOrientationMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
968 using LocalType = MessageValue1<Node, bool>;
970 // Reserve some memory inside the message queue
971 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
973 // Construct message in the message queue memory; note that delete should not be called on the return value
974 new (slot) LocalType( &node, &Node::SetInheritOrientation, inherit );
977 inline void SetParentOriginMessage( EventThreadServices& eventThreadServices, const Node& node, const Vector3& origin )
979 using LocalType = MessageValue1<Node, Vector3>;
981 // Reserve some memory inside the message queue
982 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
984 // Construct message in the message queue memory; note that delete should not be called on the return value
985 new (slot) LocalType( &node, &Node::SetParentOrigin, origin );
988 inline void SetAnchorPointMessage( EventThreadServices& eventThreadServices, const Node& node, const Vector3& anchor )
990 using LocalType = MessageValue1<Node, Vector3>;
992 // Reserve some memory inside the message queue
993 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
995 // Construct message in the message queue memory; note that delete should not be called on the return value
996 new (slot) LocalType( &node, &Node::SetAnchorPoint, anchor );
999 inline void SetInheritPositionMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
1001 using LocalType = MessageValue1<Node, bool>;
1003 // Reserve some memory inside the message queue
1004 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1006 // Construct message in the message queue memory; note that delete should not be called on the return value
1007 new (slot) LocalType( &node, &Node::SetInheritPosition, inherit );
1010 inline void SetInheritScaleMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
1012 using LocalType = MessageValue1<Node, bool>;
1014 // Reserve some memory inside the message queue
1015 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1017 // Construct message in the message queue memory; note that delete should not be called on the return value
1018 new (slot) LocalType( &node, &Node::SetInheritScale, inherit );
1021 inline void SetColorModeMessage( EventThreadServices& eventThreadServices, const Node& node, ColorMode colorMode )
1023 using LocalType = MessageValue1<Node, ColorMode>;
1025 // Reserve some memory inside the message queue
1026 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1028 // Construct message in the message queue memory; note that delete should not be called on the return value
1029 new (slot) LocalType( &node, &Node::SetColorMode, colorMode );
1032 inline void SetDrawModeMessage( EventThreadServices& eventThreadServices, const Node& node, DrawMode::Type drawMode )
1034 using LocalType = MessageValue1<Node, DrawMode::Type>;
1036 // Reserve some memory inside the message queue
1037 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1039 // Construct message in the message queue memory; note that delete should not be called on the return value
1040 new (slot) LocalType( &node, &Node::SetDrawMode, drawMode );
1043 inline void AttachRendererMessage( EventThreadServices& eventThreadServices, const Node& node, const Renderer& renderer )
1045 using LocalType = MessageValue1<Node, Renderer*>;
1047 // Reserve some memory inside the message queue
1048 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1050 // Construct message in the message queue memory; note that delete should not be called on the return value
1051 new (slot) LocalType( &node, &Node::AddRenderer, const_cast<Renderer*>( &renderer ) );
1054 inline void DetachRendererMessage( EventThreadServices& eventThreadServices, const Node& node, const Renderer& renderer )
1056 using LocalType = MessageValue1<Node, const Renderer*>;
1058 // Reserve some memory inside the message queue
1059 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1061 // Construct message in the message queue memory; note that delete should not be called on the return value
1062 new (slot) LocalType( &node, &Node::RemoveRenderer, &renderer );
1065 inline void SetDepthIndexMessage( EventThreadServices& eventThreadServices, const Node& node, uint32_t depthIndex )
1067 using LocalType = MessageValue1<Node, uint32_t>;
1069 // Reserve some memory inside the message queue
1070 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1072 // Construct message in the message queue memory; note that delete should not be called on the return value
1073 new (slot) LocalType( &node, &Node::SetDepthIndex, depthIndex );
1076 inline void SetClippingModeMessage( EventThreadServices& eventThreadServices, const Node& node, ClippingMode::Type clippingMode )
1078 using LocalType = MessageValue1<Node, ClippingMode::Type>;
1080 // Reserve some memory inside the message queue
1081 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1083 // Construct message in the message queue memory; note that delete should not be called on the return value
1084 new (slot) LocalType( &node, &Node::SetClippingMode, clippingMode );
1087 inline void SetPositionUsesAnchorPointMessage( EventThreadServices& eventThreadServices, const Node& node, bool positionUsesAnchorPoint )
1089 using LocalType = MessageValue1<Node, bool>;
1091 // Reserve some memory inside the message queue
1092 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1094 // Construct message in the message queue memory; note that delete should not be called on the return value
1095 new (slot) LocalType( &node, &Node::SetPositionUsesAnchorPoint, positionUsesAnchorPoint );
1098 } // namespace SceneGraph
1100 // Template specialisation for OwnerPointer<Node>, because delete is protected
1102 inline void OwnerPointer<Dali::Internal::SceneGraph::Node>::Reset()
1104 if (mObject != nullptr)
1106 Dali::Internal::SceneGraph::Node::Delete(mObject);
1110 } // namespace Internal
1112 // Template specialisations for OwnerContainer<Node*>, because delete is protected
1114 inline void OwnerContainer<Dali::Internal::SceneGraph::Node*>::Delete( Dali::Internal::SceneGraph::Node* pointer )
1116 Dali::Internal::SceneGraph::Node::Delete(pointer);
1120 #endif // DALI_INTERNAL_SCENE_GRAPH_NODE_H