Rename shader.h/cpp to scene-graph-shader.h/cpp
[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) 2014 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 #include <dali/integration-api/resource-declarations.h>
25 #include <dali/internal/common/message.h>
26 #include <dali/internal/common/event-to-update.h>
27 #include <dali/internal/render/shaders/scene-graph-shader.h>
28 #include <dali/internal/update/nodes/node.h>
29 #include <dali/internal/update/node-attachments/node-attachment.h>
30 #include <dali/internal/update/common/scene-graph-buffers.h>
31 #include <dali/internal/update/animation/scene-graph-animation.h>
32 #include <dali/internal/update/common/scene-graph-property-notification.h>
33 #include <dali/internal/update/nodes/scene-graph-layer.h>
34 #include <dali/internal/common/type-abstraction-enums.h>
35
36 namespace Dali
37 {
38
39 namespace Integration
40 {
41 class GlSyncAbstraction;
42 class RenderController;
43 struct DynamicsWorldSettings;
44
45 } // namespace Integration
46
47 namespace Internal
48 {
49
50 class PropertyNotifier;
51 class EventToUpdate;
52 struct DynamicsWorldSettings;
53 class NotificationManager;
54 class CompleteNotificationInterface;
55 class ResourceManager;
56 class TouchResampler;
57
58 // value types used by messages
59 template <> struct ParameterType< PropertyNotification::NotifyMode >
60 : public BasicType< PropertyNotification::NotifyMode > {};
61
62 namespace SceneGraph
63 {
64
65 class Animation;
66 class DiscardQueue;
67 class PanGesture;
68 class RenderManager;
69 class RenderTaskList;
70 class RenderQueue;
71 class DynamicsWorld;
72 class TextureCache;
73
74 /**
75  * UpdateManager holds a scene graph i.e. a tree of nodes.
76  * It controls the Update traversal, in which nodes are repositioned/animated,
77  * and organizes the the culling and rendering of the scene.
78  */
79 class UpdateManager
80 {
81 public:
82
83   /**
84    * Construct a new UpdateManager.
85    * @param[in] notificationManager This should be notified when animations have finished.
86    * @param[in] glSyncAbstraction Used to determine when framebuffers are ready
87    * @param[in] animationFinishedNotifier The CompleteNotificationInterface that handles animation completions
88    * @param[in] propertyNotifier The PropertyNotifier
89    * @param[in] resourceManager The resource manager used to load textures etc.
90    * @param[in] discardQueue Nodes are added here when disconnected from the scene-graph.
91    * @param[in] controller After messages are flushed, we request a render from the RenderController.
92    * @param[in] renderManager This is responsible for rendering the results of each "update".
93    * @param[in] renderQueue Used to queue messages for the next render.
94    * @param[in] textureCache Used for caching textures.
95    * @param[in] touchResampler Used for re-sampling touch events.
96    */
97   UpdateManager( NotificationManager& notificationManager,
98                  Integration::GlSyncAbstraction& glSyncAbstraction,
99                  CompleteNotificationInterface& animationFinishedNotifier,
100                  PropertyNotifier& propertyNotifier,
101                  ResourceManager& resourceManager,
102                  DiscardQueue& discardQueue,
103                  Integration::RenderController& controller,
104                  RenderManager& renderManager,
105                  RenderQueue& renderQueue,
106                  TextureCache& textureCache,
107                  TouchResampler& touchResampler );
108
109   /**
110    * Destructor. Not virtual as this is not a base class
111    */
112   ~UpdateManager();
113
114   /**
115    * The event-thread uses this interface to queue messages for the next update.
116    * @return The event-to-update interface.
117    */
118   EventToUpdate& GetEventToUpdate();
119
120   /**
121    * @return the event buffer index
122    */
123   BufferIndex GetEventBufferIndex() const
124   {
125     // inlined as its called often
126     return mSceneGraphBuffers.GetEventBufferIndex();
127   }
128
129   // Node connection methods
130
131   /**
132    * Get the scene graph side list of RenderTasks.
133    * @param[in] systemLevel True if using the system-level overlay.
134    * @return The list of render tasks
135    */
136   RenderTaskList* GetRenderTaskList( bool systemLevel );
137
138   /**
139    * Installs a new layer as the root node.
140    * @pre The UpdateManager does not already have an installed root node.
141    * @pre The layer is of derived Node type Layer.
142    * @pre The layer does not have a parent.
143    * @param[in] layer The new root node.
144    * @param[in] systemLevel True if using the system-level overlay.
145    * @post The node is owned by UpdateManager.
146    */
147   void InstallRoot( Layer* layer, bool systemLevel );
148
149   /**
150    * Add a Node; UpdateManager takes ownership.
151    * @pre The node does not have a parent.
152    * @param[in] node The node to add.
153    */
154   void AddNode( Node* node );
155
156   /**
157    * Connect a Node to the scene-graph.
158    * A disconnected Node has has no parent or children, and its properties cannot be animated/constrained.
159    * @pre The node does not already have a parent.
160    * @param[in] node The new parent node.
161    * @param[in] node The node to connect.
162    */
163   void ConnectNode( Node* parent, Node* node, int index );
164
165   /**
166    * Disconnect a Node from the scene-graph.
167    * A disconnected Node has has no parent or children, and its properties cannot be animated/constrained.
168    * @pre The node has a parent.
169    * @param[in] node The node to disconnect.
170    */
171   void DisconnectNode( Node* node );
172
173   /**
174    * Called when a property is set on a disconnected Node (via public API)
175    * A disconnected Node has has no parent or children, and its properties cannot be animated/constrained.
176    * @pre The node does not have a parent.
177    * @param[in] node The node to set as "active".
178    */
179   void SetNodeActive( 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    * Attach an object to a Node.
192    * The UpdateManager is responsible for calling NodeAttachment::Initialize().
193    * @param[in] node The node which will own the attachment.
194    * @param[in] attachment The object to attach.
195    */
196   void AttachToNode( Node* node, NodeAttachment* attachment );
197
198   /**
199    * Add a newly created object.
200    * @param[in] object The object to add.
201    * @post The object is owned by UpdateManager.
202    */
203   void AddObject( PropertyOwner* object );
204
205   /**
206    * Remove an object.
207    * @param[in] object The object to remove.
208    */
209   void RemoveObject( PropertyOwner* object );
210
211   // Animations
212
213   /**
214    * Add a newly created animation.
215    * @param[in] animation The animation to add.
216    * @post The animation is owned by UpdateManager.
217    */
218   void AddAnimation( Animation* animation );
219
220   /**
221    * Stop an animation.
222    * @param[in] animation The animation to stop.
223    */
224   void StopAnimation( Animation* animation );
225
226   /**
227    * Remove an animation.
228    * @param[in] animation The animation to remove.
229    */
230   void RemoveAnimation( Animation* animation );
231
232   /**
233    * Query whether any animations are currently running.
234    * @return True if any animations are running.
235    */
236   bool IsAnimationRunning() const;
237
238   // Property Notification
239
240   /**
241    * Add a newly created property notification
242    * @param[in] propertyNotification The notification to add
243    * @post The propertyNotification is owned by UpdateManager.
244    */
245   void AddPropertyNotification( PropertyNotification* propertyNotification );
246
247   /**
248    * Remove a property notification
249    * @param[in] propertyNotification The notification to remove
250    */
251   void RemovePropertyNotification( PropertyNotification* propertyNotification );
252
253   /**
254    * Set Notify state for PropertyNotification
255    * @param[in] propertyNotification The notification to remove
256    * @param[in] notifyMode The notification mode.
257    */
258   void PropertyNotificationSetNotify( PropertyNotification* propertyNotification, PropertyNotification::NotifyMode notifyMode );
259
260   // Shaders
261
262   /**
263    * Add a newly created shader.
264    * @param[in] shader The shader to add.
265    * @post The shader is owned by the UpdateManager.
266    */
267   void AddShader(Shader* shader);
268
269   /**
270    * Remove a shader.
271    * @pre The shader has been added to the UpdateManager.
272    * @param[in] shader The shader to remove.
273    * @post The shader is destroyed.
274    */
275   void RemoveShader(Shader* shader);
276
277   /**
278    * Set the shader program for a specified GeometryType to a Shader object
279    * @param[in] shader        The shader to modify
280    * @param[in] geometryType  The GeometryType to map to the program
281    * @param[in] subType       The program subtype
282    * @param[in] resourceId    A ResourceManager ticket ID for the program data (source and compiled binary)
283    * @param[in] shaderHash    hash key created with vertex and fragment shader code
284    * @param[in] modifiesGeometry True if the vertex shader modifies geometry
285    */
286   void SetShaderProgram( Shader* shader, GeometryType geometryType, ShaderSubTypes subType, Integration::ResourceId resourceId, size_t shaderHash, bool modifiesGeometry );
287
288   /**
289    * Add a newly created gesture.
290    * @param[in] gesture The gesture to add.
291    * @post The gesture is owned by the UpdateManager.
292    */
293   void AddGesture( PanGesture* gesture );
294
295   /**
296    * Remove a gesture.
297    * @pre The gesture has been added to the UpdateManager.
298    * @param[in] gesture The gesture to remove.
299    * @post The gesture is destroyed.
300    */
301   void RemoveGesture( PanGesture* gesture );
302
303 public:
304
305   /**
306    * Performs an Update traversal on the scene-graph.
307    * @param[in] elapsedSeconds The elapsed time that should be applied to animations.
308    * @param[in] lastVSyncTimeMilliseconds The last time, in milliseconds, that we had a VSync.
309    * @param[in] nextVSyncTimeMilliseconds The estimated time, in milliseconds, of the next VSync.
310    * @return True if further updates are required e.g. during animations.
311    */
312   unsigned int Update( float elapsedSeconds, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds );
313
314   /**
315    * Set the background color i.e. the glClear color used at the beginning of each frame.
316    * @param[in] color The new background color.
317    */
318   void SetBackgroundColor(const Vector4& color);
319
320   /**
321    * Set the default surface rect.
322    * @param[in] rect The rect value representing the surface.
323    */
324   void SetDefaultSurfaceRect( const Rect<int>& rect );
325
326   /**
327    * @copydoc Dali::Stage::KeepRendering()
328    */
329   void KeepRendering( float durationSeconds );
330
331   /**
332    * Sets the depths of all layers.
333    * @param layers The layers in depth order.
334    * @param[in] systemLevel True if using the system-level overlay.
335    */
336   void SetLayerDepths( const std::vector< Layer* >& layers, bool systemLevel );
337
338 #ifdef DYNAMICS_SUPPORT
339
340   /**
341    * Initialize the dynamics world
342    * @param[in] world The dynamics world
343    * @param[in] worldSettings The dynamics world settings
344    * @param[in] debugShader The shader used for rendering dynamics debug information
345    */
346   void InitializeDynamicsWorld( DynamicsWorld* world, Integration::DynamicsWorldSettings* worldSettings );
347
348   /**
349    * Terminate the dynamics world
350    */
351   void TerminateDynamicsWorld();
352
353 #endif // DYNAMICS_SUPPORT
354
355 private:
356
357   // Undefined
358   UpdateManager(const UpdateManager&);
359
360   // Undefined
361   UpdateManager& operator=(const UpdateManager& rhs);
362
363   /**
364    * Helper to check whether the update-thread should keep going.
365    * @param[in] elapsedSeconds The time in seconds since the previous update.
366    * @return True if the update-thread should keep going.
367    */
368   unsigned int KeepUpdatingCheck( float elapsedSeconds ) const;
369
370   /**
371    * Helper to calculate new camera setup when root node resizes.
372    * @param[in] updateBuffer The buffer to read the root node size from.
373    */
374   void UpdateProjectionAndViewMatrices(int updateBuffer);
375
376   /**
377    * Post process resources that have been updated by renderer
378    */
379   void PostProcessResources();
380
381   /**
382    * Helper to reset a Node properties.
383    * @param[in] node The node.
384    */
385   void ResetNodeProperty( Node& node );
386
387   /**
388    * Helper to reset all Node properties
389    */
390   void ResetProperties();
391
392   /**
393    * Perform gesture updates.
394    * @param[in]  lastVSyncTime  The last VSync time in milliseconds.
395    * @param[in]  nextVSyncTime  The estimated time of the next VSync in milliseconds.
396    * @return true, if any properties were updated.
397    */
398   bool ProcessGestures( unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds );
399
400   /**
401    * Perform animation updates
402    * @param[in] elapsedSeconds time since last frame
403    */
404   void Animate( float elapsedSeconds );
405
406   /**
407    * Perform constraint updates.
408    * @note Applies constraints to nodes first (depth first search order).
409    * Then shader constraints second (construction order)
410    */
411   void ApplyConstraints();
412
413   /**
414    * Perform property notification updates
415    */
416   void ProcessPropertyNotifications();
417
418   /**
419    * Update the default camera.
420    * This must be altered to match the root Node for 2D layouting.
421    * @param[in] updateBuffer The buffer to read the root node size from.
422    */
423   void UpdateDefaultCamera( int updateBuffer );
424
425   /**
426    * Update node shaders, opacity, geometry etc.
427    */
428   void UpdateNodes();
429
430 private:
431
432   // needs to be direct member so that getter for event buffer can be inlined
433   SceneGraphBuffers mSceneGraphBuffers;
434
435   struct Impl;
436   Impl* mImpl;
437
438 };
439
440 // Messages for UpdateManager
441
442 inline void InstallRootMessage( UpdateManager& manager, Layer& root, bool systemLevel )
443 {
444   typedef MessageValue2< UpdateManager, Layer*, bool > LocalType;
445
446   // Reserve some memory inside the message queue
447   unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
448
449   // Construct message in the message queue memory; note that delete should not be called on the return value
450   new (slot) LocalType( &manager, &UpdateManager::InstallRoot, &root, systemLevel );
451 }
452
453 inline void AddNodeMessage( UpdateManager& manager, Node& node )
454 {
455   typedef MessageValue1< UpdateManager, OwnerPointer<Node> > LocalType;
456
457   // Reserve some memory inside the message queue
458   unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
459
460   // Construct message in the message queue memory; note that delete should not be called on the return value
461   new (slot) LocalType( &manager, &UpdateManager::AddNode, &node );
462 }
463
464 inline void ConnectNodeMessage( UpdateManager& manager, const Node& constParent, const Node& constChild, int index )
465 {
466   // Update thread can edit the object
467   Node& parent = const_cast< Node& >( constParent );
468   Node& child = const_cast< Node& >( constChild );
469
470   typedef MessageValue3< UpdateManager, Node*, Node*, int > LocalType;
471
472   // Reserve some memory inside the message queue
473   unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
474
475   // Construct message in the message queue memory; note that delete should not be called on the return value
476   new (slot) LocalType( &manager, &UpdateManager::ConnectNode, &parent, &child, index );
477 }
478
479 inline void DisconnectNodeMessage( UpdateManager& manager, const Node& constNode )
480 {
481   // Scene graph thread can modify this object.
482   Node& node = const_cast< Node& >( constNode );
483
484   typedef MessageValue1< UpdateManager, Node* > LocalType;
485
486   // Reserve some memory inside the message queue
487   unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
488
489   // Construct message in the message queue memory; note that delete should not be called on the return value
490   new (slot) LocalType( &manager, &UpdateManager::DisconnectNode, &node );
491 }
492
493 inline void DestroyNodeMessage( UpdateManager& manager, const Node& constNode )
494 {
495   // Scene graph thread can destroy this object.
496   Node& node = const_cast< Node& >( constNode );
497
498   typedef MessageValue1< UpdateManager, Node* > LocalType;
499
500   // Reserve some memory inside the message queue
501   unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
502
503   // Construct message in the message queue memory; note that delete should not be called on the return value
504   new (slot) LocalType( &manager, &UpdateManager::DestroyNode, &node );
505 }
506
507 inline void AttachToNodeMessage( UpdateManager& manager, const Node& constParent, NodeAttachment* attachment )
508 {
509   // Scene graph thread can modify this object.
510   Node& parent = const_cast< Node& >( constParent );
511
512   typedef MessageValue2< UpdateManager, Node*, NodeAttachmentOwner > LocalType;
513
514   // Reserve some memory inside the message queue
515   unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
516
517   // Construct message in the message queue memory; note that delete should not be called on the return value
518   new (slot) LocalType( &manager, &UpdateManager::AttachToNode, &parent, attachment );
519 }
520
521 inline void AddObjectMessage( UpdateManager& manager, PropertyOwner* object )
522 {
523   typedef MessageValue1< UpdateManager, OwnerPointer<PropertyOwner> > LocalType;
524
525   // Reserve some memory inside the message queue
526   unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
527
528   // Construct message in the message queue memory; note that delete should not be called on the return value
529   new (slot) LocalType( &manager, &UpdateManager::AddObject, object );
530 }
531
532 inline void RemoveObjectMessage( UpdateManager& manager, PropertyOwner* object )
533 {
534   typedef MessageValue1< UpdateManager, PropertyOwner* > LocalType;
535
536   // Reserve some memory inside the message queue
537   unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
538
539   // Construct message in the message queue memory; note that delete should not be called on the return value
540   new (slot) LocalType( &manager, &UpdateManager::RemoveObject, object );
541 }
542
543 inline void AddAnimationMessage( UpdateManager& manager, Animation* animation )
544 {
545   typedef MessageValue1< UpdateManager, Animation* > LocalType;
546
547   // Reserve some memory inside the message queue
548   unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
549
550   // Construct message in the message queue memory; note that delete should not be called on the return value
551   new (slot) LocalType( &manager, &UpdateManager::AddAnimation, animation );
552 }
553
554 inline void StopAnimationMessage( UpdateManager& manager, const Animation& constAnimation )
555 {
556   // The scene-graph thread owns this object so it can safely edit it.
557   Animation& animation = const_cast< Animation& >( constAnimation );
558
559   typedef MessageValue1< UpdateManager, Animation* > LocalType;
560
561   // Reserve some memory inside the message queue
562   unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
563
564   // Construct message in the message queue memory; note that delete should not be called on the return value
565   new (slot) LocalType( &manager, &UpdateManager::StopAnimation, &animation );
566 }
567
568 inline void RemoveAnimationMessage( UpdateManager& manager, const Animation& constAnimation )
569 {
570   // The scene-graph thread owns this object so it can safely edit it.
571   Animation& animation = const_cast< Animation& >( constAnimation );
572
573   typedef MessageValue1< UpdateManager, Animation* > LocalType;
574
575   // Reserve some memory inside the message queue
576   unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
577
578   // Construct message in the message queue memory; note that delete should not be called on the return value
579   new (slot) LocalType( &manager, &UpdateManager::RemoveAnimation, &animation );
580 }
581
582 inline void AddPropertyNotificationMessage( UpdateManager& manager, PropertyNotification* propertyNotification )
583 {
584   typedef MessageValue1< UpdateManager, PropertyNotification* > LocalType;
585
586   // Reserve some memory inside the message queue
587   unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
588
589   // Construct message in the message queue memory; note that delete should not be called on the return value
590   new (slot) LocalType( &manager, &UpdateManager::AddPropertyNotification, propertyNotification );
591 }
592
593 inline void RemovePropertyNotificationMessage( UpdateManager& manager, const PropertyNotification& constPropertyNotification )
594 {
595   // The scene-graph thread owns this object so it can safely edit it.
596   PropertyNotification& propertyNotification = const_cast< PropertyNotification& >( constPropertyNotification );
597
598   typedef MessageValue1< UpdateManager, PropertyNotification* > LocalType;
599
600   // Reserve some memory inside the message queue
601   unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
602
603   // Construct message in the message queue memory; note that delete should not be called on the return value
604   new (slot) LocalType( &manager, &UpdateManager::RemovePropertyNotification, &propertyNotification );
605 }
606
607 inline void PropertyNotificationSetNotifyModeMessage( UpdateManager& manager,
608                                                       const PropertyNotification* constPropertyNotification,
609                                                       PropertyNotification::NotifyMode notifyMode )
610 {
611   // The scene-graph thread owns this object so it can safely edit it.
612   PropertyNotification* propertyNotification = const_cast< PropertyNotification* >( constPropertyNotification );
613
614   typedef MessageValue2< UpdateManager, PropertyNotification*, PropertyNotification::NotifyMode > LocalType;
615
616   // Reserve some memory inside the message queue
617   unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
618
619   // Construct message in the message queue memory; note that delete should not be called on the return value
620   new (slot) LocalType( &manager, &UpdateManager::PropertyNotificationSetNotify, propertyNotification, notifyMode );
621 }
622
623 // The render thread can safely change the Shader
624 inline void AddShaderMessage( UpdateManager& manager, Shader& shader )
625 {
626   typedef MessageValue1< UpdateManager, OwnerPointer< Shader > > LocalType;
627
628   // Reserve some memory inside the message queue
629   unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
630
631   // Construct message in the message queue memory; note that delete should not be called on the return value
632   new (slot) LocalType( &manager, &UpdateManager::AddShader, &shader );
633 }
634
635 // The render thread can safely change the Shader
636 inline void RemoveShaderMessage( UpdateManager& manager, Shader& shader )
637 {
638   typedef MessageValue1< UpdateManager, Shader* > LocalType;
639
640   // Reserve some memory inside the message queue
641   unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
642
643   // Construct message in the message queue memory; note that delete should not be called on the return value
644   new (slot) LocalType( &manager, &UpdateManager::RemoveShader, &shader );
645 }
646
647 inline void SetShaderProgramMessage( UpdateManager& manager,
648                                      Shader& shader,
649                                      GeometryType geometryType,
650                                      ShaderSubTypes subType,
651                                      Integration::ResourceId resourceId,
652                                      size_t shaderHash,
653                                      bool modifiesGeometry )
654 {
655   typedef MessageValue6< UpdateManager, Shader*, GeometryType, ShaderSubTypes, Integration::ResourceId, size_t, bool > LocalType;
656
657   // Reserve some memory inside the message queue
658   unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
659
660   // Construct message in the message queue memory; note that delete should not be called on the return value
661   new (slot) LocalType( &manager, &UpdateManager::SetShaderProgram, &shader, geometryType, subType, resourceId, shaderHash, modifiesGeometry );
662 }
663
664 inline void SetBackgroundColorMessage( UpdateManager& manager, const Vector4& color )
665 {
666   typedef MessageValue1< UpdateManager, Vector4 > LocalType;
667
668   // Reserve some memory inside the message queue
669   unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
670
671   // Construct message in the message queue memory; note that delete should not be called on the return value
672   new (slot) LocalType( &manager, &UpdateManager::SetBackgroundColor, color );
673 }
674
675 inline void SetDefaultSurfaceRectMessage( UpdateManager& manager, const Rect<int>& rect  )
676 {
677   typedef MessageValue1< UpdateManager, Rect<int> > LocalType;
678
679   // Reserve some memory inside the message queue
680   unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
681
682   // Construct message in the message queue memory; note that delete should not be called on the return value
683   new (slot) LocalType( &manager, &UpdateManager::SetDefaultSurfaceRect, rect );
684 }
685
686 inline void KeepRenderingMessage( UpdateManager& manager, float durationSeconds )
687 {
688   typedef MessageValue1< UpdateManager, float > LocalType;
689
690   // Reserve some memory inside the message queue
691   unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
692
693   // Construct message in the message queue memory; note that delete should not be called on the return value
694   new (slot) LocalType( &manager, &UpdateManager::KeepRendering, durationSeconds );
695 }
696
697 /**
698  * Create a message for setting the depth of a layer
699  * @param[in] manager The update manager
700  * @param[in] layers list of layers
701  * @param[in] systemLevel True if the layers are added via the SystemOverlay API
702  */
703 inline void SetLayerDepthsMessage( UpdateManager& manager, const std::vector< Layer* >& layers, bool systemLevel )
704 {
705   typedef MessageValue2< UpdateManager, std::vector< Layer* >, bool > LocalType;
706
707   // Reserve some memory inside the message queue
708   unsigned int* slot = manager.GetEventToUpdate().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::SetLayerDepths, layers, systemLevel );
712 }
713
714 inline void AddGestureMessage( UpdateManager& manager, PanGesture* gesture )
715 {
716   typedef MessageValue1< UpdateManager, PanGesture* > LocalType;
717
718   // Reserve some memory inside the message queue
719   unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
720
721   // Construct message in the message queue memory; note that delete should not be called on the return value
722   new (slot) LocalType( &manager, &UpdateManager::AddGesture, gesture );
723 }
724
725 inline void RemoveGestureMessage( UpdateManager& manager, PanGesture* gesture )
726 {
727   typedef MessageValue1< UpdateManager, PanGesture* > LocalType;
728
729   // Reserve some memory inside the message queue
730   unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
731
732   // Construct message in the message queue memory; note that delete should not be called on the return value
733   new (slot) LocalType( &manager, &UpdateManager::RemoveGesture, gesture );
734 }
735
736 #ifdef DYNAMICS_SUPPORT
737
738 // Dynamics messages
739 inline void InitializeDynamicsWorldMessage( UpdateManager& manager, DynamicsWorld* dynamicsworld, Integration::DynamicsWorldSettings* worldSettings )
740 {
741   typedef MessageValue2< UpdateManager, DynamicsWorld*, Integration::DynamicsWorldSettings* > LocalType;
742
743   // Reserve some memory inside the message queue
744   unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
745
746   // Construct message in the message queue memory; note that delete should not be called on the return value
747   new (slot) LocalType( &manager, &UpdateManager::InitializeDynamicsWorld, dynamicsworld, worldSettings );
748 }
749
750 inline void TerminateDynamicsWorldMessage(UpdateManager& manager)
751 {
752   typedef Message< UpdateManager > LocalType;
753
754   // Reserve some memory inside the message queue
755   unsigned int* slot = manager.GetEventToUpdate().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::TerminateDynamicsWorld );
759 }
760
761 #endif // DYNAMICS_SUPPORT
762
763 } // namespace SceneGraph
764
765 } // namespace Internal
766
767 } // namespace Dali
768
769 #endif // __DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H__