X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fupdate%2Fnodes%2Fnode.cpp;h=47318971e72569121bcd9d218bd8d647e728f313;hb=a17c4357f76f24d334fccde990de4daebf43e164;hp=0a7dc5a17dfd5cc3fa815bfa466e5be8053726d0;hpb=679e2ae09e17cd5daf74b4309d6ea5cbb7051d1b;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 0a7dc5a..4731897 --- 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. @@ -22,14 +22,24 @@ #include #include #include -#include #include #include 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 @@ -44,43 +54,69 @@ 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() { 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 ), 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 ), - mGeometryBatcher( NULL ), - mBatchIndex( BATCH_NULL_HANDLE ), - mIsBatchParent( false ), + mClippingSortModifier( 0u ), mParent( NULL ), - mBatchParent( NULL ), mExclusiveRenderTask( NULL ), mChildren(), + mClippingDepth( 0u ), + mScissorDepth( 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 ), + mPositionUsesAnchorPoint( true ) { mUniformMapChanged[0] = 0u; mUniformMapChanged[1] = 0u; + +#ifdef DEBUG_ENABLED + gNodeCount++; +#endif + } Node::~Node() @@ -89,11 +125,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() @@ -121,6 +156,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) @@ -130,7 +168,7 @@ void Node::SetRoot(bool isRoot) mIsRoot = isRoot; } -void Node::AddUniformMapping( UniformPropertyMapping* map ) +void Node::AddUniformMapping( OwnerPointer< UniformPropertyMapping >& map ) { PropertyOwner::AddUniformMapping( map ); mRegenerateUniformMap = 2; @@ -218,31 +256,25 @@ void Node::DisconnectChild( BufferIndex updateBufferIndex, Node& childNode ) void Node::AddRenderer( Renderer* renderer ) { - //Check that it has not been already added + // Check that it has not been already added. unsigned int rendererCount( mRenderer.Size() ); - for( unsigned int i(0); imBatchingEnabled ) - { - mGeometryBatcher->AddNode( this ); - } } void Node::RemoveRenderer( Renderer* renderer ) @@ -278,11 +310,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; } @@ -293,7 +322,6 @@ void Node::SetParent( Node& parentNode ) DALI_ASSERT_ALWAYS(mParent == NULL); mParent = &parentNode; - mDepth = mParent->GetDepth() + 1u; if( mTransformId != INVALID_TRANSFORM_ID ) { @@ -301,29 +329,6 @@ void Node::SetParent( Node& parentNode ) } } -void Node::SetBatchParent( Node* batchParentNode ) -{ - DALI_ASSERT_ALWAYS(!mIsRoot); - mBatchParent = batchParentNode; -} - -void Node::SetIsBatchParent( bool enabled ) -{ - if( mIsBatchParent != enabled ) - { - mIsBatchParent = enabled; - - if( enabled ) - { - mGeometryBatcher->AddBatchParent( this ); - } - else - { - mGeometryBatcher->RemoveBatchParent( this ); - } - } -} - void Node::RecursiveDisconnectFromSceneGraph( BufferIndex updateBufferIndex ) { DALI_ASSERT_ALWAYS(!mIsRoot); @@ -340,7 +345,6 @@ void Node::RecursiveDisconnectFromSceneGraph( BufferIndex updateBufferIndex ) // Remove back-pointer to parent mParent = NULL; - mDepth = 0u; // Remove all child pointers mChildren.Clear();