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