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