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