/*
- * Copyright (c) 2016 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.
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;
+#ifdef DEBUG_ENABLED
+// keep track of nodes created / deleted, to ensure we have 0 when the process exits or DALi library is unloaded
+int gNodeCount =0;
+
+// Called when the process is about to exit, Node count should be zero at this point.
+void __attribute__ ((destructor)) ShutDown(void)
+{
+DALI_ASSERT_DEBUG( (gNodeCount == 0) && "Node memory leak");
+}
+#endif
}
namespace Dali
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( NULL ),
mTransformId( INVALID_TRANSFORM_ID ),
mExclusiveRenderTask( NULL ),
mChildren(),
mClippingDepth( 0u ),
+ mScissorDepth( 0u ),
mDepthIndex( 0u ),
mRegenerateUniformMap( 0 ),
mDirtyFlags( AllFlags ),
mDrawMode( DrawMode::NORMAL ),
mColorMode( DEFAULT_COLOR_MODE ),
mClippingMode( ClippingMode::DISABLED ),
- mIsRoot( false )
+ mIsRoot( false ),
+ mIsLayer( false ),
+ mPositionUsesAnchorPoint( true )
{
mUniformMapChanged[0] = 0u;
mUniformMapChanged[1] = 0u;
+
+#ifdef DEBUG_ENABLED
+ gNodeCount++;
+#endif
+
}
Node::~Node()
{
mTransformManager->RemoveTransform(mTransformId);
}
-}
-void Node::operator delete( void* ptr )
-{
- gNodeMemoryPool.FreeThreadSafe( static_cast<Node*>( ptr ) );
+#ifdef DEBUG_ENABLED
+ gNodeCount--;
+#endif
}
void Node::OnDestroy()
mWorldScale.Initialize( transformManager, mTransformId );
mWorldOrientation.Initialize( transformManager, mTransformId );
mWorldMatrix.Initialize( transformManager, mTransformId );
+
+ //Set whether the position should use the anchor point
+ transformManager->SetPositionUsesAnchorPoint( mTransformId, mPositionUsesAnchorPoint );
}
void Node::SetRoot(bool isRoot)
mIsRoot = isRoot;
}
-void Node::AddUniformMapping( UniformPropertyMapping* map )
+void Node::AddUniformMapping( OwnerPointer< UniformPropertyMapping >& map )
{
PropertyOwner::AddUniformMapping( map );
mRegenerateUniformMap = 2;
return flags;
}
-void Node::ResetDefaultProperties( BufferIndex updateBufferIndex )
+void Node::ResetDirtyFlags( BufferIndex updateBufferIndex )
{
- mVisible.ResetToBaseValue( updateBufferIndex );
- mColor.ResetToBaseValue( updateBufferIndex );
-
mDirtyFlags = NothingFlag;
}