X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fupdate%2Fnodes%2Fnode.cpp;h=48feb8dcf221e2118245fc24bcf8de69b01cbbb2;hb=7cf931b2a8ab40cc1f673bc319e4cae5d801ce40;hp=633ded9b394b642acf955ce40648d0001a356eb0;hpb=09a4ac29b536cd57fc8c25ae586021acfce69c08;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/update/nodes/node.cpp b/dali/internal/update/nodes/node.cpp old mode 100644 new mode 100755 index 633ded9..48feb8d --- a/dali/internal/update/nodes/node.cpp +++ b/dali/internal/update/nodes/node.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -27,8 +27,19 @@ 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 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 @@ -43,12 +54,31 @@ namespace SceneGraph const PositionInheritanceMode Node::DEFAULT_POSITION_INHERITANCE_MODE( INHERIT_PARENT_POSITION ); const ColorMode Node::DEFAULT_COLOR_MODE( USE_OWN_MULTIPLY_PARENT_ALPHA ); -Node* Node::New() + +Node* Node::New( unsigned int id ) { - return new ( gNodeMemoryPool.AllocateRawThreadSafe() ) Node(); + return new ( gNodeMemoryPool.AllocateRawThreadSafe() ) Node( id ); +} + +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() +Node::Node( unsigned int id ) : mTransformManager( NULL ), mTransformId( INVALID_TRANSFORM_ID ), mParentOrigin( TRANSFORM_PROPERTY_PARENT_ORIGIN ), @@ -65,20 +95,29 @@ Node::Node() mWorldMatrix(), mWorldColor( Color::WHITE ), mClippingSortModifier( 0u ), + mId( id ), mParent( NULL ), 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() @@ -87,11 +126,10 @@ Node::~Node() { mTransformManager->RemoveTransform(mTransformId); } -} -void Node::operator delete( void* ptr ) -{ - gNodeMemoryPool.FreeThreadSafe( static_cast( ptr ) ); +#ifdef DEBUG_ENABLED + gNodeCount--; +#endif } void Node::OnDestroy() @@ -119,6 +157,9 @@ void Node::CreateTransform( SceneGraph::TransformManager* transformManager ) 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) @@ -128,7 +169,7 @@ void Node::SetRoot(bool isRoot) mIsRoot = isRoot; } -void Node::AddUniformMapping( UniformPropertyMapping* map ) +void Node::AddUniformMapping( OwnerPointer< UniformPropertyMapping >& map ) { PropertyOwner::AddUniformMapping( map ); mRegenerateUniformMap = 2; @@ -270,11 +311,8 @@ int Node::GetDirtyFlags() const return flags; } -void Node::ResetDefaultProperties( BufferIndex updateBufferIndex ) +void Node::ResetDirtyFlags( BufferIndex updateBufferIndex ) { - mVisible.ResetToBaseValue( updateBufferIndex ); - mColor.ResetToBaseValue( updateBufferIndex ); - mDirtyFlags = NothingFlag; }