Remove current and future memory leaks with messages by forcing the use of OwnerPoint...
[platform/core/uifw/dali-core.git] / dali / internal / update / manager / update-manager.h
index 5c23c9f..704b25c 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H__
-#define __DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H__
+#ifndef DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H
+#define DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_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.
@@ -22,8 +22,6 @@
 #include <dali/public-api/common/vector-wrapper.h>
 #include <dali/public-api/common/dali-common.h>
 
-#include <dali/integration-api/resource-declarations.h>
-
 #include <dali/internal/common/message.h>
 #include <dali/internal/common/type-abstraction-enums.h>
 #include <dali/internal/common/shader-saver.h>
 #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>
+#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>   // for OwnerPointer< Shader >
+#include <dali/internal/render/renderers/render-property-buffer.h>
+#include <dali/internal/event/rendering/texture-impl.h>
 
 namespace Dali
 {
@@ -54,9 +55,13 @@ namespace Internal
 class PropertyNotifier;
 class NotificationManager;
 class CompleteNotificationInterface;
-class ResourceManager;
 class TouchResampler;
 
+namespace Render
+{
+struct Sampler;
+class FrameBuffer;
+}
 // value types used by messages
 template <> struct ParameterType< PropertyNotification::NotifyMode >
 : public BasicType< PropertyNotification::NotifyMode > {};
@@ -66,20 +71,42 @@ namespace SceneGraph
 
 class Animation;
 class DiscardQueue;
-class PanGesture;
 class RenderManager;
 class RenderTaskList;
+class RenderTaskProcessor;
 class RenderQueue;
-class TextureCache;
-class Geometry;
 class PropertyBuffer;
-class Material;
-class Sampler;
-class RendererAttachment;
+
+struct NodeDepthPair
+{
+  SceneGraph::Node* node;
+  uint32_t sortedDepth;
+  NodeDepthPair( SceneGraph::Node* node, uint32_t sortedDepth )
+  : node(node),
+    sortedDepth(sortedDepth)
+  {
+  }
+};
+
+struct NodeDepths
+{
+  NodeDepths( int reserveSize )
+  {
+    nodeDepths.reserve(reserveSize);
+  }
+
+  void Add( SceneGraph::Node* node, uint32_t sortedDepth )
+  {
+    nodeDepths.push_back( NodeDepthPair( node, sortedDepth ) );
+  }
+
+  std::vector<NodeDepthPair> nodeDepths;
+};
+
 
 /**
- * UpdateManager maintains a scene graph i.e. a tree of nodes and attachments and
- * other property owner objects.
+ * UpdateManager maintains a scene graph i.e. a tree of nodes as well as
+ * other scene graph property owning objects.
  * It controls the Update traversal, in which nodes are repositioned/animated,
  * and organizes the the culling and rendering of the scene.
  * It also maintains the lifecycle of nodes and other property owners that are
@@ -92,28 +119,22 @@ public:
   /**
    * Construct a new UpdateManager.
    * @param[in] notificationManager This should be notified when animations have finished.
-   * @param[in] glSyncAbstraction Used to determine when framebuffers are ready
    * @param[in] animationFinishedNotifier The CompleteNotificationInterface that handles animation completions
    * @param[in] propertyNotifier The PropertyNotifier
-   * @param[in] resourceManager The resource manager used to load textures etc.
    * @param[in] discardQueue Nodes are added here when disconnected from the scene-graph.
    * @param[in] controller After messages are flushed, we request a render from the RenderController.
    * @param[in] renderManager This is responsible for rendering the results of each "update".
    * @param[in] renderQueue Used to queue messages for the next render.
-   * @param[in] textureCache Used for caching textures.
-   * @param[in] touchResampler Used for re-sampling touch events.
+   * @param[in] renderTaskProcessor Handles RenderTasks and RenderInstrucitons.
    */
   UpdateManager( NotificationManager& notificationManager,
-                 Integration::GlSyncAbstraction& glSyncAbstraction,
                  CompleteNotificationInterface& animationFinishedNotifier,
                  PropertyNotifier& propertyNotifier,
-                 ResourceManager& resourceManager,
                  DiscardQueue& discardQueue,
                  Integration::RenderController& controller,
                  RenderManager& renderManager,
                  RenderQueue& renderQueue,
-                 TextureCache& textureCache,
-                 TouchResampler& touchResampler );
+                 RenderTaskProcessor& renderTaskProcessor );
 
   /**
    * Destructor.
@@ -123,13 +144,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.
@@ -138,23 +152,23 @@ 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.
    * A disconnected Node has has no parent or children, and its properties cannot be animated/constrained.
    * @pre The node does not already have a parent.
-   * @param[in] node The new parent node.
-   * @param[in] node The node to connect.
+   * @param[in] parent The new parent node.
    */
-  void ConnectNode( Node* parent, Node* node, int index );
+  void ConnectNode( Node* parent, Node* node );
 
   /**
    * Disconnect a Node from the scene-graph.
@@ -165,14 +179,6 @@ public:
   void DisconnectNode( Node* node );
 
   /**
-   * Called when a property is set on a disconnected Node (via public API)
-   * A disconnected Node has has no parent or children, and its properties cannot be animated/constrained.
-   * @pre The node does not have a parent.
-   * @param[in] node The node to set as "active".
-   */
-  void SetNodeActive( Node* node );
-
-  /**
    * Destroy a Node owned by UpdateManager.
    * This is not immediate; Nodes are passed to the RenderQueue to allow GL resources to be deleted.
    * In the following update, the previously queued Nodes may be deleted.
@@ -182,25 +188,23 @@ public:
   void DestroyNode( Node* node );
 
   /**
-   * Attach an object to a Node.
-   * The UpdateManager is responsible for calling NodeAttachment::Initialize().
-   * @param[in] node The node which will own the attachment.
-   * @param[in] attachment The object to attach.
+   * Add a camera on scene
+   * @param[in] camera to add
    */
-  void AttachToNode( Node* node, NodeAttachment* attachment );
+  void AddCamera( OwnerPointer< Camera >& camera );
 
   /**
-   * Attach a renderer to the scene graph
+   * Remove a camera from scene
+   * @param[in] camera to remove
    */
-  void AttachToSceneGraph( RendererAttachment* renderer );
-
+  void RemoveCamera( const Camera* camera );
 
   /**
    * Add a newly created object.
    * @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.
@@ -215,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.
@@ -242,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
@@ -257,35 +261,6 @@ public:
    */
   void PropertyNotificationSetNotify( PropertyNotification* propertyNotification, PropertyNotification::NotifyMode notifyMode );
 
-  /**
-   * @brief Get the geometry owner
-   *
-   * @return The geometry owner
-   */
-  ObjectOwnerContainer< Geometry >& GetGeometryOwner();
-
-  /**
-   * @brief Get the material owner
-   *
-   * @return The material owner
-   */
-  ObjectOwnerContainer< Material >& GetMaterialOwner();
-
-  /**
-   * @brief Get the sampler owner
-   *
-   * @return The sampler owner
-   */
-  ObjectOwnerContainer< Sampler >& GetSamplerOwner();
-
-  /**
-   * @brief Get the property buffer owner
-   *
-   * @return The property buffer owner
-   */
-  ObjectOwnerContainer< PropertyBuffer >& GetPropertyBufferOwner();
-
-
   // Shaders
 
   /**
@@ -293,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.
@@ -301,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
@@ -324,22 +299,55 @@ public:
    */
   void SetShaderSaver( ShaderSaver& upstream );
 
+  // Renderers
+
+  /**
+   * Add a new renderer to scene
+   * @param renderer to add
+   */
+  void AddRenderer( OwnerPointer< Renderer >& renderer );
+
+  /**
+   * Add a renderer from scene
+   * @param renderer to remove
+   */
+  void RemoveRenderer( Renderer* renderer );
+
   // Gestures
 
   /**
-   * Add a newly created gesture.
-   * @param[in] gesture The gesture to add.
-   * @post The gesture is owned by the UpdateManager.
+   * Set the pan gesture processor.
+   * Pan Gesture processor lives for the lifetime of UpdateManager
+   * @param[in] gesture The gesture processor.
+   * @post The gestureProcessor is owned by the UpdateManager.
    */
-  void AddGesture( PanGesture* gesture );
+  void SetPanGestureProcessor( PanGesture* gestureProcessor );
+
+  // Textures
+
+  /**
+   * Add a newly created TextureSet.
+   * @param[in] textureSet The texture set to add.
+   * @post The TextureSet is owned by the UpdateManager.
+   */
+  void AddTextureSet( OwnerPointer< TextureSet >& textureSet );
 
   /**
-   * Remove a gesture.
-   * @pre The gesture has been added to the UpdateManager.
-   * @param[in] gesture The gesture to remove.
-   * @post The gesture is destroyed.
+   * 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
    */
-  void RemoveGesture( PanGesture* gesture );
+  RenderTaskList* GetRenderTaskList( bool systemLevel );
 
 // Message queue handling
 
@@ -377,6 +385,164 @@ public:
    */
   bool FlushQueue();
 
+  /**
+   * Add a new sampler to RenderManager
+   * @param[in] sampler The sampler to add
+   * @post Sends a message to RenderManager to add the sampler.
+   * The sampler will be owned by RenderManager
+   */
+  void AddSampler( OwnerPointer< Render::Sampler >& sampler );
+
+  /**
+   * Removes an existing sampler from RenderManager
+   * @param[in] sampler The sampler to remove
+   * @post The sampler will be destroyed in the render thread
+   */
+  void RemoveSampler( Render::Sampler* sampler );
+
+  /**
+   * Sets the filter modes for an existing sampler
+   * @param[in] sampler The sampler
+   * @param[in] minFilterMode The filter to use under minification
+   * @param[in] magFilterMode The filter to use under magnification
+   */
+  void SetFilterMode( Render::Sampler* sampler, unsigned int minFilterMode, unsigned int magFilterMode );
+
+  /**
+   * Sets the wrap mode for an existing sampler
+   * @param[in] sampler The sampler
+   * @param[in] rWrapMode Wrapping mode in z direction
+   * @param[in] sWrapMode Wrapping mode in x direction
+   * @param[in] tWrapMode Wrapping mode in y direction
+   */
+  void SetWrapMode( Render::Sampler* sampler, unsigned int rWrapMode, unsigned int sWrapMode, unsigned int tWrapMode );
+
+  /**
+   * Add a new property buffer to RenderManager
+   * @param[in] propertryBuffer The property buffer to add
+   * @post Sends a message to RenderManager to add the property buffer.
+   * The property buffer will be owned by RenderManager
+   */
+  void AddPropertyBuffer( OwnerPointer< Render::PropertyBuffer >& propertryBuffer );
+
+  /**
+   * Removes an existing PropertyBuffer from RenderManager
+   * @param[in] propertryBuffer The property buffer to remove
+   * @post The property buffer will be destroyed in the render thread
+   */
+  void RemovePropertyBuffer( Render::PropertyBuffer* propertryBuffer );
+
+  /**
+   * Sets the format of an existing property buffer
+   * @param[in] propertyBuffer The property buffer.
+   * @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, OwnerPointer< Render::PropertyBuffer::Format>& format );
+
+  /**
+   * Sets the data of an existing property buffer
+   * @param[in] propertyBuffer The property buffer.
+   * @param[in] data The new data of the buffer
+   * @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, OwnerPointer< Vector<char> >& data, size_t size );
+
+  /**
+   * Adds a geometry to the RenderManager
+   * @param[in] geometry The geometry to add
+   * @post Sends a message to RenderManager to add the Geometry
+   * The geometry will be owned by RenderManager
+   */
+  void AddGeometry( OwnerPointer< Render::Geometry >& geometry );
+
+  /**
+   * Removes an existing Geometry from RenderManager
+   * @param[in] geometry The geometry to remove
+   * @post The geometry will be destroyed in the render thread
+   */
+  void RemoveGeometry( Render::Geometry* geometry );
+
+  /**
+   * Sets the geometry type of an existing Geometry
+   * @param[in] geometry The geometry
+   * @param[in] geometryType The type of the geometry
+   */
+  void SetGeometryType( Render::Geometry* geometry, unsigned int geometryType );
+
+  /**
+   * Sets the index buffer to be used by a geometry
+   * @param[in] geometry The geometry
+   * @param[in] indices A vector containing the indices for the geometry
+   */
+  void SetIndexBuffer( Render::Geometry* geometry, Dali::Vector<unsigned short>& indices );
+
+  /**
+   * Adds a vertex buffer to a geometry
+   * @param[in] geometry The geometry
+   * @param[in] propertyBuffer The property buffer
+   */
+  void AttachVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer );
+
+  /**
+   * Removes a vertex buffer from a geometry
+   * @param[in] geometry The geometry
+   * @param[in] propertyBuffer The property buffer
+   */
+  void RemoveVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer );
+
+  /**
+   * Adds a texture to the render manager
+   * @param[in] texture The texture to add
+   * The texture will be owned by RenderManager
+   */
+  void AddTexture( OwnerPointer< Render::Texture >& texture );
+
+  /**
+   * Removes a texture from the render manager
+   * @param[in] texture The texture to remove
+   * @post The texture will be destroyed in the render thread
+   */
+  void RemoveTexture( Render::Texture* texture );
+
+  /**
+   * Uploads data to a texture owned by the RenderManager
+   * @param[in] texture The texture
+   * @param[in] pixelData The pixel data object
+   * @param[in] params The parameters for the upload
+   */
+  void UploadTexture( Render::Texture* texture, PixelDataPtr pixelData, const Texture::UploadParams& params );
+
+  /**
+   * Generates mipmaps for a texture owned by the RenderManager
+   * @param[in] texture The texture
+   */
+  void GenerateMipmaps( Render::Texture* texture );
+
+  /**
+   * Adds a framebuffer to the render manager
+   * @param[in] frameBuffer The framebuffer to add
+   * The framebuffer will be owned by RenderManager
+   */
+  void AddFrameBuffer( Render::FrameBuffer* frameBuffer );
+
+  /**
+   * Removes a FrameBuffer from the render manager
+   * @param[in] frameBuffer The FrameBuffer to remove
+   * @post The FrameBuffer will be destroyed in the render thread
+   */
+  void RemoveFrameBuffer( Render::FrameBuffer* frameBuffer );
+
+  /**
+   * Attach a texture as color output to an existing FrameBuffer
+   * @param[in] frameBuffer The FrameBuffer
+   * @param[in] texture The texture that will be used as output when rendering
+   * @param[in] mipmapLevel The mipmap of the texture to be attached
+   * @param[in] layer Indicates which layer of a cube map or array texture to attach. Unused for 2D textures
+   */
+  void AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::Texture* texture, unsigned int mipmapLevel, unsigned int face );
+
 public:
 
   /**
@@ -412,6 +578,12 @@ public:
    */
   void SetLayerDepths( const std::vector< Layer* >& layers, bool systemLevel );
 
+  /**
+   * Set the depth indices of all nodes (in LayerUI's)
+   * @param[in] nodeDepths A vector of nodes and associated depth indices
+   */
+  void SetDepthIndices( OwnerPointer< NodeDepths >& nodeDepths );
+
 private:
 
   // Undefined
@@ -428,52 +600,50 @@ private:
   unsigned int KeepUpdatingCheck( float elapsedSeconds ) const;
 
   /**
-   * Helper to calculate new camera setup when root node resizes.
-   * @param[in] updateBuffer The buffer to read the root node size from.
-   */
-  void UpdateProjectionAndViewMatrices(int updateBuffer);
-
-  /**
-   * Post process resources that have been updated by renderer
+   * Helper to reset all Node properties
+   * @param[in] bufferIndex to use
    */
-  void PostProcessResources();
+  void ResetProperties( BufferIndex bufferIndex );
 
   /**
-   * Helper to reset a Node properties.
-   * @param[in] node The node.
+   * Perform gesture updates.
+   * @param[in] bufferIndex to use
+   * @param[in] lastVSyncTime  The last VSync time in milliseconds.
+   * @param[in] nextVSyncTime  The estimated time of the next VSync in milliseconds.
+   * @return true, if any properties were updated.
    */
-  void ResetNodeProperty( Node& node );
+  bool ProcessGestures( BufferIndex bufferIndex, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds );
 
   /**
-   * Helper to reset all Node properties
+   * Perform animation updates
+   * @param[in] bufferIndex to use
+   * @param[in] elapsedSeconds time since last frame
    */
-  void ResetProperties();
+  void Animate( BufferIndex bufferIndex, float elapsedSeconds );
 
   /**
-   * Perform gesture updates.
-   * @param[in]  lastVSyncTime  The last VSync time in milliseconds.
-   * @param[in]  nextVSyncTime  The estimated time of the next VSync in milliseconds.
-   * @return true, if any properties were updated.
+   * Applies constraints to CustomObjects
+   * @param[in] bufferIndex to use
    */
-  bool ProcessGestures( unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds );
+  void ConstrainCustomObjects( BufferIndex bufferIndex );
 
   /**
-   * Perform animation updates
-   * @param[in] elapsedSeconds time since last frame
+   * Applies constraints to RenderTasks
+   * @param[in] bufferIndex to use
    */
-  void Animate( float elapsedSeconds );
+  void ConstrainRenderTasks( BufferIndex bufferIndex );
 
   /**
-   * Perform constraint updates.
-   * @note Applies constraints to nodes first (depth first search order).
-   * Then shader constraints second (construction order)
+   * Applies constraints to Shaders
+   * @param[in] bufferIndex to use
    */
-  void ApplyConstraints();
+  void ConstrainShaders( BufferIndex bufferIndex );
 
   /**
    * Perform property notification updates
+   * @param[in] bufferIndex to use
    */
-  void ProcessPropertyNotifications();
+  void ProcessPropertyNotifications( BufferIndex bufferIndex );
 
   /**
    * Pass shader binaries queued here on to event thread.
@@ -481,16 +651,16 @@ private:
   void ForwardCompiledShadersToEventThread();
 
   /**
-   * Update the default camera.
-   * This must be altered to match the root Node for 2D layouting.
-   * @param[in] updateBuffer The buffer to read the root node size from.
+   * Update node shaders, opacity, geometry etc.
+   * @param[in] bufferIndex to use
    */
-  void UpdateDefaultCamera( int updateBuffer );
+  void UpdateNodes( BufferIndex bufferIndex );
 
   /**
-   * Update node shaders, opacity, geometry etc.
+   * Update Renderers
+   * @param[in] bufferIndex to use
    */
-  void UpdateNodes();
+  void UpdateRenderers( BufferIndex bufferIndex );
 
 private:
 
@@ -504,41 +674,43 @@ private:
 
 // Messages for UpdateManager
 
-inline void InstallRootMessage( UpdateManager& manager, Layer& root, bool systemLevel )
+inline void InstallRootMessage( UpdateManager& manager, OwnerPointer<Layer>& root, bool systemLevel )
 {
-  typedef MessageValue2< UpdateManager, Layer*, bool > LocalType;
+  // Message has ownership of Layer while in transit from event -> update
+  typedef MessageValue2< UpdateManager, OwnerPointer<Layer>, bool > 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::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;
 
   // 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::AddNode, &node );
+  new (slot) LocalType( &manager, &UpdateManager::AddNode, node );
 }
 
-inline void ConnectNodeMessage( UpdateManager& manager, const Node& constParent, const Node& constChild, int index )
+inline void ConnectNodeMessage( UpdateManager& manager, const Node& constParent, const Node& constChild )
 {
   // Update thread can edit the object
   Node& parent = const_cast< Node& >( constParent );
   Node& child = const_cast< Node& >( constChild );
 
-  typedef MessageValue3< UpdateManager, Node*, Node*, int > LocalType;
+  typedef MessageValue2< UpdateManager, Node*, Node* > 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::ConnectNode, &parent, &child, index );
+  new (slot) LocalType( &manager, &UpdateManager::ConnectNode, &parent, &child );
 }
 
 inline void DisconnectNodeMessage( UpdateManager& manager, const Node& constNode )
@@ -569,35 +741,32 @@ inline void DestroyNodeMessage( UpdateManager& manager, const Node& constNode )
   new (slot) LocalType( &manager, &UpdateManager::DestroyNode, &node );
 }
 
-inline void AttachToNodeMessage( UpdateManager& manager, const Node& constParent, NodeAttachment* attachment )
+inline void AddCameraMessage( UpdateManager& manager, OwnerPointer< Camera >& camera )
 {
-  // Scene graph thread can modify this object.
-  Node& parent = const_cast< Node& >( constParent );
-
-  // @todo MESH_REWORK Don't pass by owner pointer after merge with SceneGraph::RenderableAttachment ? (not needed if we split RendererAttachment to 2 objects)
-  typedef MessageValue2< UpdateManager, Node*, NodeAttachmentOwner > LocalType;
+  // Message has ownership of Camera while in transit from event -> update
+  typedef MessageValue1< UpdateManager, OwnerPointer< Camera > > 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::AttachToNode, &parent, attachment );
+  new (slot) LocalType( &manager, &UpdateManager::AddCamera, camera );
 }
 
-inline void AttachToSceneGraphMessage( UpdateManager& manager, RendererAttachment* renderer )
+inline void RemoveCameraMessage( UpdateManager& manager, const Camera* camera )
 {
-  // @todo MESH_REWORK Pass by owner pointer after merge with SceneGraph::RenderableAttachment
-  typedef MessageValue1< UpdateManager, RendererAttachment* > LocalType;
+  typedef MessageValue1< UpdateManager, const Camera* > 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::AttachToSceneGraph, renderer );
+  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;
 
   // Reserve some memory inside the message queue
@@ -618,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 ) );
@@ -657,9 +826,10 @@ 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 )
 {
-  typedef MessageValue1< UpdateManager, PropertyNotification* > LocalType;
+  // Message has ownership of PropertyNotification while in transit from event -> update
+  typedef MessageValue1< UpdateManager, OwnerPointer< PropertyNotification > > LocalType;
 
   // Reserve some memory inside the message queue
   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
@@ -699,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;
 
@@ -707,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
@@ -786,48 +956,337 @@ inline void SetLayerDepthsMessage( UpdateManager& manager, const std::vector< La
   new (slot) LocalType( &manager, &UpdateManager::SetLayerDepths, layers, systemLevel );
 }
 
-inline void AddGestureMessage( UpdateManager& manager, PanGesture* gesture )
+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 );
+}
+
+inline void RemoveRendererMessage( UpdateManager& manager, Renderer& object )
+{
+  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( &manager, &UpdateManager::RemoveRenderer, &object );
+}
+
+// The render thread can safely change the Shader
+inline void AddTextureSetMessage( UpdateManager& manager, OwnerPointer< TextureSet >& textureSet )
 {
-  typedef MessageValue1< UpdateManager, PanGesture* > LocalType;
+  typedef MessageValue1< UpdateManager, OwnerPointer< TextureSet > > 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::AddGesture, gesture );
+  new (slot) LocalType( &manager, &UpdateManager::AddTextureSet, textureSet );
 }
 
-inline void RemoveGestureMessage( UpdateManager& manager, PanGesture* gesture )
+// The render thread can safely change the Shader
+inline void RemoveTextureSetMessage( UpdateManager& manager, TextureSet& textureSet )
 {
-  typedef MessageValue1< UpdateManager, PanGesture* > LocalType;
+  typedef MessageValue1< UpdateManager, TextureSet* > 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::RemoveGesture, gesture );
+  new (slot) LocalType( &manager, &UpdateManager::RemoveTextureSet, &textureSet );
 }
 
-template< typename T >
-inline void AddMessage( UpdateManager& manager, ObjectOwnerContainer<T>& owner, T& object )
+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;
+
+  // 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::AddSampler, sampler );
+}
+
+inline void RemoveSamplerMessage( UpdateManager& manager, Render::Sampler& sampler )
+{
+  typedef MessageValue1< UpdateManager, Render::Sampler* > 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::RemoveSampler, &sampler );
+}
+
+inline void SetFilterModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int minFilterMode, unsigned int magFilterMode )
 {
-  typedef MessageValue1< ObjectOwnerContainer<T>, OwnerPointer< T > > LocalType;
+  typedef MessageValue3< UpdateManager, Render::Sampler*, unsigned int, unsigned int > 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::SetFilterMode, &sampler, minFilterMode, magFilterMode );
 }
 
+inline void SetWrapModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int rWrapMode, unsigned int sWrapMode, unsigned int tWrapMode )
+{
+  typedef MessageValue4< UpdateManager, Render::Sampler*, unsigned int, unsigned int, unsigned int > 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::SetWrapMode, &sampler, rWrapMode, sWrapMode, tWrapMode );
+}
+
+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;
+
+  // 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::AddPropertyBuffer, propertyBuffer );
+}
+
+inline void RemovePropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer )
+{
+  typedef MessageValue1< UpdateManager, Render::PropertyBuffer*  > 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::RemovePropertyBuffer, &propertyBuffer );
+}
+
+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;
+
+  // 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::SetPropertyBufferFormat, &propertyBuffer, format );
+}
+
+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;
+
+  // 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::SetPropertyBufferData, &propertyBuffer, data, size );
+}
+
+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;
+
+  // 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::AddGeometry, geometry );
+}
+
+inline void RemoveGeometry( UpdateManager& manager, Render::Geometry& geometry )
+{
+  typedef MessageValue1< UpdateManager, Render::Geometry*  > 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::RemoveGeometry, &geometry );
+}
+
+inline void AttachVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer )
+{
+  typedef MessageValue2< UpdateManager, Render::Geometry*, Render::PropertyBuffer* > 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::AttachVertexBuffer, &geometry, const_cast<Render::PropertyBuffer*>(&vertexBuffer) );
+}
+
+inline void RemoveVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer )
+{
+  typedef MessageValue2< UpdateManager, Render::Geometry*, Render::PropertyBuffer* > 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::RemoveVertexBuffer, &geometry, const_cast<Render::PropertyBuffer*>(&vertexBuffer) );
+}
+
+// Custom message type for SetIndexBuffer() used to move data with Vector::Swap()
 template< typename T >
-inline void RemoveMessage( UpdateManager& manager, ObjectOwnerContainer<T>& owner, T& object )
+class IndexBufferMessage : public MessageBase
+{
+public:
+
+  /**
+   * Constructor which does a Vector::Swap()
+   */
+  IndexBufferMessage( T* manager, Render::Geometry* geometry, Dali::Vector<unsigned short>& indices )
+  : MessageBase(),
+    mManager( manager ),
+    mRenderGeometry( geometry )
+  {
+    mIndices.Swap( indices );
+  }
+
+  /**
+   * Virtual destructor
+   */
+  virtual ~IndexBufferMessage()
+  {
+  }
+
+  /**
+   * @copydoc MessageBase::Process
+   */
+  virtual void Process( BufferIndex /*bufferIndex*/ )
+  {
+    DALI_ASSERT_DEBUG( mManager && "Message does not have an object" );
+    mManager->SetIndexBuffer( mRenderGeometry, mIndices );
+  }
+
+private:
+
+  T* mManager;
+  Render::Geometry* mRenderGeometry;
+  Dali::Vector<unsigned short> mIndices;
+};
+
+inline void SetIndexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, Dali::Vector<unsigned short>& indices )
+{
+  typedef IndexBufferMessage< UpdateManager > 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, &geometry, indices );
+}
+
+inline void SetGeometryTypeMessage( UpdateManager& manager, Render::Geometry& geometry, unsigned int geometryType )
 {
-  typedef MessageValue1< ObjectOwnerContainer<T>, T* > LocalType;
+  typedef MessageValue2< UpdateManager, Render::Geometry*, unsigned int > 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::SetGeometryType, &geometry, geometryType );
+}
+
+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;
+
+  // 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::AddTexture, texture );
+}
+
+inline void RemoveTexture( UpdateManager& manager, Render::Texture& texture )
+{
+  typedef MessageValue1< UpdateManager, Render::Texture*  > 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::RemoveTexture, &texture );
+}
+
+inline void UploadTextureMessage( UpdateManager& manager, Render::Texture& texture, PixelDataPtr pixelData, const Texture::UploadParams& params )
+{
+  typedef MessageValue3< UpdateManager, Render::Texture*, PixelDataPtr, Texture::UploadParams > 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::UploadTexture, &texture, pixelData, params );
+}
+
+inline void GenerateMipmapsMessage( UpdateManager& manager, Render::Texture& texture )
+{
+  typedef MessageValue1< UpdateManager, Render::Texture*  > 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::GenerateMipmaps, &texture );
+}
+
+
+inline void AddFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer )
+{
+  typedef MessageValue1< UpdateManager, Render::FrameBuffer*  > 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::AddFrameBuffer, &frameBuffer );
+}
+
+inline void RemoveFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer )
+{
+  typedef MessageValue1< UpdateManager, Render::FrameBuffer*  > 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::RemoveFrameBuffer, &frameBuffer );
+}
+
+inline void AttachColorTextureToFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer, Render::Texture* texture, unsigned int mipmapLevel, unsigned int layer )
+{
+  typedef MessageValue4< UpdateManager, Render::FrameBuffer*, Render::Texture*, unsigned int, unsigned int  > 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::AttachColorTextureToFrameBuffer, &frameBuffer, texture, mipmapLevel, layer );
+}
+
+inline void SetDepthIndicesMessage( UpdateManager& manager, OwnerPointer< NodeDepths >& nodeDepths )
+{
+  typedef MessageValue1< UpdateManager, OwnerPointer< NodeDepths > > 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::SetDepthIndices, nodeDepths );
 }
 
 } // namespace SceneGraph
@@ -836,4 +1295,4 @@ inline void RemoveMessage( UpdateManager& manager, ObjectOwnerContainer<T>& owne
 
 } // namespace Dali
 
-#endif // __DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H__
+#endif // DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H