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