Added ObjectOwnerContainer class for scene graph objects 46/36746/2
authorDavid Steele <david.steele@partner.samsung.com>
Thu, 12 Mar 2015 14:43:53 +0000 (14:43 +0000)
committerFrancisco Santos <f1.santos@samsung.com>
Mon, 16 Mar 2015 17:30:18 +0000 (17:30 +0000)
Change-Id: I8dc407c30be0e5bb79fff014c3f1e4cd0fbdc904

dali/internal/update/common/scene-graph-property-buffer.h
dali/internal/update/effects/scene-graph-sampler.cpp
dali/internal/update/effects/scene-graph-sampler.h
dali/internal/update/manager/object-owner-container.h [new file with mode: 0644]
dali/internal/update/manager/update-manager.cpp
dali/internal/update/manager/update-manager.h

index ddbe558..82b1cd5 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <dali/public-api/common/dali-vector.h>
 #include <dali/internal/common/buffer-index.h>
+#include <dali/internal/update/common/property-owner.h>
 
 namespace Dali
 {
@@ -27,7 +28,7 @@ namespace Internal
 namespace SceneGraph
 {
 
-class PropertyBuffer
+class PropertyBuffer : public PropertyOwner
 {
 public:
   //@todo MESH_REWORK Remove when we have working property buffers
index 594b6e1..a46b554 100644 (file)
@@ -63,7 +63,7 @@ void Sampler::SetWrapMode( BufferIndex bufferIndex, WrapMode uWrap, WrapMode vWr
 {
 }
 
-const std::string& Sampler::GetUnitName()
+const std::string& Sampler::GetUnitName() const
 {
   return mUnitName;
 }
index 9f80850..c041e0a 100644 (file)
@@ -98,7 +98,7 @@ public: // SamplerDataProvider interface - called from RenderThread
    * Get the texture unit uniform name
    * @return the name of the texture unit uniform
    */
-  virtual const std::string& GetUnitName();
+  virtual const std::string& GetUnitName() const;
 
   /**
    * Get the texture ID
diff --git a/dali/internal/update/manager/object-owner-container.h b/dali/internal/update/manager/object-owner-container.h
new file mode 100644 (file)
index 0000000..2aa24b5
--- /dev/null
@@ -0,0 +1,138 @@
+#ifndef DALI_INTERNAL_SCENE_GRAPH_OBJECT_OWNER_CONTAINER
+#define DALI_INTERNAL_SCENE_GRAPH_OBJECT_OWNER_CONTAINER
+
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dali/internal/common/owner-container.h>
+#include <dali/internal/update/common/discard-queue.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace SceneGraph
+{
+class UpdateManager;
+
+/**
+ * ObjectOwnerContainer is an object which owns SceneGraph Objects.
+ * It is responsible for ensuring they are placed on a discard queue
+ * when removed from the container.
+ */
+template< class TypePointer >
+class ObjectOwnerContainer
+{
+public:
+  typedef typename Internal::OwnerContainer< TypePointer > ObjectContainer;
+  typedef typename Internal::OwnerContainer< TypePointer >::Iterator Iterator;
+
+  /**
+   * @brief Constructor - createw a new object container
+   *
+   * Object container own update side objects
+   *
+   * @param[in] sceneGraphBuffers Helper to get the correct buffer index
+   * @param[in] discardQueue Queue to discard objects that might still be in use in the render thread.
+   **/
+  ObjectOwnerContainer( SceneGraphBuffers& sceneGraphBuffers, DiscardQueue& discardQueue )
+  : mSceneGraphBuffers( sceneGraphBuffers ),
+    mDiscardQueue( discardQueue )
+  {
+  }
+
+  /**
+   * @brief Add an object to the owner
+   *
+   * @param[in] object Pointer to the object that will be owned
+   **/
+  void Add( TypePointer object )
+  {
+    mObjectContainer.PushBack( object );
+  }
+
+  /**
+   * @brief Remove an object from the owner.
+   *
+   * The object is put on the discard queue.
+   *
+   * @param[in] object Pointer to the object to be removed
+   **/
+  void Remove( TypePointer object )
+  {
+    DALI_ASSERT_DEBUG( object != NULL);
+
+    // Find the object
+    for( Iterator iter = mObjectContainer.Begin(); iter != mObjectContainer.End(); ++iter )
+    {
+      TypePointer current = *iter;
+      if ( current == object )
+      {
+        // Transfer ownership to the discard queue
+        // This keeps the object alive, until the render-thread has finished with it
+        mDiscardQueue.Add( mSceneGraphBuffers.GetUpdateBufferIndex(), mObjectContainer.Release( iter ) );
+
+        return;
+      }
+    }
+
+    // Should not reach here
+    DALI_ASSERT_DEBUG(false);
+  }
+
+  /**
+   * @brief Method to call ResetToBaseValues on all the objects owned.
+   *
+   * @param[in] bufferIndex Buffer index for double buffered values.
+   **/
+  void ResetToBaseValues( BufferIndex bufferIndex )
+  {
+    for ( Iterator iter = mObjectContainer.Begin(); iter != mObjectContainer.End(); ++iter)
+    {
+      TypePointer object = (*iter);
+      object->ResetToBaseValues( bufferIndex );
+    }
+  }
+
+  /**
+   * @brief Method to call ConstrainObjects on all the objects owned.
+   *
+   * @param[in] bufferIndex Buffer index for double buffered values.
+   **/
+  unsigned int ConstrainObjects( BufferIndex bufferIndex )
+  {
+    unsigned int numberOfConstrainedObjects = 0;
+
+    for ( Iterator iter = mObjectContainer.Begin(); iter != mObjectContainer.End(); ++iter)
+    {
+      TypePointer object = (*iter);
+      numberOfConstrainedObjects += ConstrainPropertyOwner( *object, bufferIndex );
+    }
+    return numberOfConstrainedObjects;
+  }
+
+private:
+  ObjectContainer mObjectContainer;       ///< Container for the objects owned
+  SceneGraphBuffers& mSceneGraphBuffers;  ///< Reference to a SceneGraphBuffers to get the indexBuffer
+  DiscardQueue& mDiscardQueue;            ///< Discard queue used for removed objects
+};
+
+} // namespace SceneGraph
+} // namespace Internal
+} // namespace Dali
+
+
+#endif // DALI_INTERNAL_SCENE_GRAPH_OBJECT_OWNER_CONTAINER
index 8d84728..50a4e02 100644 (file)
 #include <dali/internal/update/animation/scene-graph-animation.h>
 #include <dali/internal/update/common/discard-queue.h>
 #include <dali/internal/update/common/scene-graph-buffers.h>
+#include <dali/internal/update/common/scene-graph-property-buffer.h>
 #include <dali/internal/update/controllers/render-message-dispatcher.h>
 #include <dali/internal/update/controllers/scene-controller-impl.h>
 #include <dali/internal/update/effects/scene-graph-material.h>
+#include <dali/internal/update/effects/scene-graph-sampler.h>
 #include <dali/internal/update/geometry/scene-graph-geometry.h>
 #include <dali/internal/update/gestures/scene-graph-pan-gesture.h>
+#include <dali/internal/update/manager/object-owner-container.h>
 #include <dali/internal/update/manager/prepare-render-algorithms.h>
 #include <dali/internal/update/manager/process-render-tasks.h>
 #include <dali/internal/update/manager/sorted-layers.h>
@@ -126,14 +129,6 @@ void DestroyNodeSet( std::set<Node*>& nodeSet )
 
 } //namespace
 
-typedef OwnerContainer< Geometry* >            GeometryContainer;
-typedef GeometryContainer::Iterator            GeometryIter;
-typedef GeometryContainer::ConstIterator       GeometryConstIter;
-
-typedef OwnerContainer< Material* >            MaterialContainer;
-typedef MaterialContainer::Iterator            MaterialIter;
-typedef MaterialContainer::ConstIterator       MaterialConstIter;
-
 typedef OwnerContainer< Shader* >              ShaderContainer;
 typedef ShaderContainer::Iterator              ShaderIter;
 typedef ShaderContainer::ConstIterator         ShaderConstIter;
@@ -179,6 +174,10 @@ struct UpdateManager::Impl
     systemLevelTaskList ( completeStatusManager ),
     root( NULL ),
     systemLevelRoot( NULL ),
+    geometries( sceneGraphBuffers, discardQueue ),
+    materials( sceneGraphBuffers, discardQueue ),
+    samplers( sceneGraphBuffers, discardQueue ),
+    propertyBuffers( sceneGraphBuffers, discardQueue ),
     messageQueue( renderController, sceneGraphBuffers ),
     dynamicsChanged( false ),
     keepRenderingSeconds( 0.0f ),
@@ -268,8 +267,10 @@ struct UpdateManager::Impl
   AnimationContainer                  animations;                    ///< A container of owned animations
   PropertyNotificationContainer       propertyNotifications;         ///< A container of owner property notifications.
 
-  GeometryContainer                   geometries;                    ///< A container of geometries
-  MaterialContainer                   materials;                     ///< A container of materials
+  ObjectOwnerContainer<Geometry*>     geometries;                    ///< A container of geometries
+  ObjectOwnerContainer<Material*>     materials;                     ///< A container of materials
+  ObjectOwnerContainer<Sampler*>      samplers;                      ///< A container of samplers
+  ObjectOwnerContainer<PropertyBuffer*> propertyBuffers;             ///< A container of property buffers
 
   ShaderContainer                     shaders;                       ///< A container of owned shaders
 
@@ -532,66 +533,24 @@ void UpdateManager::PropertyNotificationSetNotify( PropertyNotification* propert
   propertyNotification->SetNotifyMode( notifyMode );
 }
 
-
-void UpdateManager::AddGeometry( Geometry* geometry )
+ObjectOwnerContainer<Geometry*>& UpdateManager::GetGeometryOwner()
 {
-  DALI_ASSERT_DEBUG( NULL != geometry );
-  mImpl->geometries.PushBack( geometry );
+  return mImpl->geometries;
 }
 
-void UpdateManager::RemoveGeometry( Geometry* geometry )
+ObjectOwnerContainer<Material*>& UpdateManager::GetMaterialOwner()
 {
-  DALI_ASSERT_DEBUG(geometry != NULL);
-
-  GeometryContainer& geometries = mImpl->geometries;
-
-  // Find the geometry and destroy it
-  for ( GeometryIter iter = geometries.Begin(); iter != geometries.End(); ++iter )
-  {
-    Geometry& current = **iter;
-    if ( &current == geometry )
-    {
-      // Transfer ownership to the discard queue
-      // This keeps the geometry alive, until the render-thread has finished with it
-      mImpl->discardQueue.Add( mSceneGraphBuffers.GetUpdateBufferIndex(), geometries.Release( iter ) );
-
-      return;
-    }
-  }
-
-  // Should not reach here
-  DALI_ASSERT_DEBUG(false);
+  return mImpl->materials;
 }
 
-void UpdateManager::AddMaterial( Material* material )
+ObjectOwnerContainer<Sampler*>& UpdateManager::GetSamplerOwner()
 {
-  DALI_ASSERT_DEBUG( NULL != material );
-
-  mImpl->materials.PushBack( material );
+  return mImpl->samplers;
 }
 
-void UpdateManager::RemoveMaterial( Material* material )
+ObjectOwnerContainer<PropertyBuffer*>& UpdateManager::GetPropertyBufferOwner()
 {
-  DALI_ASSERT_DEBUG(material != NULL);
-
-  MaterialContainer& materials = mImpl->materials;
-
-  // Find the material and destroy it
-  for ( MaterialIter iter = materials.Begin(); iter != materials.End(); ++iter )
-  {
-    Material& current = **iter;
-    if ( &current == material )
-    {
-      // Transfer ownership to the discard queue
-      // This keeps the material alive, until the render-thread has finished with it
-      mImpl->discardQueue.Add( mSceneGraphBuffers.GetUpdateBufferIndex(), materials.Release( iter ) );
-
-      materials.Erase(iter);
-      return;
-    }
-  }
-  // Should not reach here
-  DALI_ASSERT_DEBUG(false);
+  return mImpl->propertyBuffers;
 }
 
 void UpdateManager::AddShader( Shader* shader )
@@ -712,6 +671,8 @@ void UpdateManager::ResetProperties()
 {
   PERF_MONITOR_START(PerformanceMonitor::RESET_PROPERTIES);
 
+  BufferIndex bufferIndex = mSceneGraphBuffers.GetUpdateBufferIndex();
+
   // Clear the "animations finished" flag; This should be set if any (previously playing) animation is stopped
   mImpl->animationFinishedDuringUpdate = false;
 
@@ -739,7 +700,7 @@ void UpdateManager::ResetProperties()
   for( std::set<Node*>::iterator iter = mImpl->activeDisconnectedNodes.begin(); mImpl->activeDisconnectedNodes.end() != iter; iter = mImpl->activeDisconnectedNodes.begin() )
   {
     Node* node = *iter;
-    node->ResetToBaseValues( mSceneGraphBuffers.GetUpdateBufferIndex() );
+    node->ResetToBaseValues( bufferIndex );
     node->SetActive( false );
 
     // Move everything from activeDisconnectedNodes to disconnectedNodes (no need to reset again)
@@ -752,7 +713,7 @@ void UpdateManager::ResetProperties()
 
   for (RenderTaskList::RenderTaskContainer::ConstIterator iter = systemLevelTasks.Begin(); iter != systemLevelTasks.End(); ++iter)
   {
-    (*iter)->ResetToBaseValues( mSceneGraphBuffers.GetUpdateBufferIndex() );
+    (*iter)->ResetToBaseValues( bufferIndex );
   }
 
   // Reset render-task list properties to base values.
@@ -760,31 +721,25 @@ void UpdateManager::ResetProperties()
 
   for (RenderTaskList::RenderTaskContainer::ConstIterator iter = tasks.Begin(); iter != tasks.End(); ++iter)
   {
-    (*iter)->ResetToBaseValues( mSceneGraphBuffers.GetUpdateBufferIndex() );
+    (*iter)->ResetToBaseValues( bufferIndex );
   }
 
   // Reset custom object properties to base values
   for (OwnerContainer<PropertyOwner*>::Iterator iter = mImpl->customObjects.Begin(); iter != mImpl->customObjects.End(); ++iter)
   {
-    (*iter)->ResetToBaseValues( mSceneGraphBuffers.GetUpdateBufferIndex() );
+    (*iter)->ResetToBaseValues( bufferIndex );
   }
 
-  // Reset animatable material properties to base values
-  for (MaterialIter iter = mImpl->materials.Begin(); iter != mImpl->materials.End(); ++iter)
-  {
-    (*iter)->ResetToBaseValues( mSceneGraphBuffers.GetUpdateBufferIndex() );
-  }
+  mImpl->materials.ResetToBaseValues( bufferIndex );
+  mImpl->geometries.ResetToBaseValues( bufferIndex );
+  mImpl->propertyBuffers.ResetToBaseValues( bufferIndex );
+  mImpl->samplers.ResetToBaseValues( bufferIndex );
 
-  // Reset animatable geometry properties to base values
-  for (GeometryIter iter = mImpl->geometries.Begin(); iter != mImpl->geometries.End(); ++iter)
-  {
-    (*iter)->ResetToBaseValues( mSceneGraphBuffers.GetUpdateBufferIndex() );
-  }
 
   // Reset animatable shader properties to base values
   for (ShaderIter iter = mImpl->shaders.Begin(); iter != mImpl->shaders.End(); ++iter)
   {
-    (*iter)->ResetToBaseValues( mSceneGraphBuffers.GetUpdateBufferIndex() );
+    (*iter)->ResetToBaseValues( bufferIndex );
   }
 
   PERF_MONITOR_END(PerformanceMonitor::RESET_PROPERTIES);
@@ -844,6 +799,8 @@ void UpdateManager::ApplyConstraints()
 {
   PERF_MONITOR_START(PerformanceMonitor::APPLY_CONSTRAINTS);
 
+  BufferIndex bufferIndex = mSceneGraphBuffers.GetUpdateBufferIndex();
+
   mImpl->activeConstraints = 0;
 
   // constrain custom objects... (in construction order)
@@ -853,18 +810,18 @@ void UpdateManager::ApplyConstraints()
   for ( OwnerContainer< PropertyOwner* >::Iterator iter = customObjects.Begin(); endIter != iter; ++iter )
   {
     PropertyOwner& object = **iter;
-    mImpl->activeConstraints += ConstrainPropertyOwner( object, mSceneGraphBuffers.GetUpdateBufferIndex() );
+    mImpl->activeConstraints += ConstrainPropertyOwner( object, bufferIndex );
   }
 
   // constrain nodes... (in Depth First traversal order)
   if ( mImpl->root )
   {
-    mImpl->activeConstraints += ConstrainNodes( *(mImpl->root), mSceneGraphBuffers.GetUpdateBufferIndex() );
+    mImpl->activeConstraints += ConstrainNodes( *(mImpl->root), bufferIndex );
   }
 
   if ( mImpl->systemLevelRoot )
   {
-    mImpl->activeConstraints += ConstrainNodes( *(mImpl->systemLevelRoot), mSceneGraphBuffers.GetUpdateBufferIndex() );
+    mImpl->activeConstraints += ConstrainNodes( *(mImpl->systemLevelRoot), bufferIndex );
   }
 
   // constrain other property-owners after nodes as they are more likely to depend on a node's
@@ -882,7 +839,7 @@ void UpdateManager::ApplyConstraints()
   for ( RenderTaskList::RenderTaskContainer::ConstIterator iter = systemLevelTasks.Begin(); iter != systemLevelTasks.End(); ++iter )
   {
     RenderTask& task = **iter;
-    mImpl->activeConstraints += ConstrainPropertyOwner( task, mSceneGraphBuffers.GetUpdateBufferIndex() );
+    mImpl->activeConstraints += ConstrainPropertyOwner( task, bufferIndex );
   }
 
   // Constrain render-tasks
@@ -891,23 +848,14 @@ void UpdateManager::ApplyConstraints()
   for ( RenderTaskList::RenderTaskContainer::ConstIterator iter = tasks.Begin(); iter != tasks.End(); ++iter )
   {
     RenderTask& task = **iter;
-    mImpl->activeConstraints += ConstrainPropertyOwner( task, mSceneGraphBuffers.GetUpdateBufferIndex() );
+    mImpl->activeConstraints += ConstrainPropertyOwner( task, bufferIndex );
   }
 
   // Constrain Materials and geometries
-  MaterialContainer& materials = mImpl->materials;
-  for ( MaterialIter iter = materials.Begin(); iter != materials.End(); ++iter )
-  {
-    Material& material = **iter;
-    mImpl->activeConstraints += ConstrainPropertyOwner( material, mSceneGraphBuffers.GetUpdateBufferIndex() );
-  }
-
-  GeometryContainer& geometries = mImpl->geometries;
-  for ( GeometryIter iter = geometries.Begin(); iter != geometries.End(); ++iter )
-  {
-    Geometry& geometry = **iter;
-    mImpl->activeConstraints += ConstrainPropertyOwner( geometry, mSceneGraphBuffers.GetUpdateBufferIndex() );
-  }
+  mImpl->activeConstraints += mImpl->materials.ConstrainObjects( bufferIndex );
+  mImpl->activeConstraints += mImpl->geometries.ConstrainObjects( bufferIndex );
+  mImpl->activeConstraints += mImpl->samplers.ConstrainObjects( bufferIndex );
+  mImpl->activeConstraints += mImpl->propertyBuffers.ConstrainObjects( bufferIndex );
 
   // constrain shaders... (in construction order)
   ShaderContainer& shaders = mImpl->shaders;
@@ -915,7 +863,7 @@ void UpdateManager::ApplyConstraints()
   for ( ShaderIter iter = shaders.Begin(); iter != shaders.End(); ++iter )
   {
     Shader& shader = **iter;
-    mImpl->activeConstraints += ConstrainPropertyOwner( shader, mSceneGraphBuffers.GetUpdateBufferIndex() );
+    mImpl->activeConstraints += ConstrainPropertyOwner( shader, bufferIndex );
   }
 
   PERF_MONITOR_END(PerformanceMonitor::APPLY_CONSTRAINTS);
@@ -926,12 +874,12 @@ void UpdateManager::ProcessPropertyNotifications()
   PropertyNotificationContainer &notifications = mImpl->propertyNotifications;
   PropertyNotificationIter iter = notifications.Begin();
 
+  BufferIndex bufferIndex = mSceneGraphBuffers.GetUpdateBufferIndex();
+
   while ( iter != notifications.End() )
   {
     PropertyNotification* notification = *iter;
-
-    bool valid = notification->Check( mSceneGraphBuffers.GetUpdateBufferIndex() );
-
+    bool valid = notification->Check( bufferIndex );
     if(valid)
     {
       mImpl->notificationManager.QueueMessage( PropertyChangedMessage( mImpl->propertyNotifier, notification, notification->GetValidity() ) );
@@ -980,14 +928,16 @@ unsigned int UpdateManager::Update( float elapsedSeconds,
   // Measure the time spent in UpdateManager::Update
   PERF_MONITOR_START(PerformanceMonitor::UPDATE);
 
+  BufferIndex bufferIndex = mSceneGraphBuffers.GetUpdateBufferIndex();
+
   // Update the frame time delta on the render thread.
   mImpl->renderManager.SetFrameDeltaTime(elapsedSeconds);
 
   // 1) Clear nodes/resources which were previously discarded
-  mImpl->discardQueue.Clear( mSceneGraphBuffers.GetUpdateBufferIndex() );
+  mImpl->discardQueue.Clear( bufferIndex );
 
   // 2) Grab any loaded resources
-  bool resourceChanged = mImpl->resourceManager.UpdateCache( mSceneGraphBuffers.GetUpdateBufferIndex() );
+  bool resourceChanged = mImpl->resourceManager.UpdateCache( bufferIndex );
 
   // 3) Process Touches & Gestures
   mImpl->touchResampler.Update();
@@ -1014,7 +964,7 @@ unsigned int UpdateManager::Update( float elapsedSeconds,
   mImpl->messageQueue.ProcessMessages();
 
   // 6) Post Process Ids of resources updated by renderer
-  mImpl->resourceManager.PostProcessResources( mSceneGraphBuffers.GetUpdateBufferIndex() );
+  mImpl->resourceManager.PostProcessResources( bufferIndex );
 
   // Although the scene-graph may not require an update, we still need to synchronize double-buffered
   // renderer lists if the scene was updated in the previous frame.
@@ -1050,8 +1000,8 @@ unsigned int UpdateManager::Update( float elapsedSeconds,
     // 13) Prepare for the next render
     PERF_MONITOR_START(PerformanceMonitor::PREPARE_RENDERABLES);
 
-    PrepareRenderables( mSceneGraphBuffers.GetUpdateBufferIndex(), mImpl->sortedLayers );
-    PrepareRenderables( mSceneGraphBuffers.GetUpdateBufferIndex(), mImpl->systemLevelSortedLayers );
+    PrepareRenderables( bufferIndex, mImpl->sortedLayers );
+    PrepareRenderables( bufferIndex, mImpl->systemLevelSortedLayers );
     PERF_MONITOR_END(PerformanceMonitor::PREPARE_RENDERABLES);
 
     PERF_MONITOR_START(PerformanceMonitor::PROCESS_RENDER_TASKS);
@@ -1063,7 +1013,7 @@ unsigned int UpdateManager::Update( float elapsedSeconds,
 
     if ( NULL != mImpl->root )
     {
-      ProcessRenderTasks(  mSceneGraphBuffers.GetUpdateBufferIndex(),
+      ProcessRenderTasks(  bufferIndex,
                            mImpl->completeStatusManager,
                            mImpl->taskList,
                            *mImpl->root,
@@ -1074,7 +1024,7 @@ unsigned int UpdateManager::Update( float elapsedSeconds,
       // Process the system-level RenderTasks last
       if ( NULL != mImpl->systemLevelRoot )
       {
-        ProcessRenderTasks(  mSceneGraphBuffers.GetUpdateBufferIndex(),
+        ProcessRenderTasks(  bufferIndex,
                              mImpl->completeStatusManager,
                              mImpl->systemLevelTaskList,
                              *mImpl->systemLevelRoot,
@@ -1097,7 +1047,7 @@ unsigned int UpdateManager::Update( float elapsedSeconds,
     renderTask.UpdateState();
 
     if( renderTask.IsWaitingToRender() &&
-        renderTask.ReadyToRender(mSceneGraphBuffers.GetUpdateBufferIndex()) /*avoid updating forever when source actor is off-stage*/ )
+        renderTask.ReadyToRender( bufferIndex ) /*avoid updating forever when source actor is off-stage*/ )
     {
       mImpl->renderTaskWaiting = true; // keep update/render threads alive
     }
index 53a4cc9..0666b2a 100644 (file)
 #include <dali/internal/update/animation/scene-graph-animation.h>
 #include <dali/internal/update/common/scene-graph-buffers.h>
 #include <dali/internal/update/common/scene-graph-property-notification.h>
+#include <dali/internal/update/manager/object-owner-container.h>
 #include <dali/internal/update/node-attachments/node-attachment.h>
 #include <dali/internal/update/nodes/node.h>
 #include <dali/internal/update/nodes/scene-graph-layer.h>
 
 #include <dali/internal/render/shaders/scene-graph-shader.h>
 
-//@todo MESH_REWORK Move messages to a separate file to avoid having dependent headers
-// pollute core & slow the build down.
-#include <dali/internal/update/geometry/scene-graph-geometry.h>
-#include <dali/internal/update/effects/scene-graph-material.h>
-
 
 namespace Dali
 {
@@ -80,6 +76,10 @@ class RenderTaskList;
 class RenderQueue;
 class DynamicsWorld;
 class TextureCache;
+class Geometry;
+class PropertyBuffer;
+class Material;
+class Sampler;
 
 /**
  * UpdateManager holds a scene graph i.e. a tree of nodes.
@@ -267,30 +267,34 @@ public:
    */
   void PropertyNotificationSetNotify( PropertyNotification* propertyNotification, PropertyNotification::NotifyMode notifyMode );
 
-
   /**
-   * Add a geometry to the scene graph
-   * @param[in] geometry The geometry to add
+   * @brief Get the geometry owner
+   *
+   * @return The geometry owner
    */
-  void AddGeometry( Geometry* geometry );
+  ObjectOwnerContainer<Geometry*>& GetGeometryOwner();
 
   /**
-   * Remove a geometry from the scene graph
-   * @param[in] geometry The geometry to remove
+   * @brief Get the material owner
+   *
+   * @return The material owner
    */
-  void RemoveGeometry( Geometry* geometry );
+  ObjectOwnerContainer<Material*>& GetMaterialOwner();
 
   /**
-   * Add a material to the scene graph
-   * @param[in] material The material to add
+   * @brief Get the sampler owner
+   *
+   * @return The sampler owner
    */
-  void AddMaterial( Material* material );
+  ObjectOwnerContainer<Sampler*>& GetSamplerOwner();
 
   /**
-   * Remove a material from the scene graph
-   * @param[in] material The material to remove
+   * @brief Get the property buffer owner
+   *
+   * @return The property buffer owner
    */
-  void RemoveMaterial( Material* material );
+  ObjectOwnerContainer<PropertyBuffer*>& GetPropertyBufferOwner();
+
 
   // Shaders
 
@@ -655,51 +659,6 @@ inline void PropertyNotificationSetNotifyModeMessage( UpdateManager& manager,
   new (slot) LocalType( &manager, &UpdateManager::PropertyNotificationSetNotify, propertyNotification, notifyMode );
 }
 
-inline void AddGeometryMessage( UpdateManager& manager, Geometry& geometry )
-{
-  typedef MessageValue1< UpdateManager, OwnerPointer< Geometry > > LocalType;
-
-  // Reserve some memory inside the message queue
-  unsigned int* slot = manager.GetEventToUpdate().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 );
-}
-
-// The render thread can safely change the Geometry
-inline void RemoveGeometryMessage( UpdateManager& manager, Geometry& geometry )
-{
-  typedef MessageValue1< UpdateManager, Geometry* > LocalType;
-
-  // Reserve some memory inside the message queue
-  unsigned int* slot = manager.GetEventToUpdate().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::RemoveGeometry, &geometry );
-}
-
-inline void AddMaterialMessage( UpdateManager& manager, Material& material )
-{
-  typedef MessageValue1< UpdateManager, OwnerPointer< Material > > LocalType;
-
-  // Reserve some memory inside the message queue
-  unsigned int* slot = manager.GetEventToUpdate().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::AddMaterial, &material );
-}
-
-// The render thread can safely change the Material
-inline void RemoveMaterialMessage( UpdateManager& manager, Material& material )
-{
-  typedef MessageValue1< UpdateManager, Material* > LocalType;
-
-  // Reserve some memory inside the message queue
-  unsigned int* slot = manager.GetEventToUpdate().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::RemoveMaterial, &material );
-}
 
 
 // The render thread can safely change the Shader
@@ -842,6 +801,29 @@ inline void TerminateDynamicsWorldMessage(UpdateManager& manager)
 
 #endif // DYNAMICS_SUPPORT
 
+
+template< typename T >
+inline void AddMessage( UpdateManager& manager, ObjectOwnerContainer<T>& owner, T& object )
+{
+  typedef MessageValue1< ObjectOwnerContainer<T>, OwnerPointer< T > > LocalType;
+
+  // Reserve some memory inside the message queue
+  unsigned int* slot = manager.GetEventToUpdate().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, &ObjectOwnerContainer<T>::Add, &object );
+}
+
+template< typename T >
+inline void RemoveMessage( UpdateManager& manager, ObjectOwnerContainer<T>& owner, T& object )
+{
+  typedef MessageValue1< ObjectOwnerContainer<T>, OwnerPointer< T > > LocalType;
+
+  // Reserve some memory inside the message queue
+  unsigned int* slot = manager.GetEventToUpdate().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, &ObjectOwnerContainer<T>::Remove, &object );
+}
+
 } // namespace SceneGraph
 
 } // namespace Internal