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