X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fupdate%2Fnodes%2Fnode.h;h=c89c2451db76095202e78b763b4f0c4a758694b0;hb=3ed2e43c4376bc77c56be78849cd00434311966e;hp=f0257269a42608b6b4ab2f0574e47b22f259da93;hpb=e6af8504944020f99b87e3677f3b29c9e48a6e15;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/update/nodes/node.h b/dali/internal/update/nodes/node.h old mode 100755 new mode 100644 index f025726..c89c245 --- a/dali/internal/update/nodes/node.h +++ b/dali/internal/update/nodes/node.h @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -46,7 +45,6 @@ namespace Internal // 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 @@ -57,30 +55,9 @@ class Layer; 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 - */ -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. @@ -95,16 +72,14 @@ class Node : public PropertyOwner, public NodeDataProvider public: // Defaults - static const PositionInheritanceMode DEFAULT_POSITION_INHERITANCE_MODE; static const ColorMode DEFAULT_COLOR_MODE; // Creation methods /** * Construct a new Node. - * @param[in] id The unique ID of the node */ - static Node* New( unsigned int id ); + static Node* New(); /** * Deletes a Node. @@ -116,6 +91,11 @@ public: */ void OnDestroy(); + /** + * @return the unique ID of the node + */ + uint32_t GetId() const; + // Layer interface /** @@ -133,7 +113,22 @@ public: */ virtual Layer* GetLayer() { - return NULL; + return nullptr; + } + + /** + * 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); + } } /** @@ -224,13 +219,13 @@ public: * Remove a renderer from the node * @param[in] renderer The renderer to be removed */ - void RemoveRenderer( Renderer* renderer ); + void RemoveRenderer( const Renderer* renderer ); /* * Get the renderer at the given index * @param[in] index */ - Renderer* GetRendererAt( unsigned int index ) const + Renderer* GetRendererAt( uint32_t index ) const { return mRenderer[index]; } @@ -238,9 +233,9 @@ public: /** * Retrieve the number of renderers for the node */ - unsigned int GetRendererCount() + uint32_t GetRendererCount() const { - return mRenderer.Size(); + return static_cast( mRenderer.Size() ); } // Containment methods @@ -282,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. @@ -323,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; } @@ -333,14 +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 inherited dirty flags. + * + * @param The parentFlags to or with + * @return The inherited dirty flags + */ + NodePropertyFlags GetInheritedDirtyFlags( NodePropertyFlags parentFlags ) const; /** * Retrieve the parent-origin of the node. @@ -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,20 @@ 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 */ @@ -722,13 +747,19 @@ public: * @brief Sets the sibling order of the node * @param[in] order The new order */ - void SetDepthIndex( unsigned int depthIndex ){ mDepthIndex = depthIndex; } + void SetDepthIndex( uint32_t depthIndex ) + { + mDepthIndex = depthIndex; + } /** * @brief Get the depth index of the node * @return Current depth index */ - unsigned int GetDepthIndex(){ return mDepthIndex; } + uint32_t GetDepthIndex() const + { + return mDepthIndex; + } /** * @brief Sets the boolean which states whether the position should use the anchor-point. @@ -767,12 +798,12 @@ public: /** * @copydoc UniformMap::Add */ - void AddUniformMapping( OwnerPointer< UniformPropertyMapping >& map ); + void AddUniformMapping( OwnerPointer< UniformPropertyMapping >& map ) override; /** * @copydoc UniformMap::Remove */ - void RemoveUniformMapping( const std::string& uniformName ); + void RemoveUniformMapping( const std::string& uniformName ) override; /** * Prepare the node for rendering. @@ -806,39 +837,38 @@ protected: /** * Protected constructor; See also Node::New() - * @param[in] id The Unique ID of the actor creating the node */ - Node( unsigned int id ); + Node(); /** * Protected virtual destructor; See also Node::Delete( Node* ) * Kept protected to allow destructor chaining from layer */ - virtual ~Node(); + ~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]; } @@ -846,7 +876,7 @@ public: // From UniformMapDataProvider /** * @copydoc UniformMapDataProvider::GetUniformMap */ - virtual const CollectedUniformMap& GetUniformMap( BufferIndex bufferIndex ) const + const CollectedUniformMap& GetUniformMap( BufferIndex bufferIndex ) const override { return mCollectedUniformMap[bufferIndex]; } @@ -870,8 +900,8 @@ 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 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 @@ -880,6 +910,8 @@ public: // Default properties 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). + // Inherited properties; read-only from public API @@ -890,10 +922,12 @@ public: // Default properties InheritedColor mWorldColor; ///< Full inherited color uint32_t mClippingSortModifier; ///< Contains bit-packed clipping information for quick access when sorting - const unsigned int mId; ///< The Unique ID of the node. + const uint32_t mId; ///< The Unique ID of the node. protected: + static uint32_t mNodeCounter; ///< count of total nodes, used for unique ids + 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 @@ -902,21 +936,22 @@ protected: NodeContainer mChildren; ///< Container of children; not owned CollectedUniformMap mCollectedUniformMap[2]; ///< Uniform maps of the node - unsigned int mUniformMapChanged[2]; ///< Records if the uniform map has been altered this frame + 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 uint32_t mDepthIndex; ///< Depth index of the node // flags, compressed to bitfield - unsigned int mRegenerateUniformMap:2; ///< Indicate if the uniform map has to be regenerated this frame - int mDirtyFlags:8; ///< A composite set of flags for each of the Node properties + 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; }; @@ -925,10 +960,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 ); @@ -936,10 +971,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 ); @@ -947,10 +982,10 @@ 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 ); @@ -958,10 +993,10 @@ inline void SetAnchorPointMessage( EventThreadServices& eventThreadServices, con 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 ); @@ -969,10 +1004,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 ); @@ -980,10 +1015,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 ); @@ -991,43 +1026,43 @@ 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 ) { - 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::AddRenderer, const_cast( &renderer ) ); } -inline void RemoveRendererMessage( EventThreadServices& eventThreadServices, const Node& node, Renderer* renderer ) +inline void DetachRendererMessage( EventThreadServices& eventThreadServices, const Node& node, const Renderer& renderer ) { - 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::RemoveRenderer, &renderer ); } -inline void SetDepthIndexMessage( EventThreadServices& eventThreadServices, const Node& node, unsigned int depthIndex ) +inline void SetDepthIndexMessage( EventThreadServices& eventThreadServices, const Node& node, uint32_t depthIndex ) { - typedef MessageValue1< Node, unsigned int > 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::SetDepthIndex, depthIndex ); @@ -1035,10 +1070,10 @@ inline void SetDepthIndexMessage( EventThreadServices& eventThreadServices, cons inline void SetClippingModeMessage( EventThreadServices& eventThreadServices, const Node& node, ClippingMode::Type clippingMode ) { - typedef MessageValue1< Node, ClippingMode::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::SetClippingMode, clippingMode ); @@ -1046,10 +1081,10 @@ inline void SetClippingModeMessage( EventThreadServices& eventThreadServices, co inline void SetPositionUsesAnchorPointMessage( EventThreadServices& eventThreadServices, const Node& node, bool positionUsesAnchorPoint ) { - 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::SetPositionUsesAnchorPoint, positionUsesAnchorPoint ); @@ -1061,10 +1096,10 @@ inline void SetPositionUsesAnchorPointMessage( EventThreadServices& eventThreadS template <> inline void OwnerPointer::Reset() { - if (mObject != NULL) + if (mObject != nullptr) { Dali::Internal::SceneGraph::Node::Delete(mObject); - mObject = NULL; + mObject = nullptr; } } } // namespace Internal