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