#include <dali/internal/render/data-providers/node-data-provider.h>
#include <dali/internal/update/common/animatable-property.h>
#include <dali/internal/update/common/property-owner.h>
-#include <dali/internal/update/common/property-vector3.h>
#include <dali/internal/update/common/scene-graph-buffers.h>
#include <dali/internal/update/common/inherited-property.h>
#include <dali/internal/update/manager/transform-manager.h>
// 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 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.
public:
// Defaults
- static const PositionInheritanceMode DEFAULT_POSITION_INHERITANCE_MODE;
static const ColorMode DEFAULT_COLOR_MODE;
// Creation methods
*/
void OnDestroy();
+ /**
+ * @return the unique ID of the node
+ */
+ uint32_t GetId() const;
+
// Layer interface
/**
* 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];
}
/**
* Retrieve the number of renderers for the node
*/
- unsigned int GetRendererCount()
+ uint32_t GetRendererCount() const
{
- return mRenderer.Size();
+ return static_cast<uint32_t>( mRenderer.Size() );
}
// Containment methods
}
/**
+ * @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.
* 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;
}
*/
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.
* 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 );
}
/**
* @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.
}
}
+ /**
+ * @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 mCulled[bufferIndex];
+ }
+
public:
/**
* @copydoc UniformMap::Add
/**
* @copydoc NodeDataProvider::GetModelMatrix
*/
- virtual const Matrix& GetModelMatrix( unsigned int bufferId ) const
+ virtual const Matrix& GetModelMatrix( BufferIndex bufferIndex ) const
{
- return GetWorldMatrix( bufferId );
+ return GetWorldMatrix( bufferIndex );
}
/**
* @copydoc NodeDataProvider::GetRenderColor
*/
- virtual const Vector4& GetRenderColor( unsigned int bufferId ) const
+ virtual const Vector4& GetRenderColor( BufferIndex bufferIndex ) const
{
- return GetWorldColor( bufferId );
+ return GetWorldColor( bufferIndex );
}
public: // From UniformMapDataProvider
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
TransformManagerPropertyVector3 mScale; ///< Local transform; scale relative to parent node
AnimatableProperty<bool> mVisible; ///< Visibility can be inherited from the Node hierachy
+ AnimatableProperty<bool> mCulled; ///< True if the node is culled. This is not animatable. It is just double-buffered.
AnimatableProperty<Vector4> mColor; ///< Color can be inherited from the Node hierarchy
// Inherited properties; read-only from public API
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:
+ 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
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
- 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
+ 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;
};
typedef MessageValue1< Node, bool > LocalType;
// 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 );
typedef MessageValue1< Node, Vector3 > LocalType;
// 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 );
typedef MessageValue1< Node, Vector3 > LocalType;
// 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 );
typedef MessageValue1< Node, bool > LocalType;
// 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 );
typedef MessageValue1< Node, bool > LocalType;
// 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 );
typedef MessageValue1< Node, ColorMode > LocalType;
// 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 );
typedef MessageValue1< Node, DrawMode::Type > LocalType;
// 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;
// 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*>( &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;
+ typedef MessageValue1< Node, const Renderer* > LocalType;
// 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;
+ typedef MessageValue1< Node, uint32_t > LocalType;
// 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 );
typedef MessageValue1< Node, ClippingMode::Type > LocalType;
// 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 );
typedef MessageValue1< Node, bool > LocalType;
// 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 );
// Template specialisation for OwnerPointer<Node>, because delete is protected
template <>
-void OwnerPointer<Dali::Internal::SceneGraph::Node>::Reset();
-
+inline void OwnerPointer<Dali::Internal::SceneGraph::Node>::Reset()
+{
+ if (mObject != NULL)
+ {
+ Dali::Internal::SceneGraph::Node::Delete(mObject);
+ mObject = NULL;
+ }
+}
} // namespace Internal
// Template specialisations for OwnerContainer<Node*>, because delete is protected
template <>
-void OwnerContainer<Dali::Internal::SceneGraph::Node*>::Delete( Dali::Internal::SceneGraph::Node* pointer );
-
+inline void OwnerContainer<Dali::Internal::SceneGraph::Node*>::Delete( Dali::Internal::SceneGraph::Node* pointer )
+{
+ Dali::Internal::SceneGraph::Node::Delete(pointer);
+}
} // namespace Dali
#endif // DALI_INTERNAL_SCENE_GRAPH_NODE_H