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