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