Removal of renderable attachment
[platform/core/uifw/dali-core.git] / dali / internal / update / manager / update-manager.h
index 50ea6c2..a2bed89 100644 (file)
@@ -1,39 +1,43 @@
 #ifndef __DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H__
 #define __DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H__
 
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.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://floralicense.org/license/
-//
-// 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.
-//
+/*
+ * Copyright (c) 2014 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.
+ *
+ */
 
 // INTERNAL INCLUDES
 #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/event-to-update.h>
-#include <dali/internal/render/shaders/shader.h>
-#include <dali/internal/update/nodes/node.h>
-#include <dali/internal/update/node-attachments/node-attachment.h>
-#include <dali/internal/update/common/scene-graph-buffers.h>
+#include <dali/internal/common/type-abstraction-enums.h>
+#include <dali/internal/common/shader-saver.h>
+#include <dali/internal/event/common/event-thread-services.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/common/double-buffered.h>
-#include <dali/internal/update/modeling/scene-graph-animatable-mesh.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/event/effects/shader-declarations.h>
-#include <dali/internal/common/type-abstraction-enums.h>
+#include <dali/internal/update/rendering/scene-graph-renderer.h>
+#include <dali/internal/render/shaders/scene-graph-shader.h>
+#include <dali/internal/render/renderers/render-property-buffer.h>
 
 namespace Dali
 {
@@ -42,22 +46,22 @@ namespace Integration
 {
 class GlSyncAbstraction;
 class RenderController;
-struct DynamicsWorldSettings;
 
 } // namespace Integration
 
 namespace Internal
 {
 
-class AnimationFinishedNotifier;
 class PropertyNotifier;
-class EventToUpdate;
-struct DynamicsWorldSettings;
 class NotificationManager;
+class CompleteNotificationInterface;
 class ResourceManager;
-class RenderTaskList;
 class TouchResampler;
 
+namespace Render
+{
+class Sampler;
+}
 // value types used by messages
 template <> struct ParameterType< PropertyNotification::NotifyMode >
 : public BasicType< PropertyNotification::NotifyMode > {};
@@ -65,25 +69,26 @@ template <> struct ParameterType< PropertyNotification::NotifyMode >
 namespace SceneGraph
 {
 
-class AnimatableMesh;
 class Animation;
 class DiscardQueue;
-class Material;
 class PanGesture;
 class RenderManager;
 class RenderTaskList;
 class RenderQueue;
-class DynamicsWorld;
 class TextureCache;
-typedef OwnerContainer< AnimatableMesh* > AnimatableMeshContainer;
-typedef OwnerContainer< Material* >       MaterialContainer;
+class Geometry;
+class PropertyBuffer;
+class Material;
 
 /**
- * UpdateManager holds a scene graph i.e. a tree of nodes.
+ * UpdateManager maintains a scene graph i.e. a tree of nodes and attachments and
+ * other property owner 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
+ * disconnected from the scene graph.
  */
-class UpdateManager
+class UpdateManager : public ShaderSaver
 {
 public:
 
@@ -91,7 +96,7 @@ 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 AnimationFinishedNotifier
+   * @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.
@@ -103,7 +108,7 @@ public:
    */
   UpdateManager( NotificationManager& notificationManager,
                  Integration::GlSyncAbstraction& glSyncAbstraction,
-                 AnimationFinishedNotifier& animationFinishedNotifier,
+                 CompleteNotificationInterface& animationFinishedNotifier,
                  PropertyNotifier& propertyNotifier,
                  ResourceManager& resourceManager,
                  DiscardQueue& discardQueue,
@@ -114,33 +119,9 @@ public:
                  TouchResampler& touchResampler );
 
   /**
-   * Destructor. Not virtual as this is not a base class
-   */
-  ~UpdateManager();
-
-  /**
-   * Sets a pointer to the internal render task list.
-   *
-   * The render task list is used to notify which render tasks with refresh rate REFRESH_ONCE have finished.
-   *
-   * @param[in] renderTaskList A pointer to the internal render task list.
-   */
-  void SetRenderTaskList( Internal::RenderTaskList* renderTaskList );
-
-  /**
-   * The event-thread uses this interface to queue messages for the next update.
-   * @return The event-to-update interface.
-   */
-  EventToUpdate& GetEventToUpdate();
-
-  /**
-   * @return the event buffer index
+   * Destructor.
    */
-  BufferIndex GetEventBufferIndex() const
-  {
-    // inlined as its called often
-    return mSceneGraphBuffers.GetEventBufferIndex();
-  }
+  virtual ~UpdateManager();
 
   // Node connection methods
 
@@ -173,8 +154,7 @@ public:
    * 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 );
 
@@ -273,13 +253,30 @@ public:
    */
   void PropertyNotificationSetNotify( PropertyNotification* propertyNotification, PropertyNotification::NotifyMode notifyMode );
 
-  // Shaders
+  /**
+   * @brief Get the geometry owner
+   *
+   * @return The geometry owner
+   */
+  ObjectOwnerContainer< Geometry >& GetGeometryOwner();
 
+  ObjectOwnerContainer< Renderer >& GetRendererOwner();
   /**
-   * Retrieve the default shader.
-   * @return The default shader.
+   * @brief Get the material owner
+   *
+   * @return The material owner
    */
-  Shader* GetDefaultShader();
+  ObjectOwnerContainer< Material >& GetMaterialOwner();
+
+  /**
+   * @brief Get the property buffer owner
+   *
+   * @return The property buffer owner
+   */
+  ObjectOwnerContainer< PropertyBuffer >& GetPropertyBufferOwner();
+
+
+  // Shaders
 
   /**
    * Add a newly created shader.
@@ -297,42 +294,27 @@ public:
   void RemoveShader(Shader* shader);
 
   /**
-   * Set the shader program for a specified GeometryType to a Shader object
+   * Set the shader program for a Shader object
    * @param[in] shader        The shader to modify
-   * @param[in] geometryType  The GeometryType to map to the program
-   * @param[in] subType       The program subtype
-   * @param[in] resourceId    A ResourceManager ticket ID for the program data (source and compiled binary)
-   * @param[in] shaderHash  hash key created with vertex and fragment shader code
+   * @param[in] shaderData    Source code, hash over source, and optional compiled binary for the shader program
+   * @param[in] modifiesGeometry True if the vertex shader modifies geometry
    */
-  void SetShaderProgram( Shader* shader, GeometryType geometryType, ShaderSubTypes subType, Integration::ResourceId resourceId, size_t shaderHash );
+  void SetShaderProgram( Shader* shader, Internal::ShaderDataPtr shaderData, bool modifiesGeometry );
 
   /**
-   * Add an animatable mesh
-   * @param[in] animatableMesh The animatable mesh to add.
-   * @post the animatableMesh is owned by the UpdateManager.
+   * @brief Accept compiled shaders passed back on render thread for saving.
+   * @param[in] shaderData Source code, hash over source, and corresponding compiled binary to be saved.
    */
-  void AddAnimatableMesh( AnimatableMesh* animatableMesh );
+  virtual void SaveBinary( Internal::ShaderDataPtr shaderData );
 
   /**
-   * Remove an animatable mesh
-   * @pre The animatable mesh has been added to the update manager
-   * @param[in] animatableMesh The animatable mesh to add.
+   * @brief Set the destination for compiled shader binaries to be passed on to.
+   * The dispatcher passed in will be called from the update thread.
+   * @param[in] upstream A sink for ShaderDatas to be passed into.
    */
-  void RemoveAnimatableMesh( AnimatableMesh* animatableMesh );
+  void SetShaderSaver( ShaderSaver& upstream );
 
-  /**
-   * Add a material
-   * @param[in] material The material to add
-   * @post the material remains owned by its event object
-   */
-  void AddMaterial(Material* material);
-
-  /**
-   * Remove a material
-   * @pre The material has been added to the UpdateManager
-   * @param[in] material The material to remove
-   */
-  void RemoveMaterial(Material* material);
+  // Gestures
 
   /**
    * Add a newly created gesture.
@@ -349,16 +331,122 @@ public:
    */
   void RemoveGesture( PanGesture* gesture );
 
+// Message queue handling
+
+  /**
+   * Reserve space for another message in the queue; this must then be initialized by the caller.
+   * The message will be read from the update-thread after the next FlushMessages is called.
+   * @post Calling this method may invalidate any previously returned slots.
+   * @param[in] size The message size with respect to the size of type "char".
+   * @param[in] updateScene A flag, when true denotes that the message will cause the scene-graph node tree to require an update.
+   * @note the default value of updateScene should match that in EventThreadServices::ReserveMessageSlot.
+   * @return A pointer to the first char allocated for the message.
+   */
+  unsigned int* ReserveMessageSlot( std::size_t size, bool updateScene = true );
+
+  /**
+   * @return the current event-buffer index.
+   */
+  BufferIndex GetEventBufferIndex() const
+  {
+    // inlined as its called often from event thread
+    return mSceneGraphBuffers.GetEventBufferIndex();
+  }
+
+  /**
+   * Called by the event-thread to signal that FlushQueue will be called
+   * e.g. when it has finished event processing.
+   */
+  void EventProcessingStarted();
+
+  /**
+   * Flush the set of messages, which were previously stored with QueueMessage().
+   * Calls to this thread-safe method should be minimized, to avoid thread blocking.
+   *
+   * @return True if there are messages to process.
+   */
+  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( 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] uWrapMode Wrapping mode in x direction
+   * @param[in] vWrapMode Wrapping mode in y direction
+   */
+  void SetWrapMode( Render::Sampler* sampler, unsigned int uWrapMode, unsigned int vWrapMode );
+
+  /**
+   * Add a new sampler 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( 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, 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
+   * @post Sends a message to RenderManager to set the new data to the property buffer.
+   */
+  void SetPropertyBufferData(Render::PropertyBuffer* propertyBuffer, Dali::Vector<char>* data);
+
+  /**
+   * Sets the size of an existing property buffer
+   * @param[in] propertyBuffer The property buffer.
+   * @param[in] size The new size of the buffer
+   * @post Sends a message to RenderManager to set the new size to the property buffer.
+   */
+  void SetPropertyBufferSize(Render::PropertyBuffer* propertyBuffer, size_t size );
+
 public:
 
   /**
    * Performs an Update traversal on the scene-graph.
    * @param[in] elapsedSeconds The elapsed time that should be applied to animations.
-   * @param[in] lastVSyncTime The last time, in milliseconds, that we had a VSync.
-   * @param[in] nextVSyncTime The estimated time, in milliseconds, of the next VSync.
+   * @param[in] lastVSyncTimeMilliseconds The last time, in milliseconds, that we had a VSync.
+   * @param[in] nextVSyncTimeMilliseconds The estimated time, in milliseconds, of the next VSync.
    * @return True if further updates are required e.g. during animations.
    */
-  unsigned int Update( float elapsedSeconds, unsigned int lastVSyncTime, unsigned int nextVSyncTime );
+  unsigned int Update( float elapsedSeconds, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds );
 
   /**
    * Set the background color i.e. the glClear color used at the beginning of each frame.
@@ -384,9 +472,6 @@ public:
    */
   void SetLayerDepths( const std::vector< Layer* >& layers, bool systemLevel );
 
-  void InitializeDynamicsWorld( DynamicsWorld* world, Integration::DynamicsWorldSettings* worldSettings, Shader* debugShader );
-  void TerminateDynamicsWorld();
-
 private:
 
   // Undefined
@@ -414,40 +499,45 @@ private:
   void PostProcessResources();
 
   /**
-   * Helper to reset a Node properties.
-   * @param[in] node The node.
-   */
-  void ResetNodeProperty( Node& node );
-
-  /**
    * Helper to reset all Node properties
+   * @param[in] bufferIndex to use
    */
-  void ResetProperties();
+  void ResetProperties( BufferIndex bufferIndex );
 
   /**
    * Perform gesture updates.
-   * @param[in]  lastVSyncTime  The last VSync time.
-   * @param[in]  nextVSyncTime  The estimated time of the next VSync.
+   * @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 ProcessGestures( unsigned int lastVSyncTime, unsigned int nextVSyncTime );
+  bool ProcessGestures( BufferIndex bufferIndex, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds );
 
   /**
    * Perform animation updates
+   * @param[in] bufferIndex to use
    * @param[in] elapsedSeconds time since last frame
    */
-  void Animate( float elapsedSeconds );
+  void Animate( BufferIndex bufferIndex, float elapsedSeconds );
 
   /**
    * Perform constraint updates.
    * @note Applies constraints to nodes first (depth first search order).
    * Then shader constraints second (construction order)
+   * @param[in] bufferIndex to use
    */
-  void ApplyConstraints();
+  void ApplyConstraints( 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.
+   */
+  void ForwardCompiledShadersToEventThread();
 
   /**
    * Update the default camera.
@@ -458,24 +548,15 @@ private:
 
   /**
    * Update node shaders, opacity, geometry etc.
+   * @param[in] bufferIndex to use
    */
-  void UpdateNodes();
-
-  /**
-   * Update animatable meshes
-   */
-  void UpdateMeshes( BufferIndex updateBufferIndex, AnimatableMeshContainer& meshes );
+  void UpdateNodes( BufferIndex bufferIndex );
 
   /**
-   * Update materials - Ensure all render materials are updated with texture pointers
-   * when ready.
+   * Update Renderers
+   * @param[in] bufferIndex to use
    */
-  void UpdateMaterials( BufferIndex updateBufferIndex, MaterialContainer& materials );
-
-  /**
-   * PrepareMaterials - Ensure updated material properties are sent to render materials
-   */
-  void PrepareMaterials( BufferIndex updateBufferIndex, MaterialContainer& materials );
+  void UpdateRenderers( BufferIndex bufferIndex );
 
 private:
 
@@ -494,7 +575,7 @@ inline void InstallRootMessage( UpdateManager& manager, Layer& root, bool system
   typedef MessageValue2< UpdateManager, Layer*, bool > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
+  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 );
@@ -505,7 +586,7 @@ inline void AddNodeMessage( UpdateManager& manager, Node& node )
   typedef MessageValue1< UpdateManager, OwnerPointer<Node> > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
+  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 );
@@ -520,7 +601,7 @@ inline void ConnectNodeMessage( UpdateManager& manager, const Node& constParent,
   typedef MessageValue2< UpdateManager, Node*, Node* > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
+  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 );
@@ -534,7 +615,7 @@ inline void DisconnectNodeMessage( UpdateManager& manager, const Node& constNode
   typedef MessageValue1< UpdateManager, Node* > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
+  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::DisconnectNode, &node );
@@ -548,7 +629,7 @@ inline void DestroyNodeMessage( UpdateManager& manager, const Node& constNode )
   typedef MessageValue1< UpdateManager, Node* > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
+  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::DestroyNode, &node );
@@ -562,7 +643,7 @@ inline void AttachToNodeMessage( UpdateManager& manager, const Node& constParent
   typedef MessageValue2< UpdateManager, Node*, NodeAttachmentOwner > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
+  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 );
@@ -573,7 +654,7 @@ inline void AddObjectMessage( UpdateManager& manager, PropertyOwner* object )
   typedef MessageValue1< UpdateManager, OwnerPointer<PropertyOwner> > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
+  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::AddObject, object );
@@ -584,7 +665,7 @@ inline void RemoveObjectMessage( UpdateManager& manager, PropertyOwner* object )
   typedef MessageValue1< UpdateManager, PropertyOwner* > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
+  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::RemoveObject, object );
@@ -595,7 +676,7 @@ inline void AddAnimationMessage( UpdateManager& manager, Animation* animation )
   typedef MessageValue1< UpdateManager, Animation* > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
+  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::AddAnimation, animation );
@@ -609,7 +690,7 @@ inline void StopAnimationMessage( UpdateManager& manager, const Animation& const
   typedef MessageValue1< UpdateManager, Animation* > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
+  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::StopAnimation, &animation );
@@ -623,7 +704,7 @@ inline void RemoveAnimationMessage( UpdateManager& manager, const Animation& con
   typedef MessageValue1< UpdateManager, Animation* > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
+  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::RemoveAnimation, &animation );
@@ -634,7 +715,7 @@ inline void AddPropertyNotificationMessage( UpdateManager& manager, PropertyNoti
   typedef MessageValue1< UpdateManager, PropertyNotification* > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
+  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::AddPropertyNotification, propertyNotification );
@@ -648,7 +729,7 @@ inline void RemovePropertyNotificationMessage( UpdateManager& manager, const Pro
   typedef MessageValue1< UpdateManager, PropertyNotification* > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
+  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::RemovePropertyNotification, &propertyNotification );
@@ -664,7 +745,7 @@ inline void PropertyNotificationSetNotifyModeMessage( UpdateManager& manager,
   typedef MessageValue2< UpdateManager, PropertyNotification*, PropertyNotification::NotifyMode > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
+  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::PropertyNotificationSetNotify, propertyNotification, notifyMode );
@@ -676,7 +757,7 @@ inline void AddShaderMessage( UpdateManager& manager, Shader& shader )
   typedef MessageValue1< UpdateManager, OwnerPointer< Shader > > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
+  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 );
@@ -688,7 +769,7 @@ inline void RemoveShaderMessage( UpdateManager& manager, Shader& shader )
   typedef MessageValue1< UpdateManager, Shader* > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
+  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::RemoveShader, &shader );
@@ -696,51 +777,24 @@ inline void RemoveShaderMessage( UpdateManager& manager, Shader& shader )
 
 inline void SetShaderProgramMessage( UpdateManager& manager,
                                      Shader& shader,
-                                     GeometryType geometryType,
-                                     ShaderSubTypes subType,
-                                     Integration::ResourceId resourceId,
-                                     size_t shaderHash )
+                                     Internal::ShaderDataPtr shaderData,
+                                     bool modifiesGeometry )
 {
-  typedef MessageValue5< UpdateManager, Shader*, GeometryType, ShaderSubTypes, Integration::ResourceId, size_t > LocalType;
+  typedef MessageValue3< UpdateManager, Shader*, Internal::ShaderDataPtr, bool > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
+  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::SetShaderProgram, &shader, geometryType, subType, resourceId, shaderHash );
+  new (slot) LocalType( &manager, &UpdateManager::SetShaderProgram, &shader, shaderData, modifiesGeometry );
 }
 
-// The render thread can safely change the AnimatableMesh
-inline void AddAnimatableMeshMessage( UpdateManager& manager, AnimatableMesh& animatableMesh )
-{
-  typedef MessageValue1< UpdateManager, AnimatableMesh* > LocalType;
-
-  // Reserve some memory inside the message queue
-  unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
-
-  // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &manager, &UpdateManager::AddAnimatableMesh, &animatableMesh );
-}
-
-// The render thread can safely change the AnimatableMesh
-inline void RemoveAnimatableMeshMessage( UpdateManager& manager, AnimatableMesh& animatableMesh )
-{
-  typedef MessageValue1< UpdateManager, AnimatableMesh* > LocalType;
-
-  // Reserve some memory inside the message queue
-  unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
-
-  // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &manager, &UpdateManager::RemoveAnimatableMesh, &animatableMesh );
-}
-
-
 inline void SetBackgroundColorMessage( UpdateManager& manager, const Vector4& color )
 {
   typedef MessageValue1< UpdateManager, Vector4 > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
+  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::SetBackgroundColor, color );
@@ -751,7 +805,7 @@ inline void SetDefaultSurfaceRectMessage( UpdateManager& manager, const Rect<int
   typedef MessageValue1< UpdateManager, Rect<int> > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
+  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::SetDefaultSurfaceRect, rect );
@@ -762,7 +816,7 @@ inline void KeepRenderingMessage( UpdateManager& manager, float durationSeconds
   typedef MessageValue1< UpdateManager, float > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
+  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::KeepRendering, durationSeconds );
@@ -779,79 +833,156 @@ inline void SetLayerDepthsMessage( UpdateManager& manager, const std::vector< La
   typedef MessageValue2< UpdateManager, std::vector< Layer* >, bool > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
+  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::SetLayerDepths, layers, systemLevel );
 }
 
-// Dynamics messages
-inline void InitializeDynamicsWorldMessage(UpdateManager& manager, DynamicsWorld* dynamicsworld, Integration::DynamicsWorldSettings* worldSettings, const Shader* debugShader)
+inline void AddGestureMessage( UpdateManager& manager, PanGesture* gesture )
 {
-  typedef MessageValue3< UpdateManager, DynamicsWorld*, Integration::DynamicsWorldSettings*, Shader*> LocalType;
+  typedef MessageValue1< UpdateManager, PanGesture* > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
+  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::InitializeDynamicsWorld, dynamicsworld, worldSettings, const_cast<Shader*>(debugShader) );
+  new (slot) LocalType( &manager, &UpdateManager::AddGesture, gesture );
 }
 
-inline void TerminateDynamicsWorldMessage(UpdateManager& manager)
+inline void RemoveGestureMessage( UpdateManager& manager, PanGesture* gesture )
 {
-  typedef Message< UpdateManager > LocalType;
+  typedef MessageValue1< UpdateManager, PanGesture* > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
+  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::TerminateDynamicsWorld );
+  new (slot) LocalType( &manager, &UpdateManager::RemoveGesture, gesture );
 }
 
-inline void AddMaterialMessage( UpdateManager& manager, Material* material )
+template< typename T >
+inline void AddMessage( UpdateManager& manager, ObjectOwnerContainer<T>& owner, T& object )
 {
-  typedef MessageValue1< UpdateManager, Material* > LocalType;
+  typedef MessageValue1< ObjectOwnerContainer<T>, OwnerPointer< T > > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
+  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( &manager, &UpdateManager::AddMaterial, material );
+  new (slot) LocalType( &owner, &ObjectOwnerContainer<T>::Remove, &object );
 }
 
-inline void RemoveMaterialMessage( UpdateManager& manager, Material* material )
+inline void AddSamplerMessage( UpdateManager& manager, Render::Sampler& sampler )
 {
-  typedef MessageValue1< UpdateManager, Material* > LocalType;
+  typedef MessageValue1< UpdateManager, Render::Sampler* > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
+  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::RemoveMaterial, material );
+  new (slot) LocalType( &manager, &UpdateManager::AddSampler, &sampler );
 }
 
-inline void AddGestureMessage( UpdateManager& manager, PanGesture* gesture )
+inline void RemoveSamplerMessage( UpdateManager& manager, Render::Sampler& sampler )
 {
-  typedef MessageValue1< UpdateManager, PanGesture* > LocalType;
+  typedef MessageValue1< UpdateManager, Render::Sampler* > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
+  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::RemoveSampler, &sampler );
 }
 
-inline void RemoveGestureMessage( UpdateManager& manager, PanGesture* gesture )
+inline void SetFilterModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int minFilterMode, unsigned int magFilterMode )
 {
-  typedef MessageValue1< UpdateManager, PanGesture* > LocalType;
+  typedef MessageValue3< UpdateManager, Render::Sampler*, unsigned int, unsigned int > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
+  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::SetFilterMode, &sampler, minFilterMode, magFilterMode );
+}
+
+inline void SetWrapModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int uWrapMode, unsigned int vWrapMode )
+{
+  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( &manager, &UpdateManager::SetWrapMode, &sampler, uWrapMode, vWrapMode );
+}
+
+inline void AddPropertyBuffer( 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::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, Render::PropertyBuffer::Format* format )
+{
+  typedef MessageValue2< UpdateManager, Render::PropertyBuffer*, 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, Vector<char>* data )
+{
+  typedef MessageValue2< UpdateManager, Render::PropertyBuffer*, Vector<char>*  > 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 );
+}
+
+inline void SetPropertyBufferSize( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, size_t size )
+{
+  typedef MessageValue2< UpdateManager, Render::PropertyBuffer*, 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::SetPropertyBufferSize, &propertyBuffer, size );
+}
+
+
 } // namespace SceneGraph
 
 } // namespace Internal