X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fupdate%2Fnodes%2Fnode.h;h=d9074d6b28850993563762c4b8c043598ce22ac8;hb=8f7dc0feb4ea8914cb85aef4b4538c136d1c252d;hp=a170addfd2d55e80b9d46528bac047c71e7c4b27;hpb=ec1bd81a4e903f1c96350a35e918715a2e1278ef;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/update/nodes/node.h b/dali/internal/update/nodes/node.h index a170add..d9074d6 100644 --- a/dali/internal/update/nodes/node.h +++ b/dali/internal/update/nodes/node.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_SCENE_GRAPH_NODE_H /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -19,69 +19,50 @@ */ // INTERNAL INCLUDES -#include -#include -#include -#include -#include -#include #include #include #include #include #include +#include #include -#include #include -#include -#include #include +#include #include +#include +#include #include +#include +#include +#include +#include +#include namespace Dali { - 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 > {}; +template<> +struct ParameterType : public BasicType +{ +}; +template<> +struct ParameterType : public BasicType +{ +}; namespace SceneGraph { - class DiscardQueue; 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; +class Node; // 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. @@ -94,9 +75,7 @@ static const int RenderableUpdateFlags = TransformFlag | SortModifierFlag | Chil class Node : public PropertyOwner, public NodeDataProvider { public: - // Defaults - static const PositionInheritanceMode DEFAULT_POSITION_INHERITANCE_MODE; static const ColorMode DEFAULT_COLOR_MODE; // Creation methods @@ -107,20 +86,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 @@ -128,9 +106,9 @@ public: * Query whether the node is a layer. * @return True if the node is a layer. */ - bool IsLayer() + bool IsLayer() const { - return (GetLayer() != NULL); + return mIsLayer; } /** @@ -139,7 +117,33 @@ public: */ virtual Layer* GetLayer() { - return NULL; + return nullptr; + } + + // Camera interface + + /** + * Query whether the node is a camera. + * @return True if the node is a camera. + */ + bool IsCamera() const + { + return mIsCamera; + } + + /** + * 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 SetUpdatedTree(bool updated) + { + mUpdated = updated; + + for(Node* child : mChildren) + { + child->SetUpdatedTree(updated); + } } /** @@ -147,13 +151,14 @@ public: * 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 SetClippingInformation( const uint32_t clippingId, const uint32_t clippingDepth ) + 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 clipping depth, IE. At least 1 clipping node has been hit. + // 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( DALI_LIKELY( clippingDepth > 0u ) ) + if(clippingDepth > 0u) { mClippingDepth = clippingDepth; @@ -161,13 +166,17 @@ public: // 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 ); + 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; } /** @@ -189,12 +198,22 @@ public: } /** + * Gets the Scissor Clipping Depth for this node. + * @return The Scissor Clipping Depth for this node. + */ + uint32_t GetScissorDepth() const + { + return mScissorDepth; + } + + /** * Sets the clipping mode for this node. * @param[in] clippingMode The ClippingMode to set */ - void SetClippingMode( const ClippingMode::Type clippingMode ) + void SetClippingMode(const ClippingMode::Type clippingMode) { mClippingMode = clippingMode; + SetDirtyFlag(NodePropertyFlags::TRANSFORM); } /** @@ -210,19 +229,19 @@ public: * Add a renderer to the node * @param[in] renderer The renderer added to the node */ - void AddRenderer( Renderer* renderer ); + void AddRenderer(Renderer* renderer); /** * 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]; } @@ -230,9 +249,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 @@ -274,6 +293,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. @@ -281,7 +308,7 @@ public: * @pre The childNode is not a root node. * @param[in] childNode The child to add. */ - void ConnectChild( Node* childNode ); + void ConnectChild(Node* childNode); /** * Disconnect a child (& its children) from the scene-graph. @@ -289,7 +316,7 @@ public: * @param[in] updateBufferIndex The current update buffer index. * @param[in] childNode The node to disconnect. */ - void DisconnectChild( BufferIndex updateBufferIndex, Node& childNode ); + void DisconnectChild(BufferIndex updateBufferIndex, Node& childNode); /** * Retrieve the children a Node. @@ -325,23 +352,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. @@ -349,7 +375,12 @@ public: */ const Vector3& GetParentOrigin() const { - return mParentOrigin.Get(0); + if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID) + { + return mParentOrigin.Get(0); + } + + return Vector3::ZERO; } /** @@ -358,7 +389,7 @@ public: */ void SetParentOrigin(const Vector3& origin) { - mParentOrigin.Set(0,origin ); + mParentOrigin.Set(0, origin); } /** @@ -367,7 +398,12 @@ public: */ const Vector3& GetAnchorPoint() const { - return mAnchorPoint.Get(0); + if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID) + { + return mAnchorPoint.Get(0); + } + + return Vector3::ZERO; } /** @@ -376,7 +412,7 @@ public: */ void SetAnchorPoint(const Vector3& anchor) { - mAnchorPoint.Set(0, anchor ); + mAnchorPoint.Set(0, anchor); } /** @@ -386,7 +422,7 @@ public: */ const Vector3& GetPosition(BufferIndex bufferIndex) const { - if( mTransformId != INVALID_TRANSFORM_ID ) + if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID) { return mPosition.Get(bufferIndex); } @@ -398,9 +434,13 @@ public: * Retrieve the position of the node derived from the position of all its parents. * @return The world position. */ - const Vector3& GetWorldPosition( BufferIndex bufferIndex ) const + const Vector3& GetWorldPosition(BufferIndex bufferIndex) const { - return mWorldPosition.Get(bufferIndex); + if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID) + { + return mWorldPosition.Get(bufferIndex); + } + return Vector3::ZERO; } /** @@ -409,9 +449,9 @@ public: */ void SetInheritPosition(bool inherit) { - if( mTransformId != INVALID_TRANSFORM_ID ) + if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID) { - mTransformManager->SetInheritPosition( mTransformId, inherit ); + mTransformManagerData.Manager()->SetInheritPosition(mTransformManagerData.Id(), inherit); } } @@ -422,7 +462,7 @@ public: */ const Quaternion& GetOrientation(BufferIndex bufferIndex) const { - if( mTransformId != INVALID_TRANSFORM_ID ) + if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID) { return mOrientation.Get(0); } @@ -435,9 +475,13 @@ public: * @param[in] bufferIndex The buffer to read from. * @return The world rotation. */ - const Quaternion& GetWorldOrientation( BufferIndex bufferIndex ) const + const Quaternion& GetWorldOrientation(BufferIndex bufferIndex) const { - return mWorldOrientation.Get(0); + if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID) + { + return mWorldOrientation.Get(0); + } + return Quaternion::IDENTITY; } /** @@ -446,9 +490,9 @@ public: */ void SetInheritOrientation(bool inherit) { - if( mTransformId != INVALID_TRANSFORM_ID ) + if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID) { - mTransformManager->SetInheritOrientation(mTransformId, inherit ); + mTransformManagerData.Manager()->SetInheritOrientation(mTransformManagerData.Id(), inherit); } } @@ -459,7 +503,7 @@ public: */ const Vector3& GetScale(BufferIndex bufferIndex) const { - if( mTransformId != INVALID_TRANSFORM_ID ) + if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID) { return mScale.Get(0); } @@ -467,26 +511,29 @@ public: return Vector3::ONE; } - /** * Retrieve the scale of the node derived from the scale of all its parents. * @param[in] bufferIndex The buffer to read from. * @return The world scale. */ - const Vector3& GetWorldScale( BufferIndex bufferIndex ) const + const Vector3& GetWorldScale(BufferIndex bufferIndex) const { - return mWorldScale.Get(0); + if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID) + { + return mWorldScale.Get(0); + } + return Vector3::ONE; } /** * Set whether the Node inherits scale. * @param inherit True if the Node inherits scale. */ - void SetInheritScale( bool inherit ) + void SetInheritScale(bool inherit) { - if( mTransformId != INVALID_TRANSFORM_ID ) + if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID) { - mTransformManager->SetInheritScale(mTransformId, inherit ); + mTransformManagerData.Manager()->SetInheritScale(mTransformManagerData.Id(), inherit); } } @@ -527,7 +574,7 @@ public: */ void SetWorldColor(const Vector4& color, BufferIndex updateBufferIndex) { - mWorldColor.Set( updateBufferIndex, color ); + mWorldColor.Set(updateBufferIndex, color); } /** @@ -536,27 +583,27 @@ public: * @pre The node has a parent. * @param[in] updateBufferIndex The current update buffer index. */ - void InheritWorldColor( BufferIndex updateBufferIndex ) + void InheritWorldColor(BufferIndex updateBufferIndex) { DALI_ASSERT_DEBUG(mParent != NULL); // default first - if( mColorMode == USE_OWN_MULTIPLY_PARENT_ALPHA ) + if(mColorMode == USE_OWN_MULTIPLY_PARENT_ALPHA) { const Vector4& ownColor = mColor[updateBufferIndex]; - mWorldColor.Set( updateBufferIndex, ownColor.r, ownColor.g, ownColor.b, ownColor.a * mParent->GetWorldColor(updateBufferIndex).a ); + mWorldColor.Set(updateBufferIndex, ownColor.r, ownColor.g, ownColor.b, ownColor.a * mParent->GetWorldColor(updateBufferIndex).a); } - else if( mColorMode == USE_OWN_MULTIPLY_PARENT_COLOR ) + else if(mColorMode == USE_OWN_MULTIPLY_PARENT_COLOR) { - mWorldColor.Set( updateBufferIndex, mParent->GetWorldColor(updateBufferIndex) * mColor[updateBufferIndex] ); + mWorldColor.Set(updateBufferIndex, mParent->GetWorldColor(updateBufferIndex) * mColor[updateBufferIndex]); } - else if( mColorMode == USE_PARENT_COLOR ) + else if(mColorMode == USE_PARENT_COLOR) { - mWorldColor.Set( updateBufferIndex, mParent->GetWorldColor(updateBufferIndex) ); + mWorldColor.Set(updateBufferIndex, mParent->GetWorldColor(updateBufferIndex)); } else // USE_OWN_COLOR { - mWorldColor.Set( updateBufferIndex, mColor[updateBufferIndex] ); + mWorldColor.Set(updateBufferIndex, mColor[updateBufferIndex]); } } @@ -566,9 +613,9 @@ public: * does not need to be recalculated in the current frame. * @param[in] updateBufferIndex The current update buffer index. */ - void CopyPreviousWorldColor( BufferIndex updateBufferIndex ) + void CopyPreviousWorldColor(BufferIndex updateBufferIndex) { - mWorldColor.CopyPrevious( updateBufferIndex ); + mWorldColor.CopyPrevious(updateBufferIndex); } /** @@ -591,7 +638,7 @@ public: { mColorMode = colorMode; - SetDirtyFlag(ColorFlag); + SetDirtyFlag(NodePropertyFlags::COLOR); } /** @@ -610,7 +657,7 @@ public: */ const Vector3& GetSize(BufferIndex bufferIndex) const { - if( mTransformId != INVALID_TRANSFORM_ID ) + if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID) { return mSize.Get(0); } @@ -619,14 +666,28 @@ public: } /** + * Retrieve the update area hint of the node. + * @return The update area hint. + */ + const Vector4& GetUpdateAreaHint() const + { + if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID) + { + return mUpdateAreaHint.Get(0); + } + + return Vector4::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 ) + if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID) { - return mTransformManager->GetBoundingSphere( mTransformId ); + return mTransformManagerData.Manager()->GetBoundingSphere(mTransformManagerData.Id()); } return Vector4::ZERO; @@ -637,11 +698,11 @@ public: * @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 + void GetWorldMatrixAndSize(Matrix& worldMatrix, Vector3& size) const { - if( mTransformId != INVALID_TRANSFORM_ID ) + if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID) { - mTransformManager->GetWorldMatrixAndSize( mTransformId, worldMatrix, size ); + mTransformManagerData.Manager()->GetWorldMatrixAndSize(mTransformManagerData.Id(), worldMatrix, size); } } @@ -651,8 +712,8 @@ public: */ bool IsLocalMatrixDirty() const { - return (mTransformId != INVALID_TRANSFORM_ID) && - (mTransformManager->IsLocalMatrixDirty( mTransformId )); + return (mTransformManagerData.Id() != INVALID_TRANSFORM_ID) && + (mTransformManagerData.Manager()->IsLocalMatrixDirty(mTransformManagerData.Id())); } /** @@ -660,16 +721,21 @@ public: * @param[in] bufferIndex The buffer to read from. * @return The world-matrix. */ - const Matrix& GetWorldMatrix( BufferIndex bufferIndex ) const + const Matrix& GetWorldMatrix(BufferIndex bufferIndex) const { - return mWorldMatrix.Get(bufferIndex); + if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID) + { + return mWorldMatrix.Get(bufferIndex); + } + + return Matrix::IDENTITY; } /** * Mark the node as exclusive to a single RenderTask. * @param[in] renderTask The render-task, or NULL if the Node is not exclusive to a single RenderTask. */ - void SetExclusiveRenderTask( RenderTask* renderTask ) + void SetExclusiveRenderTask(RenderTask* renderTask) { mExclusiveRenderTask = renderTask; } @@ -687,7 +753,7 @@ public: * Set how the Node and its children should be drawn; see Dali::Actor::SetDrawMode() for more details. * @param[in] drawMode The new draw-mode to use. */ - void SetDrawMode( const DrawMode::Type& drawMode ) + void SetDrawMode(const DrawMode::Type& drawMode) { mDrawMode = drawMode; } @@ -701,53 +767,103 @@ public: return mDrawMode; } + void SetTransparent(bool transparent) + { + mTransparent = transparent; + } + + bool IsTransparent() const + { + return mTransparent; + } + /* * Returns the transform id of the node * @return The transform component id of the node */ TransformId GetTransformId() const { - return mTransformId; + return mTransformManagerData.Id(); } /** * Equality operator, checks for identity, not values. * @param[in] */ - bool operator==( const Node* rhs ) const + bool operator==(const Node* rhs) const { - return ( this == rhs ); + return (this == rhs); } /** * @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) + { + if(depthIndex != mDepthIndex) + { + SetDirtyFlag(NodePropertyFlags::DEPTH_INDEX); + 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; + } -public: /** - * @copydoc UniformMap::Add + * @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 AddUniformMapping( UniformPropertyMapping* map ); + void SetPositionUsesAnchorPoint(bool positionUsesAnchorPoint) + { + if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID && mPositionUsesAnchorPoint != positionUsesAnchorPoint) + { + mPositionUsesAnchorPoint = positionUsesAnchorPoint; + mTransformManagerData.Manager()->SetPositionUsesAnchorPoint(mTransformManagerData.Id(), mPositionUsesAnchorPoint); + } + } /** - * @copydoc UniformMap::Remove + * @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 RemoveUniformMapping( const std::string& uniformName ); + void SetCulled(BufferIndex bufferIndex, bool culled) + { + mCulled[bufferIndex] = culled; + } /** - * Prepare the node for rendering. - * This is called by the UpdateManager when an object is due to be rendered in the current frame. - * @param[in] updateBufferIndex The current update buffer index. + * @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 mCulled[bufferIndex]; + } + + /** + * @brief Returns partial rendering data associated with the node. + * @return The partial rendering data */ - void PrepareRender( BufferIndex bufferIndex ); + PartialRenderingData& GetPartialRenderingData() + { + return mPartialRenderingData; + } + +public: + /** + * @copydoc Dali::Internal::SceneGraph::PropertyOwner::IsAnimationPossible + */ + bool IsAnimationPossible() const override; /** * Called by UpdateManager when the node is added. @@ -755,124 +871,133 @@ public: * related to the transformation * @param[in] transformManager A pointer to the trnasform manager (Owned by UpdateManager) */ - void CreateTransform( SceneGraph::TransformManager* transformManager ); + void CreateTransform(SceneGraph::TransformManager* transformManager); -protected: + /** + * Reset dirty flags + */ + void ResetDirtyFlags(BufferIndex updateBufferIndex); /** + * Update uniform hash + * @param[in] bufferIndex The buffer to read from. + */ + void UpdateUniformHash(BufferIndex bufferIndex); + +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(); -private: // from NodeDataProvider - /** - * @copydoc NodeDataProvider::GetModelMatrix + * Protected virtual destructor; See also Node::Delete( Node* ) + * Kept protected to allow destructor chaining from layer */ - virtual const Matrix& GetModelMatrix( unsigned int bufferId ) const - { - return GetWorldMatrix( bufferId ); - } + ~Node() override; +private: // from NodeDataProvider /** * @copydoc NodeDataProvider::GetRenderColor */ - virtual const Vector4& GetRenderColor( unsigned int bufferId ) const - { - return GetWorldColor( bufferId ); - } - -public: // From UniformMapDataProvider - /** - * @copydoc UniformMapDataProvider::GetUniformMapChanged - */ - virtual bool GetUniformMapChanged( BufferIndex bufferIndex ) const + const Vector4& GetRenderColor(BufferIndex bufferIndex) const override { - return mUniformMapChanged[bufferIndex]; + return GetWorldColor(bufferIndex); } /** - * @copydoc UniformMapDataProvider::GetUniformMap + * @copydoc NodeDataProvider::GetNodeUniformMap */ - virtual const CollectedUniformMap& GetUniformMap( BufferIndex bufferIndex ) const + const UniformMap& GetNodeUniformMap() const override { - return mCollectedUniformMap[bufferIndex]; + return GetUniformMap(); } private: - - // Undefined - Node(const Node&); - - // Undefined - Node& operator=(const Node& rhs); - - /** - * @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties() - */ - virtual void ResetDefaultProperties( BufferIndex updateBufferIndex ); + // Delete copy and move + Node(const Node&) = delete; + Node(Node&&) = delete; + Node& operator=(const Node& rhs) = delete; + Node& operator=(Node&& rhs) = delete; /** * Recursive helper to disconnect a Node and its children. * Disconnected Nodes have no parent or children. * @param[in] updateBufferIndex The current update buffer index. */ - void RecursiveDisconnectFromSceneGraph( BufferIndex updateBufferIndex ); + void RecursiveDisconnectFromSceneGraph(BufferIndex updateBufferIndex); public: // Default properties + // Define a base offset for the following wrappers. The wrapper macros calculate offsets from the previous + // element such that each wrapper type generates a compile time offset to the transform manager data. + BASE(TransformManagerData, mTransformManagerData); + PROPERTY_WRAPPER(mTransformManagerData, TransformManagerPropertyVector3, TRANSFORM_PROPERTY_PARENT_ORIGIN, + mParentOrigin); // Local transform; the position is relative to this. Sets the Transform flag dirty when changed - 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 + PROPERTY_WRAPPER(mParentOrigin, TransformManagerPropertyVector3, TRANSFORM_PROPERTY_ANCHOR_POINT, + mAnchorPoint); // Local transform; local center of rotation. Sets the Transform flag dirty when changed - AnimatableProperty mVisible; ///< Visibility can be inherited from the Node hierachy - AnimatableProperty mColor; ///< Color can be inherited from the Node hierarchy + PROPERTY_WRAPPER(mAnchorPoint, TransformManagerPropertyVector3, TRANSFORM_PROPERTY_SIZE, + mSize); // Size is provided for layouting - // Inherited properties; read-only from public API + PROPERTY_WRAPPER(mSize, TransformManagerPropertyVector3, TRANSFORM_PROPERTY_POSITION, + mPosition); // Local transform; distance between parent-origin & anchor-point + PROPERTY_WRAPPER(mPosition, TransformManagerPropertyVector3, TRANSFORM_PROPERTY_SCALE, + mScale); // Local transform; scale relative to parent node - TransformManagerVector3Input mWorldPosition; ///< Full inherited position - TransformManagerVector3Input mWorldScale; - TransformManagerQuaternionInput mWorldOrientation; ///< Full inherited orientation - TransformManagerMatrixInput mWorldMatrix; ///< Full inherited world matrix - InheritedColor mWorldColor; ///< Full inherited color + TEMPLATE_WRAPPER(mScale, TransformManagerPropertyQuaternion, + mOrientation); // Local transform; rotation relative to parent node - uint32_t mClippingSortModifier; ///< Contains bit-packed clipping information for quick access when sorting + // Inherited properties; read-only from public API + TEMPLATE_WRAPPER(mOrientation, TransformManagerVector3Input, mWorldPosition); // Full inherited position + TEMPLATE_WRAPPER(mWorldPosition, TransformManagerVector3Input, mWorldScale); // Full inherited scale + TEMPLATE_WRAPPER(mWorldScale, TransformManagerQuaternionInput, mWorldOrientation); // Full inherited orientation + TEMPLATE_WRAPPER(mWorldOrientation, TransformManagerMatrixInput, mWorldMatrix); // Full inherited world matrix + + 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 + InheritedColor mWorldColor; ///< Full inherited color + AnimatableProperty mUpdateAreaHint; ///< Update area hint is provided for damaged area calculation. (x, y, width, height) + ///< This is not animatable. It is just double-buffered. (Because all these bloody properties are). + + uint64_t mUniformsHash{0u}; ///< Hash of uniform map property values + uint32_t mClippingSortModifier; ///< Contains bit-packed clipping information for quick access when sorting + 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 + PartialRenderingData mPartialRenderingData; ///< Cache to determine if this should be rendered again - 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 - uint32_t mClippingDepth; ///< The number of clipping nodes deep this node is + NodeContainer mChildren; ///< Container of children; not owned - uint32_t mDepthIndex; ///< Depth index of the node + 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 - 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 - ClippingMode::Type mClippingMode:2; ///< The clipping mode of this node - bool mIsRoot:1; ///< True if the node cannot have a parent + NodePropertyFlags mDirtyFlags; ///< Dirty flags for each of the Node properties + 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 mIsCamera : 1; ///< True if the node is a camera + bool mPositionUsesAnchorPoint : 1; ///< True if the node should use the anchor-point when calculating the position + bool mTransparent : 1; ///< True if this node is transparent. This value do not affect children. // Changes scope, should be at end of class DALI_LOG_OBJECT_STRING_DECLARATION; @@ -880,132 +1005,158 @@ protected: // Messages for Node -inline void SetInheritOrientationMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit ) +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 ); + new(slot) LocalType(&node, &Node::SetInheritOrientation, inherit); } -inline void SetParentOriginMessage( EventThreadServices& eventThreadServices, const Node& node, const Vector3& origin ) +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 ); + new(slot) LocalType(&node, &Node::SetParentOrigin, origin); } -inline void SetAnchorPointMessage( EventThreadServices& eventThreadServices, const Node& node, const Vector3& anchor ) +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 ); + new(slot) LocalType(&node, &Node::SetAnchorPoint, anchor); } -inline void SetInheritPositionMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit ) +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 ); + new(slot) LocalType(&node, &Node::SetInheritPosition, inherit); } -inline void SetInheritScaleMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit ) +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 ); + new(slot) LocalType(&node, &Node::SetInheritScale, inherit); } -inline void SetColorModeMessage( EventThreadServices& eventThreadServices, const Node& node, ColorMode colorMode ) +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 ); + new(slot) LocalType(&node, &Node::SetColorMode, colorMode); } -inline void SetDrawModeMessage( EventThreadServices& eventThreadServices, const Node& node, DrawMode::Type drawMode ) +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 ); + new(slot) LocalType(&node, &Node::SetDrawMode, drawMode); } -inline void AddRendererMessage( EventThreadServices& eventThreadServices, const Node& node, Renderer* renderer ) +inline void SetTransparentMessage(EventThreadServices& eventThreadServices, const Node& node, bool transparent) { - 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::SetTransparent, transparent); } -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 ); + new(slot) LocalType(&node, &Node::SetDepthIndex, depthIndex); } -inline void SetClippingModeMessage( EventThreadServices& eventThreadServices, const Node& node, ClippingMode::Type clippingMode ) +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 ); + new(slot) LocalType(&node, &Node::SetClippingMode, clippingMode); } +inline void SetPositionUsesAnchorPointMessage(EventThreadServices& eventThreadServices, const Node& node, bool positionUsesAnchorPoint) +{ + 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::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