Remove current and future memory leaks with messages by forcing the use of OwnerPoint... 10/132810/2
authorKimmo Hoikka <kimmo.hoikka@samsung.com>
Wed, 7 Jun 2017 17:35:26 +0000 (18:35 +0100)
committerKimmo Hoikka <kimmo.hoikka@samsung.com>
Thu, 8 Jun 2017 12:59:02 +0000 (13:59 +0100)
OwnerPointer no longer does the Release hack behind the scene so if you want to transfer ownership
it needs to be OwnerPointer all the way

Change-Id: I3cbf6341142fd25ef3f2a0ebc875c2ef9797e8ad

40 files changed:
dali/internal/common/message.h
dali/internal/common/owner-pointer.h
dali/internal/common/type-abstraction.h
dali/internal/event/actors/actor-impl.cpp
dali/internal/event/actors/camera-actor-impl.cpp
dali/internal/event/actors/layer-impl.cpp
dali/internal/event/animation/animation-impl.cpp
dali/internal/event/animation/constraint-impl.h
dali/internal/event/common/object-impl.cpp
dali/internal/event/common/property-buffer-impl.cpp
dali/internal/event/common/property-notification-impl.cpp
dali/internal/event/object/custom-object-internal.cpp
dali/internal/event/render-tasks/render-task-list-impl.cpp
dali/internal/event/rendering/geometry-impl.cpp
dali/internal/event/rendering/renderer-impl.cpp
dali/internal/event/rendering/sampler-impl.cpp
dali/internal/event/rendering/shader-impl.cpp
dali/internal/event/rendering/texture-impl.cpp
dali/internal/event/rendering/texture-set-impl.cpp
dali/internal/render/common/render-manager.cpp
dali/internal/render/common/render-manager.h
dali/internal/render/renderers/render-renderer.cpp
dali/internal/render/renderers/render-renderer.h
dali/internal/update/animation/scene-graph-animation.cpp
dali/internal/update/animation/scene-graph-animation.h
dali/internal/update/animation/scene-graph-constraint-base.cpp
dali/internal/update/animation/scene-graph-constraint-base.h
dali/internal/update/animation/scene-graph-constraint.h
dali/internal/update/common/property-owner-messages.h
dali/internal/update/common/property-owner.cpp
dali/internal/update/common/property-owner.h
dali/internal/update/controllers/render-message-dispatcher.cpp
dali/internal/update/controllers/render-message-dispatcher.h
dali/internal/update/manager/update-manager.cpp
dali/internal/update/manager/update-manager.h
dali/internal/update/nodes/node.cpp
dali/internal/update/nodes/node.h
dali/internal/update/render-tasks/scene-graph-render-task-list.cpp
dali/internal/update/render-tasks/scene-graph-render-task-list.h
dali/internal/update/rendering/scene-graph-renderer.cpp

index 201186c..73ad04a 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_INTERNAL_MESSAGE_H__
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -154,7 +154,7 @@ public:
   virtual void Process( BufferIndex /*bufferIndex*/ )
   {
     DALI_ASSERT_DEBUG( object && "Message does not have an object" );
-    (object->*memberFunction)( ParameterType< P >::PassObject( param1 ) );
+    (object->*memberFunction)( param1 );
   }
 
 private:
@@ -215,9 +215,7 @@ public:
   virtual void Process( BufferIndex /*bufferIndex*/ )
   {
     DALI_ASSERT_DEBUG( object && "Message does not have an object" );
-    (object->*memberFunction)(
-        ParameterType< P1 >::PassObject( param1 ),
-        ParameterType< P2 >::PassObject( param2 ) );
+    (object->*memberFunction)( param1, param2 );
   }
 
 private:
@@ -282,10 +280,7 @@ public:
   virtual void Process( BufferIndex /*bufferIndex*/ )
   {
     DALI_ASSERT_DEBUG( object && "Message does not have an object" );
-    (object->*memberFunction)(
-        ParameterType< P1 >::PassObject( param1 ),
-        ParameterType< P2 >::PassObject( param2 ),
-        ParameterType< P3 >::PassObject( param3 ) );
+    (object->*memberFunction)( param1, param2, param3 );
   }
 
 private:
@@ -355,11 +350,7 @@ public:
   virtual void Process( BufferIndex /*bufferIndex*/ )
   {
     DALI_ASSERT_DEBUG( object && "Message does not have an object" );
-    (object->*memberFunction)(
-        ParameterType< P1 >::PassObject( param1 ),
-        ParameterType< P2 >::PassObject( param2 ),
-        ParameterType< P3 >::PassObject( param3 ),
-        ParameterType< P4 >::PassObject( param4 ) );
+    (object->*memberFunction)( param1, param2, param3, param4 );
   }
 
 private:
@@ -434,12 +425,7 @@ public:
   virtual void Process( BufferIndex /*bufferIndex*/ )
   {
     DALI_ASSERT_DEBUG( object && "Message does not have an object" );
-    (object->*memberFunction)(
-        ParameterType< P1 >::PassObject( param1 ),
-        ParameterType< P2 >::PassObject( param2 ),
-        ParameterType< P3 >::PassObject( param3 ),
-        ParameterType< P4 >::PassObject( param4 ),
-        ParameterType< P5 >::PassObject( param5 ) );
+    (object->*memberFunction)( param1, param2, param3, param4, param5 );
 
   }
 
@@ -520,13 +506,7 @@ public:
   virtual void Process( BufferIndex /*bufferIndex*/ )
   {
     DALI_ASSERT_DEBUG( object && "Message does not have an object" );
-    (object->*memberFunction)(
-        ParameterType< P1 >::PassObject( param1 ),
-        ParameterType< P2 >::PassObject( param2 ),
-        ParameterType< P3 >::PassObject( param3 ),
-        ParameterType< P4 >::PassObject( param4 ),
-        ParameterType< P5 >::PassObject( param5 ),
-        ParameterType< P6 >::PassObject( param6 ) );
+    (object->*memberFunction)( param1, param2, param3, param4, param5, param6 );
 
   }
 
@@ -638,9 +618,7 @@ public:
   virtual void Process( BufferIndex bufferIndex )
   {
     DALI_ASSERT_DEBUG( object && "Message does not have an object" );
-    (object->*memberFunction)(
-        bufferIndex,
-        ParameterType< P >::PassObject( param ) );
+    (object->*memberFunction)( bufferIndex,  param );
   }
 
 private:
@@ -702,9 +680,7 @@ public:
   {
     DALI_ASSERT_DEBUG( object && "Message does not have an object" );
     (object->*memberFunction)(
-        bufferIndex,
-        ParameterType< P2 >::PassObject( param2 ),
-        ParameterType< P3 >::PassObject( param3 ) );
+        bufferIndex, param2, param3 );
   }
 
 private:
@@ -771,11 +747,7 @@ public:
   virtual void Process( BufferIndex bufferIndex )
   {
     DALI_ASSERT_DEBUG( object && "Message does not have an object" );
-    (object->*memberFunction)(
-        bufferIndex,
-        ParameterType< P2 >::PassObject( param2 ),
-        ParameterType< P3 >::PassObject( param3 ),
-        ParameterType< P4 >::PassObject( param4 ) );
+    (object->*memberFunction)( bufferIndex, param2, param3, param4 );
   }
 
 private:
@@ -846,12 +818,7 @@ public:
   virtual void Process( BufferIndex bufferIndex )
   {
     DALI_ASSERT_DEBUG( object && "Message does not have an object" );
-    (object->*memberFunction)(
-        bufferIndex,
-        ParameterType< P2 >::PassObject( param2 ),
-        ParameterType< P3 >::PassObject( param3 ),
-        ParameterType< P4 >::PassObject( param4 ),
-        ParameterType< P5 >::PassObject( param5 ) );
+    (object->*memberFunction)( bufferIndex, param2, param3, param4, param5 );
   }
 
 private:
index 5ce648f..e780920 100644 (file)
@@ -55,10 +55,12 @@ public:
    * Copy constructor. Passes the ownership of a pointer to another.
    * @param[in] other The pointer that gives away the ownership.
    */
-  OwnerPointer( OwnerPointer& other )
+  OwnerPointer( const OwnerPointer& other )
   : mObject(NULL)
   {
-    Swap( other );
+    // other needs to be const for compiler to pick up this as copy constructor;
+    // though we are using this as move as there can only be one owner
+    Swap( const_cast<OwnerPointer&>( other ) );
   }
 
   /**
index 3338913..cdf00d5 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_INTERNAL_TYPE_ABSTRACTION_H__
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -42,7 +42,6 @@ struct BasicType
 {
   typedef Type HolderType;
   typedef Type PassingType;
-  static PassingType PassObject( PassingType object ) { return object; }
 };
 
 // For complex types that are copied into the message,
@@ -52,19 +51,18 @@ struct ComplexType
 {
   typedef Type HolderType;
   typedef const Type& PassingType;
-  static PassingType PassObject( PassingType object ) { return object; }
 };
 
 // For complex types that are owned by the message,
-// They are passed as raw pointer and hold in an OwnerPointer
+// They are passed and hold in an OwnerPointer
 template <typename Type>
 struct OwnedType
 {
   typedef OwnerPointer<Type> HolderType;
-  typedef Type* PassingType;
-  static PassingType PassObject( HolderType& object ) { return object.Release(); }
+  typedef OwnerPointer<Type>& PassingType;
 };
 
+
 // Default for Vector3 and other structures
 template <class T> struct ParameterType : public ComplexType< T > {};
 
index 2ab1558..134df1f 100644 (file)
@@ -2138,11 +2138,10 @@ Actor::Actor( DerivedType derivedType )
 
 void Actor::Initialize()
 {
-  // Node creation
-  SceneGraph::Node* node = CreateNode();
-
-  AddNodeMessage( GetEventThreadServices().GetUpdateManager(), *node ); // Pass ownership to scene-graph
-  mNode = node; // Keep raw-pointer to Node
+  // 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();
 
@@ -2400,7 +2399,7 @@ void Actor::RebuildDepthTree()
 
   // Vector of scene-graph nodes and their depths to send to UpdateManager
   // in a single message
-  SceneGraph::NodeDepths* sceneGraphNodeDepths = new SceneGraph::NodeDepths(actorCount);
+  OwnerPointer< SceneGraph::NodeDepths > sceneGraphNodeDepths = new SceneGraph::NodeDepths(actorCount);
 
   // Traverse depth tree and set mSortedDepth on each actor and scenegraph node
   uint32_t sortOrder = 1u; // Don't start at zero, as visual depth can be negative
index 175643b..c5015de 100644 (file)
@@ -146,12 +146,11 @@ CameraActorPtr CameraActor::New( const Size& size )
 
   actor->SetName("DefaultCamera");
 
-  // Create scene-object and transfer ownership through message
-  SceneGraph::Camera* sceneObject = SceneGraph::Camera::New();
-  AddCameraMessage( actor->GetEventThreadServices().GetUpdateManager(), sceneObject );
-
-  // Keep raw pointer for message passing
-  actor->mSceneObject = sceneObject;
+  // Create scene-object and keep raw pointer for message passing
+  SceneGraph::Camera* camera = SceneGraph::Camera::New();
+  actor->mSceneObject = camera;
+  OwnerPointer< SceneGraph::Camera > transferOwnership( camera );
+  AddCameraMessage( actor->GetEventThreadServices().GetUpdateManager(), transferOwnership );
 
   actor->SetPerspectiveProjection( size );
 
index 81bc0f6..3e1236b 100644 (file)
@@ -96,12 +96,11 @@ LayerPtr Layer::NewRoot( LayerList& layerList, UpdateManager& manager, bool syst
 {
   LayerPtr root( new Layer( Actor::ROOT_LAYER ) );
 
-  // Second-phase construction
-  SceneGraph::Layer* layer = static_cast<SceneGraph::Layer*>( root->CreateNode() );
-  InstallRootMessage( manager, *layer, systemLevel ); // Transfer ownership to scene-graph
-
-  // Keep a raw pointer to the layer node.
-  root->mNode = layer;
+  // Second-phase construction, keep a raw pointer to the layer node.
+  SceneGraph::Layer* rootLayer = static_cast<SceneGraph::Layer*>( root->CreateNode() );
+  root->mNode = rootLayer;
+  OwnerPointer< SceneGraph::Layer > transferOwnership( rootLayer );
+  InstallRootMessage( manager, transferOwnership, systemLevel );
 
   // root actor is immediately considered to be on-stage
   root->mIsOnStage = true;
index c87941d..a57f936 100644 (file)
@@ -160,14 +160,10 @@ void Animation::CreateSceneObject()
 {
   DALI_ASSERT_DEBUG( mAnimation == NULL );
 
-  // Create a new animation, temporarily owned
-  SceneGraph::Animation* animation = SceneGraph::Animation::New( mDurationSeconds, mSpeedFactor, mPlayRange, mLoopCount, mEndAction, mDisconnectAction );
-
-  // Keep a const pointer to the animation.
-  mAnimation = animation;
-
-  // Transfer animation ownership to the update manager through a message
-  AddAnimationMessage( mEventThreadServices.GetUpdateManager(), animation );
+  // Create a new animation, Keep a const pointer to the animation.
+  mAnimation = SceneGraph::Animation::New( mDurationSeconds, mSpeedFactor, mPlayRange, mLoopCount, mEndAction, mDisconnectAction );
+  OwnerPointer< SceneGraph::Animation > transferOwnership( const_cast< SceneGraph::Animation* >( mAnimation ) );
+  AddAnimationMessage( mEventThreadServices.GetUpdateManager(), transferOwnership );
 }
 
 void Animation::DestroySceneObject()
index 78f86f1..2f9d65f 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_INTERNAL_ACTIVE_CONSTRAINT_H__
 
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -173,33 +173,21 @@ private:
       if( targetProperty->IsTransformManagerProperty() )  //It is a property managed by the transform manager
       {
         // Connect the constraint
-        SceneGraph::ConstraintBase* sceneGraphConstraint = SceneGraph::Constraint<PropertyType,TransformManagerPropertyAccessor<PropertyType> >::New( *targetProperty,
-                                                                                      propertyOwners,
-                                                                                      func );
-        DALI_ASSERT_DEBUG( NULL != sceneGraphConstraint );
-        sceneGraphConstraint->SetRemoveAction( mRemoveAction );
-
-        // object is being used in a separate thread; queue a message to apply the constraint
-        ApplyConstraintMessage( GetEventThreadServices(), *targetObject, *sceneGraphConstraint );
-
-        // Keep a raw-pointer to the scene-graph constraint
-        mSceneGraphConstraint = sceneGraphConstraint;
+        mSceneGraphConstraint = SceneGraph::Constraint<PropertyType,TransformManagerPropertyAccessor<PropertyType> >::New( *targetProperty,
+                                                                                                                           propertyOwners,
+                                                                                                                           func,
+                                                                                                                           mRemoveAction );
       }
       else  //SceneGraph property
       {
         // Connect the constraint
-        SceneGraph::ConstraintBase* sceneGraphConstraint = SceneGraphConstraint::New( *targetProperty,
-                                                                                      propertyOwners,
-                                                                                      func );
-        DALI_ASSERT_DEBUG( NULL != sceneGraphConstraint );
-        sceneGraphConstraint->SetRemoveAction( mRemoveAction );
-
-        // object is being used in a separate thread; queue a message to apply the constraint
-        ApplyConstraintMessage( GetEventThreadServices(), *targetObject, *sceneGraphConstraint );
-
-        // Keep a raw-pointer to the scene-graph constraint
-        mSceneGraphConstraint = sceneGraphConstraint;
+        mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty,
+                                                           propertyOwners,
+                                                           func,
+                                                           mRemoveAction );
       }
+      OwnerPointer< SceneGraph::ConstraintBase > transferOwnership( const_cast< SceneGraph::ConstraintBase* >( mSceneGraphConstraint ) );
+      ApplyConstraintMessage( GetEventThreadServices(), *targetObject, transferOwnership );
     }
   }
 
@@ -408,8 +396,6 @@ private:
 
       const int componentIndex = mTargetObject->GetPropertyComponentIndex( mTargetIndex );
 
-      SceneGraph::ConstraintBase* sceneGraphConstraint( NULL );
-
       if ( Property::INVALID_COMPONENT_INDEX == componentIndex )
       {
         // Not a Vector2, Vector3 or Vector4 component, expecting float type
@@ -417,9 +403,7 @@ private:
 
         typedef SceneGraph::Constraint< float, PropertyAccessor<float> > SceneGraphConstraint;
 
-        sceneGraphConstraint = SceneGraphConstraint::New( *targetProperty,
-                                                           propertyOwners,
-                                                           func );
+        mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func, mRemoveAction );
       }
       else
       {
@@ -432,12 +416,12 @@ private:
           if ( 0 == componentIndex )
           {
             typedef SceneGraph::Constraint< float, PropertyComponentAccessorX<Vector2> > SceneGraphConstraint;
-            sceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func );
+            mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func, mRemoveAction );
           }
           else if ( 1 == componentIndex )
           {
             typedef SceneGraph::Constraint< float, PropertyComponentAccessorY<Vector2> > SceneGraphConstraint;
-            sceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func );
+            mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func, mRemoveAction );
           }
         }
         else if ( PropertyTypes::Get< Vector3 >() == targetProperty->GetType() )
@@ -448,17 +432,17 @@ private:
             if ( 0 == componentIndex )
             {
               typedef SceneGraph::Constraint< float, TransformManagerPropertyComponentAccessor<Vector3,0> > SceneGraphConstraint;
-              sceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func );
+              mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func, mRemoveAction );
             }
             else if ( 1 == componentIndex )
             {
               typedef SceneGraph::Constraint< float, TransformManagerPropertyComponentAccessor<Vector3,1> > SceneGraphConstraint;
-              sceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func );
+              mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func, mRemoveAction );
             }
             else if ( 2 == componentIndex )
             {
               typedef SceneGraph::Constraint< float, TransformManagerPropertyComponentAccessor<Vector3,2> > SceneGraphConstraint;
-              sceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func );
+              mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func, mRemoveAction );
             }
           }
           else
@@ -466,17 +450,17 @@ private:
             if ( 0 == componentIndex )
             {
               typedef SceneGraph::Constraint< float, PropertyComponentAccessorX<Vector3> > SceneGraphConstraint;
-              sceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func );
+              mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func, mRemoveAction );
             }
             else if ( 1 == componentIndex )
             {
               typedef SceneGraph::Constraint< float, PropertyComponentAccessorY<Vector3> > SceneGraphConstraint;
-              sceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func );
+              mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func, mRemoveAction );
             }
             else if ( 2 == componentIndex )
             {
               typedef SceneGraph::Constraint< float, PropertyComponentAccessorZ<Vector3> > SceneGraphConstraint;
-              sceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func );
+              mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func, mRemoveAction );
             }
           }
         }
@@ -487,36 +471,30 @@ private:
           if ( 0 == componentIndex )
           {
             typedef SceneGraph::Constraint< float, PropertyComponentAccessorX<Vector4> > SceneGraphConstraint;
-            sceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func );
+            mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func, mRemoveAction );
           }
           else if ( 1 == componentIndex )
           {
             typedef SceneGraph::Constraint< float, PropertyComponentAccessorY<Vector4> > SceneGraphConstraint;
-            sceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func );
+            mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func, mRemoveAction );
           }
           else if ( 2 == componentIndex )
           {
             typedef SceneGraph::Constraint< float, PropertyComponentAccessorZ<Vector4> > SceneGraphConstraint;
-            sceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func );
+            mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func, mRemoveAction );
           }
           else if ( 3 == componentIndex )
           {
             typedef SceneGraph::Constraint< float, PropertyComponentAccessorW<Vector4> > SceneGraphConstraint;
-            sceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func );
+            mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func, mRemoveAction );
           }
         }
       }
 
-      DALI_ASSERT_DEBUG( NULL != sceneGraphConstraint );
-      if( NULL != sceneGraphConstraint )
+      if( mSceneGraphConstraint )
       {
-        sceneGraphConstraint->SetRemoveAction( mRemoveAction );
-
-        // object is being used in a separate thread; queue a message to apply the constraint
-        ApplyConstraintMessage( GetEventThreadServices(), *targetObject, *sceneGraphConstraint );
-
-        // Keep a raw-pointer to the scene-graph constraint
-        mSceneGraphConstraint = sceneGraphConstraint;
+        OwnerPointer< SceneGraph::ConstraintBase > transferOwnership( const_cast< SceneGraph::ConstraintBase* >( mSceneGraphConstraint ) );
+        ApplyConstraintMessage( GetEventThreadServices(), *targetObject, transferOwnership );
       }
     }
   }
index fb2d388..f8c9312 100644 (file)
@@ -762,7 +762,7 @@ Property::Index Object::RegisterSceneGraphProperty(const std::string& name, Prop
     }
 
     // queue a message to add the property
-    InstallCustomPropertyMessage( const_cast<EventThreadServices&>(GetEventThreadServices()), *scenePropertyOwner, newProperty.Release() ); // Message takes ownership
+    InstallCustomPropertyMessage( const_cast<EventThreadServices&>(GetEventThreadServices()), *scenePropertyOwner, newProperty ); // Message takes ownership
 
     // notify the derived class (optional) method in case it needs to do some more work on the new property
     // note! have to use the local pointer as OwnerPointer now points to NULL as it handed over its ownership
@@ -1026,9 +1026,9 @@ void Object::AddUniformMapping( Property::Index propertyIndex, const std::string
 
     if( sceneObject != NULL )
     {
-      SceneGraph::UniformPropertyMapping* map = new SceneGraph::UniformPropertyMapping( uniformName, propertyPtr );
+      OwnerPointer< SceneGraph::UniformPropertyMapping > map = new SceneGraph::UniformPropertyMapping( uniformName, propertyPtr );
       // Message takes ownership of Uniform map (and will delete it after copy)
-      AddUniformMapMessage( const_cast<EventThreadServices&>(GetEventThreadServices()), *sceneObject, map);
+      AddUniformMapMessage( const_cast<EventThreadServices&>(GetEventThreadServices()), *sceneObject, map );
     }
     else
     {
index d281d84..0a83cc9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -138,7 +138,7 @@ void PropertyBuffer::SetData( const void* data, std::size_t size )
 
   // create a new DALi vector to store the buffer data
   // the heap allocated vector will end up being owned by Render::PropertyBuffer
-  Dali::Vector<char>* bufferCopy = new Dali::Vector<char>();
+  OwnerPointer< Vector<char> > bufferCopy = new Dali::Vector<char>();
   bufferCopy->Resize( bufferSize );
 
   // copy the data
@@ -179,12 +179,13 @@ PropertyBuffer::PropertyBuffer()
 void PropertyBuffer::Initialize( Dali::Property::Map& formatMap )
 {
   mRenderObject = new Render::PropertyBuffer();
-  SceneGraph::AddPropertyBuffer(mEventThreadServices.GetUpdateManager(), *mRenderObject );
+  OwnerPointer< Render::PropertyBuffer > transferOwnership( mRenderObject );
+  SceneGraph::AddPropertyBuffer( mEventThreadServices.GetUpdateManager(), transferOwnership );
 
   size_t numComponents = formatMap.Count();
 
   // Create the format
-  Render::PropertyBuffer::Format* format = new Render::PropertyBuffer::Format();
+  OwnerPointer< Render::PropertyBuffer::Format> format = new Render::PropertyBuffer::Format();
   format->components.resize( numComponents );
 
   unsigned int currentAlignment = 0u;
index 14536a1..f119eda 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -212,19 +212,16 @@ void PropertyNotification::CreateSceneObject()
   // this method can be called from constructor and on stage connection
   if( !mPropertyNotification )
   {
-    // Create a new PropertyNotification, temporarily owned
-    SceneGraph::PropertyNotification* propertyNotification = SceneGraph::PropertyNotification::New( *mObject,
-                                                                                                    mObjectPropertyIndex,
-                                                                                                    mPropertyType,
-                                                                                                    mComponentIndex,
-                                                                                                    GetImplementation(mCondition).type,
-                                                                                                    mRawConditionArgs,
-                                                                                                    mNotifyMode );
-    // Keep a const pointer to the PropertyNotification.
-    mPropertyNotification = propertyNotification;
-
-    // Transfer scene object ownership to the update manager through a message
-    AddPropertyNotificationMessage( mUpdateManager, propertyNotification );
+    // Create a new PropertyNotification, keep a const pointer to it
+    mPropertyNotification = SceneGraph::PropertyNotification::New( *mObject,
+                                                                   mObjectPropertyIndex,
+                                                                   mPropertyType,
+                                                                   mComponentIndex,
+                                                                   GetImplementation( mCondition ).type,
+                                                                   mRawConditionArgs,
+                                                                   mNotifyMode );
+    OwnerPointer< SceneGraph::PropertyNotification > transferOwnership( const_cast<SceneGraph::PropertyNotification*>( mPropertyNotification ) );
+    AddPropertyNotificationMessage( mUpdateManager, transferOwnership );
   }
 }
 
index 55024f2..0ea8d5b 100644 (file)
@@ -127,13 +127,10 @@ CustomObject::~CustomObject()
 
 CustomObject::CustomObject()
 {
-  PropertyOwner* updateObject = PropertyOwner::New();
+  mUpdateObject = PropertyOwner::New();
 
-  // Pass ownership to the update-thread
-  AddObjectMessage( GetEventThreadServices().GetUpdateManager(), updateObject );
-
-  // Keep as const since this should only be modified from update-thread
-  mUpdateObject = updateObject;
+  OwnerPointer< PropertyOwner > transferOwnership( mUpdateObject );
+  AddObjectMessage( GetEventThreadServices().GetUpdateManager(), transferOwnership );
 }
 
 } // namespace Internal
index e7da30b..61a9803 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -62,10 +62,9 @@ Dali::RenderTask RenderTaskList::CreateTask()
   if ( mSceneObject )
   {
     SceneGraph::RenderTask* sceneObject = taskImpl->CreateSceneObject();
-    DALI_ASSERT_DEBUG( NULL != sceneObject );
 
-    // Pass ownership to SceneGraph::RenderTaskList
-    AddTaskMessage( mEventThreadServices, *mSceneObject, *sceneObject );
+    OwnerPointer< SceneGraph::RenderTask > transferOwnership( sceneObject );
+    AddTaskMessage( mEventThreadServices, *mSceneObject, transferOwnership );
   }
 
   // Set the default source & camera actors
index 6c8bf92..45c0a37 100644 (file)
@@ -39,7 +39,7 @@ GeometryPtr Geometry::New()
 std::size_t Geometry::AddVertexBuffer( PropertyBuffer& vertexBuffer )
 {
   mVertexBuffers.push_back( &vertexBuffer );
-  SceneGraph::AddVertexBufferMessage( mEventThreadServices.GetUpdateManager(), *mRenderObject, *vertexBuffer.GetRenderObject() );
+  SceneGraph::AttachVertexBufferMessage( mEventThreadServices.GetUpdateManager(), *mRenderObject, *vertexBuffer.GetRenderObject() );
   return mVertexBuffers.size() - 1u;
 }
 
@@ -98,7 +98,8 @@ Geometry::Geometry()
 void Geometry::Initialize()
 {
   mRenderObject = new Render::Geometry();
-  AddGeometry( mEventThreadServices.GetUpdateManager(), *mRenderObject );
+  OwnerPointer< Render::Geometry > transferOwnership( mRenderObject );
+  AddGeometry( mEventThreadServices.GetUpdateManager(), transferOwnership );
 }
 
 Geometry::~Geometry()
index b043b97..62c517c 100644 (file)
@@ -854,7 +854,8 @@ void Renderer::Initialize()
   SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
 
   mSceneObject = SceneGraph::Renderer::New();
-  AddRendererMessage( updateManager, *mSceneObject );
+  OwnerPointer< SceneGraph::Renderer > transferOwnership( mSceneObject );
+  AddRendererMessage( updateManager, transferOwnership );
 
   eventThreadServices.RegisterObject( this );
 }
index 8f4f25b..d6e8af0 100644 (file)
@@ -68,7 +68,8 @@ void Sampler::Initialize()
   SceneGraph::UpdateManager& updateManager = mEventThreadServices.GetUpdateManager();
 
   mRenderObject = new Render::Sampler();
-  AddSamplerMessage( updateManager, *mRenderObject );
+  OwnerPointer< Render::Sampler > transferOwnership( mRenderObject );
+  AddSamplerMessage( updateManager, transferOwnership );
 }
 
 Sampler::~Sampler()
index d851720..962514e 100644 (file)
@@ -302,8 +302,8 @@ void Shader::Initialize(
   SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
   mSceneObject = new SceneGraph::Shader( hints );
 
-  // Add to update manager
-  AddShaderMessage( updateManager, *mSceneObject );
+  OwnerPointer< SceneGraph::Shader > transferOwnership( mSceneObject );
+  AddShaderMessage( updateManager, transferOwnership );
 
   // Try to load a precompiled shader binary for the source pair:
   ThreadLocalStorage& tls = ThreadLocalStorage::Get();
index 04f8a52..4887adf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -81,7 +81,8 @@ void Texture::Initialize()
       mRenderObject = new Render::Texture( mType, mFormat, mWidth, mHeight );
     }
 
-    AddTexture( mEventThreadServices.GetUpdateManager(), *mRenderObject );
+    OwnerPointer< Render::Texture > transferOwnership( mRenderObject );
+    AddTexture( mEventThreadServices.GetUpdateManager(), transferOwnership );
   }
 }
 
index 1ebd9a0..f85cad5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -146,7 +146,8 @@ void TextureSet::Initialize()
   SceneGraph::UpdateManager& updateManager = mEventThreadServices.GetUpdateManager();
 
   mSceneObject = SceneGraph::TextureSet::New();
-  AddTextureSetMessage( updateManager, *mSceneObject );
+  OwnerPointer< SceneGraph::TextureSet > transferOwnership( mSceneObject );
+  AddTextureSetMessage( updateManager, transferOwnership );
 }
 
 TextureSet::~TextureSet()
index ce2bb78..253bb77 100644 (file)
@@ -229,12 +229,12 @@ void RenderManager::SetDefaultSurfaceRect(const Rect<int>& rect)
   mImpl->defaultSurfaceRect = rect;
 }
 
-void RenderManager::AddRenderer( Render::Renderer* renderer )
+void RenderManager::AddRenderer( OwnerPointer< Render::Renderer >& renderer )
 {
   // Initialize the renderer as we are now in render thread
   renderer->Initialize( mImpl->context );
 
-  mImpl->rendererContainer.PushBack( renderer );
+  mImpl->rendererContainer.PushBack( renderer.Release() );
 
   if( !mImpl->renderersAdded )
   {
@@ -247,9 +247,9 @@ void RenderManager::RemoveRenderer( Render::Renderer* renderer )
   mImpl->rendererContainer.EraseObject( renderer );
 }
 
-void RenderManager::AddSampler( Render::Sampler* sampler )
+void RenderManager::AddSampler( OwnerPointer< Render::Sampler >& sampler )
 {
-  mImpl->samplerContainer.PushBack( sampler );
+  mImpl->samplerContainer.PushBack( sampler.Release() );
 }
 
 void RenderManager::RemoveSampler( Render::Sampler* sampler )
@@ -257,10 +257,10 @@ void RenderManager::RemoveSampler( Render::Sampler* sampler )
   mImpl->samplerContainer.EraseObject( sampler );
 }
 
-void RenderManager::AddTexture( Render::Texture* texture )
+void RenderManager::AddTexture( OwnerPointer< Render::Texture >& texture )
 {
-  mImpl->textureContainer.PushBack( texture );
-  texture->Initialize(mImpl->context);
+  texture->Initialize( mImpl->context );
+  mImpl->textureContainer.PushBack( texture.Release() );
 }
 
 void RenderManager::RemoveTexture( Render::Texture* texture )
@@ -333,9 +333,9 @@ void RenderManager::AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameB
   frameBuffer->AttachColorTexture( mImpl->context, texture, mipmapLevel, layer );
 }
 
-void RenderManager::AddPropertyBuffer( Render::PropertyBuffer* propertyBuffer )
+void RenderManager::AddPropertyBuffer( OwnerPointer< Render::PropertyBuffer >& propertyBuffer )
 {
-  mImpl->propertyBufferContainer.PushBack( propertyBuffer );
+  mImpl->propertyBufferContainer.PushBack( propertyBuffer.Release() );
 }
 
 void RenderManager::RemovePropertyBuffer( Render::PropertyBuffer* propertyBuffer )
@@ -343,14 +343,14 @@ void RenderManager::RemovePropertyBuffer( Render::PropertyBuffer* propertyBuffer
   mImpl->propertyBufferContainer.EraseObject( propertyBuffer );
 }
 
-void RenderManager::SetPropertyBufferFormat(Render::PropertyBuffer* propertyBuffer, Render::PropertyBuffer::Format* format )
+void RenderManager::SetPropertyBufferFormat( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Render::PropertyBuffer::Format>& format )
 {
-  propertyBuffer->SetFormat( format );
+  propertyBuffer->SetFormat( format.Release() );
 }
 
-void RenderManager::SetPropertyBufferData( Render::PropertyBuffer* propertyBuffer, Dali::Vector<char>* data, size_t size )
+void RenderManager::SetPropertyBufferData( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Vector<char> >& data, size_t size )
 {
-  propertyBuffer->SetData( data, size );
+  propertyBuffer->SetData( data.Release(), size );
 }
 
 void RenderManager::SetIndexBuffer( Render::Geometry* geometry, Dali::Vector<unsigned short>& indices )
@@ -358,9 +358,9 @@ void RenderManager::SetIndexBuffer( Render::Geometry* geometry, Dali::Vector<uns
   geometry->SetIndexBuffer( indices );
 }
 
-void RenderManager::AddGeometry( Render::Geometry* geometry )
+void RenderManager::AddGeometry( OwnerPointer< Render::Geometry >& geometry )
 {
-  mImpl->geometryContainer.PushBack( geometry );
+  mImpl->geometryContainer.PushBack( geometry.Release() );
 }
 
 void RenderManager::RemoveGeometry( Render::Geometry* geometry )
@@ -368,7 +368,7 @@ void RenderManager::RemoveGeometry( Render::Geometry* geometry )
   mImpl->geometryContainer.EraseObject( geometry );
 }
 
-void RenderManager::AddVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer )
+void RenderManager::AttachVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer )
 {
   DALI_ASSERT_DEBUG( NULL != geometry );
 
index 49bc16b..400d138 100644 (file)
@@ -138,7 +138,7 @@ public:
    * @param[in] renderer The renderer to add.
    * @post renderer is owned by RenderManager
    */
-  void AddRenderer( Render::Renderer* renderer );
+  void AddRenderer( OwnerPointer< Render::Renderer >& renderer );
 
   /**
    * Remove a Renderer from the render manager.
@@ -152,7 +152,7 @@ public:
    * @param[in] sampler The sampler to add.
    * @post sampler is owned by RenderManager
    */
-  void AddSampler( Render::Sampler* sampler );
+  void AddSampler( OwnerPointer< Render::Sampler >& sampler );
 
   /**
    * Remove a sampler from the render manager.
@@ -181,7 +181,7 @@ public:
    * @param[in] propertyBuffer The property buffer to add.
    * @post propertBuffer is owned by RenderManager
    */
-  void AddPropertyBuffer( Render::PropertyBuffer* propertyBuffer );
+  void AddPropertyBuffer( OwnerPointer< Render::PropertyBuffer >& propertyBuffer );
 
   /**
    * Remove a property buffer from the render manager.
@@ -195,7 +195,7 @@ public:
    * @param[in] geometry The geometry to add.
    * @post geometry is owned by RenderManager
    */
-  void AddGeometry( Render::Geometry* geometry );
+  void AddGeometry( OwnerPointer< Render::Geometry >& geometry );
 
   /**
    * Remove a geometry from the render manager.
@@ -209,7 +209,7 @@ public:
    * @param[in] geometry The geometry
    * @param[in] propertyBuffer The property buffer to remove.
    */
-  void AddVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer );
+  void AttachVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer );
 
   /**
    * Remove a property buffer from a Render::Geometry from the render manager.
@@ -224,7 +224,7 @@ public:
    * @param[in] propertyBuffer The property buffer.
    * @param[in] format The new format of the buffer
    */
-  void SetPropertyBufferFormat( Render::PropertyBuffer* propertyBuffer, Render::PropertyBuffer::Format* format );
+  void SetPropertyBufferFormat( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Render::PropertyBuffer::Format>& format );
 
   /**
    * Sets the data of an existing property buffer
@@ -232,7 +232,7 @@ public:
    * @param[in] data The new data of the buffer
    * @param[in] size The new size of the buffer
    */
-  void SetPropertyBufferData( Render::PropertyBuffer* propertyBuffer, Dali::Vector<char>* data, size_t size );
+  void SetPropertyBufferData( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Vector<char> >& data, size_t size );
 
   /**
    * Sets the data for the index buffer of an existing geometry
@@ -252,7 +252,7 @@ public:
    * Adds a texture to the render manager
    * @param[in] texture The texture to add
    */
-  void AddTexture( Render::Texture* texture );
+  void AddTexture( OwnerPointer< Render::Texture >& texture );
 
   /**
    * Removes a texture from the render manager
@@ -319,7 +319,7 @@ public:
 
   /**
    * Renders the results of the previous "update" traversal.
-   * @param[out] status contains the flag that indicates if render instructions exist
+   * @param[out] status contains the rendering flags.
    */
   void Render( Integration::RenderStatus& status );
 
index 593316f..690ae55 100644 (file)
@@ -164,14 +164,14 @@ Renderer::~Renderer()
 {
 }
 
-void Renderer::SetRenderDataProvider( SceneGraph::RenderDataProvider* dataProvider )
+void Renderer::SetRenderDataProvider( OwnerPointer<SceneGraph::RenderDataProvider>& dataProvider )
 {
   mRenderDataProvider = dataProvider;
   mUpdateAttributesLocation = true;
 
-  //Check that the number of textures match the number of samplers in the shader
-  size_t textureCount =  dataProvider->GetTextures().size();
-  Program* program = dataProvider->GetShader().GetProgram();
+  // Check that the number of textures match the number of samplers in the shader
+  size_t textureCount =  mRenderDataProvider->GetTextures().size();
+  Program* program = mRenderDataProvider->GetShader().GetProgram();
   if( program && program->GetActiveSamplerCount() != textureCount )
   {
     DALI_LOG_WARNING("The number of active samplers in the shader(%lu) does not match the number of textures in the TextureSet(%lu)\n",
index 50a1d5d..1aaf046 100644 (file)
@@ -151,7 +151,7 @@ public:
    * Change the data providers of the renderer
    * @param[in] dataProviders The data providers
    */
-  void SetRenderDataProvider( SceneGraph::RenderDataProvider* dataProviders );
+  void SetRenderDataProvider( OwnerPointer<SceneGraph::RenderDataProvider>& dataProviders );
 
   /**
    * Change the geometry used by the renderer
index 3f33f3c..e1e027e 100644 (file)
@@ -248,12 +248,12 @@ void Animation::OnDestroy(BufferIndex bufferIndex)
   mState = Destroyed;
 }
 
-void Animation::AddAnimator( AnimatorBase* animator )
+void Animation::AddAnimator( OwnerPointer<AnimatorBase>& animator )
 {
   animator->ConnectToSceneGraph();
   animator->SetDisconnectAction( mDisconnectAction );
 
-  mAnimators.PushBack( animator );
+  mAnimators.PushBack( animator.Release() );
 }
 
 void Animation::Update(BufferIndex bufferIndex, float elapsedSeconds, bool& looped, bool& finished )
index 1885560..2b01ff8 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_INTERNAL_SCENE_GRAPH_ANIMATION_H__
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -256,7 +256,7 @@ public:
    * @param[in] propertyOwner The scene-object that owns the animatable property.
    * @post The animator is owned by this animation.
    */
-  void AddAnimator( AnimatorBase* animator );
+  void AddAnimator( OwnerPointer<AnimatorBase>& animator );
 
   /**
    * Retrieve the animators from an animation.
@@ -462,7 +462,8 @@ inline void AddAnimatorMessage( EventThreadServices& eventThreadServices, const
   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &animation, &Animation::AddAnimator, &animator );
+  OwnerPointer<AnimatorBase> parameter( &animator );
+  new (slot) LocalType( &animation, &Animation::AddAnimator, parameter );
 }
 
 
index 85bf625..9a692dd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -32,8 +32,8 @@ namespace SceneGraph
   unsigned int ConstraintBase::mTotalInstanceCount   = 0;
 #endif
 
-ConstraintBase::ConstraintBase( PropertyOwnerContainer& ownerSet )
-: mRemoveAction( Dali::Constraint::DEFAULT_REMOVE_ACTION ),
+ConstraintBase::ConstraintBase( PropertyOwnerContainer& ownerSet, RemoveAction removeAction )
+: mRemoveAction( removeAction ),
   mFirstApply( true ),
   mDisconnected( true ),
   mObservedOwners( ownerSet )
index 0a0ad82..a55bd2e 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_INTERNAL_SCENE_GRAPH_CONSTRAINT_BASE_H__
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -56,8 +56,10 @@ public:
 
   /**
    * Constructor
+   * @param ownerContainer the properties to constraint
+   * @oparam removeAction perform when removed
    */
-  ConstraintBase( PropertyOwnerContainer& ownerContainer );
+  ConstraintBase( PropertyOwnerContainer& ownerContainer, RemoveAction removeAction );
 
   /**
    * Virtual destructor.
index 265d27a..6e47cac 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_INTERNAL_SCENE_GRAPH_CONSTRAINT_H__
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -52,18 +52,21 @@ public:
    * @param[in] targetProperty The target property.
    * @param[in] ownerSet A set of property owners; func is connected to the properties provided by these objects.
    * @param[in] func The function to calculate the final constrained value.
+   * @param[in] removeAction Remove action to perform when constraint is removed
    * @return A smart-pointer to a newly allocated constraint.
    */
   static ConstraintBase* New( const PropertyBase& targetProperty,
                               PropertyOwnerContainer& ownerContainer,
-                              ConstraintFunctionPtr func )
+                              ConstraintFunctionPtr func,
+                              RemoveAction removeAction )
   {
     // Scene-graph thread can edit these objects
     PropertyBase& property = const_cast< PropertyBase& >( targetProperty );
 
     return new Constraint< PropertyType, PropertyAccessorType >( property,
                                                                  ownerContainer,
-                                                                 func );
+                                                                 func,
+                                                                 removeAction );
   }
 
   /**
@@ -113,8 +116,9 @@ private:
    */
   Constraint( PropertyBase& targetProperty,
               PropertyOwnerContainer& ownerContainer,
-              ConstraintFunctionPtr func )
-  : ConstraintBase( ownerContainer ),
+              ConstraintFunctionPtr func,
+              RemoveAction removeAction )
+  : ConstraintBase( ownerContainer, removeAction ),
     mTargetProperty( &targetProperty ),
     mFunc( func )
   {
index c8570fb..3a14bc4 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_OWNER_MESSAGES_H__
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -222,7 +222,7 @@ private:
 
 // Messages for PropertyOwner
 
-inline void InstallCustomPropertyMessage( EventThreadServices& eventThreadServices, const PropertyOwner& owner, PropertyBase* property )
+inline void InstallCustomPropertyMessage( EventThreadServices& eventThreadServices, const PropertyOwner& owner, OwnerPointer<PropertyBase>& property )
 {
   typedef MessageValue1< PropertyOwner, OwnerPointer<PropertyBase> > LocalType;
 
@@ -233,7 +233,7 @@ inline void InstallCustomPropertyMessage( EventThreadServices& eventThreadServic
   new (slot) LocalType( &owner, &PropertyOwner::InstallCustomProperty, property );
 }
 
-inline void ApplyConstraintMessage( EventThreadServices& eventThreadServices, const PropertyOwner& owner, ConstraintBase& constraint )
+inline void ApplyConstraintMessage( EventThreadServices& eventThreadServices, const PropertyOwner& owner, OwnerPointer<ConstraintBase>& constraint )
 {
   typedef MessageValue1< PropertyOwner, OwnerPointer<ConstraintBase> > LocalType;
 
@@ -241,7 +241,7 @@ inline void ApplyConstraintMessage( EventThreadServices& eventThreadServices, co
   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &owner, &PropertyOwner::ApplyConstraint, &constraint );
+  new (slot) LocalType( &owner, &PropertyOwner::ApplyConstraint, constraint );
 }
 
 inline void RemoveConstraintMessage( EventThreadServices& eventThreadServices, const PropertyOwner& owner, const ConstraintBase& constConstraint )
@@ -258,17 +258,23 @@ inline void RemoveConstraintMessage( EventThreadServices& eventThreadServices, c
   new (slot) LocalType( &owner, &PropertyOwner::RemoveConstraint, &constraint );
 }
 
-inline void AddUniformMapMessage( EventThreadServices& eventThreadServices, const PropertyOwner& owner, UniformPropertyMapping* map )
+inline void AddUniformMapMessage( EventThreadServices& eventThreadServices, const PropertyOwner& owner, OwnerPointer< UniformPropertyMapping >& map )
 {
   typedef MessageValue1< PropertyOwner, OwnerPointer< UniformPropertyMapping > > LocalType;
+
+  // Reserve some memory inside the message queue
   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+
   new (slot) LocalType( &owner, &PropertyOwner::AddUniformMapping, map );
 }
 
 inline void RemoveUniformMapMessage( EventThreadServices& eventThreadServices, const PropertyOwner& owner, const std::string& uniformName )
 {
   typedef MessageValue1< PropertyOwner, std::string > LocalType;
+
+  // Reserve some memory inside the message queue
   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+
   new (slot) LocalType( &owner, &PropertyOwner::RemoveUniformMapping, uniformName );
 }
 
index 87b3d31..aa666ef 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -110,11 +110,9 @@ void PropertyOwner::DisconnectFromSceneGraph( BufferIndex updateBufferIndex )
   mConstraints.Clear();
 }
 
-void PropertyOwner::InstallCustomProperty(PropertyBase* property)
+void PropertyOwner::InstallCustomProperty( OwnerPointer<PropertyBase>& property )
 {
-  DALI_ASSERT_DEBUG( NULL != property );
-
-  mCustomProperties.PushBack( property );
+  mCustomProperties.PushBack( property.Release() );
 }
 
 void PropertyOwner::ResetToBaseValues( BufferIndex updateBufferIndex )
@@ -135,11 +133,10 @@ ConstraintOwnerContainer& PropertyOwner::GetConstraints()
   return mConstraints;
 }
 
-void PropertyOwner::ApplyConstraint( ConstraintBase* constraint )
+void PropertyOwner::ApplyConstraint( OwnerPointer<ConstraintBase>& constraint )
 {
-  mConstraints.PushBack( constraint );
-
   constraint->OnConnect();
+  mConstraints.PushBack( constraint.Release() );
 }
 
 void PropertyOwner::RemoveConstraint( ConstraintBase* constraint )
@@ -161,9 +158,9 @@ PropertyOwner::PropertyOwner()
 {
 }
 
-void PropertyOwner::AddUniformMapping( UniformPropertyMapping* map )
+void PropertyOwner::AddUniformMapping( OwnerPointer< UniformPropertyMapping >& map )
 {
-  mUniformMaps.Add( map );
+  mUniformMaps.Add( map.Release() );
 }
 
 void PropertyOwner::RemoveUniformMapping( const std::string& uniformName )
index fa7bf46..51d3664 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_OWNER_H__
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -142,7 +142,7 @@ public:
    * @post The PropertyOwner takes ownership of the property.
    * @param[in] property A pointer to a newly allocated property.
    */
-  void InstallCustomProperty(PropertyBase* property);
+  void InstallCustomProperty( OwnerPointer<PropertyBase>& property );
 
   /**
    * Retrieve the custom properties owned by the object.
@@ -175,7 +175,7 @@ public:
    * Apply a constraint.
    * @param[in] constraint The constraint to apply.
    */
-  void ApplyConstraint( ConstraintBase* constraint );
+  void ApplyConstraint( OwnerPointer<ConstraintBase>& constraint );
 
   /**
    * Begin removal of constraints.
@@ -192,7 +192,7 @@ public:
   /**
    * @copydoc UniformMap::Add
    */
-  virtual void AddUniformMapping( UniformPropertyMapping* map );
+  virtual void AddUniformMapping( OwnerPointer< UniformPropertyMapping >& map );
 
   /**
    * @copydoc UniformMap::Remove
index cf5937f..4b5040d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -44,7 +44,7 @@ RenderMessageDispatcher::~RenderMessageDispatcher()
 {
 }
 
-void RenderMessageDispatcher::AddRenderer( Render::Renderer& renderer )
+void RenderMessageDispatcher::AddRenderer( OwnerPointer< Render::Renderer >& renderer )
 {
   // Message has ownership of renderer while in transit from update -> render
   typedef MessageValue1< RenderManager, OwnerPointer< Render::Renderer > > DerivedType;
@@ -53,7 +53,7 @@ void RenderMessageDispatcher::AddRenderer( Render::Renderer& renderer )
   unsigned int* slot = mRenderQueue.ReserveMessageSlot( mBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
 
   // Construct message in the render queue memory; note that delete should not be called on the return value
-  new (slot) DerivedType( &mRenderManager, &RenderManager::AddRenderer, &renderer );
+  new (slot) DerivedType( &mRenderManager, &RenderManager::AddRenderer, renderer );
 }
 
 void RenderMessageDispatcher::RemoveRenderer( Render::Renderer& renderer )
index 3554754..9fd218b 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_INTERNAL_SCENE_GRAPH_RENDER_MESSAGE_DISPATCHER_H__
 
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -21,6 +21,7 @@
 // INTERNAL INCLUDES
 #include <dali/internal/update/common/scene-graph-buffers.h>
 #include <dali/internal/render/gl-resources/gpu-buffer.h>
+#include <dali/internal/render/renderers/render-renderer.h>
 #include <dali/internal/render/renderers/render-property-buffer.h>
 
 namespace Dali
@@ -32,7 +33,6 @@ class MessageBase;
 
 namespace Render
 {
-class Renderer;
 class RenderTracker;
 }
 namespace SceneGraph
@@ -63,7 +63,7 @@ public:
    * @param[in] renderer The renderer to add.
    * @post renderer ownership is transferred.
    */
-  void AddRenderer( Render::Renderer& renderer );
+  void AddRenderer( OwnerPointer< Render::Renderer >& renderer );
 
   /**
    * Remove a Renderer.
index 344891a..743aa8f 100644 (file)
@@ -220,7 +220,8 @@ struct UpdateManager::Impl
       (*iter)->SetSourceNode( NULL );
     }
 
-    // UpdateManager owns the Nodes
+    // UpdateManager owns the Nodes. Although Nodes are pool allocated they contain heap allocated parts
+    // like custom properties, which get released here
     Vector<Node*>::Iterator iter = nodes.Begin()+1;
     Vector<Node*>::Iterator endIter = nodes.End();
     for(;iter!=endIter;++iter)
@@ -334,7 +335,7 @@ UpdateManager::~UpdateManager()
   delete mImpl;
 }
 
-void UpdateManager::InstallRoot( SceneGraph::Layer* layer, bool systemLevel )
+void UpdateManager::InstallRoot( OwnerPointer<Layer>& layer, bool systemLevel )
 {
   DALI_ASSERT_DEBUG( layer->IsLayer() );
   DALI_ASSERT_DEBUG( layer->GetParent() == NULL);
@@ -342,33 +343,34 @@ void UpdateManager::InstallRoot( SceneGraph::Layer* layer, bool systemLevel )
   if ( !systemLevel )
   {
     DALI_ASSERT_DEBUG( mImpl->root == NULL && "Root Node already installed" );
-    mImpl->root = layer;
+    mImpl->root = layer.Release();
     mImpl->root->CreateTransform( &mImpl->transformManager );
+    mImpl->root->SetRoot(true);
   }
   else
   {
     DALI_ASSERT_DEBUG( mImpl->systemLevelRoot == NULL && "System-level Root Node already installed" );
-    mImpl->systemLevelRoot = layer;
+    mImpl->systemLevelRoot = layer.Release();
     mImpl->systemLevelRoot->CreateTransform( &mImpl->transformManager );
+    mImpl->systemLevelRoot->SetRoot(true);
   }
 
-  layer->SetRoot(true);
 }
 
-void UpdateManager::AddNode( Node* node )
+void UpdateManager::AddNode( OwnerPointer<Node>& node )
 {
-  DALI_ASSERT_ALWAYS( NULL != node );
   DALI_ASSERT_ALWAYS( NULL == node->GetParent() ); // Should not have a parent yet
 
   // Nodes must be sorted by pointer
+  Node* rawNode = node.Release();
   Vector<Node*>::Iterator begin = mImpl->nodes.Begin();
-  for(Vector<Node*>::Iterator iter = mImpl->nodes.End()-1; iter >= begin; --iter)
+  for( Vector<Node*>::Iterator iter = mImpl->nodes.End()-1; iter >= begin; --iter )
   {
-    if(node > (*iter))
+    if( rawNode > (*iter) )
     {
-      mImpl->nodes.Insert((iter+1), node);
-      node->CreateTransform( &mImpl->transformManager );
-      break;
+      mImpl->nodes.Insert((iter+1), rawNode );
+      rawNode->CreateTransform( &mImpl->transformManager );
+      return;
     }
   }
 }
@@ -413,11 +415,9 @@ void UpdateManager::DestroyNode( Node* node )
   node->OnDestroy();
 }
 
-void UpdateManager::AddCamera( Camera* camera )
+void UpdateManager::AddCamera( OwnerPointer< Camera >& camera )
 {
-  DALI_ASSERT_DEBUG( camera != NULL );
-
-  mImpl->cameras.PushBack( camera ); // takes ownership
+  mImpl->cameras.PushBack( camera.Release() ); // takes ownership
 }
 
 void UpdateManager::RemoveCamera( const Camera* camera )
@@ -426,11 +426,9 @@ void UpdateManager::RemoveCamera( const Camera* camera )
   EraseUsingDiscardQueue( mImpl->cameras, const_cast<Camera*>( camera ), mImpl->discardQueue, mSceneGraphBuffers.GetUpdateBufferIndex() );
 }
 
-void UpdateManager::AddObject( PropertyOwner* object )
+void UpdateManager::AddObject( OwnerPointer<PropertyOwner>& object )
 {
-  DALI_ASSERT_DEBUG( NULL != object );
-
-  mImpl->customObjects.PushBack( object );
+  mImpl->customObjects.PushBack( object.Release() );
 }
 
 void UpdateManager::RemoveObject( PropertyOwner* object )
@@ -438,9 +436,9 @@ void UpdateManager::RemoveObject( PropertyOwner* object )
   mImpl->customObjects.EraseObject( object );
 }
 
-void UpdateManager::AddAnimation( Animation* animation )
+void UpdateManager::AddAnimation( OwnerPointer< SceneGraph::Animation >& animation )
 {
-  mImpl->animations.PushBack( animation );
+  mImpl->animations.PushBack( animation.Release() );
 }
 
 void UpdateManager::StopAnimation( Animation* animation )
@@ -483,9 +481,9 @@ bool UpdateManager::IsAnimationRunning() const
   return isRunning;
 }
 
-void UpdateManager::AddPropertyNotification( PropertyNotification* propertyNotification )
+void UpdateManager::AddPropertyNotification( OwnerPointer< PropertyNotification >& propertyNotification )
 {
-  mImpl->propertyNotifications.PushBack( propertyNotification );
+  mImpl->propertyNotifications.PushBack( propertyNotification.Release() );
 }
 
 void UpdateManager::RemovePropertyNotification( PropertyNotification* propertyNotification )
@@ -499,11 +497,9 @@ void UpdateManager::PropertyNotificationSetNotify( PropertyNotification* propert
   propertyNotification->SetNotifyMode( notifyMode );
 }
 
-void UpdateManager::AddShader( Shader* shader )
+void UpdateManager::AddShader( OwnerPointer< Shader >& shader )
 {
-  DALI_ASSERT_DEBUG( NULL != shader );
-
-  mImpl->shaders.PushBack( shader );
+  mImpl->shaders.PushBack( shader.Release() );
 }
 
 void UpdateManager::RemoveShader( Shader* shader )
@@ -544,13 +540,10 @@ void UpdateManager::SetShaderSaver( ShaderSaver& upstream )
   mImpl->shaderSaver = &upstream;
 }
 
-void UpdateManager::AddRenderer( Renderer* renderer )
+void UpdateManager::AddRenderer( OwnerPointer< Renderer >& renderer )
 {
-  DALI_ASSERT_DEBUG( renderer != NULL );
-
-  mImpl->renderers.PushBack( renderer );
-
   renderer->ConnectToSceneGraph( *mImpl->sceneController, mSceneGraphBuffers.GetUpdateBufferIndex() );
+  mImpl->renderers.PushBack( renderer.Release() );
 }
 
 void UpdateManager::RemoveRenderer( Renderer* renderer )
@@ -568,11 +561,9 @@ void UpdateManager::SetPanGestureProcessor( PanGesture* panGestureProcessor )
   mImpl->panGestureProcessor = panGestureProcessor;
 }
 
-void UpdateManager::AddTextureSet( TextureSet* textureSet )
+void UpdateManager::AddTextureSet( OwnerPointer< TextureSet >& textureSet )
 {
-  DALI_ASSERT_DEBUG( NULL != textureSet );
-
-  mImpl->textureSets.PushBack( textureSet );
+  mImpl->textureSets.PushBack( textureSet.Release() );
 }
 
 void UpdateManager::RemoveTextureSet( TextureSet* textureSet )
@@ -1041,22 +1032,19 @@ void UpdateManager::SetLayerDepths( const SortedLayerPointers& layers, bool syst
   }
 }
 
-void UpdateManager::SetDepthIndices( NodeDepths* nodeDepths )
+void UpdateManager::SetDepthIndices( OwnerPointer< NodeDepths >& nodeDepths )
 {
-  if( nodeDepths )
+  // note,this vector is already in depth order. It could be used as-is to
+  // remove sorting in update algorithm. However, it lacks layer boundary markers.
+  for( std::vector<NodeDepthPair>::iterator iter = nodeDepths->nodeDepths.begin(),
+         end = nodeDepths->nodeDepths.end() ;
+       iter != end ; ++iter )
   {
-    // note,this vector is already in depth order. It could be used as-is to
-    // remove sorting in update algorithm. However, it lacks layer boundary markers.
-    for( std::vector<NodeDepthPair>::iterator iter = nodeDepths->nodeDepths.begin(),
-           end = nodeDepths->nodeDepths.end() ;
-         iter != end ; ++iter )
-    {
-      iter->node->SetDepthIndex( iter->sortedDepth );
-    }
+    iter->node->SetDepthIndex( iter->sortedDepth );
   }
 }
 
-void UpdateManager::AddSampler( Render::Sampler* sampler )
+void UpdateManager::AddSampler( OwnerPointer< Render::Sampler >& sampler )
 {
   // Message has ownership of Sampler while in transit from update to render
   typedef MessageValue1< RenderManager, OwnerPointer< Render::Sampler > > DerivedType;
@@ -1101,7 +1089,7 @@ void UpdateManager::SetWrapMode( Render::Sampler* sampler, unsigned int rWrapMod
   new (slot) DerivedType( &mImpl->renderManager,  &RenderManager::SetWrapMode, sampler, rWrapMode, sWrapMode, tWrapMode );
 }
 
-void UpdateManager::AddPropertyBuffer( Render::PropertyBuffer* propertyBuffer )
+void UpdateManager::AddPropertyBuffer( OwnerPointer< Render::PropertyBuffer >& propertyBuffer )
 {
   // Message has ownership of format while in transit from update -> render
   typedef MessageValue1< RenderManager, OwnerPointer< Render::PropertyBuffer > > DerivedType;
@@ -1124,7 +1112,7 @@ void UpdateManager::RemovePropertyBuffer( Render::PropertyBuffer* propertyBuffer
   new (slot) DerivedType( &mImpl->renderManager,  &RenderManager::RemovePropertyBuffer, propertyBuffer );
 }
 
-void UpdateManager::SetPropertyBufferFormat(Render::PropertyBuffer* propertyBuffer, Render::PropertyBuffer::Format* format )
+void UpdateManager::SetPropertyBufferFormat( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Render::PropertyBuffer::Format>& format )
 {
   // Message has ownership of format while in transit from update -> render
   typedef MessageValue2< RenderManager, Render::PropertyBuffer*, OwnerPointer< Render::PropertyBuffer::Format > > DerivedType;
@@ -1136,7 +1124,7 @@ void UpdateManager::SetPropertyBufferFormat(Render::PropertyBuffer* propertyBuff
   new (slot) DerivedType( &mImpl->renderManager,  &RenderManager::SetPropertyBufferFormat, propertyBuffer, format );
 }
 
-void UpdateManager::SetPropertyBufferData( Render::PropertyBuffer* propertyBuffer, Dali::Vector<char>* data, size_t size )
+void UpdateManager::SetPropertyBufferData( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Vector<char> >& data, size_t size )
 {
   // Message has ownership of format while in transit from update -> render
   typedef MessageValue3< RenderManager, Render::PropertyBuffer*, OwnerPointer< Dali::Vector<char> >, size_t > DerivedType;
@@ -1148,7 +1136,7 @@ void UpdateManager::SetPropertyBufferData( Render::PropertyBuffer* propertyBuffe
   new (slot) DerivedType( &mImpl->renderManager, &RenderManager::SetPropertyBufferData, propertyBuffer, data, size );
 }
 
-void UpdateManager::AddGeometry( Render::Geometry* geometry )
+void UpdateManager::AddGeometry( OwnerPointer< Render::Geometry >& geometry )
 {
   // Message has ownership of format while in transit from update -> render
   typedef MessageValue1< RenderManager, OwnerPointer< Render::Geometry > > DerivedType;
@@ -1204,7 +1192,7 @@ void UpdateManager::RemoveVertexBuffer( Render::Geometry* geometry, Render::Prop
   new (slot) DerivedType( &mImpl->renderManager,  &RenderManager::RemoveVertexBuffer, geometry, propertyBuffer );
 }
 
-void UpdateManager::AddVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer )
+void UpdateManager::AttachVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer )
 {
   typedef MessageValue2< RenderManager, Render::Geometry*, Render::PropertyBuffer* > DerivedType;
 
@@ -1212,10 +1200,10 @@ void UpdateManager::AddVertexBuffer( Render::Geometry* geometry, Render::Propert
   unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
 
   // Construct message in the render queue memory; note that delete should not be called on the return value
-  new (slot) DerivedType( &mImpl->renderManager,  &RenderManager::AddVertexBuffer, geometry, propertyBuffer );
+  new (slot) DerivedType( &mImpl->renderManager,  &RenderManager::AttachVertexBuffer, geometry, propertyBuffer );
 }
 
-void UpdateManager::AddTexture( Render::Texture* texture )
+void UpdateManager::AddTexture( OwnerPointer< Render::Texture >& texture )
 {
   // Message has ownership of Texture while in transit from update -> render
   typedef MessageValue1< RenderManager, OwnerPointer< Render::Texture > > DerivedType;
@@ -1224,7 +1212,7 @@ void UpdateManager::AddTexture( Render::Texture* texture )
   unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
 
   // Construct message in the render queue memory; note that delete should not be called on the return value
-  new (slot) DerivedType( &mImpl->renderManager,  &RenderManager::AddTexture, texture );
+  new (slot) DerivedType( &mImpl->renderManager, &RenderManager::AddTexture, texture );
 }
 
 void UpdateManager::RemoveTexture( Render::Texture* texture)
index 4f92d2c..704b25c 100644 (file)
@@ -90,7 +90,6 @@ struct NodeDepthPair
 
 struct NodeDepths
 {
-  std::vector<NodeDepthPair> nodeDepths;
   NodeDepths( int reserveSize )
   {
     nodeDepths.reserve(reserveSize);
@@ -100,6 +99,8 @@ struct NodeDepths
   {
     nodeDepths.push_back( NodeDepthPair( node, sortedDepth ) );
   }
+
+  std::vector<NodeDepthPair> nodeDepths;
 };
 
 
@@ -151,14 +152,15 @@ public:
    * @param[in] systemLevel True if using the system-level overlay.
    * @post The node is owned by UpdateManager.
    */
-  void InstallRoot( Layer* layer, bool systemLevel );
+  void InstallRoot( OwnerPointer<Layer>& layer, bool systemLevel );
 
   /**
    * Add a Node; UpdateManager takes ownership.
    * @pre The node does not have a parent.
+   * @note even though nodes are pool allocated, they also contain other heap allocated data, thus using OwnerPointer when transferring the data
    * @param[in] node The node to add.
    */
-  void AddNode( Node* node );
+  void AddNode( OwnerPointer<Node>& node );
 
   /**
    * Connect a Node to the scene-graph.
@@ -189,7 +191,7 @@ public:
    * Add a camera on scene
    * @param[in] camera to add
    */
-  void AddCamera( Camera* camera );
+  void AddCamera( OwnerPointer< Camera >& camera );
 
   /**
    * Remove a camera from scene
@@ -202,7 +204,7 @@ public:
    * @param[in] object The object to add.
    * @post The object is owned by UpdateManager.
    */
-  void AddObject( PropertyOwner* object );
+  void AddObject( OwnerPointer<PropertyOwner>& object );
 
   /**
    * Remove an object.
@@ -217,7 +219,7 @@ public:
    * @param[in] animation The animation to add.
    * @post The animation is owned by UpdateManager.
    */
-  void AddAnimation( Animation* animation );
+  void AddAnimation( OwnerPointer< SceneGraph::Animation >& animation );
 
   /**
    * Stop an animation.
@@ -244,7 +246,7 @@ public:
    * @param[in] propertyNotification The notification to add
    * @post The propertyNotification is owned by UpdateManager.
    */
-  void AddPropertyNotification( PropertyNotification* propertyNotification );
+  void AddPropertyNotification( OwnerPointer< PropertyNotification >& propertyNotification );
 
   /**
    * Remove a property notification
@@ -266,7 +268,7 @@ public:
    * @param[in] shader The shader to add.
    * @post The shader is owned by the UpdateManager.
    */
-  void AddShader(Shader* shader);
+  void AddShader( OwnerPointer< Shader >& shader );
 
   /**
    * Remove a shader.
@@ -274,7 +276,7 @@ public:
    * @param[in] shader The shader to remove.
    * @post The shader is destroyed.
    */
-  void RemoveShader(Shader* shader);
+  void RemoveShader( Shader* shader );
 
   /**
    * Set the shader program for a Shader object
@@ -303,7 +305,7 @@ public:
    * Add a new renderer to scene
    * @param renderer to add
    */
-  void AddRenderer( Renderer* renderer );
+  void AddRenderer( OwnerPointer< Renderer >& renderer );
 
   /**
    * Add a renderer from scene
@@ -328,7 +330,7 @@ public:
    * @param[in] textureSet The texture set to add.
    * @post The TextureSet is owned by the UpdateManager.
    */
-  void AddTextureSet( TextureSet* textureSet );
+  void AddTextureSet( OwnerPointer< TextureSet >& textureSet );
 
   /**
    * Remove a TextureSet.
@@ -389,7 +391,7 @@ public:
    * @post Sends a message to RenderManager to add the sampler.
    * The sampler will be owned by RenderManager
    */
-  void AddSampler( Render::Sampler* sampler );
+  void AddSampler( OwnerPointer< Render::Sampler >& sampler );
 
   /**
    * Removes an existing sampler from RenderManager
@@ -421,7 +423,7 @@ public:
    * @post Sends a message to RenderManager to add the property buffer.
    * The property buffer will be owned by RenderManager
    */
-  void AddPropertyBuffer( Render::PropertyBuffer* propertryBuffer );
+  void AddPropertyBuffer( OwnerPointer< Render::PropertyBuffer >& propertryBuffer );
 
   /**
    * Removes an existing PropertyBuffer from RenderManager
@@ -436,7 +438,7 @@ public:
    * @param[in] format The new format of the buffer
    * @post Sends a message to RenderManager to set the new format to the property buffer.
    */
-  void SetPropertyBufferFormat(Render::PropertyBuffer* propertyBuffer, Render::PropertyBuffer::Format* format );
+  void SetPropertyBufferFormat( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Render::PropertyBuffer::Format>& format );
 
   /**
    * Sets the data of an existing property buffer
@@ -445,7 +447,7 @@ public:
    * @param[in] size The new size of the buffer
    * @post Sends a message to RenderManager to set the new data to the property buffer.
    */
-  void SetPropertyBufferData(Render::PropertyBuffer* propertyBuffer, Dali::Vector<char>* data, size_t size);
+  void SetPropertyBufferData( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Vector<char> >& data, size_t size );
 
   /**
    * Adds a geometry to the RenderManager
@@ -453,7 +455,7 @@ public:
    * @post Sends a message to RenderManager to add the Geometry
    * The geometry will be owned by RenderManager
    */
-  void AddGeometry( Render::Geometry* geometry );
+  void AddGeometry( OwnerPointer< Render::Geometry >& geometry );
 
   /**
    * Removes an existing Geometry from RenderManager
@@ -477,11 +479,11 @@ public:
   void SetIndexBuffer( Render::Geometry* geometry, Dali::Vector<unsigned short>& indices );
 
   /**
-   * Adds a vertex buffer to a geomtry
+   * Adds a vertex buffer to a geometry
    * @param[in] geometry The geometry
    * @param[in] propertyBuffer The property buffer
    */
-  void AddVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer );
+  void AttachVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer );
 
   /**
    * Removes a vertex buffer from a geometry
@@ -495,7 +497,7 @@ public:
    * @param[in] texture The texture to add
    * The texture will be owned by RenderManager
    */
-  void AddTexture( Render::Texture* texture );
+  void AddTexture( OwnerPointer< Render::Texture >& texture );
 
   /**
    * Removes a texture from the render manager
@@ -580,7 +582,7 @@ public:
    * Set the depth indices of all nodes (in LayerUI's)
    * @param[in] nodeDepths A vector of nodes and associated depth indices
    */
-  void SetDepthIndices( NodeDepths* nodeDepths );
+  void SetDepthIndices( OwnerPointer< NodeDepths >& nodeDepths );
 
 private:
 
@@ -672,7 +674,7 @@ private:
 
 // Messages for UpdateManager
 
-inline void InstallRootMessage( UpdateManager& manager, Layer& root, bool systemLevel )
+inline void InstallRootMessage( UpdateManager& manager, OwnerPointer<Layer>& root, bool systemLevel )
 {
   // Message has ownership of Layer while in transit from event -> update
   typedef MessageValue2< UpdateManager, OwnerPointer<Layer>, bool > LocalType;
@@ -681,10 +683,10 @@ inline void InstallRootMessage( UpdateManager& manager, Layer& root, bool system
   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &manager, &UpdateManager::InstallRoot, &root, systemLevel );
+  new (slot) LocalType( &manager, &UpdateManager::InstallRoot, root, systemLevel );
 }
 
-inline void AddNodeMessage( UpdateManager& manager, Node& node )
+inline void AddNodeMessage( UpdateManager& manager, OwnerPointer<Node>& node )
 {
   // Message has ownership of Node while in transit from event -> update
   typedef MessageValue1< UpdateManager, OwnerPointer<Node> > LocalType;
@@ -693,7 +695,7 @@ inline void AddNodeMessage( UpdateManager& manager, Node& node )
   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &manager, &UpdateManager::AddNode, &node );
+  new (slot) LocalType( &manager, &UpdateManager::AddNode, node );
 }
 
 inline void ConnectNodeMessage( UpdateManager& manager, const Node& constParent, const Node& constChild )
@@ -739,12 +741,11 @@ inline void DestroyNodeMessage( UpdateManager& manager, const Node& constNode )
   new (slot) LocalType( &manager, &UpdateManager::DestroyNode, &node );
 }
 
-inline void AddCameraMessage( UpdateManager& manager, const Camera* constCamera )
+inline void AddCameraMessage( UpdateManager& manager, OwnerPointer< Camera >& camera )
 {
   // Message has ownership of Camera while in transit from event -> update
   typedef MessageValue1< UpdateManager, OwnerPointer< Camera > > LocalType;
 
-  Camera* camera = const_cast<Camera*>( constCamera );
   // Reserve some memory inside the message queue
   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
 
@@ -763,7 +764,7 @@ inline void RemoveCameraMessage( UpdateManager& manager, const Camera* camera )
   new (slot) LocalType( &manager, &UpdateManager::RemoveCamera, camera );
 }
 
-inline void AddObjectMessage( UpdateManager& manager, PropertyOwner* object )
+inline void AddObjectMessage( UpdateManager& manager, OwnerPointer<PropertyOwner>& object )
 {
   // Message has ownership of object while in transit from event -> update
   typedef MessageValue1< UpdateManager, OwnerPointer<PropertyOwner> > LocalType;
@@ -786,9 +787,9 @@ inline void RemoveObjectMessage( UpdateManager& manager, PropertyOwner* object )
   new (slot) LocalType( &manager, &UpdateManager::RemoveObject, object );
 }
 
-inline void AddAnimationMessage( UpdateManager& manager, Animation* animation )
+inline void AddAnimationMessage( UpdateManager& manager, OwnerPointer< SceneGraph::Animation >& animation )
 {
-  typedef MessageValue1< UpdateManager, Animation* > LocalType;
+  typedef MessageValue1< UpdateManager, OwnerPointer< SceneGraph::Animation > > LocalType;
 
   // Reserve some memory inside the message queue
   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
@@ -825,7 +826,7 @@ inline void RemoveAnimationMessage( UpdateManager& manager, const Animation& con
   new (slot) LocalType( &manager, &UpdateManager::RemoveAnimation, &animation );
 }
 
-inline void AddPropertyNotificationMessage( UpdateManager& manager, PropertyNotification* propertyNotification )
+inline void AddPropertyNotificationMessage( UpdateManager& manager, OwnerPointer< PropertyNotification >& propertyNotification )
 {
   // Message has ownership of PropertyNotification while in transit from event -> update
   typedef MessageValue1< UpdateManager, OwnerPointer< PropertyNotification > > LocalType;
@@ -868,7 +869,7 @@ inline void PropertyNotificationSetNotifyModeMessage( UpdateManager& manager,
 }
 
 // The render thread can safely change the Shader
-inline void AddShaderMessage( UpdateManager& manager, Shader& shader )
+inline void AddShaderMessage( UpdateManager& manager, OwnerPointer< Shader >& shader )
 {
   typedef MessageValue1< UpdateManager, OwnerPointer< Shader > > LocalType;
 
@@ -876,7 +877,7 @@ inline void AddShaderMessage( UpdateManager& manager, Shader& shader )
   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &manager, &UpdateManager::AddShader, &shader );
+  new (slot) LocalType( &manager, &UpdateManager::AddShader, shader );
 }
 
 // The render thread can safely change the Shader
@@ -955,14 +956,14 @@ inline void SetLayerDepthsMessage( UpdateManager& manager, const std::vector< La
   new (slot) LocalType( &manager, &UpdateManager::SetLayerDepths, layers, systemLevel );
 }
 
-inline void AddRendererMessage( UpdateManager& manager, Renderer& object )
+inline void AddRendererMessage( UpdateManager& manager, OwnerPointer< Renderer >& object )
 {
   typedef MessageValue1< UpdateManager, OwnerPointer< Renderer > > LocalType;
 
   // Reserve some memory inside the message queue
   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
   // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &manager, &UpdateManager::AddRenderer, &object );
+  new (slot) LocalType( &manager, &UpdateManager::AddRenderer, object );
 }
 
 inline void RemoveRendererMessage( UpdateManager& manager, Renderer& object )
@@ -976,7 +977,7 @@ inline void RemoveRendererMessage( UpdateManager& manager, Renderer& object )
 }
 
 // The render thread can safely change the Shader
-inline void AddTextureSetMessage( UpdateManager& manager, TextureSet& textureSet )
+inline void AddTextureSetMessage( UpdateManager& manager, OwnerPointer< TextureSet >& textureSet )
 {
   typedef MessageValue1< UpdateManager, OwnerPointer< TextureSet > > LocalType;
 
@@ -984,7 +985,7 @@ inline void AddTextureSetMessage( UpdateManager& manager, TextureSet& textureSet
   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &manager, &UpdateManager::AddTextureSet, &textureSet );
+  new (slot) LocalType( &manager, &UpdateManager::AddTextureSet, textureSet );
 }
 
 // The render thread can safely change the Shader
@@ -999,7 +1000,7 @@ inline void RemoveTextureSetMessage( UpdateManager& manager, TextureSet& texture
   new (slot) LocalType( &manager, &UpdateManager::RemoveTextureSet, &textureSet );
 }
 
-inline void AddSamplerMessage( UpdateManager& manager, Render::Sampler& sampler )
+inline void AddSamplerMessage( UpdateManager& manager, OwnerPointer< Render::Sampler >& sampler )
 {
   // Message has ownership of Sampler while in transit from event -> update
   typedef MessageValue1< UpdateManager, OwnerPointer< Render::Sampler > > LocalType;
@@ -1008,7 +1009,7 @@ inline void AddSamplerMessage( UpdateManager& manager, Render::Sampler& sampler
   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &manager, &UpdateManager::AddSampler, &sampler );
+  new (slot) LocalType( &manager, &UpdateManager::AddSampler, sampler );
 }
 
 inline void RemoveSamplerMessage( UpdateManager& manager, Render::Sampler& sampler )
@@ -1044,7 +1045,7 @@ inline void SetWrapModeMessage( UpdateManager& manager, Render::Sampler& sampler
   new (slot) LocalType( &manager, &UpdateManager::SetWrapMode, &sampler, rWrapMode, sWrapMode, tWrapMode );
 }
 
-inline void AddPropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer )
+inline void AddPropertyBuffer( UpdateManager& manager, OwnerPointer< Render::PropertyBuffer >& propertyBuffer )
 {
   // Message has ownership of propertyBuffer while in transit from event -> update
   typedef MessageValue1< UpdateManager, OwnerPointer< Render::PropertyBuffer > > LocalType;
@@ -1053,7 +1054,7 @@ inline void AddPropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& p
   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &manager, &UpdateManager::AddPropertyBuffer, &propertyBuffer );
+  new (slot) LocalType( &manager, &UpdateManager::AddPropertyBuffer, propertyBuffer );
 }
 
 inline void RemovePropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer )
@@ -1067,7 +1068,7 @@ inline void RemovePropertyBuffer( UpdateManager& manager, Render::PropertyBuffer
   new (slot) LocalType( &manager, &UpdateManager::RemovePropertyBuffer, &propertyBuffer );
 }
 
-inline void SetPropertyBufferFormat( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, Render::PropertyBuffer::Format* format )
+inline void SetPropertyBufferFormat( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, OwnerPointer< Render::PropertyBuffer::Format>& format )
 {
   // Message has ownership of PropertyBuffer::Format while in transit from event -> update
   typedef MessageValue2< UpdateManager, Render::PropertyBuffer*, OwnerPointer< Render::PropertyBuffer::Format> > LocalType;
@@ -1079,7 +1080,7 @@ inline void SetPropertyBufferFormat( UpdateManager& manager, Render::PropertyBuf
   new (slot) LocalType( &manager, &UpdateManager::SetPropertyBufferFormat, &propertyBuffer, format );
 }
 
-inline void SetPropertyBufferData( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, Vector<char>* data, size_t size )
+inline void SetPropertyBufferData( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, OwnerPointer< Vector<char> >& data, size_t size )
 {
   // Message has ownership of PropertyBuffer data while in transit from event -> update
   typedef MessageValue3< UpdateManager, Render::PropertyBuffer*, OwnerPointer< Vector<char> >, size_t  > LocalType;
@@ -1091,7 +1092,7 @@ inline void SetPropertyBufferData( UpdateManager& manager, Render::PropertyBuffe
   new (slot) LocalType( &manager, &UpdateManager::SetPropertyBufferData, &propertyBuffer, data, size );
 }
 
-inline void AddGeometry( UpdateManager& manager, Render::Geometry& geometry )
+inline void AddGeometry( UpdateManager& manager, OwnerPointer< Render::Geometry >& geometry )
 {
   // Message has ownership of Geometry while in transit from event -> update
   typedef MessageValue1< UpdateManager, OwnerPointer< Render::Geometry > > LocalType;
@@ -1100,7 +1101,7 @@ inline void AddGeometry( UpdateManager& manager, Render::Geometry& geometry )
   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &manager, &UpdateManager::AddGeometry, &geometry );
+  new (slot) LocalType( &manager, &UpdateManager::AddGeometry, geometry );
 }
 
 inline void RemoveGeometry( UpdateManager& manager, Render::Geometry& geometry )
@@ -1114,7 +1115,7 @@ inline void RemoveGeometry( UpdateManager& manager, Render::Geometry& geometry )
   new (slot) LocalType( &manager, &UpdateManager::RemoveGeometry, &geometry );
 }
 
-inline void AddVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer )
+inline void AttachVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer )
 {
   typedef MessageValue2< UpdateManager, Render::Geometry*, Render::PropertyBuffer* > LocalType;
 
@@ -1122,7 +1123,7 @@ inline void AddVertexBufferMessage( UpdateManager& manager, Render::Geometry& ge
   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &manager, &UpdateManager::AddVertexBuffer, &geometry, const_cast<Render::PropertyBuffer*>(&vertexBuffer) );
+  new (slot) LocalType( &manager, &UpdateManager::AttachVertexBuffer, &geometry, const_cast<Render::PropertyBuffer*>(&vertexBuffer) );
 }
 
 inline void RemoveVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer )
@@ -1198,7 +1199,7 @@ inline void SetGeometryTypeMessage( UpdateManager& manager, Render::Geometry& ge
   new (slot) LocalType( &manager, &UpdateManager::SetGeometryType, &geometry, geometryType );
 }
 
-inline void AddTexture( UpdateManager& manager, Render::Texture& texture )
+inline void AddTexture( UpdateManager& manager, OwnerPointer< Render::Texture >& texture )
 {
   // Message has ownership of Texture while in transit from event -> update
   typedef MessageValue1< UpdateManager, OwnerPointer< Render::Texture > > LocalType;
@@ -1207,7 +1208,7 @@ inline void AddTexture( UpdateManager& manager, Render::Texture& texture )
   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &manager, &UpdateManager::AddTexture, &texture );
+  new (slot) LocalType( &manager, &UpdateManager::AddTexture, texture );
 }
 
 inline void RemoveTexture( UpdateManager& manager, Render::Texture& texture )
@@ -1277,7 +1278,7 @@ inline void AttachColorTextureToFrameBuffer( UpdateManager& manager, Render::Fra
   new (slot) LocalType( &manager, &UpdateManager::AttachColorTextureToFrameBuffer, &frameBuffer, texture, mipmapLevel, layer );
 }
 
-inline void SetDepthIndicesMessage( UpdateManager& manager, NodeDepths* nodeDepths )
+inline void SetDepthIndicesMessage( UpdateManager& manager, OwnerPointer< NodeDepths >& nodeDepths )
 {
   typedef MessageValue1< UpdateManager, OwnerPointer< NodeDepths > > LocalType;
 
@@ -1288,7 +1289,6 @@ inline void SetDepthIndicesMessage( UpdateManager& manager, NodeDepths* nodeDept
   new (slot) LocalType( &manager, &UpdateManager::SetDepthIndices, nodeDepths );
 }
 
-
 } // namespace SceneGraph
 
 } // namespace Internal
index 85077ac..a785e3d 100644 (file)
@@ -167,7 +167,7 @@ void Node::SetRoot(bool isRoot)
   mIsRoot = isRoot;
 }
 
-void Node::AddUniformMapping( UniformPropertyMapping* map )
+void Node::AddUniformMapping( OwnerPointer< UniformPropertyMapping >& map )
 {
   PropertyOwner::AddUniformMapping( map );
   mRegenerateUniformMap = 2;
index d7f25a4..2539404 100644 (file)
@@ -732,7 +732,7 @@ public:
   /**
    * @copydoc UniformMap::Add
    */
-  void AddUniformMapping( UniformPropertyMapping* map );
+  void AddUniformMapping( OwnerPointer< UniformPropertyMapping >& map );
 
   /**
    * @copydoc UniformMap::Remove
index 6704082..93fec3c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -40,13 +40,13 @@ RenderTaskList::~RenderTaskList()
 {
 }
 
-void RenderTaskList::AddTask( RenderTask* newTask )
+void RenderTaskList::AddTask( OwnerPointer< RenderTask >& newTask )
 {
   DALI_ASSERT_DEBUG( newTask != NULL && "SceneGraph RenderTask is null");
 
-  // mRenderTasks container takes ownership
-  mRenderTasks.PushBack( newTask );
   newTask->Initialize( mRenderMessageDispatcher );
+  // mRenderTasks container takes ownership
+  mRenderTasks.PushBack( newTask.Release() );
 }
 
 void RenderTaskList::RemoveTask( RenderTask* task )
index 50542ed..6f1c320 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_LIST_H__
 
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -60,7 +60,7 @@ public:
    * Add a new RenderTask to the list.
    * @param[in] newTask The RenderTaskList takes ownership of this task.
    */
-  void AddTask( RenderTask* newTask );
+  void AddTask( OwnerPointer< RenderTask >& newTask );
 
   /**
    * Remove a RenderTask from the list.
@@ -109,7 +109,7 @@ private:
 
 // Messages for RenderTaskList
 
-inline void AddTaskMessage( EventThreadServices& eventThreadServices, RenderTaskList& list, RenderTask& task )
+inline void AddTaskMessage( EventThreadServices& eventThreadServices, RenderTaskList& list, OwnerPointer< RenderTask >& task )
 {
   // Message has ownership of the RenderTask while in transit from event -> update
   typedef MessageValue1< RenderTaskList, OwnerPointer< RenderTask > > LocalType;
@@ -118,7 +118,7 @@ inline void AddTaskMessage( EventThreadServices& eventThreadServices, RenderTask
   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &list, &RenderTaskList::AddTask, &task );
+  new (slot) LocalType( &list, &RenderTaskList::AddTask, task );
 }
 
 inline void RemoveTaskMessage( EventThreadServices& eventThreadServices, RenderTaskList& list, const RenderTask& constTask )
index 9718893..715a83f 100644 (file)
@@ -212,7 +212,7 @@ void Renderer::PrepareRender( BufferIndex updateBufferIndex )
   {
     if( mResendFlag & RESEND_DATA_PROVIDER )
     {
-      RenderDataProvider* dataProvider = NewRenderDataProvider();
+      OwnerPointer<RenderDataProvider> dataProvider = NewRenderDataProvider();
 
       typedef MessageValue1< Render::Renderer, OwnerPointer<RenderDataProvider> > DerivedType;
       unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
@@ -530,7 +530,8 @@ void Renderer::ConnectToSceneGraph( SceneController& sceneController, BufferInde
   mRenderer = Render::Renderer::New( dataProvider, mGeometry, mBlendBitmask, GetBlendColor(), static_cast< FaceCullingMode::Type >( mFaceCullingMode ),
                                          mPremultipledAlphaEnabled, mDepthWriteMode, mDepthTestMode, mDepthFunction, mStencilParameters );
 
-  mSceneController->GetRenderMessageDispatcher().AddRenderer( *mRenderer );
+  OwnerPointer< Render::Renderer > transferOwnership( mRenderer );
+  mSceneController->GetRenderMessageDispatcher().AddRenderer( transferOwnership );
 }
 
 //Called just before destroying the scene-graph renderer ( when the "event-thread renderer" is no longer referenced )