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