[dali_1.2.39] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / dali / internal / update / manager / update-manager.h
1 #ifndef DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H
2 #define DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H
3
4 /*
5  * Copyright (c) 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    * 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( 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( 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( 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, 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, Dali::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( 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 geomtry
483    * @param[in] geometry The geometry
484    * @param[in] propertyBuffer The property buffer
485    */
486   void AddVertexBuffer( 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( 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( 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, 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, 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, const Camera* constCamera )
745 {
746   // Message has ownership of Camera while in transit from event -> update
747   typedef MessageValue1< UpdateManager, OwnerPointer< Camera > > LocalType;
748
749   Camera* camera = const_cast<Camera*>( constCamera );
750   // Reserve some memory inside the message queue
751   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
752
753   // Construct message in the message queue memory; note that delete should not be called on the return value
754   new (slot) LocalType( &manager, &UpdateManager::AddCamera, camera );
755 }
756
757 inline void RemoveCameraMessage( UpdateManager& manager, const Camera* camera )
758 {
759   typedef MessageValue1< UpdateManager, const Camera* > LocalType;
760
761   // Reserve some memory inside the message queue
762   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
763
764   // Construct message in the message queue memory; note that delete should not be called on the return value
765   new (slot) LocalType( &manager, &UpdateManager::RemoveCamera, camera );
766 }
767
768 inline void AddObjectMessage( UpdateManager& manager, PropertyOwner* object )
769 {
770   // Message has ownership of object while in transit from event -> update
771   typedef MessageValue1< UpdateManager, OwnerPointer<PropertyOwner> > LocalType;
772
773   // Reserve some memory inside the message queue
774   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
775
776   // Construct message in the message queue memory; note that delete should not be called on the return value
777   new (slot) LocalType( &manager, &UpdateManager::AddObject, object );
778 }
779
780 inline void RemoveObjectMessage( UpdateManager& manager, PropertyOwner* object )
781 {
782   typedef MessageValue1< UpdateManager, PropertyOwner* > LocalType;
783
784   // Reserve some memory inside the message queue
785   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
786
787   // Construct message in the message queue memory; note that delete should not be called on the return value
788   new (slot) LocalType( &manager, &UpdateManager::RemoveObject, object );
789 }
790
791 inline void AddAnimationMessage( UpdateManager& manager, Animation* animation )
792 {
793   typedef MessageValue1< UpdateManager, Animation* > LocalType;
794
795   // Reserve some memory inside the message queue
796   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
797
798   // Construct message in the message queue memory; note that delete should not be called on the return value
799   new (slot) LocalType( &manager, &UpdateManager::AddAnimation, animation );
800 }
801
802 inline void StopAnimationMessage( UpdateManager& manager, const Animation& constAnimation )
803 {
804   // The scene-graph thread owns this object so it can safely edit it.
805   Animation& animation = const_cast< Animation& >( constAnimation );
806
807   typedef MessageValue1< UpdateManager, Animation* > LocalType;
808
809   // Reserve some memory inside the message queue
810   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
811
812   // Construct message in the message queue memory; note that delete should not be called on the return value
813   new (slot) LocalType( &manager, &UpdateManager::StopAnimation, &animation );
814 }
815
816 inline void RemoveAnimationMessage( UpdateManager& manager, const Animation& constAnimation )
817 {
818   // The scene-graph thread owns this object so it can safely edit it.
819   Animation& animation = const_cast< Animation& >( constAnimation );
820
821   typedef MessageValue1< UpdateManager, Animation* > LocalType;
822
823   // Reserve some memory inside the message queue
824   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
825
826   // Construct message in the message queue memory; note that delete should not be called on the return value
827   new (slot) LocalType( &manager, &UpdateManager::RemoveAnimation, &animation );
828 }
829
830 inline void AddPropertyNotificationMessage( UpdateManager& manager, PropertyNotification* propertyNotification )
831 {
832   // Message has ownership of PropertyNotification while in transit from event -> update
833   typedef MessageValue1< UpdateManager, OwnerPointer< PropertyNotification > > LocalType;
834
835   // Reserve some memory inside the message queue
836   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
837
838   // Construct message in the message queue memory; note that delete should not be called on the return value
839   new (slot) LocalType( &manager, &UpdateManager::AddPropertyNotification, propertyNotification );
840 }
841
842 inline void RemovePropertyNotificationMessage( UpdateManager& manager, const PropertyNotification& constPropertyNotification )
843 {
844   // The scene-graph thread owns this object so it can safely edit it.
845   PropertyNotification& propertyNotification = const_cast< PropertyNotification& >( constPropertyNotification );
846
847   typedef MessageValue1< UpdateManager, PropertyNotification* > LocalType;
848
849   // Reserve some memory inside the message queue
850   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
851
852   // Construct message in the message queue memory; note that delete should not be called on the return value
853   new (slot) LocalType( &manager, &UpdateManager::RemovePropertyNotification, &propertyNotification );
854 }
855
856 inline void PropertyNotificationSetNotifyModeMessage( UpdateManager& manager,
857                                                       const PropertyNotification* constPropertyNotification,
858                                                       PropertyNotification::NotifyMode notifyMode )
859 {
860   // The scene-graph thread owns this object so it can safely edit it.
861   PropertyNotification* propertyNotification = const_cast< PropertyNotification* >( constPropertyNotification );
862
863   typedef MessageValue2< UpdateManager, PropertyNotification*, PropertyNotification::NotifyMode > LocalType;
864
865   // Reserve some memory inside the message queue
866   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
867
868   // Construct message in the message queue memory; note that delete should not be called on the return value
869   new (slot) LocalType( &manager, &UpdateManager::PropertyNotificationSetNotify, propertyNotification, notifyMode );
870 }
871
872 // The render thread can safely change the Shader
873 inline void AddShaderMessage( UpdateManager& manager, Shader& shader )
874 {
875   typedef MessageValue1< UpdateManager, OwnerPointer< Shader > > LocalType;
876
877   // Reserve some memory inside the message queue
878   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
879
880   // Construct message in the message queue memory; note that delete should not be called on the return value
881   new (slot) LocalType( &manager, &UpdateManager::AddShader, &shader );
882 }
883
884 // The render thread can safely change the Shader
885 inline void RemoveShaderMessage( UpdateManager& manager, Shader& shader )
886 {
887   typedef MessageValue1< UpdateManager, Shader* > LocalType;
888
889   // Reserve some memory inside the message queue
890   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
891
892   // Construct message in the message queue memory; note that delete should not be called on the return value
893   new (slot) LocalType( &manager, &UpdateManager::RemoveShader, &shader );
894 }
895
896 inline void SetShaderProgramMessage( UpdateManager& manager,
897                                      Shader& shader,
898                                      Internal::ShaderDataPtr shaderData,
899                                      bool modifiesGeometry )
900 {
901   typedef MessageValue3< UpdateManager, Shader*, Internal::ShaderDataPtr, bool > LocalType;
902
903   // Reserve some memory inside the message queue
904   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
905
906   // Construct message in the message queue memory; note that delete should not be called on the return value
907   new (slot) LocalType( &manager, &UpdateManager::SetShaderProgram, &shader, shaderData, modifiesGeometry );
908 }
909
910 inline void SetBackgroundColorMessage( UpdateManager& manager, const Vector4& color )
911 {
912   typedef MessageValue1< UpdateManager, Vector4 > LocalType;
913
914   // Reserve some memory inside the message queue
915   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
916
917   // Construct message in the message queue memory; note that delete should not be called on the return value
918   new (slot) LocalType( &manager, &UpdateManager::SetBackgroundColor, color );
919 }
920
921 inline void SetDefaultSurfaceRectMessage( UpdateManager& manager, const Rect<int>& rect  )
922 {
923   typedef MessageValue1< UpdateManager, Rect<int> > LocalType;
924
925   // Reserve some memory inside the message queue
926   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
927
928   // Construct message in the message queue memory; note that delete should not be called on the return value
929   new (slot) LocalType( &manager, &UpdateManager::SetDefaultSurfaceRect, rect );
930 }
931
932 inline void KeepRenderingMessage( UpdateManager& manager, float durationSeconds )
933 {
934   typedef MessageValue1< UpdateManager, float > LocalType;
935
936   // Reserve some memory inside the message queue
937   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
938
939   // Construct message in the message queue memory; note that delete should not be called on the return value
940   new (slot) LocalType( &manager, &UpdateManager::KeepRendering, durationSeconds );
941 }
942
943 /**
944  * Create a message for setting the depth of a layer
945  * @param[in] manager The update manager
946  * @param[in] layers list of layers
947  * @param[in] systemLevel True if the layers are added via the SystemOverlay API
948  */
949 inline void SetLayerDepthsMessage( UpdateManager& manager, const std::vector< Layer* >& layers, bool systemLevel )
950 {
951   typedef MessageValue2< UpdateManager, std::vector< Layer* >, bool > LocalType;
952
953   // Reserve some memory inside the message queue
954   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
955
956   // Construct message in the message queue memory; note that delete should not be called on the return value
957   new (slot) LocalType( &manager, &UpdateManager::SetLayerDepths, layers, systemLevel );
958 }
959
960 inline void AddRendererMessage( UpdateManager& manager, Renderer& object )
961 {
962   typedef MessageValue1< UpdateManager, OwnerPointer< Renderer > > LocalType;
963
964   // Reserve some memory inside the message queue
965   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
966   // Construct message in the message queue memory; note that delete should not be called on the return value
967   new (slot) LocalType( &manager, &UpdateManager::AddRenderer, &object );
968 }
969
970 inline void RemoveRendererMessage( UpdateManager& manager, Renderer& object )
971 {
972   typedef MessageValue1< UpdateManager, Renderer* > LocalType;
973
974   // Reserve some memory inside the message queue
975   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
976   // Construct message in the message queue memory; note that delete should not be called on the return value
977   new (slot) LocalType( &manager, &UpdateManager::RemoveRenderer, &object );
978 }
979
980 // The render thread can safely change the Shader
981 inline void AddTextureSetMessage( UpdateManager& manager, TextureSet& textureSet )
982 {
983   typedef MessageValue1< UpdateManager, OwnerPointer< TextureSet > > LocalType;
984
985   // Reserve some memory inside the message queue
986   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
987
988   // Construct message in the message queue memory; note that delete should not be called on the return value
989   new (slot) LocalType( &manager, &UpdateManager::AddTextureSet, &textureSet );
990 }
991
992 // The render thread can safely change the Shader
993 inline void RemoveTextureSetMessage( UpdateManager& manager, TextureSet& textureSet )
994 {
995   typedef MessageValue1< UpdateManager, TextureSet* > LocalType;
996
997   // Reserve some memory inside the message queue
998   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
999
1000   // Construct message in the message queue memory; note that delete should not be called on the return value
1001   new (slot) LocalType( &manager, &UpdateManager::RemoveTextureSet, &textureSet );
1002 }
1003
1004 inline void AddSamplerMessage( UpdateManager& manager, Render::Sampler& sampler )
1005 {
1006   // Message has ownership of Sampler while in transit from event -> update
1007   typedef MessageValue1< UpdateManager, OwnerPointer< Render::Sampler > > LocalType;
1008
1009   // Reserve some memory inside the message queue
1010   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1011
1012   // Construct message in the message queue memory; note that delete should not be called on the return value
1013   new (slot) LocalType( &manager, &UpdateManager::AddSampler, &sampler );
1014 }
1015
1016 inline void RemoveSamplerMessage( UpdateManager& manager, Render::Sampler& sampler )
1017 {
1018   typedef MessageValue1< UpdateManager, Render::Sampler* > LocalType;
1019
1020   // Reserve some memory inside the message queue
1021   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1022
1023   // Construct message in the message queue memory; note that delete should not be called on the return value
1024   new (slot) LocalType( &manager, &UpdateManager::RemoveSampler, &sampler );
1025 }
1026
1027 inline void SetFilterModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int minFilterMode, unsigned int magFilterMode )
1028 {
1029   typedef MessageValue3< UpdateManager, Render::Sampler*, unsigned int, unsigned int > LocalType;
1030
1031   // Reserve some memory inside the message queue
1032   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1033
1034   // Construct message in the message queue memory; note that delete should not be called on the return value
1035   new (slot) LocalType( &manager, &UpdateManager::SetFilterMode, &sampler, minFilterMode, magFilterMode );
1036 }
1037
1038 inline void SetWrapModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int rWrapMode, unsigned int sWrapMode, unsigned int tWrapMode )
1039 {
1040   typedef MessageValue4< UpdateManager, Render::Sampler*, unsigned int, unsigned int, unsigned int > LocalType;
1041
1042   // Reserve some memory inside the message queue
1043   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1044
1045   // Construct message in the message queue memory; note that delete should not be called on the return value
1046   new (slot) LocalType( &manager, &UpdateManager::SetWrapMode, &sampler, rWrapMode, sWrapMode, tWrapMode );
1047 }
1048
1049 inline void AddPropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer )
1050 {
1051   // Message has ownership of propertyBuffer while in transit from event -> update
1052   typedef MessageValue1< UpdateManager, OwnerPointer< Render::PropertyBuffer > > LocalType;
1053
1054   // Reserve some memory inside the message queue
1055   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1056
1057   // Construct message in the message queue memory; note that delete should not be called on the return value
1058   new (slot) LocalType( &manager, &UpdateManager::AddPropertyBuffer, &propertyBuffer );
1059 }
1060
1061 inline void RemovePropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer )
1062 {
1063   typedef MessageValue1< UpdateManager, Render::PropertyBuffer*  > LocalType;
1064
1065   // Reserve some memory inside the message queue
1066   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1067
1068   // Construct message in the message queue memory; note that delete should not be called on the return value
1069   new (slot) LocalType( &manager, &UpdateManager::RemovePropertyBuffer, &propertyBuffer );
1070 }
1071
1072 inline void SetPropertyBufferFormat( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, Render::PropertyBuffer::Format* format )
1073 {
1074   // Message has ownership of PropertyBuffer::Format while in transit from event -> update
1075   typedef MessageValue2< UpdateManager, Render::PropertyBuffer*, OwnerPointer< Render::PropertyBuffer::Format> > LocalType;
1076
1077   // Reserve some memory inside the message queue
1078   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1079
1080   // Construct message in the message queue memory; note that delete should not be called on the return value
1081   new (slot) LocalType( &manager, &UpdateManager::SetPropertyBufferFormat, &propertyBuffer, format );
1082 }
1083
1084 inline void SetPropertyBufferData( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, Vector<char>* data, size_t size )
1085 {
1086   // Message has ownership of PropertyBuffer data while in transit from event -> update
1087   typedef MessageValue3< UpdateManager, Render::PropertyBuffer*, OwnerPointer< Vector<char> >, size_t  > LocalType;
1088
1089   // Reserve some memory inside the message queue
1090   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1091
1092   // Construct message in the message queue memory; note that delete should not be called on the return value
1093   new (slot) LocalType( &manager, &UpdateManager::SetPropertyBufferData, &propertyBuffer, data, size );
1094 }
1095
1096 inline void AddGeometry( UpdateManager& manager, Render::Geometry& geometry )
1097 {
1098   // Message has ownership of Geometry while in transit from event -> update
1099   typedef MessageValue1< UpdateManager, OwnerPointer< Render::Geometry > > LocalType;
1100
1101   // Reserve some memory inside the message queue
1102   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1103
1104   // Construct message in the message queue memory; note that delete should not be called on the return value
1105   new (slot) LocalType( &manager, &UpdateManager::AddGeometry, &geometry );
1106 }
1107
1108 inline void RemoveGeometry( UpdateManager& manager, Render::Geometry& geometry )
1109 {
1110   typedef MessageValue1< UpdateManager, Render::Geometry*  > LocalType;
1111
1112   // Reserve some memory inside the message queue
1113   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1114
1115   // Construct message in the message queue memory; note that delete should not be called on the return value
1116   new (slot) LocalType( &manager, &UpdateManager::RemoveGeometry, &geometry );
1117 }
1118
1119 inline void AddVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer )
1120 {
1121   typedef MessageValue2< UpdateManager, Render::Geometry*, Render::PropertyBuffer* > LocalType;
1122
1123   // Reserve some memory inside the message queue
1124   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1125
1126   // Construct message in the message queue memory; note that delete should not be called on the return value
1127   new (slot) LocalType( &manager, &UpdateManager::AddVertexBuffer, &geometry, const_cast<Render::PropertyBuffer*>(&vertexBuffer) );
1128 }
1129
1130 inline void RemoveVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer )
1131 {
1132   typedef MessageValue2< UpdateManager, Render::Geometry*, Render::PropertyBuffer* > LocalType;
1133
1134   // Reserve some memory inside the message queue
1135   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1136
1137   // Construct message in the message queue memory; note that delete should not be called on the return value
1138   new (slot) LocalType( &manager, &UpdateManager::RemoveVertexBuffer, &geometry, const_cast<Render::PropertyBuffer*>(&vertexBuffer) );
1139 }
1140
1141 // Custom message type for SetIndexBuffer() used to move data with Vector::Swap()
1142 template< typename T >
1143 class IndexBufferMessage : public MessageBase
1144 {
1145 public:
1146
1147   /**
1148    * Constructor which does a Vector::Swap()
1149    */
1150   IndexBufferMessage( T* manager, Render::Geometry* geometry, Dali::Vector<unsigned short>& indices )
1151   : MessageBase(),
1152     mManager( manager ),
1153     mRenderGeometry( geometry )
1154   {
1155     mIndices.Swap( indices );
1156   }
1157
1158   /**
1159    * Virtual destructor
1160    */
1161   virtual ~IndexBufferMessage()
1162   {
1163   }
1164
1165   /**
1166    * @copydoc MessageBase::Process
1167    */
1168   virtual void Process( BufferIndex /*bufferIndex*/ )
1169   {
1170     DALI_ASSERT_DEBUG( mManager && "Message does not have an object" );
1171     mManager->SetIndexBuffer( mRenderGeometry, mIndices );
1172   }
1173
1174 private:
1175
1176   T* mManager;
1177   Render::Geometry* mRenderGeometry;
1178   Dali::Vector<unsigned short> mIndices;
1179 };
1180
1181 inline void SetIndexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, Dali::Vector<unsigned short>& indices )
1182 {
1183   typedef IndexBufferMessage< UpdateManager > LocalType;
1184
1185   // Reserve some memory inside the message queue
1186   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1187
1188   // Construct message in the message queue memory; note that delete should not be called on the return value
1189   new (slot) LocalType( &manager, &geometry, indices );
1190 }
1191
1192 inline void SetGeometryTypeMessage( UpdateManager& manager, Render::Geometry& geometry, unsigned int geometryType )
1193 {
1194   typedef MessageValue2< UpdateManager, Render::Geometry*, unsigned int > LocalType;
1195
1196   // Reserve some memory inside the message queue
1197   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1198
1199   // Construct message in the message queue memory; note that delete should not be called on the return value
1200   new (slot) LocalType( &manager, &UpdateManager::SetGeometryType, &geometry, geometryType );
1201 }
1202
1203 inline void AddTexture( UpdateManager& manager, Render::Texture& texture )
1204 {
1205   // Message has ownership of Texture while in transit from event -> update
1206   typedef MessageValue1< UpdateManager, OwnerPointer< Render::Texture > > LocalType;
1207
1208   // Reserve some memory inside the message queue
1209   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1210
1211   // Construct message in the message queue memory; note that delete should not be called on the return value
1212   new (slot) LocalType( &manager, &UpdateManager::AddTexture, &texture );
1213 }
1214
1215 inline void RemoveTexture( UpdateManager& manager, Render::Texture& texture )
1216 {
1217   typedef MessageValue1< UpdateManager, Render::Texture*  > LocalType;
1218
1219   // Reserve some memory inside the message queue
1220   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1221
1222   // Construct message in the message queue memory; note that delete should not be called on the return value
1223   new (slot) LocalType( &manager, &UpdateManager::RemoveTexture, &texture );
1224 }
1225
1226 inline void UploadTextureMessage( UpdateManager& manager, Render::Texture& texture, PixelDataPtr pixelData, const Texture::UploadParams& params )
1227 {
1228   typedef MessageValue3< UpdateManager, Render::Texture*, PixelDataPtr, Texture::UploadParams > LocalType;
1229
1230   // Reserve some memory inside the message queue
1231   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1232
1233   // Construct message in the message queue memory; note that delete should not be called on the return value
1234   new (slot) LocalType( &manager, &UpdateManager::UploadTexture, &texture, pixelData, params );
1235 }
1236
1237 inline void GenerateMipmapsMessage( UpdateManager& manager, Render::Texture& texture )
1238 {
1239   typedef MessageValue1< UpdateManager, Render::Texture*  > LocalType;
1240
1241   // Reserve some memory inside the message queue
1242   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1243
1244   // Construct message in the message queue memory; note that delete should not be called on the return value
1245   new (slot) LocalType( &manager, &UpdateManager::GenerateMipmaps, &texture );
1246 }
1247
1248
1249 inline void AddFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer )
1250 {
1251   typedef MessageValue1< UpdateManager, Render::FrameBuffer*  > LocalType;
1252
1253   // Reserve some memory inside the message queue
1254   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1255
1256   // Construct message in the message queue memory; note that delete should not be called on the return value
1257   new (slot) LocalType( &manager, &UpdateManager::AddFrameBuffer, &frameBuffer );
1258 }
1259
1260 inline void RemoveFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer )
1261 {
1262   typedef MessageValue1< UpdateManager, Render::FrameBuffer*  > LocalType;
1263
1264   // Reserve some memory inside the message queue
1265   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1266
1267   // Construct message in the message queue memory; note that delete should not be called on the return value
1268   new (slot) LocalType( &manager, &UpdateManager::RemoveFrameBuffer, &frameBuffer );
1269 }
1270
1271 inline void AttachColorTextureToFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer, Render::Texture* texture, unsigned int mipmapLevel, unsigned int layer )
1272 {
1273   typedef MessageValue4< UpdateManager, Render::FrameBuffer*, Render::Texture*, unsigned int, unsigned int  > LocalType;
1274
1275   // Reserve some memory inside the message queue
1276   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1277
1278   // Construct message in the message queue memory; note that delete should not be called on the return value
1279   new (slot) LocalType( &manager, &UpdateManager::AttachColorTextureToFrameBuffer, &frameBuffer, texture, mipmapLevel, layer );
1280 }
1281
1282 inline void SetDepthIndicesMessage( UpdateManager& manager, NodeDepths* nodeDepths )
1283 {
1284   typedef MessageValue1< UpdateManager, OwnerPointer< NodeDepths > > LocalType;
1285
1286   // Reserve some memory inside the message queue
1287   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1288
1289   // Construct message in the message queue memory; note that delete should not be called on the return value
1290   new (slot) LocalType( &manager, &UpdateManager::SetDepthIndices, nodeDepths );
1291 }
1292
1293
1294 } // namespace SceneGraph
1295
1296 } // namespace Internal
1297
1298 } // namespace Dali
1299
1300 #endif // DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H