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 9b51224..704b25c 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.
@@ -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/nodes/node.h>
 #include <dali/internal/update/nodes/scene-graph-layer.h>
-#include <dali/internal/update/rendering/scene-graph-renderer.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>
 
@@ -71,14 +71,38 @@ namespace SceneGraph
 
 class Animation;
 class DiscardQueue;
-class PanGesture;
 class RenderManager;
 class RenderTaskList;
 class RenderTaskProcessor;
 class RenderQueue;
 class PropertyBuffer;
-class TextureSet;
-class Camera;
+
+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 as well as
@@ -120,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.
@@ -135,14 +152,15 @@ public:
    * @param[in] systemLevel True if using the system-level overlay.
    * @post The node is owned by UpdateManager.
    */
-  void InstallRoot( Layer* layer, bool systemLevel );
+  void InstallRoot( OwnerPointer<Layer>& layer, bool systemLevel );
 
   /**
    * Add a Node; UpdateManager takes ownership.
    * @pre The node does not have a parent.
+   * @note even though nodes are pool allocated, they also contain other heap allocated data, thus using OwnerPointer when transferring the data
    * @param[in] node The node to add.
    */
-  void AddNode( Node* node );
+  void AddNode( OwnerPointer<Node>& node );
 
   /**
    * Connect a Node to the scene-graph.
@@ -173,7 +191,7 @@ public:
    * Add a camera on scene
    * @param[in] camera to add
    */
-  void AddCamera( Camera* camera );
+  void AddCamera( OwnerPointer< Camera >& camera );
 
   /**
    * Remove a camera from scene
@@ -186,7 +204,7 @@ public:
    * @param[in] object The object to add.
    * @post The object is owned by UpdateManager.
    */
-  void AddObject( PropertyOwner* object );
+  void AddObject( OwnerPointer<PropertyOwner>& object );
 
   /**
    * Remove an object.
@@ -201,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.
@@ -228,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
@@ -243,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
 
   /**
@@ -265,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.
@@ -273,22 +276,7 @@ public:
    * @param[in] shader The shader to remove.
    * @post The shader is destroyed.
    */
-  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);
+  void RemoveShader( Shader* shader );
 
   /**
    * Set the shader program for a Shader object
@@ -311,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 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 AddGesture( PanGesture* gesture );
+  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 RemoveGesture( PanGesture* gesture );
+  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
 
@@ -370,7 +391,7 @@ public:
    * @post Sends a message to RenderManager to add the sampler.
    * The sampler will be owned by RenderManager
    */
-  void AddSampler( Render::Sampler* sampler );
+  void AddSampler( OwnerPointer< Render::Sampler >& sampler );
 
   /**
    * Removes an existing sampler from RenderManager
@@ -402,7 +423,7 @@ public:
    * @post Sends a message to RenderManager to add the property buffer.
    * The property buffer will be owned by RenderManager
    */
-  void AddPropertyBuffer( Render::PropertyBuffer* propertryBuffer );
+  void AddPropertyBuffer( OwnerPointer< Render::PropertyBuffer >& propertryBuffer );
 
   /**
    * Removes an existing PropertyBuffer from RenderManager
@@ -417,7 +438,7 @@ public:
    * @param[in] format The new format of the buffer
    * @post Sends a message to RenderManager to set the new format to the property buffer.
    */
-  void SetPropertyBufferFormat(Render::PropertyBuffer* propertyBuffer, Render::PropertyBuffer::Format* format );
+  void SetPropertyBufferFormat( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Render::PropertyBuffer::Format>& format );
 
   /**
    * Sets the data of an existing property buffer
@@ -426,7 +447,7 @@ public:
    * @param[in] size The new size of the buffer
    * @post Sends a message to RenderManager to set the new data to the property buffer.
    */
-  void SetPropertyBufferData(Render::PropertyBuffer* propertyBuffer, Dali::Vector<char>* data, size_t size);
+  void SetPropertyBufferData( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Vector<char> >& data, size_t size );
 
   /**
    * Adds a geometry to the RenderManager
@@ -434,7 +455,7 @@ public:
    * @post Sends a message to RenderManager to add the Geometry
    * The geometry will be owned by RenderManager
    */
-  void AddGeometry( Render::Geometry* geometry );
+  void AddGeometry( OwnerPointer< Render::Geometry >& geometry );
 
   /**
    * Removes an existing Geometry from RenderManager
@@ -458,11 +479,11 @@ public:
   void SetIndexBuffer( Render::Geometry* geometry, Dali::Vector<unsigned short>& indices );
 
   /**
-   * Adds a vertex buffer to a geomtry
+   * Adds a vertex buffer to a geometry
    * @param[in] geometry The geometry
    * @param[in] propertyBuffer The property buffer
    */
-  void AddVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer );
+  void AttachVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer );
 
   /**
    * Removes a vertex buffer from a geometry
@@ -476,7 +497,7 @@ public:
    * @param[in] texture The texture to add
    * The texture will be owned by RenderManager
    */
-  void AddTexture( Render::Texture* texture );
+  void AddTexture( OwnerPointer< Render::Texture >& texture );
 
   /**
    * Removes a texture from the render manager
@@ -557,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
@@ -573,11 +600,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
    */
@@ -652,7 +674,7 @@ private:
 
 // Messages for UpdateManager
 
-inline void InstallRootMessage( UpdateManager& manager, Layer& root, bool systemLevel )
+inline void InstallRootMessage( UpdateManager& manager, OwnerPointer<Layer>& root, bool systemLevel )
 {
   // Message has ownership of Layer while in transit from event -> update
   typedef MessageValue2< UpdateManager, OwnerPointer<Layer>, bool > LocalType;
@@ -661,10 +683,10 @@ inline void InstallRootMessage( UpdateManager& manager, Layer& root, bool system
   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &manager, &UpdateManager::InstallRoot, &root, systemLevel );
+  new (slot) LocalType( &manager, &UpdateManager::InstallRoot, root, systemLevel );
 }
 
-inline void AddNodeMessage( UpdateManager& manager, Node& node )
+inline void AddNodeMessage( UpdateManager& manager, OwnerPointer<Node>& node )
 {
   // Message has ownership of Node while in transit from event -> update
   typedef MessageValue1< UpdateManager, OwnerPointer<Node> > LocalType;
@@ -673,7 +695,7 @@ inline void AddNodeMessage( UpdateManager& manager, Node& node )
   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &manager, &UpdateManager::AddNode, &node );
+  new (slot) LocalType( &manager, &UpdateManager::AddNode, node );
 }
 
 inline void ConnectNodeMessage( UpdateManager& manager, const Node& constParent, const Node& constChild )
@@ -719,11 +741,11 @@ inline void DestroyNodeMessage( UpdateManager& manager, const Node& constNode )
   new (slot) LocalType( &manager, &UpdateManager::DestroyNode, &node );
 }
 
-inline void AddCameraMessage( UpdateManager& manager, const Camera* constCamera )
+inline void AddCameraMessage( UpdateManager& manager, OwnerPointer< Camera >& camera )
 {
-  typedef MessageValue1< UpdateManager, Camera* > LocalType;
+  // Message has ownership of Camera while in transit from event -> update
+  typedef MessageValue1< UpdateManager, OwnerPointer< Camera > > LocalType;
 
-  Camera* camera = const_cast<Camera*>( constCamera );
   // Reserve some memory inside the message queue
   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
 
@@ -742,8 +764,9 @@ inline void RemoveCameraMessage( UpdateManager& manager, const Camera* camera )
   new (slot) LocalType( &manager, &UpdateManager::RemoveCamera, camera );
 }
 
-inline void AddObjectMessage( UpdateManager& manager, PropertyOwner* object )
+inline void AddObjectMessage( UpdateManager& manager, OwnerPointer<PropertyOwner>& object )
 {
+  // Message has ownership of object while in transit from event -> update
   typedef MessageValue1< UpdateManager, OwnerPointer<PropertyOwner> > LocalType;
 
   // Reserve some memory inside the message queue
@@ -764,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 ) );
@@ -803,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 ) );
@@ -845,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;
 
@@ -853,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
@@ -932,52 +956,28 @@ inline void SetLayerDepthsMessage( UpdateManager& manager, const std::vector< La
   new (slot) LocalType( &manager, &UpdateManager::SetLayerDepths, layers, systemLevel );
 }
 
-inline void AddGestureMessage( UpdateManager& manager, PanGesture* gesture )
-{
-  typedef MessageValue1< UpdateManager, PanGesture* > 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 );
-}
-
-inline void RemoveGestureMessage( UpdateManager& manager, PanGesture* gesture )
+inline void AddRendererMessage( UpdateManager& manager, OwnerPointer< Renderer >& object )
 {
-  typedef MessageValue1< UpdateManager, PanGesture* > 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( &manager, &UpdateManager::RemoveGesture, gesture );
+  new (slot) LocalType( &manager, &UpdateManager::AddRenderer, object );
 }
 
-template< typename T >
-inline void AddMessage( UpdateManager& manager, ObjectOwnerContainer<T>& owner, T& object )
+inline void RemoveRendererMessage( UpdateManager& manager, Renderer& object )
 {
-  typedef MessageValue1< ObjectOwnerContainer<T>, OwnerPointer< 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>::Add, &object );
-}
-
-template< typename T >
-inline void RemoveMessage( UpdateManager& manager, ObjectOwnerContainer<T>& owner, T& object )
-{
-  typedef MessageValue1< ObjectOwnerContainer<T>, 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( &owner, &ObjectOwnerContainer<T>::Remove, &object );
+  new (slot) LocalType( &manager, &UpdateManager::RemoveRenderer, &object );
 }
 
 // The render thread can safely change the Shader
-inline void AddTextureSetMessage( UpdateManager& manager, TextureSet& textureSet )
+inline void AddTextureSetMessage( UpdateManager& manager, OwnerPointer< TextureSet >& textureSet )
 {
   typedef MessageValue1< UpdateManager, OwnerPointer< TextureSet > > LocalType;
 
@@ -985,7 +985,7 @@ inline void AddTextureSetMessage( UpdateManager& manager, TextureSet& textureSet
   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &manager, &UpdateManager::AddTextureSet, &textureSet );
+  new (slot) LocalType( &manager, &UpdateManager::AddTextureSet, textureSet );
 }
 
 // The render thread can safely change the Shader
@@ -1000,15 +1000,16 @@ inline void RemoveTextureSetMessage( UpdateManager& manager, TextureSet& texture
   new (slot) LocalType( &manager, &UpdateManager::RemoveTextureSet, &textureSet );
 }
 
-inline void AddSamplerMessage( UpdateManager& manager, Render::Sampler& sampler )
+inline void AddSamplerMessage( UpdateManager& manager, OwnerPointer< Render::Sampler >& sampler )
 {
-  typedef MessageValue1< UpdateManager, Render::Sampler* > LocalType;
+  // 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 );
+  new (slot) LocalType( &manager, &UpdateManager::AddSampler, sampler );
 }
 
 inline void RemoveSamplerMessage( UpdateManager& manager, Render::Sampler& sampler )
@@ -1044,15 +1045,16 @@ inline void SetWrapModeMessage( UpdateManager& manager, Render::Sampler& sampler
   new (slot) LocalType( &manager, &UpdateManager::SetWrapMode, &sampler, rWrapMode, sWrapMode, tWrapMode );
 }
 
-inline void AddPropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer )
+inline void AddPropertyBuffer( UpdateManager& manager, OwnerPointer< Render::PropertyBuffer >& propertyBuffer )
 {
-  typedef MessageValue1< UpdateManager, Render::PropertyBuffer*  > LocalType;
+  // 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 );
+  new (slot) LocalType( &manager, &UpdateManager::AddPropertyBuffer, propertyBuffer );
 }
 
 inline void RemovePropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer )
@@ -1066,9 +1068,10 @@ inline void RemovePropertyBuffer( UpdateManager& manager, Render::PropertyBuffer
   new (slot) LocalType( &manager, &UpdateManager::RemovePropertyBuffer, &propertyBuffer );
 }
 
-inline void SetPropertyBufferFormat( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, Render::PropertyBuffer::Format* format )
+inline void SetPropertyBufferFormat( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, OwnerPointer< Render::PropertyBuffer::Format>& format )
 {
-  typedef MessageValue2< UpdateManager, Render::PropertyBuffer*, Render::PropertyBuffer::Format*  > LocalType;
+  // 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 ) );
@@ -1077,9 +1080,10 @@ inline void SetPropertyBufferFormat( UpdateManager& manager, Render::PropertyBuf
   new (slot) LocalType( &manager, &UpdateManager::SetPropertyBufferFormat, &propertyBuffer, format );
 }
 
-inline void SetPropertyBufferData( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, Vector<char>* data, size_t size )
+inline void SetPropertyBufferData( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, OwnerPointer< Vector<char> >& data, size_t size )
 {
-  typedef MessageValue3< UpdateManager, Render::PropertyBuffer*, Vector<char>*, size_t  > LocalType;
+  // 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 ) );
@@ -1088,15 +1092,16 @@ inline void SetPropertyBufferData( UpdateManager& manager, Render::PropertyBuffe
   new (slot) LocalType( &manager, &UpdateManager::SetPropertyBufferData, &propertyBuffer, data, size );
 }
 
-inline void AddGeometry( UpdateManager& manager, Render::Geometry& geometry )
+inline void AddGeometry( UpdateManager& manager, OwnerPointer< Render::Geometry >& geometry )
 {
-  typedef MessageValue1< UpdateManager, Render::Geometry*  > LocalType;
+  // 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 );
+  new (slot) LocalType( &manager, &UpdateManager::AddGeometry, geometry );
 }
 
 inline void RemoveGeometry( UpdateManager& manager, Render::Geometry& geometry )
@@ -1110,7 +1115,7 @@ inline void RemoveGeometry( UpdateManager& manager, Render::Geometry& geometry )
   new (slot) LocalType( &manager, &UpdateManager::RemoveGeometry, &geometry );
 }
 
-inline void AddVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer )
+inline void AttachVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer )
 {
   typedef MessageValue2< UpdateManager, Render::Geometry*, Render::PropertyBuffer* > LocalType;
 
@@ -1118,7 +1123,7 @@ inline void AddVertexBufferMessage( UpdateManager& manager, Render::Geometry& ge
   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &manager, &UpdateManager::AddVertexBuffer, &geometry, const_cast<Render::PropertyBuffer*>(&vertexBuffer) );
+  new (slot) LocalType( &manager, &UpdateManager::AttachVertexBuffer, &geometry, const_cast<Render::PropertyBuffer*>(&vertexBuffer) );
 }
 
 inline void RemoveVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer )
@@ -1194,15 +1199,16 @@ inline void SetGeometryTypeMessage( UpdateManager& manager, Render::Geometry& ge
   new (slot) LocalType( &manager, &UpdateManager::SetGeometryType, &geometry, geometryType );
 }
 
-inline void AddTexture( UpdateManager& manager, Render::Texture& texture )
+inline void AddTexture( UpdateManager& manager, OwnerPointer< Render::Texture >& texture )
 {
-  typedef MessageValue1< UpdateManager, Render::Texture*  > LocalType;
+  // 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 );
+  new (slot) LocalType( &manager, &UpdateManager::AddTexture, texture );
 }
 
 inline void RemoveTexture( UpdateManager& manager, Render::Texture& texture )
@@ -1272,6 +1278,16 @@ inline void AttachColorTextureToFrameBuffer( UpdateManager& manager, Render::Fra
   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( &manager, &UpdateManager::SetDepthIndices, nodeDepths );
+}
 
 } // namespace SceneGraph