ffde6fc63ce960ecdc7285de207c4b2be90f5fd0
[platform/core/uifw/dali-core.git] / dali / internal / update / manager / update-manager.h
1 #ifndef DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H
2 #define DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H
3
4 /*
5  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/common/vector-wrapper.h>
23 #include <dali/public-api/common/dali-common.h>
24
25 #include <dali/integration-api/resource-declarations.h>
26
27 #include <dali/internal/common/message.h>
28 #include <dali/internal/common/type-abstraction-enums.h>
29 #include <dali/internal/common/shader-saver.h>
30 #include <dali/internal/event/common/event-thread-services.h>
31 #include <dali/internal/update/animation/scene-graph-animation.h>
32 #include <dali/internal/update/common/scene-graph-buffers.h>
33 #include <dali/internal/update/common/scene-graph-property-notification.h>
34 #include <dali/internal/update/manager/object-owner-container.h>
35 #include <dali/internal/update/nodes/node.h>
36 #include <dali/internal/update/nodes/scene-graph-layer.h>
37 #include <dali/internal/update/rendering/scene-graph-renderer.h>
38 #include <dali/internal/update/gestures/scene-graph-pan-gesture.h>
39 #include <dali/internal/update/render-tasks/scene-graph-camera.h>
40 #include <dali/internal/render/shaders/scene-graph-shader.h>
41 #include <dali/internal/render/renderers/render-property-buffer.h>
42 #include <dali/internal/event/rendering/texture-impl.h>
43
44 namespace Dali
45 {
46
47 namespace Integration
48 {
49 class GlSyncAbstraction;
50 class RenderController;
51
52 } // namespace Integration
53
54 namespace Internal
55 {
56
57 class PropertyNotifier;
58 class NotificationManager;
59 class CompleteNotificationInterface;
60 class TouchResampler;
61
62 namespace Render
63 {
64 struct Sampler;
65 class FrameBuffer;
66 }
67 // value types used by messages
68 template <> struct ParameterType< PropertyNotification::NotifyMode >
69 : public BasicType< PropertyNotification::NotifyMode > {};
70
71 namespace SceneGraph
72 {
73
74 class Animation;
75 class DiscardQueue;
76 class RenderManager;
77 class RenderTaskList;
78 class RenderTaskProcessor;
79 class RenderQueue;
80 class PropertyBuffer;
81 class TextureSet;
82
83 struct NodeDepthPair
84 {
85   SceneGraph::Node* node;
86   uint32_t sortedDepth;
87   NodeDepthPair( SceneGraph::Node* node, uint32_t sortedDepth )
88   : node(node),
89     sortedDepth(sortedDepth)
90   {
91   }
92 };
93
94 struct NodeDepths
95 {
96   std::vector<NodeDepthPair> nodeDepths;
97   NodeDepths( int reserveSize )
98   {
99     nodeDepths.reserve(reserveSize);
100   }
101
102   void Add( SceneGraph::Node* node, uint32_t sortedDepth )
103   {
104     nodeDepths.push_back( NodeDepthPair( node, sortedDepth ) );
105   }
106 };
107
108
109 /**
110  * UpdateManager maintains a scene graph i.e. a tree of nodes as well as
111  * other scene graph property owning objects.
112  * It controls the Update traversal, in which nodes are repositioned/animated,
113  * and organizes the the culling and rendering of the scene.
114  * It also maintains the lifecycle of nodes and other property owners that are
115  * disconnected from the scene graph.
116  */
117 class UpdateManager : public ShaderSaver
118 {
119 public:
120
121   /**
122    * Construct a new UpdateManager.
123    * @param[in] notificationManager This should be notified when animations have finished.
124    * @param[in] animationFinishedNotifier The CompleteNotificationInterface that handles animation completions
125    * @param[in] propertyNotifier The PropertyNotifier
126    * @param[in] discardQueue Nodes are added here when disconnected from the scene-graph.
127    * @param[in] controller After messages are flushed, we request a render from the RenderController.
128    * @param[in] renderManager This is responsible for rendering the results of each "update".
129    * @param[in] renderQueue Used to queue messages for the next render.
130    * @param[in] renderTaskProcessor Handles RenderTasks and RenderInstrucitons.
131    */
132   UpdateManager( NotificationManager& notificationManager,
133                  CompleteNotificationInterface& animationFinishedNotifier,
134                  PropertyNotifier& propertyNotifier,
135                  DiscardQueue& discardQueue,
136                  Integration::RenderController& controller,
137                  RenderManager& renderManager,
138                  RenderQueue& renderQueue,
139                  RenderTaskProcessor& renderTaskProcessor );
140
141   /**
142    * Destructor.
143    */
144   virtual ~UpdateManager();
145
146   // Node connection methods
147
148   /**
149    * Get the scene graph side list of RenderTasks.
150    * @param[in] systemLevel True if using the system-level overlay.
151    * @return The list of render tasks
152    */
153   RenderTaskList* GetRenderTaskList( bool systemLevel );
154
155   /**
156    * Installs a new layer as the root node.
157    * @pre The UpdateManager does not already have an installed root node.
158    * @pre The layer is of derived Node type Layer.
159    * @pre The layer does not have a parent.
160    * @param[in] layer The new root node.
161    * @param[in] systemLevel True if using the system-level overlay.
162    * @post The node is owned by UpdateManager.
163    */
164   void InstallRoot( Layer* layer, bool systemLevel );
165
166   /**
167    * Add a Node; UpdateManager takes ownership.
168    * @pre The node does not have a parent.
169    * @param[in] node The node to add.
170    */
171   void AddNode( Node* node );
172
173   /**
174    * Connect a Node to the scene-graph.
175    * A disconnected Node has has no parent or children, and its properties cannot be animated/constrained.
176    * @pre The node does not already have a parent.
177    * @param[in] parent The new parent node.
178    */
179   void ConnectNode( Node* parent, Node* node );
180
181   /**
182    * Disconnect a Node from the scene-graph.
183    * A disconnected Node has has no parent or children, and its properties cannot be animated/constrained.
184    * @pre The node has a parent.
185    * @param[in] node The node to disconnect.
186    */
187   void DisconnectNode( Node* node );
188
189   /**
190    * Destroy a Node owned by UpdateManager.
191    * This is not immediate; Nodes are passed to the RenderQueue to allow GL resources to be deleted.
192    * In the following update, the previously queued Nodes may be deleted.
193    * @pre The node has been disconnected from the scene-graph i.e. has no parent or children.
194    * @param[in] node The node to destroy.
195    */
196   void DestroyNode( Node* node );
197
198   /**
199    * Add a camera on scene
200    * @param[in] camera to add
201    */
202   void AddCamera( Camera* camera );
203
204   /**
205    * Remove a camera from scene
206    * @param[in] camera to remove
207    */
208   void RemoveCamera( const Camera* camera );
209
210   /**
211    * Add a newly created object.
212    * @param[in] object The object to add.
213    * @post The object is owned by UpdateManager.
214    */
215   void AddObject( PropertyOwner* object );
216
217   /**
218    * Remove an object.
219    * @param[in] object The object to remove.
220    */
221   void RemoveObject( PropertyOwner* object );
222
223   // Animations
224
225   /**
226    * Add a newly created animation.
227    * @param[in] animation The animation to add.
228    * @post The animation is owned by UpdateManager.
229    */
230   void AddAnimation( Animation* animation );
231
232   /**
233    * Stop an animation.
234    * @param[in] animation The animation to stop.
235    */
236   void StopAnimation( Animation* animation );
237
238   /**
239    * Remove an animation.
240    * @param[in] animation The animation to remove.
241    */
242   void RemoveAnimation( Animation* animation );
243
244   /**
245    * Query whether any animations are currently running.
246    * @return True if any animations are running.
247    */
248   bool IsAnimationRunning() const;
249
250   // Property Notification
251
252   /**
253    * Add a newly created property notification
254    * @param[in] propertyNotification The notification to add
255    * @post The propertyNotification is owned by UpdateManager.
256    */
257   void AddPropertyNotification( PropertyNotification* propertyNotification );
258
259   /**
260    * Remove a property notification
261    * @param[in] propertyNotification The notification to remove
262    */
263   void RemovePropertyNotification( PropertyNotification* propertyNotification );
264
265   /**
266    * Set Notify state for PropertyNotification
267    * @param[in] propertyNotification The notification to remove
268    * @param[in] notifyMode The notification mode.
269    */
270   void PropertyNotificationSetNotify( PropertyNotification* propertyNotification, PropertyNotification::NotifyMode notifyMode );
271
272   /**
273    * @brief Get the renderer owner
274    *
275    * @return The renderer owner
276    */
277   ObjectOwnerContainer< Renderer >& GetRendererOwner();
278
279   /**
280    * @brief Get the property buffer owner
281    *
282    * @return The property buffer owner
283    */
284   ObjectOwnerContainer< PropertyBuffer >& GetPropertyBufferOwner();
285
286
287   // Shaders
288
289   /**
290    * Add a newly created shader.
291    * @param[in] shader The shader to add.
292    * @post The shader is owned by the UpdateManager.
293    */
294   void AddShader(Shader* shader);
295
296   /**
297    * Remove a shader.
298    * @pre The shader has been added to the UpdateManager.
299    * @param[in] shader The shader to remove.
300    * @post The shader is destroyed.
301    */
302   void RemoveShader(Shader* shader);
303
304   /**
305    * Add a newly created TextureSet.
306    * @param[in] textureSet The texture set to add.
307    * @post The TextureSet is owned by the UpdateManager.
308    */
309   void AddTextureSet(TextureSet* textureSet);
310
311   /**
312    * Remove a TextureSet.
313    * @pre The TextureSet has been added to the UpdateManager.
314    * @param[in] textureSet The TextureSet to remove.
315    * @post The TextureSet is destroyed.
316    */
317   void RemoveTextureSet(TextureSet* textureSet);
318
319   /**
320    * Set the shader program for a Shader object
321    * @param[in] shader        The shader to modify
322    * @param[in] shaderData    Source code, hash over source, and optional compiled binary for the shader program
323    * @param[in] modifiesGeometry True if the vertex shader modifies geometry
324    */
325   void SetShaderProgram( Shader* shader, Internal::ShaderDataPtr shaderData, bool modifiesGeometry );
326
327   /**
328    * @brief Accept compiled shaders passed back on render thread for saving.
329    * @param[in] shaderData Source code, hash over source, and corresponding compiled binary to be saved.
330    */
331   virtual void SaveBinary( Internal::ShaderDataPtr shaderData );
332
333   /**
334    * @brief Set the destination for compiled shader binaries to be passed on to.
335    * The dispatcher passed in will be called from the update thread.
336    * @param[in] upstream A sink for ShaderDatas to be passed into.
337    */
338   void SetShaderSaver( ShaderSaver& upstream );
339
340   // Gestures
341
342   /**
343    * Add a newly created gesture.
344    * @param[in] gesture The gesture to add.
345    * @post The gesture is owned by the UpdateManager.
346    */
347   void AddGesture( PanGesture* gesture );
348
349   /**
350    * Remove a gesture.
351    * @pre The gesture has been added to the UpdateManager.
352    * @param[in] gesture The gesture to remove.
353    * @post The gesture is destroyed.
354    */
355   void RemoveGesture( PanGesture* gesture );
356
357 // Message queue handling
358
359   /**
360    * Reserve space for another message in the queue; this must then be initialized by the caller.
361    * The message will be read from the update-thread after the next FlushMessages is called.
362    * @post Calling this method may invalidate any previously returned slots.
363    * @param[in] size The message size with respect to the size of type "char".
364    * @param[in] updateScene A flag, when true denotes that the message will cause the scene-graph node tree to require an update.
365    * @note the default value of updateScene should match that in EventThreadServices::ReserveMessageSlot.
366    * @return A pointer to the first char allocated for the message.
367    */
368   unsigned int* ReserveMessageSlot( std::size_t size, bool updateScene = true );
369
370   /**
371    * @return the current event-buffer index.
372    */
373   BufferIndex GetEventBufferIndex() const
374   {
375     // inlined as its called often from event thread
376     return mSceneGraphBuffers.GetEventBufferIndex();
377   }
378
379   /**
380    * Called by the event-thread to signal that FlushQueue will be called
381    * e.g. when it has finished event processing.
382    */
383   void EventProcessingStarted();
384
385   /**
386    * Flush the set of messages, which were previously stored with QueueMessage().
387    * Calls to this thread-safe method should be minimized, to avoid thread blocking.
388    *
389    * @return True if there are messages to process.
390    */
391   bool FlushQueue();
392
393   /**
394    * Add a new sampler to RenderManager
395    * @param[in] sampler The sampler to add
396    * @post Sends a message to RenderManager to add the sampler.
397    * The sampler will be owned by RenderManager
398    */
399   void AddSampler( Render::Sampler* sampler );
400
401   /**
402    * Removes an existing sampler from RenderManager
403    * @param[in] sampler The sampler to remove
404    * @post The sampler will be destroyed in the render thread
405    */
406   void RemoveSampler( Render::Sampler* sampler );
407
408   /**
409    * Sets the filter modes for an existing sampler
410    * @param[in] sampler The sampler
411    * @param[in] minFilterMode The filter to use under minification
412    * @param[in] magFilterMode The filter to use under magnification
413    */
414   void SetFilterMode( Render::Sampler* sampler, unsigned int minFilterMode, unsigned int magFilterMode );
415
416   /**
417    * Sets the wrap mode for an existing sampler
418    * @param[in] sampler The sampler
419    * @param[in] rWrapMode Wrapping mode in z direction
420    * @param[in] sWrapMode Wrapping mode in x direction
421    * @param[in] tWrapMode Wrapping mode in y direction
422    */
423   void SetWrapMode( Render::Sampler* sampler, unsigned int rWrapMode, unsigned int sWrapMode, unsigned int tWrapMode );
424
425   /**
426    * Add a new property buffer to RenderManager
427    * @param[in] propertryBuffer The property buffer to add
428    * @post Sends a message to RenderManager to add the property buffer.
429    * The property buffer will be owned by RenderManager
430    */
431   void AddPropertyBuffer( Render::PropertyBuffer* propertryBuffer );
432
433   /**
434    * Removes an existing PropertyBuffer from RenderManager
435    * @param[in] propertryBuffer The property buffer to remove
436    * @post The property buffer will be destroyed in the render thread
437    */
438   void RemovePropertyBuffer( Render::PropertyBuffer* propertryBuffer );
439
440   /**
441    * Sets the format of an existing property buffer
442    * @param[in] propertyBuffer The property buffer.
443    * @param[in] format The new format of the buffer
444    * @post Sends a message to RenderManager to set the new format to the property buffer.
445    */
446   void SetPropertyBufferFormat(Render::PropertyBuffer* propertyBuffer, Render::PropertyBuffer::Format* format );
447
448   /**
449    * Sets the data of an existing property buffer
450    * @param[in] propertyBuffer The property buffer.
451    * @param[in] data The new data of the buffer
452    * @param[in] size The new size of the buffer
453    * @post Sends a message to RenderManager to set the new data to the property buffer.
454    */
455   void SetPropertyBufferData(Render::PropertyBuffer* propertyBuffer, Dali::Vector<char>* data, size_t size);
456
457   /**
458    * Adds a geometry to the RenderManager
459    * @param[in] geometry The geometry to add
460    * @post Sends a message to RenderManager to add the Geometry
461    * The geometry will be owned by RenderManager
462    */
463   void AddGeometry( Render::Geometry* geometry );
464
465   /**
466    * Removes an existing Geometry from RenderManager
467    * @param[in] geometry The geometry to remove
468    * @post The geometry will be destroyed in the render thread
469    */
470   void RemoveGeometry( Render::Geometry* geometry );
471
472   /**
473    * Sets the geometry type of an existing Geometry
474    * @param[in] geometry The geometry
475    * @param[in] geometryType The type of the geometry
476    */
477   void SetGeometryType( Render::Geometry* geometry, unsigned int geometryType );
478
479   /**
480    * Sets the index buffer to be used by a geometry
481    * @param[in] geometry The geometry
482    * @param[in] indices A vector containing the indices for the geometry
483    */
484   void SetIndexBuffer( Render::Geometry* geometry, Dali::Vector<unsigned short>& indices );
485
486   /**
487    * Adds a vertex buffer to a geomtry
488    * @param[in] geometry The geometry
489    * @param[in] propertyBuffer The property buffer
490    */
491   void AddVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer );
492
493   /**
494    * Removes a vertex buffer from a geometry
495    * @param[in] geometry The geometry
496    * @param[in] propertyBuffer The property buffer
497    */
498   void RemoveVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer );
499
500   /**
501    * Adds a texture to the render manager
502    * @param[in] texture The texture to add
503    * The texture will be owned by RenderManager
504    */
505   void AddTexture( Render::Texture* texture );
506
507   /**
508    * Removes a texture from the render manager
509    * @param[in] texture The texture to remove
510    * @post The texture will be destroyed in the render thread
511    */
512   void RemoveTexture( Render::Texture* texture );
513
514   /**
515    * Uploads data to a texture owned by the RenderManager
516    * @param[in] texture The texture
517    * @param[in] pixelData The pixel data object
518    * @param[in] params The parameters for the upload
519    */
520   void UploadTexture( Render::Texture* texture, PixelDataPtr pixelData, const Texture::UploadParams& params );
521
522   /**
523    * Generates mipmaps for a texture owned by the RenderManager
524    * @param[in] texture The texture
525    */
526   void GenerateMipmaps( Render::Texture* texture );
527
528   /**
529    * Adds a framebuffer to the render manager
530    * @param[in] frameBuffer The framebuffer to add
531    * The framebuffer will be owned by RenderManager
532    */
533   void AddFrameBuffer( Render::FrameBuffer* frameBuffer );
534
535   /**
536    * Removes a FrameBuffer from the render manager
537    * @param[in] frameBuffer The FrameBuffer to remove
538    * @post The FrameBuffer will be destroyed in the render thread
539    */
540   void RemoveFrameBuffer( Render::FrameBuffer* frameBuffer );
541
542   /**
543    * Attach a texture as color output to an existing FrameBuffer
544    * @param[in] frameBuffer The FrameBuffer
545    * @param[in] texture The texture that will be used as output when rendering
546    * @param[in] mipmapLevel The mipmap of the texture to be attached
547    * @param[in] layer Indicates which layer of a cube map or array texture to attach. Unused for 2D textures
548    */
549   void AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::Texture* texture, unsigned int mipmapLevel, unsigned int face );
550
551 public:
552
553   /**
554    * Performs an Update traversal on the scene-graph.
555    * @param[in] elapsedSeconds The elapsed time that should be applied to animations.
556    * @param[in] lastVSyncTimeMilliseconds The last time, in milliseconds, that we had a VSync.
557    * @param[in] nextVSyncTimeMilliseconds The estimated time, in milliseconds, of the next VSync.
558    * @return True if further updates are required e.g. during animations.
559    */
560   unsigned int Update( float elapsedSeconds, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds );
561
562   /**
563    * Set the background color i.e. the glClear color used at the beginning of each frame.
564    * @param[in] color The new background color.
565    */
566   void SetBackgroundColor(const Vector4& color);
567
568   /**
569    * Set the default surface rect.
570    * @param[in] rect The rect value representing the surface.
571    */
572   void SetDefaultSurfaceRect( const Rect<int>& rect );
573
574   /**
575    * @copydoc Dali::Stage::KeepRendering()
576    */
577   void KeepRendering( float durationSeconds );
578
579   /**
580    * Sets the depths of all layers.
581    * @param layers The layers in depth order.
582    * @param[in] systemLevel True if using the system-level overlay.
583    */
584   void SetLayerDepths( const std::vector< Layer* >& layers, bool systemLevel );
585
586   /**
587    * Set the depth indices of all nodes (in LayerUI's)
588    * @param[in] nodeDepths A vector of nodes and associated depth indices
589    */
590   void SetDepthIndices( NodeDepths* nodeDepths );
591
592 private:
593
594   // Undefined
595   UpdateManager(const UpdateManager&);
596
597   // Undefined
598   UpdateManager& operator=(const UpdateManager& rhs);
599
600   /**
601    * Helper to check whether the update-thread should keep going.
602    * @param[in] elapsedSeconds The time in seconds since the previous update.
603    * @return True if the update-thread should keep going.
604    */
605   unsigned int KeepUpdatingCheck( float elapsedSeconds ) const;
606
607   /**
608    * Post process resources that have been updated by renderer
609    */
610   void PostProcessResources();
611
612   /**
613    * Helper to reset all Node properties
614    * @param[in] bufferIndex to use
615    */
616   void ResetProperties( BufferIndex bufferIndex );
617
618   /**
619    * Perform gesture updates.
620    * @param[in] bufferIndex to use
621    * @param[in] lastVSyncTime  The last VSync time in milliseconds.
622    * @param[in] nextVSyncTime  The estimated time of the next VSync in milliseconds.
623    * @return true, if any properties were updated.
624    */
625   bool ProcessGestures( BufferIndex bufferIndex, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds );
626
627   /**
628    * Perform animation updates
629    * @param[in] bufferIndex to use
630    * @param[in] elapsedSeconds time since last frame
631    */
632   void Animate( BufferIndex bufferIndex, float elapsedSeconds );
633
634   /**
635    * Applies constraints to CustomObjects
636    * @param[in] bufferIndex to use
637    */
638   void ConstrainCustomObjects( BufferIndex bufferIndex );
639
640   /**
641    * Applies constraints to RenderTasks
642    * @param[in] bufferIndex to use
643    */
644   void ConstrainRenderTasks( BufferIndex bufferIndex );
645
646   /**
647    * Applies constraints to Shaders
648    * @param[in] bufferIndex to use
649    */
650   void ConstrainShaders( BufferIndex bufferIndex );
651
652   /**
653    * Perform property notification updates
654    * @param[in] bufferIndex to use
655    */
656   void ProcessPropertyNotifications( BufferIndex bufferIndex );
657
658   /**
659    * Pass shader binaries queued here on to event thread.
660    */
661   void ForwardCompiledShadersToEventThread();
662
663   /**
664    * Update node shaders, opacity, geometry etc.
665    * @param[in] bufferIndex to use
666    */
667   void UpdateNodes( BufferIndex bufferIndex );
668
669   /**
670    * Update Renderers
671    * @param[in] bufferIndex to use
672    */
673   void UpdateRenderers( BufferIndex bufferIndex );
674
675 private:
676
677   // needs to be direct member so that getter for event buffer can be inlined
678   SceneGraphBuffers mSceneGraphBuffers;
679
680   struct Impl;
681   Impl* mImpl;
682
683 };
684
685 // Messages for UpdateManager
686
687 inline void InstallRootMessage( UpdateManager& manager, Layer& root, bool systemLevel )
688 {
689   // Message has ownership of Layer while in transit from event -> update
690   typedef MessageValue2< UpdateManager, OwnerPointer<Layer>, bool > LocalType;
691
692   // Reserve some memory inside the message queue
693   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
694
695   // Construct message in the message queue memory; note that delete should not be called on the return value
696   new (slot) LocalType( &manager, &UpdateManager::InstallRoot, &root, systemLevel );
697 }
698
699 inline void AddNodeMessage( UpdateManager& manager, Node& node )
700 {
701   // Message has ownership of Node while in transit from event -> update
702   typedef MessageValue1< UpdateManager, OwnerPointer<Node> > LocalType;
703
704   // Reserve some memory inside the message queue
705   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
706
707   // Construct message in the message queue memory; note that delete should not be called on the return value
708   new (slot) LocalType( &manager, &UpdateManager::AddNode, &node );
709 }
710
711 inline void ConnectNodeMessage( UpdateManager& manager, const Node& constParent, const Node& constChild )
712 {
713   // Update thread can edit the object
714   Node& parent = const_cast< Node& >( constParent );
715   Node& child = const_cast< Node& >( constChild );
716
717   typedef MessageValue2< UpdateManager, Node*, Node* > LocalType;
718
719   // Reserve some memory inside the message queue
720   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
721
722   // Construct message in the message queue memory; note that delete should not be called on the return value
723   new (slot) LocalType( &manager, &UpdateManager::ConnectNode, &parent, &child );
724 }
725
726 inline void DisconnectNodeMessage( UpdateManager& manager, const Node& constNode )
727 {
728   // Scene graph thread can modify this object.
729   Node& node = const_cast< Node& >( constNode );
730
731   typedef MessageValue1< UpdateManager, Node* > LocalType;
732
733   // Reserve some memory inside the message queue
734   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
735
736   // Construct message in the message queue memory; note that delete should not be called on the return value
737   new (slot) LocalType( &manager, &UpdateManager::DisconnectNode, &node );
738 }
739
740 inline void DestroyNodeMessage( UpdateManager& manager, const Node& constNode )
741 {
742   // Scene graph thread can destroy this object.
743   Node& node = const_cast< Node& >( constNode );
744
745   typedef MessageValue1< UpdateManager, Node* > LocalType;
746
747   // Reserve some memory inside the message queue
748   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
749
750   // Construct message in the message queue memory; note that delete should not be called on the return value
751   new (slot) LocalType( &manager, &UpdateManager::DestroyNode, &node );
752 }
753
754 inline void AddCameraMessage( UpdateManager& manager, const Camera* constCamera )
755 {
756   // Message has ownership of Camera while in transit from event -> update
757   typedef MessageValue1< UpdateManager, OwnerPointer< Camera > > LocalType;
758
759   Camera* camera = const_cast<Camera*>( constCamera );
760   // Reserve some memory inside the message queue
761   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
762
763   // Construct message in the message queue memory; note that delete should not be called on the return value
764   new (slot) LocalType( &manager, &UpdateManager::AddCamera, camera );
765 }
766
767 inline void RemoveCameraMessage( UpdateManager& manager, const Camera* camera )
768 {
769   typedef MessageValue1< UpdateManager, const Camera* > LocalType;
770
771   // Reserve some memory inside the message queue
772   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
773
774   // Construct message in the message queue memory; note that delete should not be called on the return value
775   new (slot) LocalType( &manager, &UpdateManager::RemoveCamera, camera );
776 }
777
778 inline void AddObjectMessage( UpdateManager& manager, PropertyOwner* object )
779 {
780   // Message has ownership of object while in transit from event -> update
781   typedef MessageValue1< UpdateManager, OwnerPointer<PropertyOwner> > LocalType;
782
783   // Reserve some memory inside the message queue
784   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
785
786   // Construct message in the message queue memory; note that delete should not be called on the return value
787   new (slot) LocalType( &manager, &UpdateManager::AddObject, object );
788 }
789
790 inline void RemoveObjectMessage( UpdateManager& manager, PropertyOwner* object )
791 {
792   typedef MessageValue1< UpdateManager, PropertyOwner* > LocalType;
793
794   // Reserve some memory inside the message queue
795   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
796
797   // Construct message in the message queue memory; note that delete should not be called on the return value
798   new (slot) LocalType( &manager, &UpdateManager::RemoveObject, object );
799 }
800
801 inline void AddAnimationMessage( UpdateManager& manager, Animation* animation )
802 {
803   typedef MessageValue1< UpdateManager, Animation* > LocalType;
804
805   // Reserve some memory inside the message queue
806   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
807
808   // Construct message in the message queue memory; note that delete should not be called on the return value
809   new (slot) LocalType( &manager, &UpdateManager::AddAnimation, animation );
810 }
811
812 inline void StopAnimationMessage( UpdateManager& manager, const Animation& constAnimation )
813 {
814   // The scene-graph thread owns this object so it can safely edit it.
815   Animation& animation = const_cast< Animation& >( constAnimation );
816
817   typedef MessageValue1< UpdateManager, Animation* > LocalType;
818
819   // Reserve some memory inside the message queue
820   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
821
822   // Construct message in the message queue memory; note that delete should not be called on the return value
823   new (slot) LocalType( &manager, &UpdateManager::StopAnimation, &animation );
824 }
825
826 inline void RemoveAnimationMessage( UpdateManager& manager, const Animation& constAnimation )
827 {
828   // The scene-graph thread owns this object so it can safely edit it.
829   Animation& animation = const_cast< Animation& >( constAnimation );
830
831   typedef MessageValue1< UpdateManager, Animation* > LocalType;
832
833   // Reserve some memory inside the message queue
834   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
835
836   // Construct message in the message queue memory; note that delete should not be called on the return value
837   new (slot) LocalType( &manager, &UpdateManager::RemoveAnimation, &animation );
838 }
839
840 inline void AddPropertyNotificationMessage( UpdateManager& manager, PropertyNotification* propertyNotification )
841 {
842   // Message has ownership of PropertyNotification while in transit from event -> update
843   typedef MessageValue1< UpdateManager, OwnerPointer< PropertyNotification > > LocalType;
844
845   // Reserve some memory inside the message queue
846   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
847
848   // Construct message in the message queue memory; note that delete should not be called on the return value
849   new (slot) LocalType( &manager, &UpdateManager::AddPropertyNotification, propertyNotification );
850 }
851
852 inline void RemovePropertyNotificationMessage( UpdateManager& manager, const PropertyNotification& constPropertyNotification )
853 {
854   // The scene-graph thread owns this object so it can safely edit it.
855   PropertyNotification& propertyNotification = const_cast< PropertyNotification& >( constPropertyNotification );
856
857   typedef MessageValue1< UpdateManager, PropertyNotification* > LocalType;
858
859   // Reserve some memory inside the message queue
860   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
861
862   // Construct message in the message queue memory; note that delete should not be called on the return value
863   new (slot) LocalType( &manager, &UpdateManager::RemovePropertyNotification, &propertyNotification );
864 }
865
866 inline void PropertyNotificationSetNotifyModeMessage( UpdateManager& manager,
867                                                       const PropertyNotification* constPropertyNotification,
868                                                       PropertyNotification::NotifyMode notifyMode )
869 {
870   // The scene-graph thread owns this object so it can safely edit it.
871   PropertyNotification* propertyNotification = const_cast< PropertyNotification* >( constPropertyNotification );
872
873   typedef MessageValue2< UpdateManager, PropertyNotification*, PropertyNotification::NotifyMode > LocalType;
874
875   // Reserve some memory inside the message queue
876   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
877
878   // Construct message in the message queue memory; note that delete should not be called on the return value
879   new (slot) LocalType( &manager, &UpdateManager::PropertyNotificationSetNotify, propertyNotification, notifyMode );
880 }
881
882 // The render thread can safely change the Shader
883 inline void AddShaderMessage( UpdateManager& manager, Shader& shader )
884 {
885   typedef MessageValue1< UpdateManager, OwnerPointer< Shader > > LocalType;
886
887   // Reserve some memory inside the message queue
888   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
889
890   // Construct message in the message queue memory; note that delete should not be called on the return value
891   new (slot) LocalType( &manager, &UpdateManager::AddShader, &shader );
892 }
893
894 // The render thread can safely change the Shader
895 inline void RemoveShaderMessage( UpdateManager& manager, Shader& shader )
896 {
897   typedef MessageValue1< UpdateManager, Shader* > LocalType;
898
899   // Reserve some memory inside the message queue
900   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
901
902   // Construct message in the message queue memory; note that delete should not be called on the return value
903   new (slot) LocalType( &manager, &UpdateManager::RemoveShader, &shader );
904 }
905
906 inline void SetShaderProgramMessage( UpdateManager& manager,
907                                      Shader& shader,
908                                      Internal::ShaderDataPtr shaderData,
909                                      bool modifiesGeometry )
910 {
911   typedef MessageValue3< UpdateManager, Shader*, Internal::ShaderDataPtr, bool > LocalType;
912
913   // Reserve some memory inside the message queue
914   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
915
916   // Construct message in the message queue memory; note that delete should not be called on the return value
917   new (slot) LocalType( &manager, &UpdateManager::SetShaderProgram, &shader, shaderData, modifiesGeometry );
918 }
919
920 inline void SetBackgroundColorMessage( UpdateManager& manager, const Vector4& color )
921 {
922   typedef MessageValue1< UpdateManager, Vector4 > LocalType;
923
924   // Reserve some memory inside the message queue
925   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
926
927   // Construct message in the message queue memory; note that delete should not be called on the return value
928   new (slot) LocalType( &manager, &UpdateManager::SetBackgroundColor, color );
929 }
930
931 inline void SetDefaultSurfaceRectMessage( UpdateManager& manager, const Rect<int>& rect  )
932 {
933   typedef MessageValue1< UpdateManager, Rect<int> > LocalType;
934
935   // Reserve some memory inside the message queue
936   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
937
938   // Construct message in the message queue memory; note that delete should not be called on the return value
939   new (slot) LocalType( &manager, &UpdateManager::SetDefaultSurfaceRect, rect );
940 }
941
942 inline void KeepRenderingMessage( UpdateManager& manager, float durationSeconds )
943 {
944   typedef MessageValue1< UpdateManager, float > LocalType;
945
946   // Reserve some memory inside the message queue
947   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
948
949   // Construct message in the message queue memory; note that delete should not be called on the return value
950   new (slot) LocalType( &manager, &UpdateManager::KeepRendering, durationSeconds );
951 }
952
953 /**
954  * Create a message for setting the depth of a layer
955  * @param[in] manager The update manager
956  * @param[in] layers list of layers
957  * @param[in] systemLevel True if the layers are added via the SystemOverlay API
958  */
959 inline void SetLayerDepthsMessage( UpdateManager& manager, const std::vector< Layer* >& layers, bool systemLevel )
960 {
961   typedef MessageValue2< UpdateManager, std::vector< Layer* >, bool > LocalType;
962
963   // Reserve some memory inside the message queue
964   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
965
966   // Construct message in the message queue memory; note that delete should not be called on the return value
967   new (slot) LocalType( &manager, &UpdateManager::SetLayerDepths, layers, systemLevel );
968 }
969
970 inline void AddGestureMessage( UpdateManager& manager, PanGesture* gesture )
971 {
972   // Message has ownership of PanGesture while in transit from event -> update
973   typedef MessageValue1< UpdateManager, OwnerPointer< PanGesture > > LocalType;
974
975   // Reserve some memory inside the message queue
976   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
977
978   // Construct message in the message queue memory; note that delete should not be called on the return value
979   new (slot) LocalType( &manager, &UpdateManager::AddGesture, gesture );
980 }
981
982 inline void RemoveGestureMessage( UpdateManager& manager, PanGesture* gesture )
983 {
984   typedef MessageValue1< UpdateManager, PanGesture* > LocalType;
985
986   // Reserve some memory inside the message queue
987   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
988
989   // Construct message in the message queue memory; note that delete should not be called on the return value
990   new (slot) LocalType( &manager, &UpdateManager::RemoveGesture, gesture );
991 }
992
993 template< typename T >
994 inline void AddMessage( UpdateManager& manager, ObjectOwnerContainer<T>& owner, T& object )
995 {
996   typedef MessageValue1< ObjectOwnerContainer<T>, OwnerPointer< T > > LocalType;
997
998   // Reserve some memory inside the message queue
999   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1000   // Construct message in the message queue memory; note that delete should not be called on the return value
1001   new (slot) LocalType( &owner, &ObjectOwnerContainer<T>::Add, &object );
1002 }
1003
1004 template< typename T >
1005 inline void RemoveMessage( UpdateManager& manager, ObjectOwnerContainer<T>& owner, T& object )
1006 {
1007   typedef MessageValue1< ObjectOwnerContainer<T>, T* > LocalType;
1008
1009   // Reserve some memory inside the message queue
1010   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1011   // Construct message in the message queue memory; note that delete should not be called on the return value
1012   new (slot) LocalType( &owner, &ObjectOwnerContainer<T>::Remove, &object );
1013 }
1014
1015 // The render thread can safely change the Shader
1016 inline void AddTextureSetMessage( UpdateManager& manager, TextureSet& textureSet )
1017 {
1018   typedef MessageValue1< UpdateManager, OwnerPointer< TextureSet > > LocalType;
1019
1020   // Reserve some memory inside the message queue
1021   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1022
1023   // Construct message in the message queue memory; note that delete should not be called on the return value
1024   new (slot) LocalType( &manager, &UpdateManager::AddTextureSet, &textureSet );
1025 }
1026
1027 // The render thread can safely change the Shader
1028 inline void RemoveTextureSetMessage( UpdateManager& manager, TextureSet& textureSet )
1029 {
1030   typedef MessageValue1< UpdateManager, TextureSet* > LocalType;
1031
1032   // Reserve some memory inside the message queue
1033   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1034
1035   // Construct message in the message queue memory; note that delete should not be called on the return value
1036   new (slot) LocalType( &manager, &UpdateManager::RemoveTextureSet, &textureSet );
1037 }
1038
1039 inline void AddSamplerMessage( UpdateManager& manager, Render::Sampler& sampler )
1040 {
1041   // Message has ownership of Sampler while in transit from event -> update
1042   typedef MessageValue1< UpdateManager, OwnerPointer< Render::Sampler > > LocalType;
1043
1044   // Reserve some memory inside the message queue
1045   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1046
1047   // Construct message in the message queue memory; note that delete should not be called on the return value
1048   new (slot) LocalType( &manager, &UpdateManager::AddSampler, &sampler );
1049 }
1050
1051 inline void RemoveSamplerMessage( UpdateManager& manager, Render::Sampler& sampler )
1052 {
1053   typedef MessageValue1< UpdateManager, Render::Sampler* > LocalType;
1054
1055   // Reserve some memory inside the message queue
1056   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1057
1058   // Construct message in the message queue memory; note that delete should not be called on the return value
1059   new (slot) LocalType( &manager, &UpdateManager::RemoveSampler, &sampler );
1060 }
1061
1062 inline void SetFilterModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int minFilterMode, unsigned int magFilterMode )
1063 {
1064   typedef MessageValue3< UpdateManager, Render::Sampler*, unsigned int, unsigned int > LocalType;
1065
1066   // Reserve some memory inside the message queue
1067   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1068
1069   // Construct message in the message queue memory; note that delete should not be called on the return value
1070   new (slot) LocalType( &manager, &UpdateManager::SetFilterMode, &sampler, minFilterMode, magFilterMode );
1071 }
1072
1073 inline void SetWrapModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int rWrapMode, unsigned int sWrapMode, unsigned int tWrapMode )
1074 {
1075   typedef MessageValue4< UpdateManager, Render::Sampler*, unsigned int, unsigned int, unsigned int > LocalType;
1076
1077   // Reserve some memory inside the message queue
1078   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1079
1080   // Construct message in the message queue memory; note that delete should not be called on the return value
1081   new (slot) LocalType( &manager, &UpdateManager::SetWrapMode, &sampler, rWrapMode, sWrapMode, tWrapMode );
1082 }
1083
1084 inline void AddPropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer )
1085 {
1086   // Message has ownership of propertyBuffer while in transit from event -> update
1087   typedef MessageValue1< UpdateManager, OwnerPointer< Render::PropertyBuffer > > LocalType;
1088
1089   // Reserve some memory inside the message queue
1090   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1091
1092   // Construct message in the message queue memory; note that delete should not be called on the return value
1093   new (slot) LocalType( &manager, &UpdateManager::AddPropertyBuffer, &propertyBuffer );
1094 }
1095
1096 inline void RemovePropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer )
1097 {
1098   typedef MessageValue1< UpdateManager, Render::PropertyBuffer*  > LocalType;
1099
1100   // Reserve some memory inside the message queue
1101   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1102
1103   // Construct message in the message queue memory; note that delete should not be called on the return value
1104   new (slot) LocalType( &manager, &UpdateManager::RemovePropertyBuffer, &propertyBuffer );
1105 }
1106
1107 inline void SetPropertyBufferFormat( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, Render::PropertyBuffer::Format* format )
1108 {
1109   // Message has ownership of PropertyBuffer::Format while in transit from event -> update
1110   typedef MessageValue2< UpdateManager, Render::PropertyBuffer*, OwnerPointer< Render::PropertyBuffer::Format> > LocalType;
1111
1112   // Reserve some memory inside the message queue
1113   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1114
1115   // Construct message in the message queue memory; note that delete should not be called on the return value
1116   new (slot) LocalType( &manager, &UpdateManager::SetPropertyBufferFormat, &propertyBuffer, format );
1117 }
1118
1119 inline void SetPropertyBufferData( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, Vector<char>* data, size_t size )
1120 {
1121   // Message has ownership of PropertyBuffer data while in transit from event -> update
1122   typedef MessageValue3< UpdateManager, Render::PropertyBuffer*, OwnerPointer< Vector<char> >, size_t  > LocalType;
1123
1124   // Reserve some memory inside the message queue
1125   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1126
1127   // Construct message in the message queue memory; note that delete should not be called on the return value
1128   new (slot) LocalType( &manager, &UpdateManager::SetPropertyBufferData, &propertyBuffer, data, size );
1129 }
1130
1131 inline void AddGeometry( UpdateManager& manager, Render::Geometry& geometry )
1132 {
1133   // Message has ownership of Geometry while in transit from event -> update
1134   typedef MessageValue1< UpdateManager, OwnerPointer< Render::Geometry > > LocalType;
1135
1136   // Reserve some memory inside the message queue
1137   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1138
1139   // Construct message in the message queue memory; note that delete should not be called on the return value
1140   new (slot) LocalType( &manager, &UpdateManager::AddGeometry, &geometry );
1141 }
1142
1143 inline void RemoveGeometry( UpdateManager& manager, Render::Geometry& geometry )
1144 {
1145   typedef MessageValue1< UpdateManager, Render::Geometry*  > LocalType;
1146
1147   // Reserve some memory inside the message queue
1148   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1149
1150   // Construct message in the message queue memory; note that delete should not be called on the return value
1151   new (slot) LocalType( &manager, &UpdateManager::RemoveGeometry, &geometry );
1152 }
1153
1154 inline void AddVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer )
1155 {
1156   typedef MessageValue2< UpdateManager, Render::Geometry*, Render::PropertyBuffer* > LocalType;
1157
1158   // Reserve some memory inside the message queue
1159   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1160
1161   // Construct message in the message queue memory; note that delete should not be called on the return value
1162   new (slot) LocalType( &manager, &UpdateManager::AddVertexBuffer, &geometry, const_cast<Render::PropertyBuffer*>(&vertexBuffer) );
1163 }
1164
1165 inline void RemoveVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer )
1166 {
1167   typedef MessageValue2< UpdateManager, Render::Geometry*, Render::PropertyBuffer* > LocalType;
1168
1169   // Reserve some memory inside the message queue
1170   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1171
1172   // Construct message in the message queue memory; note that delete should not be called on the return value
1173   new (slot) LocalType( &manager, &UpdateManager::RemoveVertexBuffer, &geometry, const_cast<Render::PropertyBuffer*>(&vertexBuffer) );
1174 }
1175
1176 // Custom message type for SetIndexBuffer() used to move data with Vector::Swap()
1177 template< typename T >
1178 class IndexBufferMessage : public MessageBase
1179 {
1180 public:
1181
1182   /**
1183    * Constructor which does a Vector::Swap()
1184    */
1185   IndexBufferMessage( T* manager, Render::Geometry* geometry, Dali::Vector<unsigned short>& indices )
1186   : MessageBase(),
1187     mManager( manager ),
1188     mRenderGeometry( geometry )
1189   {
1190     mIndices.Swap( indices );
1191   }
1192
1193   /**
1194    * Virtual destructor
1195    */
1196   virtual ~IndexBufferMessage()
1197   {
1198   }
1199
1200   /**
1201    * @copydoc MessageBase::Process
1202    */
1203   virtual void Process( BufferIndex /*bufferIndex*/ )
1204   {
1205     DALI_ASSERT_DEBUG( mManager && "Message does not have an object" );
1206     mManager->SetIndexBuffer( mRenderGeometry, mIndices );
1207   }
1208
1209 private:
1210
1211   T* mManager;
1212   Render::Geometry* mRenderGeometry;
1213   Dali::Vector<unsigned short> mIndices;
1214 };
1215
1216 inline void SetIndexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, Dali::Vector<unsigned short>& indices )
1217 {
1218   typedef IndexBufferMessage< UpdateManager > LocalType;
1219
1220   // Reserve some memory inside the message queue
1221   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1222
1223   // Construct message in the message queue memory; note that delete should not be called on the return value
1224   new (slot) LocalType( &manager, &geometry, indices );
1225 }
1226
1227 inline void SetGeometryTypeMessage( UpdateManager& manager, Render::Geometry& geometry, unsigned int geometryType )
1228 {
1229   typedef MessageValue2< UpdateManager, Render::Geometry*, unsigned int > LocalType;
1230
1231   // Reserve some memory inside the message queue
1232   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1233
1234   // Construct message in the message queue memory; note that delete should not be called on the return value
1235   new (slot) LocalType( &manager, &UpdateManager::SetGeometryType, &geometry, geometryType );
1236 }
1237
1238 inline void AddTexture( UpdateManager& manager, Render::Texture& texture )
1239 {
1240   // Message has ownership of Texture while in transit from event -> update
1241   typedef MessageValue1< UpdateManager, OwnerPointer< Render::Texture > > LocalType;
1242
1243   // Reserve some memory inside the message queue
1244   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1245
1246   // Construct message in the message queue memory; note that delete should not be called on the return value
1247   new (slot) LocalType( &manager, &UpdateManager::AddTexture, &texture );
1248 }
1249
1250 inline void RemoveTexture( UpdateManager& manager, Render::Texture& texture )
1251 {
1252   typedef MessageValue1< UpdateManager, Render::Texture*  > LocalType;
1253
1254   // Reserve some memory inside the message queue
1255   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1256
1257   // Construct message in the message queue memory; note that delete should not be called on the return value
1258   new (slot) LocalType( &manager, &UpdateManager::RemoveTexture, &texture );
1259 }
1260
1261 inline void UploadTextureMessage( UpdateManager& manager, Render::Texture& texture, PixelDataPtr pixelData, const Texture::UploadParams& params )
1262 {
1263   typedef MessageValue3< UpdateManager, Render::Texture*, PixelDataPtr, Texture::UploadParams > LocalType;
1264
1265   // Reserve some memory inside the message queue
1266   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1267
1268   // Construct message in the message queue memory; note that delete should not be called on the return value
1269   new (slot) LocalType( &manager, &UpdateManager::UploadTexture, &texture, pixelData, params );
1270 }
1271
1272 inline void GenerateMipmapsMessage( UpdateManager& manager, Render::Texture& texture )
1273 {
1274   typedef MessageValue1< UpdateManager, Render::Texture*  > LocalType;
1275
1276   // Reserve some memory inside the message queue
1277   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1278
1279   // Construct message in the message queue memory; note that delete should not be called on the return value
1280   new (slot) LocalType( &manager, &UpdateManager::GenerateMipmaps, &texture );
1281 }
1282
1283
1284 inline void AddFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer )
1285 {
1286   typedef MessageValue1< UpdateManager, Render::FrameBuffer*  > LocalType;
1287
1288   // Reserve some memory inside the message queue
1289   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1290
1291   // Construct message in the message queue memory; note that delete should not be called on the return value
1292   new (slot) LocalType( &manager, &UpdateManager::AddFrameBuffer, &frameBuffer );
1293 }
1294
1295 inline void RemoveFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer )
1296 {
1297   typedef MessageValue1< UpdateManager, Render::FrameBuffer*  > LocalType;
1298
1299   // Reserve some memory inside the message queue
1300   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1301
1302   // Construct message in the message queue memory; note that delete should not be called on the return value
1303   new (slot) LocalType( &manager, &UpdateManager::RemoveFrameBuffer, &frameBuffer );
1304 }
1305
1306 inline void AttachColorTextureToFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer, Render::Texture* texture, unsigned int mipmapLevel, unsigned int layer )
1307 {
1308   typedef MessageValue4< UpdateManager, Render::FrameBuffer*, Render::Texture*, unsigned int, unsigned int  > LocalType;
1309
1310   // Reserve some memory inside the message queue
1311   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1312
1313   // Construct message in the message queue memory; note that delete should not be called on the return value
1314   new (slot) LocalType( &manager, &UpdateManager::AttachColorTextureToFrameBuffer, &frameBuffer, texture, mipmapLevel, layer );
1315 }
1316
1317 inline void SetDepthIndicesMessage( UpdateManager& manager, NodeDepths* nodeDepths )
1318 {
1319   typedef MessageValue1< UpdateManager, OwnerPointer< NodeDepths > > LocalType;
1320
1321   // Reserve some memory inside the message queue
1322   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1323
1324   // Construct message in the message queue memory; note that delete should not be called on the return value
1325   new (slot) LocalType( &manager, &UpdateManager::SetDepthIndices, nodeDepths );
1326 }
1327
1328
1329 } // namespace SceneGraph
1330
1331 } // namespace Internal
1332
1333 } // namespace Dali
1334
1335 #endif // DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H