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