namespace //Unnamed namespace
{
-//Memory pool used to allocate new nodes. Memory used by this pool will be released when shutting down DALi
+//Memory pool used to allocate new nodes. Memory used by this pool will be released when process dies
+// or DALI library is unloaded
Dali::Internal::MemoryPoolObjectAllocator<Dali::Internal::SceneGraph::Node> gNodeMemoryPool;
}
const PositionInheritanceMode Node::DEFAULT_POSITION_INHERITANCE_MODE( INHERIT_PARENT_POSITION );
const ColorMode Node::DEFAULT_COLOR_MODE( USE_OWN_MULTIPLY_PARENT_ALPHA );
+
Node* Node::New()
{
return new ( gNodeMemoryPool.AllocateRawThreadSafe() ) Node();
}
+void Node::Delete( Node* node )
+{
+ // check we have a node not a layer
+ if( !node->mIsLayer )
+ {
+ // Manually call the destructor
+ node->~Node();
+
+ // Mark the memory it used as free in the memory pool
+ gNodeMemoryPool.FreeThreadSafe( node );
+ }
+ else
+ {
+ // not in the pool, just delete it.
+ delete node;
+ }
+}
+
Node::Node()
: mTransformManager(0),
mTransformId( INVALID_TRANSFORM_ID ),
mParentOrigin( TRANSFORM_PROPERTY_PARENT_ORIGIN ),
mAnchorPoint( TRANSFORM_PROPERTY_ANCHOR_POINT ),
- mSize(TRANSFORM_PROPERTY_SIZE), // zero initialized by default
- mPosition(TRANSFORM_PROPERTY_POSITION), // zero initialized by default
- mOrientation(), // initialized to identity by default
+ mSize( TRANSFORM_PROPERTY_SIZE ), // Zero initialized by default
+ mPosition( TRANSFORM_PROPERTY_POSITION ), // Zero initialized by default
+ mOrientation(), // Initialized to identity by default
mScale( TRANSFORM_PROPERTY_SCALE ),
mVisible( true ),
mColor( Color::WHITE ),
- mWorldPosition(TRANSFORM_PROPERTY_WORLD_POSITION, Vector3(0.0f,0.0f,0.0f)), // zero initialized by default
- mWorldScale( TRANSFORM_PROPERTY_WORLD_SCALE, Vector3(1.0f,1.0f,1.0f) ),
- mWorldOrientation(), // initialized to identity by default
+ mWorldPosition( TRANSFORM_PROPERTY_WORLD_POSITION, Vector3( 0.0f,0.0f,0.0f ) ), // Zero initialized by default
+ mWorldScale( TRANSFORM_PROPERTY_WORLD_SCALE, Vector3( 1.0f,1.0f,1.0f ) ),
+ mWorldOrientation(), // Initialized to identity by default
mWorldMatrix(),
mWorldColor( Color::WHITE ),
+ mClippingSortModifier( 0u ),
mParent( NULL ),
mExclusiveRenderTask( NULL ),
mChildren(),
+ mClippingDepth( 0u ),
+ mDepthIndex( 0u ),
mRegenerateUniformMap( 0 ),
- mDepth(0u),
- mDirtyFlags(AllFlags),
- mIsRoot( false ),
+ mDirtyFlags( AllFlags ),
mDrawMode( DrawMode::NORMAL ),
- mColorMode( DEFAULT_COLOR_MODE )
+ mColorMode( DEFAULT_COLOR_MODE ),
+ mClippingMode( ClippingMode::DISABLED ),
+ mIsRoot( false ),
+ mIsLayer( false )
{
mUniformMapChanged[0] = 0u;
mUniformMapChanged[1] = 0u;
}
}
-void Node::operator delete( void* ptr )
-{
- gNodeMemoryPool.FreeThreadSafe( static_cast<Node*>( ptr ) );
-}
-
void Node::OnDestroy()
{
// Animators, Constraints etc. should be disconnected from the child's properties.
DALI_ASSERT_ALWAYS(mParent == NULL);
mParent = &parentNode;
- mDepth = mParent->GetDepth() + 1u;
if( mTransformId != INVALID_TRANSFORM_ID )
{
// Remove back-pointer to parent
mParent = NULL;
- mDepth = 0u;
// Remove all child pointers
mChildren.Clear();
} // namespace SceneGraph
+template <>
+void OwnerPointer<Dali::Internal::SceneGraph::Node>::Reset()
+{
+ if( mObject != NULL )
+ {
+ Dali::Internal::SceneGraph::Node::Delete( mObject );
+ mObject = NULL;
+ }
+}
+
} // namespace Internal
+template <>
+void OwnerContainer<Dali::Internal::SceneGraph::Node*>::Delete(Dali::Internal::SceneGraph::Node* pointer)
+{
+ Dali::Internal::SceneGraph::Node::Delete( pointer );
+}
+
} // namespace Dali