Remove some unreachable and duplicate code from Actor-impl.cpp by making mNode a... 61/192261/4
authorKimmo Hoikka <kimmo.hoikka@samsung.com>
Thu, 1 Nov 2018 17:40:30 +0000 (17:40 +0000)
committerKimmo Hoikka <kimmo.hoikka@samsung.com>
Tue, 6 Nov 2018 10:12:56 +0000 (10:12 +0000)
Alternative approach to: https://review.tizen.org/gerrit/#/c/192259/

Change-Id: Ia2546ce82f766bc25e265a8fa77b7ef0e0be5657

12 files changed:
dali/internal/event/actors/actor-impl.cpp
dali/internal/event/actors/actor-impl.h
dali/internal/event/actors/camera-actor-impl.cpp
dali/internal/event/actors/camera-actor-impl.h
dali/internal/event/actors/custom-actor-internal.cpp
dali/internal/event/actors/custom-actor-internal.h
dali/internal/event/actors/layer-impl.cpp
dali/internal/event/actors/layer-impl.h
dali/internal/update/nodes/node.cpp
dali/internal/update/nodes/node.h
dali/internal/update/nodes/scene-graph-layer.cpp
dali/internal/update/nodes/scene-graph-layer.h

index 7effe7c..37baa3b 100644 (file)
@@ -68,8 +68,6 @@ namespace Dali
 namespace Internal
 {
 
-uint32_t Actor::mActorCounter = 0;
-
 namespace
 {
 /// Using a function because of library initialisation order. Vector3::ONE may not have been initialised yet.
@@ -408,7 +406,8 @@ void EmitVisibilityChangedSignalRecursively( ActorPtr actor, bool visible, Devel
 
 ActorPtr Actor::New()
 {
-  ActorPtr actor( new Actor( BASIC ) );
+  // pass a reference to actor, actor does not own its node
+  ActorPtr actor( new Actor( BASIC, *CreateNode() ) );
 
   // Second-phase construction
   actor->Initialize();
@@ -416,6 +415,16 @@ ActorPtr Actor::New()
   return actor;
 }
 
+const SceneGraph::Node* Actor::CreateNode()
+{
+  // create node. Nodes are owned by the update manager
+  SceneGraph::Node* node = SceneGraph::Node::New();
+  OwnerPointer< SceneGraph::Node > transferOwnership( node );
+  AddNodeMessage( Stage::GetCurrent()->GetUpdateManager(), transferOwnership );
+
+  return node;
+}
+
 const std::string& Actor::GetName() const
 {
   return mName;
@@ -425,16 +434,13 @@ void Actor::SetName( const std::string& name )
 {
   mName = name;
 
-  if( NULL != mNode )
-  {
-    // ATTENTION: string for debug purposes is not thread safe.
-    DALI_LOG_SET_OBJECT_STRING( const_cast< SceneGraph::Node* >( mNode ), name );
-  }
+  // ATTENTION: string for debug purposes is not thread safe.
+  DALI_LOG_SET_OBJECT_STRING( const_cast< SceneGraph::Node* >( &mNode ), name );
 }
 
 uint32_t Actor::GetId() const
 {
-  return mId;
+  return mNode.GetId();
 }
 
 bool Actor::OnStage() const
@@ -609,7 +615,7 @@ ActorPtr Actor::FindChildByName( const std::string& actorName )
 ActorPtr Actor::FindChildById( const uint32_t id )
 {
   ActorPtr child = 0;
-  if( id == mId )
+  if( id == GetId() )
   {
     child = this;
   }
@@ -631,11 +637,8 @@ ActorPtr Actor::FindChildById( const uint32_t id )
 
 void Actor::SetParentOrigin( const Vector3& origin )
 {
-  if( NULL != mNode )
-  {
-    // mNode is being used in a separate thread; queue a message to set the value & base value
-    SetParentOriginMessage( GetEventThreadServices(), *mNode, origin );
-  }
+  // mNode is being used in a separate thread; queue a message to set the value & base value
+  SetParentOriginMessage( GetEventThreadServices(), mNode, origin );
 
   // Cache for event-thread access
   if( !mParentOrigin )
@@ -682,11 +685,8 @@ const Vector3& Actor::GetCurrentParentOrigin() const
 
 void Actor::SetAnchorPoint( const Vector3& anchor )
 {
-  if( NULL != mNode )
-  {
-    // mNode is being used in a separate thread; queue a message to set the value & base value
-    SetAnchorPointMessage( GetEventThreadServices(), *mNode, anchor );
-  }
+  // mNode is being used in a separate thread; queue a message to set the value & base value
+  SetAnchorPointMessage( GetEventThreadServices(), mNode, anchor );
 
   // Cache for event-thread access
   if( !mAnchorPoint )
@@ -745,66 +745,46 @@ void Actor::SetPosition( const Vector3& position )
 {
   mTargetPosition = position;
 
-  if( NULL != mNode )
-  {
-    // mNode is being used in a separate thread; queue a message to set the value & base value
-    SceneGraph::NodeTransformPropertyMessage<Vector3>::Send( GetEventThreadServices(), mNode, &mNode->mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::Bake, position );
-  }
+  // mNode is being used in a separate thread; queue a message to set the value & base value
+  SceneGraph::NodeTransformPropertyMessage<Vector3>::Send( GetEventThreadServices(), &mNode, &mNode.mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::Bake, position );
 }
 
 void Actor::SetX( float x )
 {
   mTargetPosition.x = x;
 
-  if( NULL != mNode )
-  {
-    // mNode is being used in a separate thread; queue a message to set the value & base value
-    SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), mNode, &mNode->mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeX, x );
-  }
+  // mNode is being used in a separate thread; queue a message to set the value & base value
+  SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), &mNode, &mNode.mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeX, x );
 }
 
 void Actor::SetY( float y )
 {
   mTargetPosition.y = y;
 
-  if( NULL != mNode )
-  {
-    // mNode is being used in a separate thread; queue a message to set the value & base value
-    SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), mNode, &mNode->mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeY, y );
-  }
+  // mNode is being used in a separate thread; queue a message to set the value & base value
+  SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), &mNode, &mNode.mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeY, y );
 }
 
 void Actor::SetZ( float z )
 {
   mTargetPosition.z = z;
 
-  if( NULL != mNode )
-  {
-    // mNode is being used in a separate thread; queue a message to set the value & base value
-    SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), mNode, &mNode->mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeZ, z );
-  }
+  // mNode is being used in a separate thread; queue a message to set the value & base value
+  SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), &mNode, &mNode.mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeZ, z );
 }
 
 void Actor::TranslateBy( const Vector3& distance )
 {
   mTargetPosition += distance;
 
-  if( NULL != mNode )
-  {
-    // mNode is being used in a separate thread; queue a message to set the value & base value
-    SceneGraph::NodeTransformPropertyMessage<Vector3>::Send( GetEventThreadServices(), mNode, &mNode->mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeRelative, distance );
-  }
+  // mNode is being used in a separate thread; queue a message to set the value & base value
+  SceneGraph::NodeTransformPropertyMessage<Vector3>::Send( GetEventThreadServices(), &mNode, &mNode.mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeRelative, distance );
 }
 
 const Vector3& Actor::GetCurrentPosition() const
 {
-  if( NULL != mNode )
-  {
-    // mNode is being used in a separate thread; copy the value from the previous update
-    return mNode->GetPosition(GetEventThreadServices().GetEventBufferIndex());
-  }
-
-  return Vector3::ZERO;
+  // mNode is being used in a separate thread; copy the value from the previous update
+  return mNode.GetPosition(GetEventThreadServices().GetEventBufferIndex());
 }
 
 const Vector3& Actor::GetTargetPosition() const
@@ -814,22 +794,17 @@ const Vector3& Actor::GetTargetPosition() const
 
 const Vector3& Actor::GetCurrentWorldPosition() const
 {
-  if( NULL != mNode )
-  {
-    // mNode is being used in a separate thread; copy the value from the previous update
-    return mNode->GetWorldPosition( GetEventThreadServices().GetEventBufferIndex() );
-  }
-
-  return Vector3::ZERO;
+  // mNode is being used in a separate thread; copy the value from the previous update
+  return mNode.GetWorldPosition( GetEventThreadServices().GetEventBufferIndex() );
 }
 
 const Vector2 Actor::GetCurrentScreenPosition() const
 {
   StagePtr stage = Stage::GetCurrent();
-  if( stage && OnStage() && NULL != mNode )
+  if( stage && OnStage() )
   {
-    Vector3 worldPosition =  mNode->GetWorldPosition( GetEventThreadServices().GetEventBufferIndex() );
-    Vector3 cameraPosition = stage->GetDefaultCameraActor().mNode->GetWorldPosition( GetEventThreadServices().GetEventBufferIndex() );
+    Vector3 worldPosition =  mNode.GetWorldPosition( GetEventThreadServices().GetEventBufferIndex() );
+    Vector3 cameraPosition = stage->GetDefaultCameraActor().mNode.GetWorldPosition( GetEventThreadServices().GetEventBufferIndex() );
     worldPosition -= cameraPosition;
 
     Vector3 actorSize = GetCurrentSize() * GetCurrentWorldScale();
@@ -848,11 +823,8 @@ void Actor::SetPositionInheritanceMode( PositionInheritanceMode mode )
 {
   // this flag is not animatable so keep the value
   mPositionInheritanceMode = mode;
-  if( NULL != mNode )
-  {
-    // mNode is being used in a separate thread; queue a message to set the value
-    SetInheritPositionMessage( GetEventThreadServices(), *mNode, mode == INHERIT_PARENT_POSITION );
-  }
+  // mNode is being used in a separate thread; queue a message to set the value
+  SetInheritPositionMessage( GetEventThreadServices(), mNode, mode == INHERIT_PARENT_POSITION );
 }
 
 PositionInheritanceMode Actor::GetPositionInheritanceMode() const
@@ -863,11 +835,11 @@ PositionInheritanceMode Actor::GetPositionInheritanceMode() const
 
 void Actor::SetInheritPosition( bool inherit )
 {
-  if( mInheritPosition != inherit && NULL != mNode )
+  if( mInheritPosition != inherit )
   {
     // non animateable so keep local copy
     mInheritPosition = inherit;
-    SetInheritPositionMessage( GetEventThreadServices(), *mNode, inherit );
+    SetInheritPositionMessage( GetEventThreadServices(), mNode, inherit );
   }
 }
 
@@ -890,11 +862,8 @@ void Actor::SetOrientation( const Quaternion& orientation )
 {
   mTargetOrientation = orientation;
 
-  if( NULL != mNode )
-  {
-    // mNode is being used in a separate thread; queue a message to set the value & base value
-    SceneGraph::NodeTransformPropertyMessage<Quaternion>::Send( GetEventThreadServices(), mNode, &mNode->mOrientation, &SceneGraph::TransformManagerPropertyHandler<Quaternion>::Bake, orientation );
-  }
+  // mNode is being used in a separate thread; queue a message to set the value & base value
+  SceneGraph::NodeTransformPropertyMessage<Quaternion>::Send( GetEventThreadServices(), &mNode, &mNode.mOrientation, &SceneGraph::TransformManagerPropertyHandler<Quaternion>::Bake, orientation );
 }
 
 void Actor::RotateBy( const Radian& angle, const Vector3& axis )
@@ -906,33 +875,20 @@ void Actor::RotateBy( const Quaternion& relativeRotation )
 {
   mTargetOrientation *= Quaternion( relativeRotation );
 
-  if( NULL != mNode )
-  {
-    // mNode is being used in a separate thread; queue a message to set the value & base value
-    SceneGraph::NodeTransformPropertyMessage<Quaternion>::Send( GetEventThreadServices(), mNode, &mNode->mOrientation, &SceneGraph::TransformManagerPropertyHandler<Quaternion>::BakeRelative, relativeRotation );
-  }
+  // mNode is being used in a separate thread; queue a message to set the value & base value
+  SceneGraph::NodeTransformPropertyMessage<Quaternion>::Send( GetEventThreadServices(), &mNode, &mNode.mOrientation, &SceneGraph::TransformManagerPropertyHandler<Quaternion>::BakeRelative, relativeRotation );
 }
 
 const Quaternion& Actor::GetCurrentOrientation() const
 {
-  if( NULL != mNode )
-  {
-    // mNode is being used in a separate thread; copy the value from the previous update
-    return mNode->GetOrientation(GetEventThreadServices().GetEventBufferIndex());
-  }
-
-  return Quaternion::IDENTITY;
+  // mNode is being used in a separate thread; copy the value from the previous update
+  return mNode.GetOrientation(GetEventThreadServices().GetEventBufferIndex());
 }
 
 const Quaternion& Actor::GetCurrentWorldOrientation() const
 {
-  if( NULL != mNode )
-  {
-    // mNode is being used in a separate thread; copy the value from the previous update
-    return mNode->GetWorldOrientation( GetEventThreadServices().GetEventBufferIndex() );
-  }
-
-  return Quaternion::IDENTITY;
+  // mNode is being used in a separate thread; copy the value from the previous update
+  return mNode.GetWorldOrientation( GetEventThreadServices().GetEventBufferIndex() );
 }
 
 void Actor::SetScale( float scale )
@@ -949,88 +905,62 @@ void Actor::SetScale( const Vector3& scale )
 {
   mTargetScale = scale;
 
-  if( NULL != mNode )
-  {
-    // mNode is being used in a separate thread; queue a message to set the value & base value
-    SceneGraph::NodeTransformPropertyMessage<Vector3>::Send( GetEventThreadServices(), mNode, &mNode->mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::Bake, scale );
-  }
+  // mNode is being used in a separate thread; queue a message to set the value & base value
+  SceneGraph::NodeTransformPropertyMessage<Vector3>::Send( GetEventThreadServices(), &mNode, &mNode.mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::Bake, scale );
 }
 
 void Actor::SetScaleX( float x )
 {
   mTargetScale.x = x;
 
-  if( NULL != mNode )
-  {
-    // mNode is being used in a separate thread; queue a message to set the value & base value
-    SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), mNode, &mNode->mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeX, x );
-  }
+  // mNode is being used in a separate thread; queue a message to set the value & base value
+  SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), &mNode, &mNode.mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeX, x );
 }
 
 void Actor::SetScaleY( float y )
 {
   mTargetScale.y = y;
 
-  if( NULL != mNode )
-  {
-    // mNode is being used in a separate thread; queue a message to set the value & base value
-    SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), mNode, &mNode->mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeY, y );
-  }
+  // mNode is being used in a separate thread; queue a message to set the value & base value
+  SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), &mNode, &mNode.mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeY, y );
 }
 
 void Actor::SetScaleZ( float z )
 {
   mTargetScale.z = z;
 
-  if( NULL != mNode )
-  {
-    // mNode is being used in a separate thread; queue a message to set the value & base value
-    SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), mNode, &mNode->mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeZ, z );
-  }
+  // mNode is being used in a separate thread; queue a message to set the value & base value
+  SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), &mNode, &mNode.mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeZ, z );
 }
 
 void Actor::ScaleBy(const Vector3& relativeScale)
 {
   mTargetScale *= relativeScale;
 
-  if( NULL != mNode )
-  {
-    // mNode is being used in a separate thread; queue a message to set the value & base value
-    SceneGraph::NodeTransformPropertyMessage<Vector3>::Send( GetEventThreadServices(), mNode, &mNode->mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeRelativeMultiply, relativeScale );
-  }
+  // mNode is being used in a separate thread; queue a message to set the value & base value
+  SceneGraph::NodeTransformPropertyMessage<Vector3>::Send( GetEventThreadServices(), &mNode, &mNode.mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeRelativeMultiply, relativeScale );
 }
 
 const Vector3& Actor::GetCurrentScale() const
 {
-  if( NULL != mNode )
-  {
-    // mNode is being used in a separate thread; copy the value from the previous update
-    return mNode->GetScale(GetEventThreadServices().GetEventBufferIndex());
-  }
-
-  return Vector3::ONE;
+  // mNode is being used in a separate thread; copy the value from the previous update
+  return mNode.GetScale(GetEventThreadServices().GetEventBufferIndex());
 }
 
 const Vector3& Actor::GetCurrentWorldScale() const
 {
-  if( NULL != mNode )
-  {
-    // mNode is being used in a separate thread; copy the value from the previous update
-    return mNode->GetWorldScale( GetEventThreadServices().GetEventBufferIndex() );
-  }
-
-  return Vector3::ONE;
+  // mNode is being used in a separate thread; copy the value from the previous update
+  return mNode.GetWorldScale( GetEventThreadServices().GetEventBufferIndex() );
 }
 
 void Actor::SetInheritScale( bool inherit )
 {
-
-  if( mInheritScale != inherit && NULL != mNode )
+  if( mInheritScale != inherit )
   {
     // non animateable so keep local copy
     mInheritScale = inherit;
     // mNode is being used in a separate thread; queue a message to set the value
-    SetInheritScaleMessage( GetEventThreadServices(), *mNode, inherit );
+    SetInheritScaleMessage( GetEventThreadServices(), mNode, inherit );
   }
 }
 
@@ -1041,12 +971,7 @@ bool Actor::IsScaleInherited() const
 
 Matrix Actor::GetCurrentWorldMatrix() const
 {
-  if( NULL != mNode )
-  {
-    return mNode->GetWorldMatrix(0);
-  }
-
-  return Matrix::IDENTITY;
+  return mNode.GetWorldMatrix(0);
 }
 
 void Actor::SetVisible( bool visible )
@@ -1056,35 +981,22 @@ void Actor::SetVisible( bool visible )
 
 bool Actor::IsVisible() const
 {
-  if( NULL != mNode )
-  {
-    // mNode is being used in a separate thread; copy the value from the previous update
-    return mNode->IsVisible( GetEventThreadServices().GetEventBufferIndex() );
-  }
-
-  return true;
+  // mNode is being used in a separate thread; copy the value from the previous update
+  return mNode.IsVisible( GetEventThreadServices().GetEventBufferIndex() );
 }
 
 void Actor::SetOpacity( float opacity )
 {
   mTargetColor.a = opacity;
 
-  if( NULL != mNode )
-  {
-    // mNode is being used in a separate thread; queue a message to set the value & base value
-    SceneGraph::NodePropertyComponentMessage<Vector4>::Send( GetEventThreadServices(), mNode, &mNode->mColor, &AnimatableProperty<Vector4>::BakeW, opacity );
-  }
+  // mNode is being used in a separate thread; queue a message to set the value & base value
+  SceneGraph::NodePropertyComponentMessage<Vector4>::Send( GetEventThreadServices(), &mNode, &mNode.mColor, &AnimatableProperty<Vector4>::BakeW, opacity );
 }
 
 float Actor::GetCurrentOpacity() const
 {
-  if( NULL != mNode )
-  {
-    // mNode is being used in a separate thread; copy the value from the previous update
-    return mNode->GetOpacity(GetEventThreadServices().GetEventBufferIndex());
-  }
-
-  return 1.0f;
+  // mNode is being used in a separate thread; copy the value from the previous update
+  return mNode.GetOpacity(GetEventThreadServices().GetEventBufferIndex());
 }
 
 ClippingMode::Type Actor::GetClippingMode() const
@@ -1099,77 +1011,55 @@ uint32_t Actor::GetSortingDepth()
 
 const Vector4& Actor::GetCurrentWorldColor() const
 {
-  if( NULL != mNode )
-  {
-    return mNode->GetWorldColor( GetEventThreadServices().GetEventBufferIndex() );
-  }
-
-  return Color::WHITE;
+  return mNode.GetWorldColor( GetEventThreadServices().GetEventBufferIndex() );
 }
 
 void Actor::SetColor( const Vector4& color )
 {
   mTargetColor = color;
 
-  if( NULL != mNode )
-  {
-    // mNode is being used in a separate thread; queue a message to set the value & base value
-    SceneGraph::NodePropertyMessage<Vector4>::Send( GetEventThreadServices(), mNode, &mNode->mColor, &AnimatableProperty<Vector4>::Bake, color );
-  }
+  // mNode is being used in a separate thread; queue a message to set the value & base value
+  SceneGraph::NodePropertyMessage<Vector4>::Send( GetEventThreadServices(), &mNode, &mNode.mColor, &AnimatableProperty<Vector4>::Bake, color );
 }
 
 void Actor::SetColorRed( float red )
 {
   mTargetColor.r = red;
 
-  if( NULL != mNode )
-  {
-    // mNode is being used in a separate thread; queue a message to set the value & base value
-    SceneGraph::NodePropertyComponentMessage<Vector4>::Send( GetEventThreadServices(), mNode, &mNode->mColor, &AnimatableProperty<Vector4>::BakeX, red );
-  }
+  // mNode is being used in a separate thread; queue a message to set the value & base value
+  SceneGraph::NodePropertyComponentMessage<Vector4>::Send( GetEventThreadServices(), &mNode, &mNode.mColor, &AnimatableProperty<Vector4>::BakeX, red );
 }
 
 void Actor::SetColorGreen( float green )
 {
   mTargetColor.g = green;
 
-  if( NULL != mNode )
-  {
-    // mNode is being used in a separate thread; queue a message to set the value & base value
-    SceneGraph::NodePropertyComponentMessage<Vector4>::Send( GetEventThreadServices(), mNode, &mNode->mColor, &AnimatableProperty<Vector4>::BakeY, green );
-  }
+  // mNode is being used in a separate thread; queue a message to set the value & base value
+  SceneGraph::NodePropertyComponentMessage<Vector4>::Send( GetEventThreadServices(), &mNode, &mNode.mColor, &AnimatableProperty<Vector4>::BakeY, green );
 }
 
 void Actor::SetColorBlue( float blue )
 {
   mTargetColor.b = blue;
 
-  if( NULL != mNode )
-  {
-    // mNode is being used in a separate thread; queue a message to set the value & base value
-    SceneGraph::NodePropertyComponentMessage<Vector4>::Send( GetEventThreadServices(), mNode, &mNode->mColor, &AnimatableProperty<Vector4>::BakeZ, blue );
-  }
+  // mNode is being used in a separate thread; queue a message to set the value & base value
+  SceneGraph::NodePropertyComponentMessage<Vector4>::Send( GetEventThreadServices(), &mNode, &mNode.mColor, &AnimatableProperty<Vector4>::BakeZ, blue );
 }
 
 const Vector4& Actor::GetCurrentColor() const
 {
-  if( NULL != mNode )
-  {
-    // mNode is being used in a separate thread; copy the value from the previous update
-    return mNode->GetColor(GetEventThreadServices().GetEventBufferIndex());
-  }
-
-  return Color::WHITE;
+  // mNode is being used in a separate thread; copy the value from the previous update
+  return mNode.GetColor(GetEventThreadServices().GetEventBufferIndex());
 }
 
 void Actor::SetInheritOrientation( bool inherit )
 {
-  if( mInheritOrientation != inherit && NULL != mNode)
+  if( mInheritOrientation != inherit )
   {
     // non animateable so keep local copy
     mInheritOrientation = inherit;
     // mNode is being used in a separate thread; queue a message to set the value
-    SetInheritOrientationMessage( GetEventThreadServices(), *mNode, inherit );
+    SetInheritOrientationMessage( GetEventThreadServices(), mNode, inherit );
   }
 }
 
@@ -1199,11 +1089,8 @@ void Actor::SetColorMode( ColorMode colorMode )
 {
   // non animateable so keep local copy
   mColorMode = colorMode;
-  if( NULL != mNode )
-  {
-    // mNode is being used in a separate thread; queue a message to set the value
-    SetColorModeMessage( GetEventThreadServices(), *mNode, colorMode );
-  }
+  // mNode is being used in a separate thread; queue a message to set the value
+  SetColorModeMessage( GetEventThreadServices(), mNode, colorMode );
 }
 
 ColorMode Actor::GetColorMode() const
@@ -1250,15 +1137,14 @@ void Actor::SetSizeInternal( const Vector3& size )
   // dont allow recursive loop
   DALI_ASSERT_ALWAYS( !mInsideOnSizeSet && "Cannot call SetSize from OnSizeSet" );
   // check that we have a node AND the new size width, height or depth is at least a little bit different from the old one
-  if( ( NULL != mNode )&&
-      ( ( fabsf( mTargetSize.width - size.width  ) > Math::MACHINE_EPSILON_1 )||
-        ( fabsf( mTargetSize.height- size.height ) > Math::MACHINE_EPSILON_1 )||
-        ( fabsf( mTargetSize.depth - size.depth  ) > Math::MACHINE_EPSILON_1 ) ) )
+  if( ( fabsf( mTargetSize.width - size.width  ) > Math::MACHINE_EPSILON_1 )||
+      ( fabsf( mTargetSize.height- size.height ) > Math::MACHINE_EPSILON_1 )||
+      ( fabsf( mTargetSize.depth - size.depth  ) > Math::MACHINE_EPSILON_1 ) )
   {
     mTargetSize = size;
 
     // mNode is being used in a separate thread; queue a message to set the value & base value
-    SceneGraph::NodeTransformPropertyMessage<Vector3>::Send( GetEventThreadServices(), mNode, &mNode->mSize, &SceneGraph::TransformManagerPropertyHandler<Vector3>::Bake, mTargetSize );
+    SceneGraph::NodeTransformPropertyMessage<Vector3>::Send( GetEventThreadServices(), &mNode, &mNode.mSize, &SceneGraph::TransformManagerPropertyHandler<Vector3>::Bake, mTargetSize );
 
     // Notification for derived classes
     mInsideOnSizeSet = true;
@@ -1284,11 +1170,8 @@ void Actor::SetWidth( float width )
   {
     mTargetSize.width = width;
 
-    if( NULL != mNode )
-    {
-      // mNode is being used in a separate thread; queue a message to set the value & base value
-      SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), mNode, &mNode->mSize, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeX, width );
-    }
+    // mNode is being used in a separate thread; queue a message to set the value & base value
+    SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), &mNode, &mNode.mSize, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeX, width );
   }
 
   RelayoutRequest();
@@ -1305,11 +1188,8 @@ void Actor::SetHeight( float height )
   {
     mTargetSize.height = height;
 
-    if( NULL != mNode )
-    {
-      // mNode is being used in a separate thread; queue a message to set the value & base value
-      SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), mNode, &mNode->mSize, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeY, height );
-    }
+    // mNode is being used in a separate thread; queue a message to set the value & base value
+    SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), &mNode, &mNode.mSize, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeY, height );
   }
 
   RelayoutRequest();
@@ -1319,11 +1199,8 @@ void Actor::SetDepth( float depth )
 {
   mTargetSize.depth = depth;
 
-  if( NULL != mNode )
-  {
-    // mNode is being used in a separate thread; queue a message to set the value & base value
-    SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), mNode, &mNode->mSize, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeZ, depth );
-  }
+  // mNode is being used in a separate thread; queue a message to set the value & base value
+  SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), &mNode, &mNode.mSize, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeZ, depth );
 }
 
 Vector3 Actor::GetTargetSize() const
@@ -1345,13 +1222,8 @@ Vector3 Actor::GetTargetSize() const
 
 const Vector3& Actor::GetCurrentSize() const
 {
-  if( NULL != mNode )
-  {
-    // mNode is being used in a separate thread; copy the value from the previous update
-    return mNode->GetSize( GetEventThreadServices().GetEventBufferIndex() );
-  }
-
-  return Vector3::ZERO;
+  // mNode is being used in a separate thread; copy the value from the previous update
+  return mNode.GetSize( GetEventThreadServices().GetEventBufferIndex() );
 }
 
 Vector3 Actor::GetNaturalSize() const
@@ -1574,7 +1446,7 @@ uint32_t Actor::AddRenderer( Renderer& renderer )
   uint32_t index = static_cast<uint32_t>( mRenderers->size() ); //  4,294,967,295 renderers per actor
   RendererPtr rendererPtr = RendererPtr( &renderer );
   mRenderers->push_back( rendererPtr );
-  AddRendererMessage( GetEventThreadServices(), *mNode, renderer.GetRendererSceneObject() );
+  AddRendererMessage( GetEventThreadServices(), mNode, renderer.GetRendererSceneObject() );
   return index;
 }
 
@@ -1610,7 +1482,7 @@ void Actor::RemoveRenderer( Renderer& renderer )
       if( (*iter).Get() == &renderer )
       {
         mRenderers->erase( iter );
-        RemoveRendererMessage( GetEventThreadServices(), *mNode, renderer.GetRendererSceneObject() );
+        RemoveRendererMessage( GetEventThreadServices(), mNode, renderer.GetRendererSceneObject() );
         break;
       }
     }
@@ -1622,7 +1494,7 @@ void Actor::RemoveRenderer( uint32_t index )
   if( index < GetRendererCount() )
   {
     RendererPtr renderer = ( *mRenderers )[ index ];
-    RemoveRendererMessage( GetEventThreadServices(), *mNode, renderer.Get()->GetRendererSceneObject() );
+    RemoveRendererMessage( GetEventThreadServices(), mNode, renderer.Get()->GetRendererSceneObject() );
     mRenderers->erase( mRenderers->begin()+index );
   }
 }
@@ -1636,10 +1508,10 @@ void Actor::SetDrawMode( DrawMode::Type drawMode )
 {
   // this flag is not animatable so keep the value
   mDrawMode = drawMode;
-  if( ( NULL != mNode ) && ( drawMode != DrawMode::STENCIL ) )
+  if( drawMode != DrawMode::STENCIL )
   {
     // mNode is being used in a separate thread; queue a message to set the value
-    SetDrawModeMessage( GetEventThreadServices(), *mNode, drawMode );
+    SetDrawModeMessage( GetEventThreadServices(), mNode, drawMode );
   }
 }
 
@@ -1698,7 +1570,7 @@ bool Actor::ScreenToLocal( const RenderTask& renderTask, float& localX, float& l
 
 bool Actor::ScreenToLocal( const Matrix& viewMatrix, const Matrix& projectionMatrix, const Viewport& viewport, float& localX, float& localY, float screenX, float screenY ) const
 {
-  // Early-out if mNode is NULL
+  // Early-out if not on stage
   if( !OnStage() )
   {
     return false;
@@ -1706,7 +1578,7 @@ bool Actor::ScreenToLocal( const Matrix& viewMatrix, const Matrix& projectionMat
 
   // Get the ModelView matrix
   Matrix modelView;
-  Matrix::Multiply( modelView, mNode->GetWorldMatrix(0), viewMatrix );
+  Matrix::Multiply( modelView, mNode.GetWorldMatrix(0), viewMatrix );
 
   // Calculate the inverted ModelViewProjection matrix; this will be used for 2 unprojects
   Matrix invertedMvp( false/*don't init*/);
@@ -1809,8 +1681,8 @@ bool Actor::RaySphereTest( const Vector4& rayOrigin, const Vector4& rayDir ) con
    C = o dot o - r^2
    */
 
-  // Early out if mNode is NULL
-  if( !mNode )
+  // Early-out if not on stage
+  if( !OnStage() )
   {
     return false;
   }
@@ -1818,14 +1690,14 @@ bool Actor::RaySphereTest( const Vector4& rayOrigin, const Vector4& rayDir ) con
   BufferIndex bufferIndex( GetEventThreadServices().GetEventBufferIndex() );
 
   // Transforms the ray to the local reference system. As the test is against a sphere, only the translation and scale are needed.
-  const Vector3& translation( mNode->GetWorldPosition( bufferIndex ) );
+  const Vector3& translation( mNode.GetWorldPosition( bufferIndex ) );
   Vector3 rayOriginLocal( rayOrigin.x - translation.x, rayOrigin.y - translation.y, rayOrigin.z - translation.z );
 
   // Compute the radius is not needed, square radius it's enough.
-  const Vector3& size( mNode->GetSize( bufferIndex ) );
+  const Vector3& size( mNode.GetSize( bufferIndex ) );
 
   // Scale the sphere.
-  const Vector3& scale( mNode->GetWorldScale( bufferIndex ) );
+  const Vector3& scale( mNode.GetWorldScale( bufferIndex ) );
 
   const float width = size.width * scale.width;
   const float height = size.height * scale.height;
@@ -1843,14 +1715,14 @@ bool Actor::RayActorTest( const Vector4& rayOrigin, const Vector4& rayDir, Vecto
 {
   bool hit = false;
 
-  if( OnStage() && NULL != mNode )
+  if( OnStage() )
   {
     // Transforms the ray to the local reference system.
     // Calculate the inverse of Model matrix
     Matrix invModelMatrix( false/*don't init*/);
 
     BufferIndex bufferIndex( GetEventThreadServices().GetEventBufferIndex() );
-    invModelMatrix = mNode->GetWorldMatrix(0);
+    invModelMatrix = mNode.GetWorldMatrix(0);
     invModelMatrix.Invert();
 
     Vector4 rayOriginLocal( invModelMatrix * rayOrigin );
@@ -1866,7 +1738,7 @@ bool Actor::RayActorTest( const Vector4& rayOrigin, const Vector4& rayDir, Vecto
       // Ray travels distance * rayDirLocal to intersect with plane.
       distance = a / b;
 
-      const Vector3& size = mNode->GetSize( bufferIndex );
+      const Vector3& size = mNode.GetSize( bufferIndex );
 
       hitPointLocal.x = rayOriginLocal.x + rayDirLocal.x * distance + size.x * 0.5f;
       hitPointLocal.y = rayOriginLocal.y + rayDirLocal.y * distance + size.y * 0.5f;
@@ -2152,11 +2024,11 @@ bool Actor::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tra
   return connected;
 }
 
-Actor::Actor( DerivedType derivedType )
+Actor::Actor( DerivedType derivedType, const SceneGraph::Node& node )
 : mParent( NULL ),
   mChildren( NULL ),
   mRenderers( NULL ),
-  mNode( NULL ),
+  mNode( node ),
   mParentOrigin( NULL ),
   mAnchorPoint( NULL ),
   mRelayoutData( NULL ),
@@ -2179,7 +2051,6 @@ Actor::Actor( DerivedType derivedType )
   mTargetPosition( Vector3::ZERO ),
   mTargetScale( Vector3::ONE ),
   mName(),
-  mId( ++mActorCounter ), // actor ID is initialised to start from 1, and 0 is reserved
   mSortedDepth( 0u ),
   mDepth( 0u ),
   mIsRoot( ROOT_LAYER == derivedType ),
@@ -2209,11 +2080,6 @@ Actor::Actor( DerivedType derivedType )
 
 void Actor::Initialize()
 {
-  // Node creation, keep raw-pointer to Node for messaging
-  mNode = CreateNode();
-  OwnerPointer< SceneGraph::Node > transferOwnership( const_cast< SceneGraph::Node* >( mNode ) );
-  AddNodeMessage( GetEventThreadServices().GetUpdateManager(), transferOwnership );
-
   OnInitialize();
 
   GetEventThreadServices().RegisterObject( this );
@@ -2237,11 +2103,7 @@ Actor::~Actor()
   // Guard to allow handle destruction after Core has been destroyed
   if( EventThreadServices::IsCoreRunning() )
   {
-    if( NULL != mNode )
-    {
-      DestroyNodeMessage( GetEventThreadServices().GetUpdateManager(), *mNode );
-      mNode = NULL; // Node is about to be destroyed
-    }
+    DestroyNodeMessage( GetEventThreadServices().GetUpdateManager(), mNode );
 
     GetEventThreadServices().UnregisterObject( this );
   }
@@ -2254,10 +2116,7 @@ Actor::~Actor()
   delete mAnchorPoint;
 
   // Delete optional relayout data
-  if( mRelayoutData )
-  {
-    delete mRelayoutData;
-  }
+  delete mRelayoutData;
 }
 
 void Actor::ConnectToStage( uint32_t parentDepth )
@@ -2319,13 +2178,10 @@ void Actor::RecursiveConnectToStage( ActorContainer& connectionList, uint32_t de
  */
 void Actor::ConnectToSceneGraph()
 {
-  DALI_ASSERT_DEBUG( mNode != NULL); DALI_ASSERT_DEBUG( mParent != NULL); DALI_ASSERT_DEBUG( mParent->mNode != NULL );
+  DALI_ASSERT_DEBUG( mParent != NULL);
 
-  if( NULL != mNode )
-  {
-    // Reparent Node in next Update
-    ConnectNodeMessage( GetEventThreadServices().GetUpdateManager(), *(mParent->mNode), *mNode );
-  }
+  // Reparent Node in next Update
+  ConnectNodeMessage( GetEventThreadServices().GetUpdateManager(), mParent->mNode, mNode );
 
   // Request relayout on all actors that are added to the scenegraph
   RelayoutRequest();
@@ -2443,9 +2299,9 @@ bool Actor::IsNodeConnected() const
 {
   bool connected( false );
 
-  if( OnStage() && ( NULL != mNode ) )
+  if( OnStage() )
   {
-    if( IsRoot() || mNode->GetParent() )
+    if( IsRoot() || mNode.GetParent() )
     {
       connected = true;
     }
@@ -2478,7 +2334,7 @@ void Actor::RebuildDepthTree()
 void Actor::DepthTraverseActorTree( OwnerPointer<SceneGraph::NodeDepths>& sceneGraphNodeDepths, int32_t& depthIndex )
 {
   mSortedDepth = depthIndex * DevelLayer::SIBLING_ORDER_MULTIPLIER;
-  sceneGraphNodeDepths->Add( const_cast<SceneGraph::Node*>( mNode ), mSortedDepth );
+  sceneGraphNodeDepths->Add( const_cast<SceneGraph::Node*>( &mNode ), mSortedDepth );
 
   // Create/add to children of this node
   if( mChildren )
@@ -2852,10 +2708,7 @@ void Actor::SetDefaultProperty( Property::Index index, const Property::Value& pr
       if( Scripting::GetEnumerationProperty< ClippingMode::Type >( property, CLIPPING_MODE_TABLE, CLIPPING_MODE_TABLE_COUNT, convertedValue ) )
       {
         mClippingMode = convertedValue;
-        if( NULL != mNode )
-        {
-          SetClippingModeMessage( GetEventThreadServices(), *mNode, mClippingMode );
-        }
+        SetClippingModeMessage( GetEventThreadServices(), mNode, mClippingMode );
       }
       break;
     }
@@ -2866,10 +2719,7 @@ void Actor::SetDefaultProperty( Property::Index index, const Property::Value& pr
       if( property.Get( value ) && value != mPositionUsesAnchorPoint )
       {
         mPositionUsesAnchorPoint = value;
-        if( NULL != mNode )
-        {
-          SetPositionUsesAnchorPointMessage( GetEventThreadServices(), *mNode, mPositionUsesAnchorPoint );
-        }
+        SetPositionUsesAnchorPointMessage( GetEventThreadServices(), mNode, mPositionUsesAnchorPoint );
       }
       break;
     }
@@ -2915,7 +2765,7 @@ void Actor::SetSceneGraphProperty( Property::Index index, const PropertyMetadata
       DALI_ASSERT_DEBUG( NULL != property );
 
       // property is being used in a separate thread; queue a message to set the property
-      SceneGraph::NodePropertyMessage<bool>::Send( GetEventThreadServices(), mNode, property, &AnimatableProperty<bool>::Bake, value.Get<bool>() );
+      SceneGraph::NodePropertyMessage<bool>::Send( GetEventThreadServices(), &mNode, property, &AnimatableProperty<bool>::Bake, value.Get<bool>() );
 
       break;
     }
@@ -2926,7 +2776,7 @@ void Actor::SetSceneGraphProperty( Property::Index index, const PropertyMetadata
       DALI_ASSERT_DEBUG( NULL != property );
 
       // property is being used in a separate thread; queue a message to set the property
-      SceneGraph::NodePropertyMessage<int>::Send( GetEventThreadServices(), mNode, property, &AnimatableProperty<int>::Bake, value.Get<int>() );
+      SceneGraph::NodePropertyMessage<int>::Send( GetEventThreadServices(), &mNode, property, &AnimatableProperty<int>::Bake, value.Get<int>() );
 
       break;
     }
@@ -2937,7 +2787,7 @@ void Actor::SetSceneGraphProperty( Property::Index index, const PropertyMetadata
       DALI_ASSERT_DEBUG( NULL != property );
 
       // property is being used in a separate thread; queue a message to set the property
-      SceneGraph::NodePropertyMessage<float>::Send( GetEventThreadServices(), mNode, property, &AnimatableProperty<float>::Bake, value.Get<float>() );
+      SceneGraph::NodePropertyMessage<float>::Send( GetEventThreadServices(), &mNode, property, &AnimatableProperty<float>::Bake, value.Get<float>() );
 
       break;
     }
@@ -2950,15 +2800,15 @@ void Actor::SetSceneGraphProperty( Property::Index index, const PropertyMetadata
       // property is being used in a separate thread; queue a message to set the property
       if(entry.componentIndex == 0)
       {
-        SceneGraph::NodePropertyComponentMessage<Vector2>::Send( GetEventThreadServices(), mNode, property, &AnimatableProperty<Vector2>::BakeX, value.Get<float>() );
+        SceneGraph::NodePropertyComponentMessage<Vector2>::Send( GetEventThreadServices(), &mNode, property, &AnimatableProperty<Vector2>::BakeX, value.Get<float>() );
       }
       else if(entry.componentIndex == 1)
       {
-        SceneGraph::NodePropertyComponentMessage<Vector2>::Send( GetEventThreadServices(), mNode, property, &AnimatableProperty<Vector2>::BakeY, value.Get<float>() );
+        SceneGraph::NodePropertyComponentMessage<Vector2>::Send( GetEventThreadServices(), &mNode, property, &AnimatableProperty<Vector2>::BakeY, value.Get<float>() );
       }
       else
       {
-        SceneGraph::NodePropertyMessage<Vector2>::Send( GetEventThreadServices(), mNode, property, &AnimatableProperty<Vector2>::Bake, value.Get<Vector2>() );
+        SceneGraph::NodePropertyMessage<Vector2>::Send( GetEventThreadServices(), &mNode, property, &AnimatableProperty<Vector2>::Bake, value.Get<Vector2>() );
       }
 
       break;
@@ -2972,19 +2822,19 @@ void Actor::SetSceneGraphProperty( Property::Index index, const PropertyMetadata
       // property is being used in a separate thread; queue a message to set the property
       if(entry.componentIndex == 0)
       {
-        SceneGraph::NodePropertyComponentMessage<Vector3>::Send( GetEventThreadServices(), mNode, property, &AnimatableProperty<Vector3>::BakeX, value.Get<float>() );
+        SceneGraph::NodePropertyComponentMessage<Vector3>::Send( GetEventThreadServices(), &mNode, property, &AnimatableProperty<Vector3>::BakeX, value.Get<float>() );
       }
       else if(entry.componentIndex == 1)
       {
-        SceneGraph::NodePropertyComponentMessage<Vector3>::Send( GetEventThreadServices(), mNode, property, &AnimatableProperty<Vector3>::BakeY, value.Get<float>() );
+        SceneGraph::NodePropertyComponentMessage<Vector3>::Send( GetEventThreadServices(), &mNode, property, &AnimatableProperty<Vector3>::BakeY, value.Get<float>() );
       }
       else if(entry.componentIndex == 2)
       {
-        SceneGraph::NodePropertyComponentMessage<Vector3>::Send( GetEventThreadServices(), mNode, property, &AnimatableProperty<Vector3>::BakeZ, value.Get<float>() );
+        SceneGraph::NodePropertyComponentMessage<Vector3>::Send( GetEventThreadServices(), &mNode, property, &AnimatableProperty<Vector3>::BakeZ, value.Get<float>() );
       }
       else
       {
-        SceneGraph::NodePropertyMessage<Vector3>::Send( GetEventThreadServices(), mNode, property, &AnimatableProperty<Vector3>::Bake, value.Get<Vector3>() );
+        SceneGraph::NodePropertyMessage<Vector3>::Send( GetEventThreadServices(), &mNode, property, &AnimatableProperty<Vector3>::Bake, value.Get<Vector3>() );
       }
 
       break;
@@ -2998,23 +2848,23 @@ void Actor::SetSceneGraphProperty( Property::Index index, const PropertyMetadata
       // property is being used in a separate thread; queue a message to set the property
       if(entry.componentIndex == 0)
       {
-        SceneGraph::NodePropertyComponentMessage<Vector4>::Send( GetEventThreadServices(), mNode, property, &AnimatableProperty<Vector4>::BakeX, value.Get<float>() );
+        SceneGraph::NodePropertyComponentMessage<Vector4>::Send( GetEventThreadServices(), &mNode, property, &AnimatableProperty<Vector4>::BakeX, value.Get<float>() );
       }
       else if(entry.componentIndex == 1)
       {
-        SceneGraph::NodePropertyComponentMessage<Vector4>::Send( GetEventThreadServices(), mNode, property, &AnimatableProperty<Vector4>::BakeY, value.Get<float>() );
+        SceneGraph::NodePropertyComponentMessage<Vector4>::Send( GetEventThreadServices(), &mNode, property, &AnimatableProperty<Vector4>::BakeY, value.Get<float>() );
       }
       else if(entry.componentIndex == 2)
       {
-        SceneGraph::NodePropertyComponentMessage<Vector4>::Send( GetEventThreadServices(), mNode, property, &AnimatableProperty<Vector4>::BakeZ, value.Get<float>() );
+        SceneGraph::NodePropertyComponentMessage<Vector4>::Send( GetEventThreadServices(), &mNode, property, &AnimatableProperty<Vector4>::BakeZ, value.Get<float>() );
       }
       else if(entry.componentIndex == 3)
       {
-        SceneGraph::NodePropertyComponentMessage<Vector4>::Send( GetEventThreadServices(), mNode, property, &AnimatableProperty<Vector4>::BakeW, value.Get<float>() );
+        SceneGraph::NodePropertyComponentMessage<Vector4>::Send( GetEventThreadServices(), &mNode, property, &AnimatableProperty<Vector4>::BakeW, value.Get<float>() );
       }
       else
       {
-        SceneGraph::NodePropertyMessage<Vector4>::Send( GetEventThreadServices(), mNode, property, &AnimatableProperty<Vector4>::Bake, value.Get<Vector4>() );
+        SceneGraph::NodePropertyMessage<Vector4>::Send( GetEventThreadServices(), &mNode, property, &AnimatableProperty<Vector4>::Bake, value.Get<Vector4>() );
       }
 
       break;
@@ -3026,7 +2876,7 @@ void Actor::SetSceneGraphProperty( Property::Index index, const PropertyMetadata
       DALI_ASSERT_DEBUG( NULL != property );
 
       // property is being used in a separate thread; queue a message to set the property
-      SceneGraph::NodePropertyMessage<Quaternion>::Send( GetEventThreadServices(), mNode, property,&AnimatableProperty<Quaternion>::Bake,  value.Get<Quaternion>() );
+      SceneGraph::NodePropertyMessage<Quaternion>::Send( GetEventThreadServices(), &mNode, property,&AnimatableProperty<Quaternion>::Bake,  value.Get<Quaternion>() );
 
       break;
     }
@@ -3037,7 +2887,7 @@ void Actor::SetSceneGraphProperty( Property::Index index, const PropertyMetadata
       DALI_ASSERT_DEBUG( NULL != property );
 
       // property is being used in a separate thread; queue a message to set the property
-      SceneGraph::NodePropertyMessage<Matrix>::Send( GetEventThreadServices(), mNode, property,&AnimatableProperty<Matrix>::Bake,  value.Get<Matrix>() );
+      SceneGraph::NodePropertyMessage<Matrix>::Send( GetEventThreadServices(), &mNode, property,&AnimatableProperty<Matrix>::Bake,  value.Get<Matrix>() );
 
       break;
     }
@@ -3048,7 +2898,7 @@ void Actor::SetSceneGraphProperty( Property::Index index, const PropertyMetadata
       DALI_ASSERT_DEBUG( NULL != property );
 
       // property is being used in a separate thread; queue a message to set the property
-      SceneGraph::NodePropertyMessage<Matrix3>::Send( GetEventThreadServices(), mNode, property,&AnimatableProperty<Matrix3>::Bake,  value.Get<Matrix3>() );
+      SceneGraph::NodePropertyMessage<Matrix3>::Send( GetEventThreadServices(), &mNode, property,&AnimatableProperty<Matrix3>::Bake,  value.Get<Matrix3>() );
 
       break;
     }
@@ -3392,13 +3242,13 @@ void Actor::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::In
 
 const SceneGraph::PropertyOwner* Actor::GetPropertyOwner() const
 {
-  return mNode;
+  return &mNode;
 }
 
 const SceneGraph::PropertyOwner* Actor::GetSceneObject() const
 {
   // This method should only return an object connected to the scene-graph
-  return OnStage() ? mNode : NULL;
+  return OnStage() ? &mNode : NULL;
 }
 
 const PropertyBase* Actor::GetSceneObjectAnimatableProperty( Property::Index index ) const
@@ -3428,89 +3278,58 @@ const PropertyBase* Actor::GetSceneObjectAnimatableProperty( Property::Index ind
 
     property = custom->GetSceneGraphProperty();
   }
-  else if( NULL != mNode )
+  else
   {
     switch( index )
     {
-      case Dali::Actor::Property::SIZE:
-        property = &mNode->mSize;
-        break;
-
-      case Dali::Actor::Property::SIZE_WIDTH:
-        property = &mNode->mSize;
-        break;
-
-      case Dali::Actor::Property::SIZE_HEIGHT:
-        property = &mNode->mSize;
-        break;
-
+      case Dali::Actor::Property::SIZE:        // FALLTHROUGH
+      case Dali::Actor::Property::SIZE_WIDTH:  // FALLTHROUGH
+      case Dali::Actor::Property::SIZE_HEIGHT: // FALLTHROUGH
       case Dali::Actor::Property::SIZE_DEPTH:
-        property = &mNode->mSize;
-        break;
-
-      case Dali::Actor::Property::POSITION:
-        property = &mNode->mPosition;
-        break;
-
-      case Dali::Actor::Property::POSITION_X:
-        property = &mNode->mPosition;
-        break;
-
-      case Dali::Actor::Property::POSITION_Y:
-        property = &mNode->mPosition;
+      {
+        property = &mNode.mSize;
         break;
-
+      }
+      case Dali::Actor::Property::POSITION:   // FALLTHROUGH
+      case Dali::Actor::Property::POSITION_X: // FALLTHROUGH
+      case Dali::Actor::Property::POSITION_Y: // FALLTHROUGH
       case Dali::Actor::Property::POSITION_Z:
-        property = &mNode->mPosition;
+      {
+        property = &mNode.mPosition;
         break;
-
+      }
       case Dali::Actor::Property::ORIENTATION:
-        property = &mNode->mOrientation;
-        break;
-
-      case Dali::Actor::Property::SCALE:
-        property = &mNode->mScale;
-        break;
-
-      case Dali::Actor::Property::SCALE_X:
-        property = &mNode->mScale;
-        break;
-
-      case Dali::Actor::Property::SCALE_Y:
-        property = &mNode->mScale;
+      {
+        property = &mNode.mOrientation;
         break;
-
+      }
+      case Dali::Actor::Property::SCALE:   // FALLTHROUGH
+      case Dali::Actor::Property::SCALE_X: // FALLTHROUGH
+      case Dali::Actor::Property::SCALE_Y: // FALLTHROUGH
       case Dali::Actor::Property::SCALE_Z:
-        property = &mNode->mScale;
+      {
+        property = &mNode.mScale;
         break;
-
+      }
       case Dali::Actor::Property::VISIBLE:
-        property = &mNode->mVisible;
-        break;
-
-      case Dali::Actor::Property::COLOR:
-        property = &mNode->mColor;
-        break;
-
-      case Dali::Actor::Property::COLOR_RED:
-        property = &mNode->mColor;
-        break;
-
-      case Dali::Actor::Property::COLOR_GREEN:
-        property = &mNode->mColor;
-        break;
-
-      case Dali::Actor::Property::COLOR_BLUE:
-        property = &mNode->mColor;
+      {
+        property = &mNode.mVisible;
         break;
-
-      case Dali::Actor::Property::COLOR_ALPHA:
+      }
+      case Dali::Actor::Property::COLOR:       // FALLTHROUGH
+      case Dali::Actor::Property::COLOR_RED:   // FALLTHROUGH
+      case Dali::Actor::Property::COLOR_GREEN: // FALLTHROUGH
+      case Dali::Actor::Property::COLOR_BLUE:  // FALLTHROUGH
+      case Dali::Actor::Property::COLOR_ALPHA: // FALLTHROUGH
       case Dali::DevelActor::Property::OPACITY:
-        property = &mNode->mColor;
+      {
+        property = &mNode.mColor;
         break;
-
+      }
       default:
+      {
         break;
+      }
     }
   }
 
@@ -3541,159 +3360,107 @@ const PropertyInputImpl* Actor::GetSceneObjectInputProperty( Property::Index ind
     DALI_ASSERT_ALWAYS( custom && "Property index is invalid" );
     property = custom->GetSceneGraphProperty();
   }
-  else if( NULL != mNode )
+  else
   {
     switch( index )
     {
-      case Dali::Actor::Property::PARENT_ORIGIN:
-        property = &mNode->mParentOrigin;
-        break;
-
-      case Dali::Actor::Property::PARENT_ORIGIN_X:
-        property = &mNode->mParentOrigin;
-        break;
-
-      case Dali::Actor::Property::PARENT_ORIGIN_Y:
-        property = &mNode->mParentOrigin;
-        break;
-
+      case Dali::Actor::Property::PARENT_ORIGIN:   // FALLTHROUGH
+      case Dali::Actor::Property::PARENT_ORIGIN_X: // FALLTHROUGH
+      case Dali::Actor::Property::PARENT_ORIGIN_Y: // FALLTHROUGH
       case Dali::Actor::Property::PARENT_ORIGIN_Z:
-        property = &mNode->mParentOrigin;
-        break;
-
-      case Dali::Actor::Property::ANCHOR_POINT:
-        property = &mNode->mAnchorPoint;
-        break;
-
-      case Dali::Actor::Property::ANCHOR_POINT_X:
-        property = &mNode->mAnchorPoint;
-        break;
-
-      case Dali::Actor::Property::ANCHOR_POINT_Y:
-        property = &mNode->mAnchorPoint;
+      {
+        property = &mNode.mParentOrigin;
         break;
-
+      }
+      case Dali::Actor::Property::ANCHOR_POINT:   // FALLTHROUGH
+      case Dali::Actor::Property::ANCHOR_POINT_X: // FALLTHROUGH
+      case Dali::Actor::Property::ANCHOR_POINT_Y: // FALLTHROUGH
       case Dali::Actor::Property::ANCHOR_POINT_Z:
-        property = &mNode->mAnchorPoint;
-        break;
-
-      case Dali::Actor::Property::SIZE:
-        property = &mNode->mSize;
-        break;
-
-      case Dali::Actor::Property::SIZE_WIDTH:
-        property = &mNode->mSize;
-        break;
-
-      case Dali::Actor::Property::SIZE_HEIGHT:
-        property = &mNode->mSize;
+      {
+        property = &mNode.mAnchorPoint;
         break;
-
+      }
+      case Dali::Actor::Property::SIZE:        // FALLTHROUGH
+      case Dali::Actor::Property::SIZE_WIDTH:  // FALLTHROUGH
+      case Dali::Actor::Property::SIZE_HEIGHT: // FALLTHROUGH
       case Dali::Actor::Property::SIZE_DEPTH:
-        property = &mNode->mSize;
-        break;
-
-      case Dali::Actor::Property::POSITION:
-        property = &mNode->mPosition;
-        break;
-
-      case Dali::Actor::Property::POSITION_X:
-        property = &mNode->mPosition;
-        break;
-
-      case Dali::Actor::Property::POSITION_Y:
-        property = &mNode->mPosition;
+      {
+        property = &mNode.mSize;
         break;
-
+      }
+      case Dali::Actor::Property::POSITION:   // FALLTHROUGH
+      case Dali::Actor::Property::POSITION_X: // FALLTHROUGH
+      case Dali::Actor::Property::POSITION_Y: // FALLTHROUGH
       case Dali::Actor::Property::POSITION_Z:
-        property = &mNode->mPosition;
-        break;
-
-      case Dali::Actor::Property::WORLD_POSITION:
-        property = &mNode->mWorldPosition;
-        break;
-
-      case Dali::Actor::Property::WORLD_POSITION_X:
-        property = &mNode->mWorldPosition;
-        break;
-
-      case Dali::Actor::Property::WORLD_POSITION_Y:
-        property = &mNode->mWorldPosition;
+      {
+        property = &mNode.mPosition;
         break;
-
+      }
+      case Dali::Actor::Property::WORLD_POSITION:   // FALLTHROUGH
+      case Dali::Actor::Property::WORLD_POSITION_X: // FALLTHROUGH
+      case Dali::Actor::Property::WORLD_POSITION_Y: // FALLTHROUGH
       case Dali::Actor::Property::WORLD_POSITION_Z:
-        property = &mNode->mWorldPosition;
+      {
+        property = &mNode.mWorldPosition;
         break;
-
+      }
       case Dali::Actor::Property::ORIENTATION:
-        property = &mNode->mOrientation;
+      {
+        property = &mNode.mOrientation;
         break;
-
+      }
       case Dali::Actor::Property::WORLD_ORIENTATION:
-        property = &mNode->mWorldOrientation;
-        break;
-
-      case Dali::Actor::Property::SCALE:
-        property = &mNode->mScale;
-        break;
-
-      case Dali::Actor::Property::SCALE_X:
-        property = &mNode->mScale;
-        break;
-
-      case Dali::Actor::Property::SCALE_Y:
-        property = &mNode->mScale;
+      {
+        property = &mNode.mWorldOrientation;
         break;
-
+      }
+      case Dali::Actor::Property::SCALE:   // FALLTHROUGH
+      case Dali::Actor::Property::SCALE_X: // FALLTHROUGH
+      case Dali::Actor::Property::SCALE_Y: // FALLTHROUGH
       case Dali::Actor::Property::SCALE_Z:
-        property = &mNode->mScale;
+      {
+        property = &mNode.mScale;
         break;
-
+      }
       case Dali::Actor::Property::WORLD_SCALE:
-        property = &mNode->mWorldScale;
+      {
+        property = &mNode.mWorldScale;
         break;
-
+      }
       case Dali::Actor::Property::VISIBLE:
-        property = &mNode->mVisible;
-        break;
-
-      case Dali::Actor::Property::COLOR:
-        property = &mNode->mColor;
-        break;
-
-      case Dali::Actor::Property::COLOR_RED:
-        property = &mNode->mColor;
-        break;
-
-      case Dali::Actor::Property::COLOR_GREEN:
-        property = &mNode->mColor;
-        break;
-
-      case Dali::Actor::Property::COLOR_BLUE:
-        property = &mNode->mColor;
+      {
+        property = &mNode.mVisible;
         break;
-
-      case Dali::Actor::Property::COLOR_ALPHA:
+      }
+      case Dali::Actor::Property::COLOR:       // FALLTHROUGH
+      case Dali::Actor::Property::COLOR_RED:   // FALLTHROUGH
+      case Dali::Actor::Property::COLOR_GREEN: // FALLTHROUGH
+      case Dali::Actor::Property::COLOR_BLUE:  // FALLTHROUGH
+      case Dali::Actor::Property::COLOR_ALPHA: // FALLTHROUGH
       case Dali::DevelActor::Property::OPACITY:
       {
-        property = &mNode->mColor;
+        property = &mNode.mColor;
         break;
       }
-
       case Dali::Actor::Property::WORLD_COLOR:
-        property = &mNode->mWorldColor;
+      {
+        property = &mNode.mWorldColor;
         break;
-
+      }
       case Dali::Actor::Property::WORLD_MATRIX:
-        property = &mNode->mWorldMatrix;
+      {
+        property = &mNode.mWorldMatrix;
         break;
-
+      }
       case Dali::DevelActor::Property::CULLED:
-        property = &mNode->mCulled;
+      {
+        property = &mNode.mCulled;
         break;
-
+      }
       default:
+      {
         break;
+      }
     }
   }
 
@@ -3798,13 +3565,8 @@ void Actor::SetParent( Actor* parent )
     if ( EventThreadServices::IsCoreRunning() && // Don't emit signals or send messages during Core destruction
          OnStage() )
     {
-      DALI_ASSERT_ALWAYS( mNode != NULL );
-
-      if( NULL != mNode )
-      {
-        // Disconnect the Node & its children from the scene-graph.
-        DisconnectNodeMessage( GetEventThreadServices().GetUpdateManager(), *mNode );
-      }
+      // Disconnect the Node & its children from the scene-graph.
+      DisconnectNodeMessage( GetEventThreadServices().GetUpdateManager(), mNode );
 
       // Instruct each actor to discard pointers to the scene-graph
       DisconnectFromStage();
@@ -3812,11 +3574,6 @@ void Actor::SetParent( Actor* parent )
   }
 }
 
-SceneGraph::Node* Actor::CreateNode() const
-{
-  return Node::New( mId );
-}
-
 bool Actor::DoAction( BaseObject* object, const std::string& actionName, const Property::Map& /* attributes */ )
 {
   bool done = false;
@@ -4336,7 +4093,7 @@ bool Actor::GetCurrentPropertyValue( Property::Index index, Property::Value& val
 
     case DevelActor::Property::CULLED:
     {
-      value = mNode->IsCulled( GetEventThreadServices().GetEventBufferIndex() );
+      value = mNode.IsCulled( GetEventThreadServices().GetEventBufferIndex() );
       break;
     }
 
@@ -5098,10 +4855,10 @@ void Actor::SetVisibleInternal( bool visible, SendMessage::Type sendMessage )
 {
   if( mVisible != visible )
   {
-    if( sendMessage == SendMessage::TRUE && NULL != mNode )
+    if( sendMessage == SendMessage::TRUE )
     {
       // mNode is being used in a separate thread; queue a message to set the value & base value
-      SceneGraph::NodePropertyMessage<bool>::Send( GetEventThreadServices(), mNode, &mNode->mVisible, &AnimatableProperty<bool>::Bake, visible );
+      SceneGraph::NodePropertyMessage<bool>::Send( GetEventThreadServices(), &mNode, &mNode.mVisible, &AnimatableProperty<bool>::Bake, visible );
     }
 
     mVisible = visible;
index 92e25e5..0a78f08 100755 (executable)
@@ -122,6 +122,12 @@ public:
   static ActorPtr New();
 
   /**
+   * Helper to create node for derived classes who don't have their own node type
+   * @return pointer to newly created unique node
+   */
+  static const SceneGraph::Node* CreateNode();
+
+  /**
    * Retrieve the name of the actor.
    * @return The name.
    */
@@ -1543,8 +1549,9 @@ protected:
    * Protected Constructor.  See Actor::New().
    * The second-phase construction Initialize() member should be called immediately after this.
    * @param[in] derivedType The derived type of actor (if any).
+   * @param[in] reference to the node
    */
-  Actor( DerivedType derivedType );
+  Actor( DerivedType derivedType, const SceneGraph::Node& node );
 
   /**
    * Second-phase constructor. Must be called immediately after creating a new Actor;
@@ -1685,7 +1692,7 @@ public:
    */
   const SceneGraph::Node& GetNode() const
   {
-    return *mNode;
+    return mNode;
   }
 
   /**
@@ -1730,11 +1737,9 @@ private:
   };
 
   // Remove default constructor and copy constructor
-  Actor()=delete;
-  Actor( const Actor& )=delete;
-
-  // Undefined
-  Actor& operator=( const Actor& rhs );
+  Actor() = delete;
+  Actor( const Actor& ) = delete;
+  Actor& operator=( const Actor& rhs ) = delete;
 
   /**
    * Set the actors parent.
@@ -1743,13 +1748,6 @@ private:
   void SetParent( Actor* parent );
 
   /**
-   * Helper to create a Node for this Actor.
-   * To be overriden in derived classes.
-   * @return A newly allocated node.
-   */
-  virtual SceneGraph::Node* CreateNode() const;
-
-  /**
    * For use in derived classes, called after Initialize()
    */
   virtual void OnInitialize()
@@ -1939,7 +1937,7 @@ protected:
   ActorContainer* mChildren;      ///< Container of referenced actors, lazily initialized
   RendererContainer* mRenderers;   ///< Renderer container
 
-  const SceneGraph::Node* mNode;  ///< Not owned
+  const SceneGraph::Node& mNode;  ///< Not owned
   Vector3* mParentOrigin;         ///< NULL means ParentOrigin::DEFAULT. ParentOrigin is non-animatable
   Vector3* mAnchorPoint;          ///< NULL means AnchorPoint::DEFAULT. AnchorPoint is non-animatable
 
@@ -1968,10 +1966,9 @@ protected:
   Vector3         mTargetPosition;    ///< Event-side storage for position (not a pointer as most actors will have a position)
   Vector3         mTargetScale;       ///< Event-side storage for scale
 
-  std::string     mName;      ///< Name of the actor
-  uint32_t        mId;        ///< A unique ID to identify the actor starting from 1, and 0 is reserved
-  uint32_t mSortedDepth;      ///< The sorted depth index. A combination of tree traversal and sibling order.
-  int16_t mDepth;             ///< The depth in the hierarchy of the actor. Only 32,767 levels of depth are supported
+  std::string     mName;              ///< Name of the actor
+  uint32_t        mSortedDepth;       ///< The sorted depth index. A combination of tree traversal and sibling order.
+  int16_t         mDepth;             ///< The depth in the hierarchy of the actor. Only 32,767 levels of depth are supported
 
   const bool mIsRoot                               : 1; ///< Flag to identify the root actor
   const bool mIsLayer                              : 1; ///< Flag to identify that this is a layer
@@ -1999,7 +1996,7 @@ protected:
 private:
 
   static ActorContainer mNullChildren;  ///< Empty container (shared by all actors, returned by GetChildren() const)
-  static uint32_t mActorCounter;        ///< A counter to track the actor instance creation
+
 };
 
 } // namespace Internal
index 04efae9..3383f00 100644 (file)
@@ -140,7 +140,7 @@ void BuildOrthoPickingRay( const Matrix& viewMatrix,
 
 CameraActorPtr CameraActor::New( const Size& size )
 {
-  CameraActorPtr actor( new CameraActor() );
+  CameraActorPtr actor( new CameraActor( *CreateNode() ) );
 
   // Second-phase construction
   actor->Initialize();
@@ -155,8 +155,8 @@ CameraActorPtr CameraActor::New( const Size& size )
   return actor;
 }
 
-CameraActor::CameraActor()
-: Actor( Actor::BASIC ),
+CameraActor::CameraActor( const SceneGraph::Node& node )
+: Actor( Actor::BASIC, node ),
   mSceneObject( NULL ),
   mTarget( SceneGraph::Camera::DEFAULT_TARGET_POSITION ),
   mType( SceneGraph::Camera::DEFAULT_TYPE ),
@@ -188,7 +188,7 @@ void CameraActor::OnInitialize()
   SceneGraph::Camera* sceneGraphCamera = SceneGraph::Camera::New();
 
   // Store a pointer to this camera node inside the scene-graph camera.
-  sceneGraphCamera->SetNode( mNode );
+  sceneGraphCamera->SetNode( &mNode );
 
   mSceneObject = sceneGraphCamera;
   OwnerPointer< SceneGraph::Camera > sceneGraphCameraOwner( sceneGraphCamera );
@@ -453,7 +453,7 @@ bool CameraActor::BuildPickingRay( const Vector2& screenCoordinates,
   {
     // Build a picking ray in the world reference system.
     // ray starts from the camera world position
-    rayOrigin = mNode->GetWorldMatrix(0).GetTranslation();
+    rayOrigin = mNode.GetWorldMatrix(0).GetTranslation();
     rayOrigin.w = 1.0f;
 
     // Transform the touch point from the screen coordinate system to the world coordinates system.
index 0623333..fe26f13 100644 (file)
@@ -227,8 +227,9 @@ private:
 
   /**
    * Constructor; see also CameraActor::New()
+   * @param node the scene graph node
    */
-  CameraActor();
+  CameraActor( const SceneGraph::Node& node );
 
   /**
    * A reference counted object may only be deleted by calling Unreference()
index 0ff93f9..eb6549e 100644 (file)
@@ -27,7 +27,7 @@ namespace Internal
 
 CustomActorPtr CustomActor::New(CustomActorImpl& extension)
 {
-  CustomActorPtr actor(new CustomActor(extension));
+  CustomActorPtr actor(new CustomActor( *CreateNode(), extension));
 
   // Second-phase construction
   extension.Initialize(*actor);
@@ -36,8 +36,8 @@ CustomActorPtr CustomActor::New(CustomActorImpl& extension)
   return actor;
 }
 
-CustomActor::CustomActor(CustomActorImpl& extension)
-: Actor( Actor::BASIC ),
+CustomActor::CustomActor( const SceneGraph::Node& node, CustomActorImpl& extension)
+: Actor( Actor::BASIC, node ),
   mImpl( &extension )
 {
   mDerivedRequiresTouch = extension.RequiresTouchEvents();
index 259b785..eaa9636 100644 (file)
@@ -240,17 +240,17 @@ private:
   /**
    * Private constructor; see also CustomActor::New()
    */
-  CustomActor(CustomActorImpl& extension);
+  CustomActor( const SceneGraph::Node& node, CustomActorImpl& extension );
 
-  // Undefined
-  CustomActor(const CustomActor&);
-
-  // Undefined
-  CustomActor& operator=(const CustomActor& rhs);
+  // no default or copy constructor or assignment
+  CustomActor() = delete;
+  CustomActor( const CustomActor& ) = delete;
+  CustomActor& operator=( const CustomActor& rhs ) = delete;
 
 protected:
 
   CustomActorImplPtr mImpl;
+
 };
 
 } // namespace Internal
index e3c0bea..a6bcc71 100644 (file)
@@ -84,7 +84,11 @@ TypeAction a4( mType, ACTION_LOWER_TO_BOTTOM, &Layer::DoAction );
 
 LayerPtr Layer::New()
 {
-  LayerPtr layer( new Layer( Actor::LAYER ) );
+  // create node, nodes are owned by UpdateManager
+  SceneGraph::Layer* layerNode = SceneGraph::Layer::New();
+  OwnerPointer< SceneGraph::Node > transferOwnership( layerNode );
+  AddNodeMessage( Stage::GetCurrent()->GetUpdateManager(), transferOwnership );
+  LayerPtr layer( new Layer( Actor::LAYER, *layerNode ) );
 
   // Second-phase construction
   layer->Initialize();
@@ -94,14 +98,13 @@ LayerPtr Layer::New()
 
 LayerPtr Layer::NewRoot( LayerList& layerList, UpdateManager& manager )
 {
-  LayerPtr root( new Layer( Actor::ROOT_LAYER ) );
-
-  // Second-phase construction, keep a raw pointer to the layer node.
-  SceneGraph::Layer* rootLayer = static_cast<SceneGraph::Layer*>( root->CreateNode() );
-  root->mNode = rootLayer;
+  // create node, nodes are owned by UpdateManager
+  SceneGraph::Layer* rootLayer = SceneGraph::Layer::New();
   OwnerPointer< SceneGraph::Layer > transferOwnership( rootLayer );
   InstallRootMessage( manager, transferOwnership );
 
+  LayerPtr root( new Layer( Actor::ROOT_LAYER, *rootLayer ) );
+
   // root actor is immediately considered to be on-stage
   root->mIsOnStage = true;
 
@@ -116,8 +119,8 @@ LayerPtr Layer::NewRoot( LayerList& layerList, UpdateManager& manager )
   return root;
 }
 
-Layer::Layer( Actor::DerivedType type )
-: Actor( type ),
+Layer::Layer( Actor::DerivedType type, const SceneGraph::Layer& layer )
+: Actor( type, layer ),
   mLayerList( NULL ),
   mClippingBox( 0, 0, 0, 0 ),
   mSortFunction( Layer::ZValue ),
@@ -313,11 +316,6 @@ bool Layer::IsHoverConsumed() const
   return mHoverConsumed;
 }
 
-SceneGraph::Node* Layer::CreateNode() const
-{
-  return SceneGraph::Layer::New( mId );
-}
-
 void Layer::OnStageConnectionInternal()
 {
   if ( !mIsRoot )
@@ -350,8 +348,7 @@ void Layer::OnStageDisconnectionInternal()
 
 const SceneGraph::Layer& Layer::GetSceneLayerOnStage() const
 {
-  DALI_ASSERT_DEBUG( mNode != NULL );
-  return dynamic_cast< const SceneGraph::Layer& >( *mNode );
+  return dynamic_cast< const SceneGraph::Layer& >( mNode );
 }
 
 void Layer::SetDefaultProperty( Property::Index index, const Property::Value& propertyValue )
index 92d5f7d..87f00f1 100644 (file)
@@ -232,8 +232,9 @@ protected:
   /**
    * Construct a new layer.
    * @param[in] type Either Actor::LAYER or Actor::ROOT_LAYER if this is the root actor.
+   * @param[in] layer the scene graph layer
    */
-  Layer( Actor::DerivedType type );
+  Layer( Actor::DerivedType type, const SceneGraph::Layer& layer );
 
   /**
    * A reference counted object may only be deleted by calling Unreference()
@@ -243,12 +244,6 @@ protected:
 private: // From Actor
 
   /**
-   * From Actor; create a node to represent the layer in the scene-graph.
-   * @return A newly allocated layer node.
-   */
-  virtual SceneGraph::Node* CreateNode() const;
-
-  /**
    * From Actor.
    */
   virtual void OnStageConnectionInternal();
index f5259db..813a99a 100755 (executable)
 #include <dali/public-api/common/dali-common.h>
 #include <dali/public-api/common/constants.h>
 
-namespace //Unnamed namespace
+namespace
 {
 //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
-int32_t gNodeCount =0;
+// keep track of nodes alive, to ensure we have 0 when the process exits or DALi library is unloaded
+int32_t gNodeCount = 0;
 
 // Called when the process is about to exit, Node count should be zero at this point.
 void __attribute__ ((destructor)) ShutDown(void)
@@ -40,7 +40,7 @@ void __attribute__ ((destructor)) ShutDown(void)
 DALI_ASSERT_DEBUG( (gNodeCount == 0) && "Node memory leak");
 }
 #endif
-}
+} // Unnamed namespace
 
 namespace Dali
 {
@@ -54,9 +54,11 @@ 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( uint32_t id )
+uint32_t Node::mNodeCounter = 0;        ///< A counter to provide unique node ids, up-to 4 billion
+
+Node* Node::New()
 {
-  return new ( gNodeMemoryPool.AllocateRawThreadSafe() ) Node( id );
+  return new ( gNodeMemoryPool.AllocateRawThreadSafe() ) Node;
 }
 
 void Node::Delete( Node* node )
@@ -77,7 +79,7 @@ void Node::Delete( Node* node )
   }
 }
 
-Node::Node( uint32_t id )
+Node::Node()
 : mTransformManager( NULL ),
   mTransformId( INVALID_TRANSFORM_ID ),
   mParentOrigin( TRANSFORM_PROPERTY_PARENT_ORIGIN ),
@@ -95,7 +97,7 @@ Node::Node( uint32_t id )
   mWorldMatrix(),
   mWorldColor( Color::WHITE ),
   mClippingSortModifier( 0u ),
-  mId( id ),
+  mId( ++mNodeCounter ),
   mParent( NULL ),
   mExclusiveRenderTask( NULL ),
   mChildren(),
@@ -138,6 +140,11 @@ void Node::OnDestroy()
   PropertyOwner::Destroy();
 }
 
+uint32_t Node::GetId() const
+{
+  return mId;
+}
+
 void Node::CreateTransform( SceneGraph::TransformManager* transformManager )
 {
   //Create a new transform
index 4ba53e3..8f07f4f 100755 (executable)
@@ -81,9 +81,8 @@ public:
 
   /**
    * Construct a new Node.
-   * @param[in] id The unique ID of the node
    */
-  static Node* New( uint32_t id );
+  static Node* New();
 
   /**
    * Deletes a Node.
@@ -95,6 +94,11 @@ public:
    */
   void OnDestroy();
 
+  /**
+   * @return the unique ID of the node
+   */
+  uint32_t GetId() const;
+
   // Layer interface
 
   /**
@@ -799,9 +803,8 @@ protected:
 
   /**
    * Protected constructor; See also Node::New()
-   * @param[in] id The Unique ID of the actor creating the node
    */
-  Node( uint32_t id );
+  Node();
 
   /**
    * Protected virtual destructor; See also Node::Delete( Node* )
@@ -887,6 +890,8 @@ public: // Default properties
 
 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
 
@@ -910,6 +915,7 @@ protected:
   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;
 };
index b9a65a8..04aeea8 100755 (executable)
@@ -31,15 +31,15 @@ namespace Internal
 namespace SceneGraph
 {
 
-SceneGraph::Layer* Layer::New( uint32_t id )
+SceneGraph::Layer* Layer::New()
 {
   // Layers are currently heap allocated, unlike Nodes which are in a memory pool
   // However Node::Delete( layer ) will correctly delete a layer / node depending on type
-  return new Layer( id );
+  return new Layer();
 }
 
-Layer::Layer( uint32_t id )
-: Node( id ),
+Layer::Layer()
+: Node(),
   mSortFunction( Internal::Layer::ZValue ),
   mClippingBox( 0,0,0,0 ),
   mLastCamera( NULL ),
index 7109694..c49f84f 100755 (executable)
@@ -77,10 +77,9 @@ public:
 
   /**
    * Construct a new Layer.
-   * @param[in] id The Unique ID of the actor creating the node
    * @return A smart-pointer to a newly allocated Node
    */
-  static SceneGraph::Layer* New( uint32_t id );
+  static SceneGraph::Layer* New();
 
   /**
    * Virtual destructor
@@ -211,10 +210,9 @@ private:
 
   /**
    * Private constructor.
-   * @param[in] id The Unique ID of the actor creating the node
    * See also Layer::New()
    */
-  Layer( uint32_t id );
+  Layer();
 
   // Undefined
   Layer(const Layer&);