X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fupdate%2Fnodes%2Fnode.h;h=77bd5acc481fcbc44459da63b2737c16002e061f;hb=0b1a36885914bce024aec63a236058f83809e1db;hp=e12c5ada46819c5621c029a70325c74ef25313b0;hpb=2f99fe6e68e7b8f01e40a505501c3529f0511a3b;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/update/nodes/node.h b/dali/internal/update/nodes/node.h index e12c5ad..77bd5ac 100644 --- a/dali/internal/update/nodes/node.h +++ b/dali/internal/update/nodes/node.h @@ -1,8 +1,8 @@ -#ifndef __DALI_INTERNAL_SCENE_GRAPH_NODE_H__ -#define __DALI_INTERNAL_SCENE_GRAPH_NODE_H__ +#ifndef DALI_INTERNAL_SCENE_GRAPH_NODE_H +#define DALI_INTERNAL_SCENE_GRAPH_NODE_H /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,6 @@ // INTERNAL INCLUDES #include #include -#include #include #include #include @@ -31,13 +30,11 @@ #include #include #include -#include #include #include #include #include #include -#include #include namespace Dali @@ -46,44 +43,21 @@ namespace Dali namespace Internal { -// value types used by messages +// Value types used by messages. template <> struct ParameterType< ColorMode > : public BasicType< ColorMode > {}; -template <> struct ParameterType< PositionInheritanceMode > : public BasicType< PositionInheritanceMode > {}; +template <> struct ParameterType< ClippingMode::Type > : public BasicType< ClippingMode::Type > {}; namespace SceneGraph { class DiscardQueue; class Layer; -class NodeAttachment; class RenderTask; class UpdateManager; -/** - * Flag whether property has changed, during the Update phase. - */ -enum NodePropertyFlags -{ - NothingFlag = 0x000, - TransformFlag = 0x001, - VisibleFlag = 0x002, - ColorFlag = 0x004, - SizeFlag = 0x008, - OverlayFlag = 0x010, - SortModifierFlag = 0x020, - ChildDeletedFlag = 0x040 -}; - -static const int AllFlags = ( ChildDeletedFlag << 1 ) - 1; // all the flags - -/** - * Size is not inherited. - * VisibleFlag is inherited so that attachments can be synchronized with nodes after they become visible - */ -static const int InheritedDirtyFlags = TransformFlag | VisibleFlag | ColorFlag | OverlayFlag; // Flags which require the scene renderable lists to be updated -static const int RenderableUpdateFlags = TransformFlag | SortModifierFlag | ChildDeletedFlag; +static NodePropertyFlags RenderableUpdateFlags = NodePropertyFlags::TRANSFORM | NodePropertyFlags::CHILD_DELETED; /** * Node is the base class for all nodes in the Scene Graph. @@ -98,7 +72,6 @@ class Node : public PropertyOwner, public NodeDataProvider public: // Defaults - static const PositionInheritanceMode DEFAULT_POSITION_INHERITANCE_MODE; static const ColorMode DEFAULT_COLOR_MODE; // Creation methods @@ -109,20 +82,19 @@ public: static Node* New(); /** - * Virtual destructor + * Deletes a Node. */ - virtual ~Node(); + static void Delete( Node* node ); /** - * Overriden delete operator - * Deletes the node from its global memory pool + * Called during UpdateManager::DestroyNode shortly before Node is destroyed. */ - void operator delete( void* ptr ); + void OnDestroy(); /** - * Called during UpdateManager::DestroyNode shortly before Node is destroyed. + * @return the unique ID of the node */ - void OnDestroy(); + uint32_t GetId() const; // Layer interface @@ -132,7 +104,7 @@ public: */ bool IsLayer() { - return (GetLayer() != NULL); + return mIsLayer; } /** @@ -141,65 +113,119 @@ public: */ virtual Layer* GetLayer() { - return NULL; + return nullptr; } - // Attachments + /** + * Mark an node and its sub tree according to the updated flag. + * @param[in] updated The updated flag + * (used for partial rendering to mark an animating sub tree for example). + */ + void SetUpdated(bool updated) override + { + mUpdated = updated; + + for (Node* child : mChildren) + { + child->SetUpdated(updated); + } + } /** - * Attach an object to this Node; This should only be done by UpdateManager::AttachToNode. - * @pre The Node does not already have an attachment. - * @param[in] attachment The object to attach. + * This method sets clipping information on the node based on its hierarchy in the scene-graph. + * A value is calculated that can be used during sorting to increase sort speed. + * @param[in] clippingId The Clipping ID of the node to set + * @param[in] clippingDepth The Clipping Depth of the node to set + * @param[in] scissorDepth The Scissor Clipping Depth of the node to set */ - void Attach( NodeAttachment& attachment ); + void SetClippingInformation( const uint32_t clippingId, const uint32_t clippingDepth, const uint32_t scissorDepth ) + { + // We only set up the sort value if we have a stencil clipping depth, IE. At least 1 clipping node has been hit. + // If not, if we traverse down a clipping tree and back up, and there is another + // node on the parent, this will have a non-zero clipping ID that must be ignored + if( clippingDepth > 0u ) + { + mClippingDepth = clippingDepth; + + // Calculate the sort value here on write, as when read (during sort) it may be accessed several times. + // The items must be sorted by Clipping ID first (so the ID is kept in the most-significant bits). + // For the same ID, the clipping nodes must be first, so we negate the + // clipping enabled flag and set it as the least significant bit. + mClippingSortModifier = ( clippingId << 1u ) | ( mClippingMode == ClippingMode::DISABLED ? 1u : 0u ); + } + else + { + // If we do not have a clipping depth, then set this to 0 so we do not have a Clipping ID either. + mClippingSortModifier = 0u; + } + + // The scissor depth does not modify the clipping sort modifier (as scissor clips are 2D only). + // For this reason we can always update the member variable. + mScissorDepth = scissorDepth; + } /** - * Query the node if it has an attachment. - * @return True if it has an attachment. + * Gets the Clipping ID for this node. + * @return The Clipping ID for this node. */ - bool HasAttachment() const + uint32_t GetClippingId() const { - return mAttachment; + return mClippingSortModifier >> 1u; } /** - * Add a renderer to the node - * @param[in] renderer The renderer added to the node + * Gets the Clipping Depth for this node. + * @return The Clipping Depth for this node. */ - void AddRenderer( Renderer* renderer ) + uint32_t GetClippingDepth() const { - //Check that it has not been already added - unsigned int rendererCount( mRenderer.Size() ); - for( unsigned int i(0); i( mRenderer.Size() ); } // Containment methods @@ -260,6 +277,14 @@ public: } /** + * @return true if the node is connected to SceneGraph + */ + bool ConnectedToScene() + { + return IsRoot() || GetParent(); + } + + /** * Connect a node to the scene-graph. * @pre A node cannot be added to itself. * @pre The parent node is connected to the scene-graph. @@ -301,7 +326,7 @@ public: * Flag that one of the node values has changed in the current frame. * @param[in] flag The flag to set. */ - void SetDirtyFlag(NodePropertyFlags flag) + void SetDirtyFlag( NodePropertyFlags flag ) { mDirtyFlags |= flag; } @@ -311,23 +336,22 @@ public: */ void SetAllDirtyFlags() { - mDirtyFlags = AllFlags; + mDirtyFlags = NodePropertyFlags::ALL; } /** * Query whether a node is dirty. * @return The dirty flags */ - int GetDirtyFlags() const; + NodePropertyFlags GetDirtyFlags() const; /** - * Query whether a node is clean. - * @return True if the node is clean. + * Query inherited dirty flags. + * + * @param The parentFlags to or with + * @return The inherited dirty flags */ - bool IsClean() const - { - return ( NothingFlag == GetDirtyFlags() ); - } + NodePropertyFlags GetInheritedDirtyFlags( NodePropertyFlags parentFlags ) const; /** * Retrieve the parent-origin of the node. @@ -402,19 +426,6 @@ public: } /** - * Set the position inheritance mode. - * @see Dali::Actor::PositionInheritanceMode - * @param[in] mode The new position inheritance mode. - */ - void SetPositionInheritanceMode( PositionInheritanceMode mode ) - { - if( mTransformId != INVALID_TRANSFORM_ID ) - { - mTransformManager->SetInheritPosition(mTransformId, mode == INHERIT_PARENT_POSITION ); - } - } - - /** * Retrieve the local orientation of the node, relative to its parent. * @param[in] bufferIndex The buffer to read from. * @return The local orientation. @@ -586,11 +597,11 @@ public: * or inherits its parent color. * @param[in] colorMode The new color mode. */ - void SetColorMode(ColorMode colorMode) + void SetColorMode( ColorMode colorMode ) { mColorMode = colorMode; - SetDirtyFlag(ColorFlag); + SetDirtyFlag( NodePropertyFlags::COLOR ); } /** @@ -618,6 +629,47 @@ public: } /** + * Retrieve the update size hint of the node. + * @return The update size hint. + */ + const Vector3& GetUpdateSizeHint() const + { + if( mTransformId != INVALID_TRANSFORM_ID ) + { + return mUpdateSizeHint.Get(0); + } + + return Vector3::ZERO; + } + + /** + * Retrieve the bounding sphere of the node + * @return A vector4 describing the bounding sphere. XYZ is the center and W is the radius + */ + const Vector4& GetBoundingSphere() const + { + if( mTransformId != INVALID_TRANSFORM_ID ) + { + return mTransformManager->GetBoundingSphere( mTransformId ); + } + + return Vector4::ZERO; + } + + /** + * Retrieve world matrix and size of the node + * @param[out] The local to world matrix of the node + * @param[out] size The current size of the node + */ + void GetWorldMatrixAndSize( Matrix& worldMatrix, Vector3& size ) const + { + if( mTransformId != INVALID_TRANSFORM_ID ) + { + mTransformManager->GetWorldMatrixAndSize( mTransformId, worldMatrix, size ); + } + } + + /** * Checks if local matrix has changed since last update * @return true if local matrix has changed, false otherwise */ @@ -627,7 +679,6 @@ public: (mTransformManager->IsLocalMatrixDirty( mTransformId )); } - /** * Retrieve the cached world-matrix of a node. * @param[in] bufferIndex The buffer to read from. @@ -685,32 +736,79 @@ public: /** * Equality operator, checks for identity, not values. - * + * @param[in] */ bool operator==( const Node* rhs ) const { - if ( this == rhs ) + return ( this == rhs ); + } + + /** + * @brief Sets the sibling order of the node + * @param[in] order The new order + */ + void SetDepthIndex( uint32_t depthIndex ) + { + mDepthIndex = depthIndex; + } + + /** + * @brief Get the depth index of the node + * @return Current depth index + */ + uint32_t GetDepthIndex() const + { + return mDepthIndex; + } + + /** + * @brief Sets the boolean which states whether the position should use the anchor-point. + * @param[in] positionUsesAnchorPoint True if the position should use the anchor-point + */ + void SetPositionUsesAnchorPoint( bool positionUsesAnchorPoint ) + { + if( mTransformId != INVALID_TRANSFORM_ID && mPositionUsesAnchorPoint != positionUsesAnchorPoint ) { - return true; + mPositionUsesAnchorPoint = positionUsesAnchorPoint; + mTransformManager->SetPositionUsesAnchorPoint( mTransformId, mPositionUsesAnchorPoint ); } - return false; } - unsigned short GetDepth() const + /** + * @brief Sets whether the node is culled or not. + * @param[in] bufferIndex The buffer to read from. + * @param[in] culled True if the node is culled. + */ + void SetCulled( BufferIndex bufferIndex, bool culled ) + { + mCulled[bufferIndex] = culled; + } + + /** + * @brief Retrieves whether the node is culled or not. + * @param[in] bufferIndex The buffer to read from. + * @return True if the node is culled. + */ + bool IsCulled( BufferIndex bufferIndex ) const { - return mDepth; + return mCulled[bufferIndex]; } public: /** * @copydoc UniformMap::Add */ - void AddUniformMapping( UniformPropertyMapping* map ); + void AddUniformMapping(const UniformPropertyMapping& map) override; /** * @copydoc UniformMap::Remove */ - void RemoveUniformMapping( const std::string& uniformName ); + void RemoveUniformMapping( const ConstString& uniformName ) override; + + /** + * @copydoc Dali::Internal::SceneGraph::PropertyOwner::IsAnimationPossible + */ + bool IsAnimationPossible() const override; /** * Prepare the node for rendering. @@ -727,42 +825,55 @@ public: */ void CreateTransform( SceneGraph::TransformManager* transformManager ); + /** + * Reset dirty flags + */ + void ResetDirtyFlags( BufferIndex updateBufferIndex ); + protected: /** * Set the parent of a Node. * @param[in] parentNode the new parent. */ - void SetParent(Node& parentNode); + void SetParent( Node& parentNode ); + +protected: /** * Protected constructor; See also Node::New() */ Node(); + /** + * Protected virtual destructor; See also Node::Delete( Node* ) + * Kept protected to allow destructor chaining from layer + */ + ~Node() override; + private: // from NodeDataProvider /** * @copydoc NodeDataProvider::GetModelMatrix */ - virtual const Matrix& GetModelMatrix( unsigned int bufferId ) const + const Matrix& GetModelMatrix( BufferIndex bufferIndex ) const override { - return GetWorldMatrix( bufferId ); + return GetWorldMatrix( bufferIndex ); } /** * @copydoc NodeDataProvider::GetRenderColor */ - virtual const Vector4& GetRenderColor( unsigned int bufferId ) const + const Vector4& GetRenderColor( BufferIndex bufferIndex ) const override { - return GetWorldColor( bufferId ); + return GetWorldColor( bufferIndex ); } public: // From UniformMapDataProvider /** * @copydoc UniformMapDataProvider::GetUniformMapChanged */ - virtual bool GetUniformMapChanged( BufferIndex bufferIndex ) const + bool GetUniformMapChanged( BufferIndex bufferIndex ) const override { return mUniformMapChanged[bufferIndex]; } @@ -770,7 +881,7 @@ public: // From UniformMapDataProvider /** * @copydoc UniformMapDataProvider::GetUniformMap */ - virtual const CollectedUniformMap& GetUniformMap( BufferIndex bufferIndex ) const + const CollectedUniformMap& GetUniformMap( BufferIndex bufferIndex ) const override { return mCollectedUniformMap[bufferIndex]; } @@ -784,11 +895,6 @@ private: Node& operator=(const Node& rhs); /** - * @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties() - */ - virtual void ResetDefaultProperties( BufferIndex updateBufferIndex ); - - /** * Recursive helper to disconnect a Node and its children. * Disconnected Nodes have no parent or children. * @param[in] updateBufferIndex The current update buffer index. @@ -797,48 +903,59 @@ private: public: // Default properties - TransformManager* mTransformManager; - TransformId mTransformId; - TransformManagerPropertyVector3 mParentOrigin; ///< Local transform; the position is relative to this. Sets the TransformFlag dirty when changed - TransformManagerPropertyVector3 mAnchorPoint; ///< Local transform; local center of rotation. Sets the TransformFlag dirty when changed - TransformManagerPropertyVector3 mSize; ///< Size is provided for layouting - TransformManagerPropertyVector3 mPosition; ///< Local transform; distance between parent-origin & anchor-point - TransformManagerPropertyQuaternion mOrientation; ///< Local transform; rotation relative to parent node - TransformManagerPropertyVector3 mScale; ///< Local transform; scale relative to parent node + TransformManager* mTransformManager; + TransformId mTransformId; + TransformManagerPropertyVector3 mParentOrigin; ///< Local transform; the position is relative to this. Sets the Transform flag dirty when changed + TransformManagerPropertyVector3 mAnchorPoint; ///< Local transform; local center of rotation. Sets the Transform flag dirty when changed + TransformManagerPropertyVector3 mSize; ///< Size is provided for layouting + TransformManagerPropertyVector3 mPosition; ///< Local transform; distance between parent-origin & anchor-point + TransformManagerPropertyQuaternion mOrientation; ///< Local transform; rotation relative to parent node + TransformManagerPropertyVector3 mScale; ///< Local transform; scale relative to parent node + + AnimatableProperty mVisible; ///< Visibility can be inherited from the Node hierachy + AnimatableProperty mCulled; ///< True if the node is culled. This is not animatable. It is just double-buffered. + AnimatableProperty mColor; ///< Color can be inherited from the Node hierarchy + AnimatableProperty 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). - AnimatableProperty mVisible; ///< Visibility can be inherited from the Node hierachy - AnimatableProperty mColor; ///< Color can be inherited from the Node hierarchy // Inherited properties; read-only from public API - TransformManagerVector3Input mWorldPosition; ///< Full inherited position - TransformManagerVector3Input mWorldScale; - TransformManagerQuaternionInput mWorldOrientation; ///< Full inherited orientation - TransformManagerMatrixInput mWorldMatrix; ///< Full inherited world matrix - InheritedColor mWorldColor; ///< Full inherited color + TransformManagerVector3Input mWorldPosition; ///< Full inherited position + TransformManagerVector3Input mWorldScale; + TransformManagerQuaternionInput mWorldOrientation; ///< Full inherited orientation + TransformManagerMatrixInput mWorldMatrix; ///< Full inherited world matrix + InheritedColor mWorldColor; ///< Full inherited color + + uint32_t mClippingSortModifier; ///< Contains bit-packed clipping information for quick access when sorting + const uint32_t mId; ///< The Unique ID of the node. protected: - Node* mParent; ///< Pointer to parent node (a child is owned by its parent) - RenderTask* mExclusiveRenderTask; ///< Nodes can be marked as exclusive to a single RenderTask + static uint32_t mNodeCounter; ///< count of total nodes, used for unique ids - NodeAttachmentOwner mAttachment; ///< Optional owned attachment - RendererContainer mRenderer; ///< Container of renderers; not owned + Node* mParent; ///< Pointer to parent node (a child is owned by its parent) + RenderTask* mExclusiveRenderTask; ///< Nodes can be marked as exclusive to a single RenderTask - NodeContainer mChildren; ///< Container of children; not owned + RendererContainer mRenderer; ///< Container of renderers; not owned - CollectedUniformMap mCollectedUniformMap[2]; ///< Uniform maps of the node - unsigned int mUniformMapChanged[2]; ///< Records if the uniform map has been altered this frame - unsigned int mRegenerateUniformMap : 2; ///< Indicate if the uniform map has to be regenerated this frame + NodeContainer mChildren; ///< Container of children; not owned - // flags, compressed to bitfield - unsigned short mDepth: 12; ///< Depth in the hierarchy - int mDirtyFlags:8; ///< A composite set of flags for each of the Node properties + CollectedUniformMap mCollectedUniformMap[2]; ///< Uniform maps of the node + uint32_t mUniformMapChanged[2]; ///< Records if the uniform map has been altered this frame + uint32_t mClippingDepth; ///< The number of stencil clipping nodes deep this node is + uint32_t mScissorDepth; ///< The number of scissor clipping nodes deep this node is - bool mIsRoot:1; ///< True if the node cannot have a parent + uint32_t mDepthIndex; ///< Depth index of the node - DrawMode::Type mDrawMode:2; ///< How the Node and its children should be drawn - ColorMode mColorMode:2; ///< Determines whether mWorldColor is inherited, 2 bits is enough + // flags, compressed to bitfield + NodePropertyFlags mDirtyFlags; ///< Dirty flags for each of the Node properties + uint32_t mRegenerateUniformMap:2; ///< Indicate if the uniform map has to be regenerated this frame + DrawMode::Type mDrawMode:3; ///< How the Node and its children should be drawn + ColorMode mColorMode:3; ///< Determines whether mWorldColor is inherited, 2 bits is enough + ClippingMode::Type mClippingMode:3; ///< The clipping mode of this node + bool mIsRoot:1; ///< True if the node cannot have a parent + bool mIsLayer:1; ///< True if the node is a layer + bool mPositionUsesAnchorPoint:1; ///< True if the node should use the anchor-point when calculating the position // Changes scope, should be at end of class DALI_LOG_OBJECT_STRING_DECLARATION; @@ -848,10 +965,10 @@ protected: inline void SetInheritOrientationMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit ) { - typedef MessageValue1< Node, bool > LocalType; + using LocalType = MessageValue1; // Reserve some memory inside the message queue - unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); // Construct message in the message queue memory; note that delete should not be called on the return value new (slot) LocalType( &node, &Node::SetInheritOrientation, inherit ); @@ -859,10 +976,10 @@ inline void SetInheritOrientationMessage( EventThreadServices& eventThreadServic inline void SetParentOriginMessage( EventThreadServices& eventThreadServices, const Node& node, const Vector3& origin ) { - typedef MessageValue1< Node, Vector3 > LocalType; + using LocalType = MessageValue1; // Reserve some memory inside the message queue - unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); // Construct message in the message queue memory; note that delete should not be called on the return value new (slot) LocalType( &node, &Node::SetParentOrigin, origin ); @@ -870,32 +987,21 @@ inline void SetParentOriginMessage( EventThreadServices& eventThreadServices, co inline void SetAnchorPointMessage( EventThreadServices& eventThreadServices, const Node& node, const Vector3& anchor ) { - typedef MessageValue1< Node, Vector3 > LocalType; + using LocalType = MessageValue1; // Reserve some memory inside the message queue - unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); // Construct message in the message queue memory; note that delete should not be called on the return value new (slot) LocalType( &node, &Node::SetAnchorPoint, anchor ); } -inline void SetPositionInheritanceModeMessage( EventThreadServices& eventThreadServices, const Node& node, PositionInheritanceMode mode ) -{ - typedef MessageValue1< Node, PositionInheritanceMode > LocalType; - - // Reserve some memory inside the message queue - unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &node, &Node::SetPositionInheritanceMode, mode ); -} - inline void SetInheritPositionMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit ) { - typedef MessageValue1< Node, bool > LocalType; + using LocalType = MessageValue1; // Reserve some memory inside the message queue - unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); // Construct message in the message queue memory; note that delete should not be called on the return value new (slot) LocalType( &node, &Node::SetInheritPosition, inherit ); @@ -903,10 +1009,10 @@ inline void SetInheritPositionMessage( EventThreadServices& eventThreadServices, inline void SetInheritScaleMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit ) { - typedef MessageValue1< Node, bool > LocalType; + using LocalType = MessageValue1; // Reserve some memory inside the message queue - unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); // Construct message in the message queue memory; note that delete should not be called on the return value new (slot) LocalType( &node, &Node::SetInheritScale, inherit ); @@ -914,10 +1020,10 @@ inline void SetInheritScaleMessage( EventThreadServices& eventThreadServices, co inline void SetColorModeMessage( EventThreadServices& eventThreadServices, const Node& node, ColorMode colorMode ) { - typedef MessageValue1< Node, ColorMode > LocalType; + using LocalType = MessageValue1; // Reserve some memory inside the message queue - unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); // Construct message in the message queue memory; note that delete should not be called on the return value new (slot) LocalType( &node, &Node::SetColorMode, colorMode ); @@ -925,40 +1031,90 @@ inline void SetColorModeMessage( EventThreadServices& eventThreadServices, const inline void SetDrawModeMessage( EventThreadServices& eventThreadServices, const Node& node, DrawMode::Type drawMode ) { - typedef MessageValue1< Node, DrawMode::Type > LocalType; + using LocalType = MessageValue1; // Reserve some memory inside the message queue - unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); // Construct message in the message queue memory; note that delete should not be called on the return value new (slot) LocalType( &node, &Node::SetDrawMode, drawMode ); } -inline void AddRendererMessage( EventThreadServices& eventThreadServices, const Node& node, Renderer* renderer ) +inline void AttachRendererMessage( EventThreadServices& eventThreadServices, const Node& node, const Renderer& renderer ) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new (slot) LocalType( &node, &Node::AddRenderer, const_cast( &renderer ) ); +} + +inline void DetachRendererMessage( EventThreadServices& eventThreadServices, const Node& node, const Renderer& renderer ) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new (slot) LocalType( &node, &Node::RemoveRenderer, &renderer ); +} + +inline void SetDepthIndexMessage( EventThreadServices& eventThreadServices, const Node& node, uint32_t depthIndex ) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new (slot) LocalType( &node, &Node::SetDepthIndex, depthIndex ); +} + +inline void SetClippingModeMessage( EventThreadServices& eventThreadServices, const Node& node, ClippingMode::Type clippingMode ) { - typedef MessageValue1< Node, Renderer* > LocalType; + using LocalType = MessageValue1; // Reserve some memory inside the message queue - unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &node, &Node::AddRenderer, renderer ); + new (slot) LocalType( &node, &Node::SetClippingMode, clippingMode ); } -inline void RemoveRendererMessage( EventThreadServices& eventThreadServices, const Node& node, Renderer* renderer ) +inline void SetPositionUsesAnchorPointMessage( EventThreadServices& eventThreadServices, const Node& node, bool positionUsesAnchorPoint ) { - typedef MessageValue1< Node, Renderer* > LocalType; + using LocalType = MessageValue1; // Reserve some memory inside the message queue - unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &node, &Node::RemoveRenderer, renderer ); + new (slot) LocalType( &node, &Node::SetPositionUsesAnchorPoint, positionUsesAnchorPoint ); } + } // namespace SceneGraph +// Template specialisation for OwnerPointer, because delete is protected +template <> +inline void OwnerPointer::Reset() +{ + if (mObject != nullptr) + { + Dali::Internal::SceneGraph::Node::Delete(mObject); + mObject = nullptr; + } +} } // namespace Internal +// Template specialisations for OwnerContainer, because delete is protected +template <> +inline void OwnerContainer::Delete( Dali::Internal::SceneGraph::Node* pointer ) +{ + Dali::Internal::SceneGraph::Node::Delete(pointer); +} } // namespace Dali -#endif // __DALI_INTERNAL_SCENE_GRAPH_NODE_H_ +#endif // DALI_INTERNAL_SCENE_GRAPH_NODE_H