Remove obsolete template and harmonize UpdateManager code 87/127987/8
authorKimmo Hoikka <kimmo.hoikka@samsung.com>
Wed, 3 May 2017 13:04:41 +0000 (14:04 +0100)
committerKimmo Hoikka <kimmo.hoikka@samsung.com>
Wed, 3 May 2017 16:43:52 +0000 (17:43 +0100)
- typedef containers in same naming convention
- use helpers to iterate containers
- remove obsolete object owner container and related unnecessary templated code
- put method definitions in declaration order
- data members in size order

Change-Id: I650f7b6714390504294d8d31111890fea8bc9059

dali/internal/event/rendering/renderer-impl.cpp
dali/internal/render/shaders/scene-graph-shader.cpp
dali/internal/render/shaders/scene-graph-shader.h
dali/internal/update/manager/object-owner-container.h [deleted file]
dali/internal/update/manager/update-manager.cpp
dali/internal/update/manager/update-manager.h
dali/internal/update/rendering/scene-graph-renderer.h

index f5efe54..b043b97 100644 (file)
@@ -854,7 +854,7 @@ void Renderer::Initialize()
   SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
 
   mSceneObject = SceneGraph::Renderer::New();
-  AddMessage( updateManager, updateManager.GetRendererOwner(), *mSceneObject );
+  AddRendererMessage( updateManager, *mSceneObject );
 
   eventThreadServices.RegisterObject( this );
 }
@@ -881,7 +881,7 @@ Renderer::~Renderer()
   {
     EventThreadServices& eventThreadServices = GetEventThreadServices();
     SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
-    RemoveMessage( updateManager, updateManager.GetRendererOwner(), *mSceneObject );
+    RemoveRendererMessage( updateManager, *mSceneObject );
 
     eventThreadServices.UnregisterObject( this );
   }
index d8f1e86..dc78aed 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.
@@ -68,14 +68,6 @@ Program* Shader::GetProgram()
   return mProgram;
 }
 
-void Shader::ConnectToSceneGraph( SceneController& sceneController, BufferIndex bufferIndex )
-{
-}
-
-void Shader::DisconnectFromSceneGraph( SceneController& sceneController, BufferIndex bufferIndex )
-{
-}
-
 void Shader::AddConnectionObserver( ConnectionChangePropagator::Observer& observer )
 {
   mConnectionObservers.Add(observer);
index 876d4eb..5caeda6 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_INTERNAL_SCENE_GRAPH_SHADER_H__
 
 /*
- * 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.
@@ -56,7 +56,7 @@ public:
   virtual ~Shader();
 
   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-  // The following methods are called during UpdateManager::Update()
+  // The following methods are called during Update
   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
   /**
@@ -95,7 +95,7 @@ public:
   }
 
   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-  // The following methods are called in Render thread
+  // The following methods are called during Render
   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
   /**
@@ -115,23 +115,6 @@ public:
    */
   Program* GetProgram();
 
-public: // Implementation of ObjectOwnerContainer template methods
-
-  /**
-   * Connect the object to the scene graph
-   *
-   * @param[in] sceneController The scene controller - used for sending messages to render thread
-   * @param[in] bufferIndex The current buffer index - used for sending messages to render thread
-   */
-  void ConnectToSceneGraph( SceneController& sceneController, BufferIndex bufferIndex );
-
-  /**
-   * Disconnect the object from the scene graph
-   * @param[in] sceneController The scene controller - used for sending messages to render thread
-   * @param[in] bufferIndex The current buffer index - used for sending messages to render thread
-   */
-  void DisconnectFromSceneGraph( SceneController& sceneController, BufferIndex bufferIndex );
-
 public: // Implementation of ConnectionChangePropagator
 
   /**
@@ -144,8 +127,6 @@ public: // Implementation of ConnectionChangePropagator
    */
   void RemoveConnectionObserver(ConnectionChangePropagator::Observer& observer);
 
-public:
-
 public: // UniformMap::Observer
   /**
    * @copydoc UniformMap::Observer::UniformMappingsChanged
diff --git a/dali/internal/update/manager/object-owner-container.h b/dali/internal/update/manager/object-owner-container.h
deleted file mode 100644 (file)
index 3f6e739..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-#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.
- */
-
-// EXTERNAL INCLUDES
-#include <algorithm>
-
-// INTERNAL INCLUDES
-#include <dali/devel-api/common/owner-container.h>
-#include <dali/internal/update/common/discard-queue.h>
-#include <dali/internal/update/controllers/scene-controller.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 Type >
-class ObjectOwnerContainer
-{
-public:
-  typedef typename Dali::OwnerContainer< Type* > ObjectContainer;
-  typedef typename Dali::OwnerContainer< Type* >::Iterator Iterator;
-
-  /**
-   * @brief Constructor - create 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 )
-  : mSceneController( NULL ),
-    mSceneGraphBuffers( sceneGraphBuffers ),
-    mDiscardQueue( discardQueue )
-  {
-  }
-
-  /**
-   * @brief Set the SceneController on this owner
-   *
-   * @param[in] sceneController The SceneController
-   **/
-  void SetSceneController( SceneController& sceneController )
-  {
-    mSceneController = &sceneController;
-  }
-
-  /**
-   * @brief Add an object to the owner
-   *
-   * @param[in] object Pointer to the object that will be owned
-   **/
-  void Add( Type* pointer )
-  {
-    DALI_ASSERT_DEBUG( pointer && "Pointer should not be null" );
-
-    mObjectContainer.PushBack( pointer );
-
-    pointer->ConnectToSceneGraph(*mSceneController, mSceneGraphBuffers.GetUpdateBufferIndex() );
-  }
-
-  /**
-   * @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( Type* pointer )
-  {
-    DALI_ASSERT_DEBUG( pointer && "Pointer should not be null" );
-
-    // Find the object
-    Iterator match = std::find( mObjectContainer.Begin(), mObjectContainer.End(), pointer );
-    DALI_ASSERT_DEBUG( match != mObjectContainer.End() && "Should always find a match" );
-
-    mDiscardQueue.Add( mSceneGraphBuffers.GetUpdateBufferIndex(), mObjectContainer.Release( match ) );
-    pointer->DisconnectFromSceneGraph(*mSceneController, mSceneGraphBuffers.GetUpdateBufferIndex() );
-  }
-
-  /**
-   * @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)
-    {
-      Type* object = (*iter);
-      object->ResetToBaseValues( bufferIndex );
-    }
-  }
-
-  /**
-   * @brief Method to call ConstrainObjects on all the objects owned.
-   *
-   * @param[in] bufferIndex Buffer index for double buffered values.
-   **/
-  void ConstrainObjects( BufferIndex bufferIndex )
-  {
-    for ( Iterator iter = mObjectContainer.Begin(); iter != mObjectContainer.End(); ++iter)
-    {
-      Type* object = (*iter);
-      ConstrainPropertyOwner( *object, bufferIndex );
-    }
-  }
-
-  const ObjectContainer& GetObjectContainer()
-  {
-    return mObjectContainer;
-  }
-
-private:
-  SceneController* mSceneController;      ///< SceneController used to send messages
-  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 cac355a..1327074 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.
@@ -44,7 +44,6 @@
 #include <dali/internal/update/controllers/render-message-dispatcher.h>
 #include <dali/internal/update/controllers/scene-controller-impl.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/render-task-processor.h>
 #include <dali/internal/update/manager/sorted-layers.h>
 #include <dali/internal/update/manager/update-algorithms.h>
@@ -55,7 +54,6 @@
 #include <dali/internal/update/queue/update-message-queue.h>
 #include <dali/internal/update/render-tasks/scene-graph-render-task.h>
 #include <dali/internal/update/render-tasks/scene-graph-render-task-list.h>
-#include <dali/internal/update/rendering/scene-graph-texture-set.h>
 #include <dali/internal/update/render-tasks/scene-graph-camera.h>
 
 #include <dali/internal/render/common/render-instruction-container.h>
@@ -99,19 +97,65 @@ namespace Internal
 namespace SceneGraph
 {
 
-typedef OwnerContainer< Shader* >              ShaderContainer;
-typedef ShaderContainer::Iterator              ShaderIter;
-typedef ShaderContainer::ConstIterator         ShaderConstIter;
+namespace
+{
+/**
+ * Helper to reset animate-able objects to base values
+ * @param container to iterate over
+ * @param updateBufferIndex to use
+ */
+template< class T >
+inline void ResetToBaseValues( OwnerContainer<T*>& container, BufferIndex updateBufferIndex )
+{
+  // Reset animatable properties to base values
+  typename OwnerContainer<T*>::Iterator iter = container.Begin();
+  const typename OwnerContainer<T*>::ConstIterator endIter = container.End();
+  for ( ; iter != endIter; ++iter )
+  {
+    (*iter)->ResetToBaseValues( updateBufferIndex );
+  }
+}
 
+/**
+ * Helper to Erase an object from OwnerContainer using discard queue
+ * @param container to remove from
+ * @param object to remove
+ * @param discardQueue to put the object to
+ * @param updateBufferIndex to use
+ */
+template < class T >
+inline void EraseUsingDiscardQueue( OwnerContainer<T*>& container, T* object, DiscardQueue& discardQueue, BufferIndex updateBufferIndex )
+{
+  typename OwnerContainer<T*>::Iterator iter = container.Begin();
+  const typename OwnerContainer<T*>::ConstIterator endIter = container.End();
+  for ( ; iter != endIter; ++iter )
+  {
+    if ( *iter == object )
+    {
+      // Transfer ownership to the discard queue, this keeps the object alive, until the render-thread has finished with it
+      discardQueue.Add( updateBufferIndex, container.Release( iter ) );
+      return;
+    }
+  }
+}
+
+}
+
+typedef OwnerContainer< Shader* >              ShaderOwner;
+typedef ShaderOwner::Iterator                  ShaderIter;
 typedef std::vector<Internal::ShaderDataPtr>   ShaderDataBinaryQueue;
 
-typedef OwnerContainer<PanGesture*>            GestureContainer;
-typedef GestureContainer::Iterator             GestureIter;
-typedef GestureContainer::ConstIterator        GestureConstIter;
+typedef OwnerContainer< TextureSet* >          TextureSetOwner;
+typedef TextureSetOwner::Iterator              TextureSetIter;
 
-typedef OwnerContainer< TextureSet* >          TextureSetContainer;
-typedef TextureSetContainer::Iterator          TextureSetIter;
-typedef TextureSetContainer::ConstIterator     TextureSetConstIter;
+typedef OwnerContainer<Renderer*>              RendererOwner;
+typedef RendererOwner::Iterator                RendererIter;
+
+typedef OwnerContainer<PanGesture*>            GestureOwner;
+typedef GestureOwner::Iterator                 GestureIter;
+
+typedef OwnerContainer< Camera* >              CameraOwner;
+typedef OwnerContainer< PropertyOwner* >       CustomObjectOwner;
 
 /**
  * Structure to contain UpdateManager internal data
@@ -145,20 +189,20 @@ struct UpdateManager::Impl
     systemLevelTaskList( renderMessageDispatcher ),
     root( NULL ),
     systemLevelRoot( NULL ),
-    renderers( sceneGraphBuffers, discardQueue ),
+    renderers(),
     textureSets(),
+    shaders(),
+    gestures(),
     messageQueue( renderController, sceneGraphBuffers ),
     keepRenderingSeconds( 0.0f ),
-    animationFinishedDuringUpdate( false ),
     nodeDirtyFlags( TransformFlag ), // set to TransformFlag to ensure full update the first time through Update()
-    previousUpdateScene( false ),
     frameCounter( 0 ),
+    animationFinishedDuringUpdate( false ),
+    previousUpdateScene( false ),
     renderTaskWaiting( false )
   {
     sceneController = new SceneControllerImpl( renderMessageDispatcher, renderQueue, discardQueue );
 
-    renderers.SetSceneController( *sceneController );
-
     // create first 'dummy' node
     nodes.PushBack(0u);
   }
@@ -235,16 +279,16 @@ struct UpdateManager::Impl
   SortedLayerPointers                 sortedLayers;                  ///< A container of Layer pointers sorted by depth
   SortedLayerPointers                 systemLevelSortedLayers;       ///< A separate container of system-level Layers
 
-  OwnerContainer< Camera* >           cameras;                       ///< A container of cameras
-  OwnerContainer< PropertyOwner* >    customObjects;                 ///< A container of owned objects (with custom properties)
+  CameraOwner                         cameras;                       ///< A container of cameras
+  CustomObjectOwner                   customObjects;                 ///< A container of owned objects (with custom properties)
 
   AnimationContainer                  animations;                    ///< A container of owned animations
   PropertyNotificationContainer       propertyNotifications;         ///< A container of owner property notifications.
 
-  ObjectOwnerContainer<Renderer>      renderers;
-  TextureSetContainer                 textureSets;                   ///< A container of texture sets
-
-  ShaderContainer                     shaders;                       ///< A container of owned shaders
+  RendererOwner                       renderers;                     ///< A container of owned renderers
+  TextureSetOwner                     textureSets;                   ///< A container of owned texture sets
+  ShaderOwner                         shaders;                       ///< A container of owned shaders
+  GestureOwner                        gestures;                      ///< A container of owned gesture detectors
 
   MessageQueue                        messageQueue;                  ///< The messages queued from the event-thread
   ShaderDataBinaryQueue               renderCompiledShaders;         ///< Shaders compiled on Render thread are inserted here for update thread to pass on to event thread.
@@ -252,14 +296,11 @@ struct UpdateManager::Impl
   Mutex                               compiledShaderMutex;           ///< lock to ensure no corruption on the renderCompiledShaders
 
   float                               keepRenderingSeconds;          ///< Set via Dali::Stage::KeepRendering
-  bool                                animationFinishedDuringUpdate; ///< Flag whether any animations finished during the Update()
-
   int                                 nodeDirtyFlags;                ///< cumulative node dirty flags from previous frame
-  bool                                previousUpdateScene;           ///< True if the scene was updated in the previous frame (otherwise it was optimized out)
-
   int                                 frameCounter;                  ///< Frame counter used in debugging to choose which frame to debug and which to ignore.
 
-  GestureContainer                    gestures;                      ///< A container of owned gesture detectors
+  bool                                animationFinishedDuringUpdate; ///< Flag whether any animations finished during the Update()
+  bool                                previousUpdateScene;           ///< True if the scene was updated in the previous frame (otherwise it was optimized out)
   bool                                renderTaskWaiting;             ///< A REFRESH_ONCE render task is waiting to be rendered
 
 private:
@@ -383,21 +424,8 @@ void UpdateManager::AddCamera( Camera* camera )
 
 void UpdateManager::RemoveCamera( const Camera* camera )
 {
-  // Find the camera
-  OwnerContainer<Camera*>::Iterator iter = mImpl->cameras.Begin();
-  OwnerContainer<Camera*>::ConstIterator end = mImpl->cameras.End();
-  for ( ; iter != end; ++iter )
-  {
-    Camera* value = *iter;
-    if ( camera == value )
-    {
-      // Transfer ownership to the discard queue
-      mImpl->discardQueue.Add( mSceneGraphBuffers.GetUpdateBufferIndex(), mImpl->cameras.Release( iter ) );
-
-      return;
-    }
-  }
-
+  // Find the camera and destroy it
+  EraseUsingDiscardQueue( mImpl->cameras, const_cast<Camera*>( camera ), mImpl->discardQueue, mSceneGraphBuffers.GetUpdateBufferIndex() );
 }
 
 void UpdateManager::AddObject( PropertyOwner* object )
@@ -500,11 +528,6 @@ void UpdateManager::PropertyNotificationSetNotify( PropertyNotification* propert
   propertyNotification->SetNotifyMode( notifyMode );
 }
 
-ObjectOwnerContainer<Renderer>& UpdateManager::GetRendererOwner()
-{
-  return mImpl->renderers;
-}
-
 void UpdateManager::AddShader( Shader* shader )
 {
   DALI_ASSERT_DEBUG( NULL != shader );
@@ -516,23 +539,8 @@ void UpdateManager::RemoveShader( Shader* shader )
 {
   DALI_ASSERT_DEBUG(shader != NULL);
 
-  ShaderContainer& shaders = mImpl->shaders;
-
   // Find the shader and destroy it
-  for ( ShaderIter iter = shaders.Begin(); iter != shaders.End(); ++iter )
-  {
-    Shader& current = **iter;
-    if ( &current == shader )
-    {
-      // Transfer ownership to the discard queue
-      // This keeps the shader alive, until the render-thread has finished with it
-      mImpl->discardQueue.Add( mSceneGraphBuffers.GetUpdateBufferIndex(), shaders.Release( iter ) );
-
-      return;
-    }
-  }
-  // Should not reach here
-  DALI_ASSERT_DEBUG(false);
+  EraseUsingDiscardQueue( mImpl->shaders, shader, mImpl->discardQueue, mSceneGraphBuffers.GetUpdateBufferIndex() );
 }
 
 void UpdateManager::SetShaderProgram( Shader* shader,
@@ -562,18 +570,28 @@ void UpdateManager::SaveBinary( Internal::ShaderDataPtr shaderData )
   }
 }
 
-RenderTaskList* UpdateManager::GetRenderTaskList( bool systemLevel )
+void UpdateManager::SetShaderSaver( ShaderSaver& upstream )
 {
-  if ( !systemLevel )
-  {
-    // copy the list, this is only likely to happen once in application life cycle
-    return &(mImpl->taskList);
-  }
-  else
-  {
-    // copy the list, this is only likely to happen once in application life cycle
-    return &(mImpl->systemLevelTaskList);
-  }
+  mImpl->shaderSaver = &upstream;
+}
+
+void UpdateManager::AddRenderer( Renderer* renderer )
+{
+  DALI_ASSERT_DEBUG( renderer != NULL );
+
+  mImpl->renderers.PushBack( renderer );
+
+  renderer->ConnectToSceneGraph( *mImpl->sceneController, mSceneGraphBuffers.GetUpdateBufferIndex() );
+}
+
+void UpdateManager::RemoveRenderer( Renderer* renderer )
+{
+  DALI_ASSERT_DEBUG( renderer != NULL );
+
+  renderer->DisconnectFromSceneGraph( *mImpl->sceneController, mSceneGraphBuffers.GetUpdateBufferIndex() );
+
+  // Find the renderer and destroy it
+  EraseUsingDiscardQueue( mImpl->renderers, renderer, mImpl->discardQueue, mSceneGraphBuffers.GetUpdateBufferIndex() );
 }
 
 void UpdateManager::AddGesture( PanGesture* gesture )
@@ -587,20 +605,16 @@ void UpdateManager::RemoveGesture( PanGesture* gesture )
 {
   DALI_ASSERT_DEBUG( gesture != NULL );
 
-  GestureContainer& gestures = mImpl->gestures;
-
   // Find the gesture and destroy it
+  GestureOwner& gestures = mImpl->gestures;
   for ( GestureIter iter = gestures.Begin(), endIter = gestures.End(); iter != endIter; ++iter )
   {
-    PanGesture& current = **iter;
-    if ( &current == gesture )
+    if ( *iter == gesture )
     {
-      mImpl->gestures.Erase( iter );
+      gestures.Erase( iter );
       return;
     }
   }
-  // Should not reach here
-  DALI_ASSERT_DEBUG(false);
 }
 
 void UpdateManager::AddTextureSet( TextureSet* textureSet )
@@ -611,21 +625,34 @@ void UpdateManager::AddTextureSet( TextureSet* textureSet )
 
 void UpdateManager::RemoveTextureSet( TextureSet* textureSet )
 {
-  DALI_ASSERT_DEBUG(textureSet != NULL);
-  size_t textureSetCount( mImpl->textureSets.Size() );
-  for( size_t i(0); i<textureSetCount; ++i )
+  DALI_ASSERT_DEBUG( textureSet != NULL );
+
+  // Find the texture and destroy it
+  TextureSetOwner& textures = mImpl->textureSets;
+  for ( TextureSetIter iter = textures.Begin(), endIter = textures.End(); iter != endIter; ++iter )
   {
-    if( textureSet == mImpl->textureSets[i] )
+    if ( *iter == textureSet )
     {
-      mImpl->textureSets.Remove( mImpl->textureSets.Begin() + i );
-
-      // Update manager has ownership of the TextureSet
-      delete textureSet;
+      textures.Erase( iter );
       return;
     }
   }
 }
 
+RenderTaskList* UpdateManager::GetRenderTaskList( bool systemLevel )
+{
+  if ( !systemLevel )
+  {
+    // copy the list, this is only likely to happen once in application life cycle
+    return &(mImpl->taskList);
+  }
+  else
+  {
+    // copy the list, this is only likely to happen once in application life cycle
+    return &(mImpl->systemLevelTaskList);
+  }
+}
+
 unsigned int* UpdateManager::ReserveMessageSlot( std::size_t size, bool updateScene )
 {
   return mImpl->messageQueue.ReserveMessageSlot( size, updateScene );
@@ -661,40 +688,25 @@ void UpdateManager::ResetProperties( BufferIndex bufferIndex )
   // Reset all the nodes
   Vector<Node*>::Iterator iter = mImpl->nodes.Begin()+1;
   Vector<Node*>::Iterator endIter = mImpl->nodes.End();
-  for(;iter != endIter; ++iter)
+  for( ;iter != endIter; ++iter )
   {
     (*iter)->ResetToBaseValues( bufferIndex );
   }
 
   // Reset system-level render-task list properties to base values
-  const RenderTaskList::RenderTaskContainer& systemLevelTasks = mImpl->systemLevelTaskList.GetTasks();
-
-  for (RenderTaskList::RenderTaskContainer::ConstIterator iter = systemLevelTasks.Begin(); iter != systemLevelTasks.End(); ++iter)
-  {
-    (*iter)->ResetToBaseValues( bufferIndex );
-  }
+  ResetToBaseValues( mImpl->systemLevelTaskList.GetTasks(), bufferIndex );
 
   // Reset render-task list properties to base values.
-  const RenderTaskList::RenderTaskContainer& tasks = mImpl->taskList.GetTasks();
-
-  for (RenderTaskList::RenderTaskContainer::ConstIterator iter = tasks.Begin(); iter != tasks.End(); ++iter)
-  {
-    (*iter)->ResetToBaseValues( bufferIndex );
-  }
+  ResetToBaseValues( mImpl->taskList.GetTasks(), bufferIndex );
 
   // Reset custom object properties to base values
-  for (OwnerContainer<PropertyOwner*>::Iterator iter = mImpl->customObjects.Begin(); iter != mImpl->customObjects.End(); ++iter)
-  {
-    (*iter)->ResetToBaseValues( bufferIndex );
-  }
+  ResetToBaseValues( mImpl->customObjects, bufferIndex );
 
-  mImpl->renderers.ResetToBaseValues( bufferIndex );
+  // Reset animatable renderer properties to base values
+  ResetToBaseValues( mImpl->renderers, bufferIndex );
 
   // Reset animatable shader properties to base values
-  for (ShaderIter iter = mImpl->shaders.Begin(); iter != mImpl->shaders.End(); ++iter)
-  {
-    (*iter)->ResetToBaseValues( bufferIndex );
-  }
+  ResetToBaseValues( mImpl->shaders, bufferIndex );
 }
 
 bool UpdateManager::ProcessGestures( BufferIndex bufferIndex, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds )
@@ -702,7 +714,7 @@ bool UpdateManager::ProcessGestures( BufferIndex bufferIndex, unsigned int lastV
   bool gestureUpdated( false );
 
   // constrain gestures... (in construction order)
-  GestureContainer& gestures = mImpl->gestures;
+  GestureOwner& gestures = mImpl->gestures;
 
   for ( GestureIter iter = gestures.Begin(), endIter = gestures.End(); iter != endIter; ++iter )
   {
@@ -782,7 +794,7 @@ void UpdateManager::ConstrainRenderTasks( BufferIndex bufferIndex )
 void UpdateManager::ConstrainShaders( BufferIndex bufferIndex )
 {
   // constrain shaders... (in construction order)
-  ShaderContainer& shaders = mImpl->shaders;
+  ShaderOwner& shaders = mImpl->shaders;
   for ( ShaderIter iter = shaders.Begin(); iter != shaders.End(); ++iter )
   {
     Shader& shader = **iter;
@@ -836,14 +848,13 @@ void UpdateManager::ForwardCompiledShadersToEventThread()
 
 void UpdateManager::UpdateRenderers( BufferIndex bufferIndex )
 {
-  const OwnerContainer<Renderer*>& rendererContainer( mImpl->renderers.GetObjectContainer() );
-  unsigned int rendererCount( rendererContainer.Size() );
-  for( unsigned int i(0); i<rendererCount; ++i )
+  const unsigned int rendererCount = mImpl->renderers.Count();
+  for( unsigned int i = 0; i < rendererCount; ++i )
   {
     //Apply constraints
-    ConstrainPropertyOwner( *rendererContainer[i], bufferIndex );
+    ConstrainPropertyOwner( *mImpl->renderers[i], bufferIndex );
 
-    rendererContainer[i]->PrepareRender( bufferIndex );
+    mImpl->renderers[i]->PrepareRender( bufferIndex );
   }
 }
 
@@ -1107,11 +1118,6 @@ void UpdateManager::SetDepthIndices( NodeDepths* nodeDepths )
   }
 }
 
-void UpdateManager::SetShaderSaver( ShaderSaver& upstream )
-{
-  mImpl->shaderSaver = &upstream;
-}
-
 void UpdateManager::AddSampler( Render::Sampler* sampler )
 {
   // Message has ownership of Sampler while in transit from update to render
index ffde6fc..a1712a4 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H
 
 /*
- * 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.
 #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/nodes/node.h>
 #include <dali/internal/update/nodes/scene-graph-layer.h>
-#include <dali/internal/update/rendering/scene-graph-renderer.h>
+#include <dali/internal/update/rendering/scene-graph-renderer.h>  // for OwnerPointer< Renderer >
+#include <dali/internal/update/rendering/scene-graph-texture-set.h> // for OwnerPointer< TextureSet >
 #include <dali/internal/update/gestures/scene-graph-pan-gesture.h>
 #include <dali/internal/update/render-tasks/scene-graph-camera.h>
-#include <dali/internal/render/shaders/scene-graph-shader.h>
+#include <dali/internal/render/shaders/scene-graph-shader.h>   // for OwnerPointer< Shader >
 #include <dali/internal/render/renderers/render-property-buffer.h>
 #include <dali/internal/event/rendering/texture-impl.h>
 
@@ -78,7 +78,6 @@ class RenderTaskList;
 class RenderTaskProcessor;
 class RenderQueue;
 class PropertyBuffer;
-class TextureSet;
 
 struct NodeDepthPair
 {
@@ -146,13 +145,6 @@ public:
   // Node connection methods
 
   /**
-   * Get the scene graph side list of RenderTasks.
-   * @param[in] systemLevel True if using the system-level overlay.
-   * @return The list of render tasks
-   */
-  RenderTaskList* GetRenderTaskList( bool systemLevel );
-
-  /**
    * Installs a new layer as the root node.
    * @pre The UpdateManager does not already have an installed root node.
    * @pre The layer is of derived Node type Layer.
@@ -269,21 +261,6 @@ public:
    */
   void PropertyNotificationSetNotify( PropertyNotification* propertyNotification, PropertyNotification::NotifyMode notifyMode );
 
-  /**
-   * @brief Get the renderer owner
-   *
-   * @return The renderer owner
-   */
-  ObjectOwnerContainer< Renderer >& GetRendererOwner();
-
-  /**
-   * @brief Get the property buffer owner
-   *
-   * @return The property buffer owner
-   */
-  ObjectOwnerContainer< PropertyBuffer >& GetPropertyBufferOwner();
-
-
   // Shaders
 
   /**
@@ -302,21 +279,6 @@ public:
   void RemoveShader(Shader* shader);
 
   /**
-   * Add a newly created TextureSet.
-   * @param[in] textureSet The texture set to add.
-   * @post The TextureSet is owned by the UpdateManager.
-   */
-  void AddTextureSet(TextureSet* textureSet);
-
-  /**
-   * Remove a TextureSet.
-   * @pre The TextureSet has been added to the UpdateManager.
-   * @param[in] textureSet The TextureSet to remove.
-   * @post The TextureSet is destroyed.
-   */
-  void RemoveTextureSet(TextureSet* textureSet);
-
-  /**
    * Set the shader program for a Shader object
    * @param[in] shader        The shader to modify
    * @param[in] shaderData    Source code, hash over source, and optional compiled binary for the shader program
@@ -337,6 +299,20 @@ public:
    */
   void SetShaderSaver( ShaderSaver& upstream );
 
+  // Renderers
+
+  /**
+   * Add a new renderer to scene
+   * @param renderer to add
+   */
+  void AddRenderer( Renderer* renderer );
+
+  /**
+   * Add a renderer from scene
+   * @param renderer to remove
+   */
+  void RemoveRenderer( Renderer* renderer );
+
   // Gestures
 
   /**
@@ -354,6 +330,32 @@ public:
    */
   void RemoveGesture( PanGesture* gesture );
 
+  // Textures
+
+  /**
+   * Add a newly created TextureSet.
+   * @param[in] textureSet The texture set to add.
+   * @post The TextureSet is owned by the UpdateManager.
+   */
+  void AddTextureSet( TextureSet* textureSet );
+
+  /**
+   * Remove a TextureSet.
+   * @pre The TextureSet has been added to the UpdateManager.
+   * @param[in] textureSet The TextureSet to remove.
+   * @post The TextureSet is destroyed.
+   */
+  void RemoveTextureSet( TextureSet* textureSet );
+
+  // Render tasks
+
+  /**
+   * Get the scene graph side list of RenderTasks.
+   * @param[in] systemLevel True if using the system-level overlay.
+   * @return The list of render tasks
+   */
+  RenderTaskList* GetRenderTaskList( bool systemLevel );
+
 // Message queue handling
 
   /**
@@ -605,11 +607,6 @@ private:
   unsigned int KeepUpdatingCheck( float elapsedSeconds ) const;
 
   /**
-   * Post process resources that have been updated by renderer
-   */
-  void PostProcessResources();
-
-  /**
    * Helper to reset all Node properties
    * @param[in] bufferIndex to use
    */
@@ -990,26 +987,24 @@ inline void RemoveGestureMessage( UpdateManager& manager, PanGesture* gesture )
   new (slot) LocalType( &manager, &UpdateManager::RemoveGesture, gesture );
 }
 
-template< typename T >
-inline void AddMessage( UpdateManager& manager, ObjectOwnerContainer<T>& owner, T& object )
+inline void AddRendererMessage( UpdateManager& manager, Renderer& object )
 {
-  typedef MessageValue1< ObjectOwnerContainer<T>, OwnerPointer< T > > LocalType;
+  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( &owner, &ObjectOwnerContainer<T>::Add, &object );
+  new (slot) LocalType( &manager, &UpdateManager::AddRenderer, &object );
 }
 
-template< typename T >
-inline void RemoveMessage( UpdateManager& manager, ObjectOwnerContainer<T>& owner, T& object )
+inline void RemoveRendererMessage( UpdateManager& manager, Renderer& object )
 {
-  typedef MessageValue1< ObjectOwnerContainer<T>, T* > LocalType;
+  typedef MessageValue1< UpdateManager, 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( &owner, &ObjectOwnerContainer<T>::Remove, &object );
+  new (slot) LocalType( &manager, &UpdateManager::RemoveRenderer, &object );
 }
 
 // The render thread can safely change the Shader
index ea1308b..b150ee3 100644 (file)
@@ -282,7 +282,6 @@ public:
    */
   void TextureSetDeleted();
 
-public: // Implementation of ObjectOwnerContainer template methods
   /**
    * Connect the object to the scene graph
    *
@@ -309,9 +308,6 @@ public: // Implementation of ConnectionChangePropagator
    */
   void RemoveConnectionObserver(ConnectionChangePropagator::Observer& observer){};
 
-public:
-
-
 public: // UniformMap::Observer
   /**
    * @copydoc UniformMap::Observer::UniformMappingsChanged