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