[Tizen] Implement partial update
[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) 2018 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/devel-api/common/stage-devel.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/property-resetter.h>
33 #include <dali/internal/update/common/scene-graph-buffers.h>
34 #include <dali/internal/update/common/scene-graph-property-notification.h>
35 #include <dali/internal/update/nodes/node.h>
36 #include <dali/internal/update/nodes/scene-graph-layer.h>
37 #include <dali/internal/update/manager/scene-graph-frame-callback.h> // for OwnerPointer< FrameCallback >
38 #include <dali/internal/update/rendering/scene-graph-renderer.h>  // for OwnerPointer< Renderer >
39 #include <dali/internal/update/rendering/scene-graph-texture-set.h> // for OwnerPointer< TextureSet >
40 #include <dali/internal/update/gestures/scene-graph-pan-gesture.h>
41 #include <dali/internal/update/render-tasks/scene-graph-camera.h>
42 #include <dali/internal/update/render-tasks/scene-graph-render-task-list.h>
43 #include <dali/internal/render/shaders/scene-graph-shader.h>   // for OwnerPointer< Shader >
44 #include <dali/internal/render/renderers/render-property-buffer.h>
45 #include <dali/internal/event/rendering/texture-impl.h>
46
47 namespace Dali
48 {
49
50 class FrameCallbackInterface;
51
52 namespace Integration
53 {
54 class GlSyncAbstraction;
55 class RenderController;
56
57 } // namespace Integration
58
59 namespace Internal
60 {
61
62 class PropertyNotifier;
63 class NotificationManager;
64 class CompleteNotificationInterface;
65 class TouchResampler;
66
67 namespace Render
68 {
69 struct Sampler;
70 class FrameBuffer;
71 }
72 // value types used by messages
73 template <> struct ParameterType< PropertyNotification::NotifyMode >
74 : public BasicType< PropertyNotification::NotifyMode > {};
75
76 namespace SceneGraph
77 {
78
79 class Animation;
80 class DiscardQueue;
81 class RenderManager;
82 class RenderTaskList;
83 class RenderTaskProcessor;
84 class RenderQueue;
85 class PropertyBuffer;
86
87 struct NodeDepthPair
88 {
89   SceneGraph::Node* node;
90   uint32_t sortedDepth;
91   NodeDepthPair( SceneGraph::Node* node, uint32_t sortedDepth )
92   : node(node),
93     sortedDepth(sortedDepth)
94   {
95   }
96 };
97
98 struct NodeDepths
99 {
100   NodeDepths()
101   {
102   }
103
104   void Add( SceneGraph::Node* node, uint32_t sortedDepth )
105   {
106     nodeDepths.push_back( NodeDepthPair( node, sortedDepth ) );
107   }
108
109   std::vector<NodeDepthPair> nodeDepths;
110 };
111
112
113 /**
114  * UpdateManager maintains a scene graph i.e. a tree of nodes as well as
115  * other scene graph property owning objects.
116  * It controls the Update traversal, in which nodes are repositioned/animated,
117  * and organizes the the culling and rendering of the scene.
118  * It also maintains the lifecycle of nodes and other property owners that are
119  * disconnected from the scene graph.
120  */
121 class UpdateManager : public ShaderSaver
122 {
123 public:
124
125   /**
126    * Construct a new UpdateManager.
127    * @param[in] notificationManager This should be notified when animations have finished.
128    * @param[in] animationPlaylist The CompleteNotificationInterface that handles the animations
129    * @param[in] propertyNotifier The PropertyNotifier
130    * @param[in] discardQueue Nodes are added here when disconnected from the scene-graph.
131    * @param[in] controller After messages are flushed, we request a render from the RenderController.
132    * @param[in] renderManager This is responsible for rendering the results of each "update".
133    * @param[in] renderQueue Used to queue messages for the next render.
134    * @param[in] renderTaskProcessor Handles RenderTasks and RenderInstrucitons.
135    * @param[in] partialUpdateAvailble whether the partial update is available 
136    */
137   UpdateManager( NotificationManager& notificationManager,
138                  CompleteNotificationInterface& animationPlaylist,
139                  PropertyNotifier& propertyNotifier,
140                  DiscardQueue& discardQueue,
141                  Integration::RenderController& controller,
142                  RenderManager& renderManager,
143                  RenderQueue& renderQueue,
144                  RenderTaskProcessor& renderTaskProcessor,
145                  bool partialUpdateAvailable );
146
147   /**
148    * Destructor.
149    */
150   virtual ~UpdateManager();
151
152   // Node connection methods
153
154   /**
155    * Installs a new layer as the root node.
156    * @pre The layer is of derived Node type Layer.
157    * @pre The layer does not have a parent.
158    * @param[in] layer The new root node.
159    * @post The node is owned by UpdateManager.
160    */
161   void InstallRoot( OwnerPointer<Layer>& layer );
162
163   /**
164    * Uninstalls the root node.
165    * @pre The layer is of derived Node type Layer.
166    * @pre The layer does not have a parent.
167    * @param[in] layer The root node.
168    * @post The node is owned by UpdateManager.
169    */
170   void UninstallRoot( Layer* layer );
171
172   /**
173    * Add a Node; UpdateManager takes ownership.
174    * @pre The node does not have a parent.
175    * @note even though nodes are pool allocated, they also contain other heap allocated data, thus using OwnerPointer when transferring the data
176    * @param[in] node The node to add.
177    */
178   void AddNode( OwnerPointer<Node>& node );
179
180   /**
181    * Connect a Node to the scene-graph.
182    * A disconnected Node has has no parent or children, and its properties cannot be animated/constrained.
183    * @pre The node does not already have a parent.
184    * @param[in] parent The new parent node.
185    */
186   void ConnectNode( Node* parent, Node* node );
187
188   /**
189    * Disconnect a Node from the scene-graph.
190    * A disconnected Node has has no parent or children, and its properties cannot be animated/constrained.
191    * @pre The node has a parent.
192    * @param[in] node The node to disconnect.
193    */
194   void DisconnectNode( Node* node );
195
196   /**
197    * Destroy a Node owned by UpdateManager.
198    * This is not immediate; Nodes are passed to the RenderQueue to allow GL resources to be deleted.
199    * In the following update, the previously queued Nodes may be deleted.
200    * @pre The node has been disconnected from the scene-graph i.e. has no parent or children.
201    * @param[in] node The node to destroy.
202    */
203   void DestroyNode( Node* node );
204
205   /**
206    * Add a camera on scene
207    * @param[in] camera The camera to add
208    */
209   void AddCamera( OwnerPointer< Camera >& camera );
210
211   /**
212    * Remove a camera from scene
213    * @param[in] camera to remove
214    */
215   void RemoveCamera( Camera* camera );
216
217   /**
218    * Add a newly created object.
219    * @param[in] object The object to add.
220    * @post The object is owned by UpdateManager.
221    */
222   void AddObject( OwnerPointer<PropertyOwner>& object );
223
224   /**
225    * Remove an object.
226    * @param[in] object The object to remove.
227    */
228   void RemoveObject( PropertyOwner* object );
229
230   /**
231    * Add a newly created render task list.
232    * @param[in] taskList The render task list to add.
233    * @post The render task list is owned by UpdateManager.
234    */
235   void AddRenderTaskList( OwnerPointer<RenderTaskList>& taskList );
236
237   /**
238    * Remove a render task list.
239    * @param[in] taskList The render task list to remove.
240    */
241   void RemoveRenderTaskList( RenderTaskList* taskList );
242
243   // Animations
244
245   /**
246    * Add a newly created animation.
247    * @param[in] animation The animation to add.
248    * @post The animation is owned by UpdateManager.
249    */
250   void AddAnimation( OwnerPointer< SceneGraph::Animation >& animation );
251
252   /**
253    * Stop an animation.
254    * @param[in] animation The animation to stop.
255    */
256   void StopAnimation( Animation* animation );
257
258   /**
259    * Remove an animation.
260    * @param[in] animation The animation to remove.
261    */
262   void RemoveAnimation( Animation* animation );
263
264   /**
265    * Query whether any animations are currently running.
266    * @return True if any animations are running.
267    */
268   bool IsAnimationRunning() const;
269
270   /**
271    * Add a property resetter. UpdateManager takes ownership of the object.
272    * It will be killed by UpdateManager when the associated animator or
273    * constraint has finished; or the property owner of the property is destroyed.
274    */
275   void AddPropertyResetter( OwnerPointer<PropertyResetterBase>& propertyResetter );
276
277   // Property Notification
278
279   /**
280    * Add a newly created property notification
281    * @param[in] propertyNotification The notification to add
282    * @post The propertyNotification is owned by UpdateManager.
283    */
284   void AddPropertyNotification( OwnerPointer< PropertyNotification >& propertyNotification );
285
286   /**
287    * Remove a property notification
288    * @param[in] propertyNotification The notification to remove
289    */
290   void RemovePropertyNotification( PropertyNotification* propertyNotification );
291
292   /**
293    * Set Notify state for PropertyNotification
294    * @param[in] propertyNotification The notification to remove
295    * @param[in] notifyMode The notification mode.
296    */
297   void PropertyNotificationSetNotify( PropertyNotification* propertyNotification, PropertyNotification::NotifyMode notifyMode );
298
299   // Shaders
300
301   /**
302    * Add a newly created shader.
303    * @param[in] shader The shader to add.
304    * @post The shader is owned by the UpdateManager.
305    */
306   void AddShader( OwnerPointer< Shader >& shader );
307
308   /**
309    * Remove a shader.
310    * @pre The shader has been added to the UpdateManager.
311    * @param[in] shader The shader to remove.
312    * @post The shader is destroyed.
313    */
314   void RemoveShader( Shader* shader );
315
316   /**
317    * Set the shader program for a Shader object
318    * @param[in] shader        The shader to modify
319    * @param[in] shaderData    Source code, hash over source, and optional compiled binary for the shader program
320    * @param[in] modifiesGeometry True if the vertex shader modifies geometry
321    */
322   void SetShaderProgram( Shader* shader, Internal::ShaderDataPtr shaderData, bool modifiesGeometry );
323
324   /**
325    * @brief Accept compiled shaders passed back on render thread for saving.
326    * @param[in] shaderData Source code, hash over source, and corresponding compiled binary to be saved.
327    */
328   virtual void SaveBinary( Internal::ShaderDataPtr shaderData );
329
330   /**
331    * @brief Set the destination for compiled shader binaries to be passed on to.
332    * The dispatcher passed in will be called from the update thread.
333    * @param[in] upstream A sink for ShaderDatas to be passed into.
334    */
335   void SetShaderSaver( ShaderSaver& upstream );
336
337   // Renderers
338
339   /**
340    * Add a new renderer to scene
341    * @param renderer to add
342    */
343   void AddRenderer( OwnerPointer< Renderer >& renderer );
344
345   /**
346    * Add a renderer from scene
347    * @param renderer to remove
348    */
349   void RemoveRenderer( Renderer* renderer );
350
351   // Gestures
352
353   /**
354    * Set the pan gesture processor.
355    * Pan Gesture processor lives for the lifetime of UpdateManager
356    * @param[in] gesture The gesture processor.
357    * @post The gestureProcessor is owned by the UpdateManager.
358    */
359   void SetPanGestureProcessor( PanGesture* gestureProcessor );
360
361   // Textures
362
363   /**
364    * Add a newly created TextureSet.
365    * @param[in] textureSet The texture set to add.
366    * @post The TextureSet is owned by the UpdateManager.
367    */
368   void AddTextureSet( OwnerPointer< TextureSet >& textureSet );
369
370   /**
371    * Remove a TextureSet.
372    * @pre The TextureSet has been added to the UpdateManager.
373    * @param[in] textureSet The TextureSet to remove.
374    * @post The TextureSet is destroyed.
375    */
376   void RemoveTextureSet( TextureSet* textureSet );
377
378   // Render tasks
379
380   /**
381    * Get the scene graph side list of RenderTasks.
382    * @param[in] systemLevel True if using the system-level overlay.
383    * @return The list of render tasks
384    */
385   RenderTaskList* GetRenderTaskList( bool systemLevel );
386
387 // Message queue handling
388
389   /**
390    * Reserve space for another message in the queue; this must then be initialized by the caller.
391    * The message will be read from the update-thread after the next FlushMessages is called.
392    * @post Calling this method may invalidate any previously returned slots.
393    * @param[in] size The message size with respect to the size of type "char".
394    * @param[in] updateScene A flag, when true denotes that the message will cause the scene-graph node tree to require an update.
395    * @note the default value of updateScene should match that in EventThreadServices::ReserveMessageSlot.
396    * @return A pointer to the first char allocated for the message.
397    */
398   uint32_t* ReserveMessageSlot( uint32_t size, bool updateScene = true );
399
400   /**
401    * @return the current event-buffer index.
402    */
403   BufferIndex GetEventBufferIndex() const
404   {
405     // inlined as its called often from event thread
406     return mSceneGraphBuffers.GetEventBufferIndex();
407   }
408
409   /**
410    * Called by the event-thread to signal that FlushQueue will be called
411    * e.g. when it has finished event processing.
412    */
413   void EventProcessingStarted();
414
415   /**
416    * Flush the set of messages, which were previously stored with QueueMessage().
417    * Calls to this thread-safe method should be minimized, to avoid thread blocking.
418    *
419    * @return True if there are messages to process.
420    */
421   bool FlushQueue();
422
423   /**
424    * Add a new sampler to RenderManager
425    * @param[in] sampler The sampler to add
426    * @post Sends a message to RenderManager to add the sampler.
427    * The sampler will be owned by RenderManager
428    */
429   void AddSampler( OwnerPointer< Render::Sampler >& sampler );
430
431   /**
432    * Removes an existing sampler from RenderManager
433    * @param[in] sampler The sampler to remove
434    * @post The sampler will be destroyed in the render thread
435    */
436   void RemoveSampler( Render::Sampler* sampler );
437
438   /**
439    * Sets the filter modes for an existing sampler
440    * @param[in] sampler The sampler
441    * @param[in] minFilterMode The filter to use under minification
442    * @param[in] magFilterMode The filter to use under magnification
443    */
444   void SetFilterMode( Render::Sampler* sampler, uint32_t minFilterMode, uint32_t magFilterMode );
445
446   /**
447    * Sets the wrap mode for an existing sampler
448    * @param[in] sampler The sampler
449    * @param[in] rWrapMode Wrapping mode in z direction
450    * @param[in] sWrapMode Wrapping mode in x direction
451    * @param[in] tWrapMode Wrapping mode in y direction
452    */
453   void SetWrapMode( Render::Sampler* sampler, uint32_t rWrapMode, uint32_t sWrapMode, uint32_t tWrapMode );
454
455   /**
456    * Add a new property buffer to RenderManager
457    * @param[in] propertryBuffer The property buffer to add
458    * @post Sends a message to RenderManager to add the property buffer.
459    * The property buffer will be owned by RenderManager
460    */
461   void AddPropertyBuffer( OwnerPointer< Render::PropertyBuffer >& propertryBuffer );
462
463   /**
464    * Removes an existing PropertyBuffer from RenderManager
465    * @param[in] propertryBuffer The property buffer to remove
466    * @post The property buffer will be destroyed in the render thread
467    */
468   void RemovePropertyBuffer( Render::PropertyBuffer* propertryBuffer );
469
470   /**
471    * Sets the format of an existing property buffer
472    * @param[in] propertyBuffer The property buffer.
473    * @param[in] format The new format of the buffer
474    * @post Sends a message to RenderManager to set the new format to the property buffer.
475    */
476   void SetPropertyBufferFormat( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Render::PropertyBuffer::Format>& format );
477
478   /**
479    * Sets the data of an existing property buffer
480    * @param[in] propertyBuffer The property buffer.
481    * @param[in] data The new data of the buffer
482    * @param[in] size The new size of the buffer
483    * @post Sends a message to RenderManager to set the new data to the property buffer.
484    */
485   void SetPropertyBufferData( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Vector<uint8_t> >& data, uint32_t size );
486
487   /**
488    * Adds a geometry to the RenderManager
489    * @param[in] geometry The geometry to add
490    * @post Sends a message to RenderManager to add the Geometry
491    * The geometry will be owned by RenderManager
492    */
493   void AddGeometry( OwnerPointer< Render::Geometry >& geometry );
494
495   /**
496    * Removes an existing Geometry from RenderManager
497    * @param[in] geometry The geometry to remove
498    * @post The geometry will be destroyed in the render thread
499    */
500   void RemoveGeometry( Render::Geometry* geometry );
501
502   /**
503    * Sets the geometry type of an existing Geometry
504    * @param[in] geometry The geometry
505    * @param[in] geometryType The type of the geometry
506    */
507   void SetGeometryType( Render::Geometry* geometry, uint32_t geometryType );
508
509   /**
510    * Sets the index buffer to be used by a geometry
511    * @param[in] geometry The geometry
512    * @param[in] indices A vector containing the indices for the geometry
513    */
514   void SetIndexBuffer( Render::Geometry* geometry, Dali::Vector<uint16_t>& indices );
515
516   /**
517    * Adds a vertex buffer to a geometry
518    * @param[in] geometry The geometry
519    * @param[in] propertyBuffer The property buffer
520    */
521   void AttachVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer );
522
523   /**
524    * Removes a vertex buffer from a geometry
525    * @param[in] geometry The geometry
526    * @param[in] propertyBuffer The property buffer
527    */
528   void RemoveVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer );
529
530   /**
531    * Adds a texture to the render manager
532    * @param[in] texture The texture to add
533    * The texture will be owned by RenderManager
534    */
535   void AddTexture( OwnerPointer< Render::Texture >& texture );
536
537   /**
538    * Removes a texture from the render manager
539    * @param[in] texture The texture to remove
540    * @post The texture will be destroyed in the render thread
541    */
542   void RemoveTexture( Render::Texture* texture );
543
544   /**
545    * Uploads data to a texture owned by the RenderManager
546    * @param[in] texture The texture
547    * @param[in] pixelData The pixel data object
548    * @param[in] params The parameters for the upload
549    */
550   void UploadTexture( Render::Texture* texture, PixelDataPtr pixelData, const Texture::UploadParams& params );
551
552   /**
553    * Generates mipmaps for a texture owned by the RenderManager
554    * @param[in] texture The texture
555    */
556   void GenerateMipmaps( Render::Texture* texture );
557
558   /**
559    * Adds a framebuffer to the render manager
560    * @param[in] frameBuffer The framebuffer to add
561    * The framebuffer will be owned by RenderManager
562    */
563   void AddFrameBuffer( OwnerPointer< Render::FrameBuffer >& frameBuffer );
564
565   /**
566    * Removes a FrameBuffer from the render manager
567    * @param[in] frameBuffer The FrameBuffer to remove
568    * @post The FrameBuffer will be destroyed in the render thread
569    */
570   void RemoveFrameBuffer( Render::FrameBuffer* frameBuffer );
571
572   /**
573    * Attach a texture as color output to an existing FrameBuffer
574    * @param[in] frameBuffer The FrameBuffer
575    * @param[in] texture The texture that will be used as output when rendering
576    * @param[in] mipmapLevel The mipmap of the texture to be attached
577    * @param[in] layer Indicates which layer of a cube map or array texture to attach. Unused for 2D textures
578    */
579   void AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::Texture* texture, uint32_t mipmapLevel, uint32_t face );
580
581 public:
582
583   /**
584    * Performs an Update traversal on the scene-graph.
585    * @param[in] elapsedSeconds The elapsed time that should be applied to animations.
586    * @param[in] lastVSyncTimeMilliseconds The last time, in milliseconds, that we had a VSync.
587    * @param[in] nextVSyncTimeMilliseconds The estimated time, in milliseconds, of the next VSync.
588    * @param[in] renderToFboEnabled Whether rendering into the Frame Buffer Object is enabled.
589    * @param[in] isRenderingToFbo   Whether this frame is being rendered into the Frame Buffer Object.
590    * @return True if further updates are required e.g. during animations.
591    */
592   uint32_t Update( float elapsedSeconds,
593                    uint32_t lastVSyncTimeMilliseconds,
594                    uint32_t nextVSyncTimeMilliseconds,
595                    bool renderToFboEnabled,
596                    bool isRenderingToFbo );
597
598   /**
599    * Set the background color i.e. the glClear color used at the beginning of each frame.
600    * @param[in] color The new background color.
601    */
602   void SetBackgroundColor(const Vector4& color);
603
604   /**
605    * Set the default surface rect.
606    * @param[in] rect The rect value representing the surface.
607    */
608   void SetDefaultSurfaceRect( const Rect<int>& rect );
609
610   /**
611    * Set the default surface orientation.
612    * @param[in] orientation The orientation value representing the surface.
613    */
614   void SetDefaultSurfaceOrientation( int orientation );
615
616   /**
617    * @copydoc Dali::Stage::KeepRendering()
618    */
619   void KeepRendering( float durationSeconds );
620
621   /**
622    * @copydoc Dali::DevelStage::SetRenderingBehavior()
623    */
624   void SetRenderingBehavior( DevelStage::Rendering renderingBehavior );
625
626   /**
627    * Sets the depths of all layers.
628    * @param layers The layers in depth order.
629    * @param[in] rootLayer The root layer of the sorted layers.
630    */
631   void SetLayerDepths( const std::vector< Layer* >& layers, const Layer* rootLayer );
632
633   /**
634    * Set the depth indices of all nodes (in LayerUI's)
635    * @param[in] nodeDepths A vector of nodes and associated depth indices
636    */
637   void SetDepthIndices( OwnerPointer< NodeDepths >& nodeDepths );
638
639   /**
640    * Query wheter the default surface rect is changed or not.
641    * @return true if the default surface rect is changed.
642    */
643   bool IsDefaultSurfaceRectChanged();
644
645   /**
646    * Adds an implementation of the FrameCallbackInterface.
647    * @param[in] frameCallback An OwnerPointer to the SceneGraph FrameCallback object
648    * @param[in] rootNode A pointer to the root node to apply the FrameCallback to
649    */
650   void AddFrameCallback( OwnerPointer< FrameCallback >& frameCallback, const Node* rootNode );
651
652   /**
653    * Removes the specified implementation of FrameCallbackInterface.
654    * @param[in] frameCallback A pointer to the implementation of the FrameCallbackInterface to remove.
655    */
656   void RemoveFrameCallback( FrameCallbackInterface* frameCallback );
657
658 private:
659
660   // Undefined
661   UpdateManager(const UpdateManager&);
662
663   // Undefined
664   UpdateManager& operator=(const UpdateManager& rhs);
665
666   /**
667    * Helper to check whether the update-thread should keep going.
668    * @param[in] elapsedSeconds The time in seconds since the previous update.
669    * @return True if the update-thread should keep going.
670    */
671   uint32_t KeepUpdatingCheck( float elapsedSeconds ) const;
672
673   /**
674    * Helper to reset all Node properties
675    * @param[in] bufferIndex to use
676    */
677   void ResetProperties( BufferIndex bufferIndex );
678
679   /**
680    * Perform gesture updates.
681    * @param[in] bufferIndex to use
682    * @param[in] lastVSyncTime  The last VSync time in milliseconds.
683    * @param[in] nextVSyncTime  The estimated time of the next VSync in milliseconds.
684    * @return true, if any properties were updated.
685    */
686   bool ProcessGestures( BufferIndex bufferIndex, uint32_t lastVSyncTimeMilliseconds, uint32_t nextVSyncTimeMilliseconds );
687
688   /**
689    * Perform animation updates
690    * @param[in] bufferIndex to use
691    * @param[in] elapsedSeconds time since last frame
692    */
693   void Animate( BufferIndex bufferIndex, float elapsedSeconds );
694
695   /**
696    * Applies constraints to CustomObjects
697    * @param[in] bufferIndex to use
698    */
699   void ConstrainCustomObjects( BufferIndex bufferIndex );
700
701   /**
702    * Applies constraints to RenderTasks
703    * @param[in] bufferIndex to use
704    */
705   void ConstrainRenderTasks( BufferIndex bufferIndex );
706
707   /**
708    * Applies constraints to Shaders
709    * @param[in] bufferIndex to use
710    */
711   void ConstrainShaders( BufferIndex bufferIndex );
712
713   /**
714    * Perform property notification updates
715    * @param[in] bufferIndex to use
716    */
717   void ProcessPropertyNotifications( BufferIndex bufferIndex );
718
719   /**
720    * Pass shader binaries queued here on to event thread.
721    */
722   void ForwardCompiledShadersToEventThread();
723
724   /**
725    * Update node shaders, opacity, geometry etc.
726    * @param[in] bufferIndex to use
727    */
728   void UpdateNodes( BufferIndex bufferIndex );
729
730   /**
731    * Update Renderers
732    * @param[in] bufferIndex to use
733    */
734   void UpdateRenderers( BufferIndex bufferIndex );
735
736 private:
737
738   // needs to be direct member so that getter for event buffer can be inlined
739   SceneGraphBuffers mSceneGraphBuffers;
740
741   struct Impl;
742   Impl* mImpl;
743
744 };
745
746 // Messages for UpdateManager
747
748 inline void InstallRootMessage( UpdateManager& manager, OwnerPointer<Layer>& root )
749 {
750   // Message has ownership of Layer while in transit from event -> update
751   typedef MessageValue1< UpdateManager, OwnerPointer<Layer> > LocalType;
752
753   // Reserve some memory inside the message queue
754   uint32_t* 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::InstallRoot, root );
758 }
759
760 inline void UninstallRootMessage( UpdateManager& manager, const Layer* constRoot )
761 {
762   // Scene graph thread can destroy this object.
763   Layer* root = const_cast< Layer* >( constRoot );
764
765   typedef MessageValue1< UpdateManager, Layer* > LocalType;
766
767   // Reserve some memory inside the message queue
768   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
769
770   // Construct message in the message queue memory; note that delete should not be called on the return value
771   new (slot) LocalType( &manager, &UpdateManager::UninstallRoot, root );
772 }
773
774 inline void AddNodeMessage( UpdateManager& manager, OwnerPointer<Node>& node )
775 {
776   // Message has ownership of Node while in transit from event -> update
777   typedef MessageValue1< UpdateManager, OwnerPointer<Node> > LocalType;
778
779   // Reserve some memory inside the message queue
780   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
781
782   // Construct message in the message queue memory; note that delete should not be called on the return value
783   new (slot) LocalType( &manager, &UpdateManager::AddNode, node );
784 }
785
786 inline void ConnectNodeMessage( UpdateManager& manager, const Node& constParent, const Node& constChild )
787 {
788   // Update thread can edit the object
789   Node& parent = const_cast< Node& >( constParent );
790   Node& child = const_cast< Node& >( constChild );
791
792   typedef MessageValue2< UpdateManager, Node*, Node* > LocalType;
793
794   // Reserve some memory inside the message queue
795   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
796
797   // Construct message in the message queue memory; note that delete should not be called on the return value
798   new (slot) LocalType( &manager, &UpdateManager::ConnectNode, &parent, &child );
799 }
800
801 inline void DisconnectNodeMessage( UpdateManager& manager, const Node& constNode )
802 {
803   // Scene graph thread can modify this object.
804   Node& node = const_cast< Node& >( constNode );
805
806   typedef MessageValue1< UpdateManager, Node* > LocalType;
807
808   // Reserve some memory inside the message queue
809   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
810
811   // Construct message in the message queue memory; note that delete should not be called on the return value
812   new (slot) LocalType( &manager, &UpdateManager::DisconnectNode, &node );
813 }
814
815 inline void DestroyNodeMessage( UpdateManager& manager, const Node& constNode )
816 {
817   // Scene graph thread can destroy this object.
818   Node& node = const_cast< Node& >( constNode );
819
820   typedef MessageValue1< UpdateManager, Node* > LocalType;
821
822   // Reserve some memory inside the message queue
823   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
824
825   // Construct message in the message queue memory; note that delete should not be called on the return value
826   new (slot) LocalType( &manager, &UpdateManager::DestroyNode, &node );
827 }
828
829 inline void AddCameraMessage( UpdateManager& manager, OwnerPointer< Camera >& camera )
830 {
831   // Message has ownership of Camera while in transit from event -> update
832   typedef MessageValue1< UpdateManager, OwnerPointer< Camera > > LocalType;
833
834   // Reserve some memory inside the message queue
835   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
836
837   // Construct message in the message queue memory; note that delete should not be called on the return value
838   new (slot) LocalType( &manager, &UpdateManager::AddCamera, camera );
839 }
840
841 inline void RemoveCameraMessage( UpdateManager& manager, const Camera* camera )
842 {
843   typedef MessageValue1< UpdateManager, Camera* > LocalType;
844
845   // Reserve some memory inside the message queue
846   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
847
848   // Construct message in the message queue memory; note that delete should not be called on the return value
849   new (slot) LocalType( &manager, &UpdateManager::RemoveCamera, const_cast<Camera*>( camera ) );
850 }
851
852 inline void AddObjectMessage( UpdateManager& manager, OwnerPointer<PropertyOwner>& object )
853 {
854   // Message has ownership of object while in transit from event -> update
855   typedef MessageValue1< UpdateManager, OwnerPointer<PropertyOwner> > LocalType;
856
857   // Reserve some memory inside the message queue
858   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
859
860   // Construct message in the message queue memory; note that delete should not be called on the return value
861   new (slot) LocalType( &manager, &UpdateManager::AddObject, object );
862 }
863
864 inline void RemoveObjectMessage( UpdateManager& manager, const PropertyOwner* object )
865 {
866   typedef MessageValue1< UpdateManager, PropertyOwner* > LocalType;
867
868   // Reserve some memory inside the message queue
869   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
870
871   // Construct message in the message queue memory; note that delete should not be called on the return value
872   new (slot) LocalType( &manager, &UpdateManager::RemoveObject, const_cast<PropertyOwner*>( object ) );
873 }
874
875 inline void AddAnimationMessage( UpdateManager& manager, OwnerPointer< SceneGraph::Animation >& animation )
876 {
877   typedef MessageValue1< UpdateManager, OwnerPointer< SceneGraph::Animation > > LocalType;
878
879   // Reserve some memory inside the message queue
880   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
881
882   // Construct message in the message queue memory; note that delete should not be called on the return value
883   new (slot) LocalType( &manager, &UpdateManager::AddAnimation, animation );
884 }
885
886 inline void StopAnimationMessage( UpdateManager& manager, const Animation& constAnimation )
887 {
888   // The scene-graph thread owns this object so it can safely edit it.
889   Animation& animation = const_cast< Animation& >( constAnimation );
890
891   typedef MessageValue1< UpdateManager, Animation* > LocalType;
892
893   // Reserve some memory inside the message queue
894   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
895
896   // Construct message in the message queue memory; note that delete should not be called on the return value
897   new (slot) LocalType( &manager, &UpdateManager::StopAnimation, &animation );
898 }
899
900 inline void RemoveAnimationMessage( UpdateManager& manager, const Animation& constAnimation )
901 {
902   // The scene-graph thread owns this object so it can safely edit it.
903   Animation& animation = const_cast< Animation& >( constAnimation );
904
905   typedef MessageValue1< UpdateManager, Animation* > LocalType;
906
907   // Reserve some memory inside the message queue
908   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
909
910   // Construct message in the message queue memory; note that delete should not be called on the return value
911   new (slot) LocalType( &manager, &UpdateManager::RemoveAnimation, &animation );
912 }
913
914 inline void AddRenderTaskListMessage( UpdateManager& manager, OwnerPointer< SceneGraph::RenderTaskList >& taskList )
915 {
916   typedef MessageValue1< UpdateManager, OwnerPointer< SceneGraph::RenderTaskList > > LocalType;
917
918   // Reserve some memory inside the message queue
919   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
920
921   // Construct message in the message queue memory; note that delete should not be called on the return value
922   new (slot) LocalType( &manager, &UpdateManager::AddRenderTaskList, taskList );
923 }
924
925 inline void RemoveRenderTaskListMessage( UpdateManager& manager, const RenderTaskList& constTaskList )
926 {
927   // The scene-graph thread owns this object so it can safely edit it.
928   RenderTaskList& taskList = const_cast< RenderTaskList& >( constTaskList );
929
930   typedef MessageValue1< UpdateManager, RenderTaskList* > LocalType;
931
932   // Reserve some memory inside the message queue
933   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
934
935   // Construct message in the message queue memory; note that delete should not be called on the return value
936   new (slot) LocalType( &manager, &UpdateManager::RemoveRenderTaskList, &taskList );
937 }
938
939 inline void AddPropertyNotificationMessage( UpdateManager& manager, OwnerPointer< PropertyNotification >& propertyNotification )
940 {
941   // Message has ownership of PropertyNotification while in transit from event -> update
942   typedef MessageValue1< UpdateManager, OwnerPointer< PropertyNotification > > LocalType;
943
944   // Reserve some memory inside the message queue
945   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
946
947   // Construct message in the message queue memory; note that delete should not be called on the return value
948   new (slot) LocalType( &manager, &UpdateManager::AddPropertyNotification, propertyNotification );
949 }
950
951 inline void RemovePropertyNotificationMessage( UpdateManager& manager, const PropertyNotification& constPropertyNotification )
952 {
953   // The scene-graph thread owns this object so it can safely edit it.
954   PropertyNotification& propertyNotification = const_cast< PropertyNotification& >( constPropertyNotification );
955
956   typedef MessageValue1< UpdateManager, PropertyNotification* > LocalType;
957
958   // Reserve some memory inside the message queue
959   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
960
961   // Construct message in the message queue memory; note that delete should not be called on the return value
962   new (slot) LocalType( &manager, &UpdateManager::RemovePropertyNotification, &propertyNotification );
963 }
964
965 inline void PropertyNotificationSetNotifyModeMessage( UpdateManager& manager,
966                                                       const PropertyNotification* constPropertyNotification,
967                                                       PropertyNotification::NotifyMode notifyMode )
968 {
969   // The scene-graph thread owns this object so it can safely edit it.
970   PropertyNotification* propertyNotification = const_cast< PropertyNotification* >( constPropertyNotification );
971
972   typedef MessageValue2< UpdateManager, PropertyNotification*, PropertyNotification::NotifyMode > LocalType;
973
974   // Reserve some memory inside the message queue
975   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
976
977   // Construct message in the message queue memory; note that delete should not be called on the return value
978   new (slot) LocalType( &manager, &UpdateManager::PropertyNotificationSetNotify, propertyNotification, notifyMode );
979 }
980
981 // The render thread can safely change the Shader
982 inline void AddShaderMessage( UpdateManager& manager, OwnerPointer< Shader >& shader )
983 {
984   typedef MessageValue1< UpdateManager, OwnerPointer< Shader > > LocalType;
985
986   // Reserve some memory inside the message queue
987   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
988
989   // Construct message in the message queue memory; note that delete should not be called on the return value
990   new (slot) LocalType( &manager, &UpdateManager::AddShader, shader );
991 }
992
993 // The render thread can safely change the Shader
994 inline void RemoveShaderMessage( UpdateManager& manager, const Shader* shader )
995 {
996   typedef MessageValue1< UpdateManager, Shader* > LocalType;
997
998   // Reserve some memory inside the message queue
999   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1000
1001   // Construct message in the message queue memory; note that delete should not be called on the return value
1002   new (slot) LocalType( &manager, &UpdateManager::RemoveShader, const_cast<Shader*>( shader ) );
1003 }
1004
1005 inline void SetShaderProgramMessage( UpdateManager& manager,
1006                                      const Shader& shader,
1007                                      Internal::ShaderDataPtr shaderData,
1008                                      bool modifiesGeometry )
1009 {
1010   typedef MessageValue3< UpdateManager, Shader*, Internal::ShaderDataPtr, bool > LocalType;
1011
1012   // Reserve some memory inside the message queue
1013   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1014
1015   // Construct message in the message queue memory; note that delete should not be called on the return value
1016   new (slot) LocalType( &manager, &UpdateManager::SetShaderProgram, const_cast<Shader*>( &shader ), shaderData, modifiesGeometry );
1017 }
1018
1019 inline void SetBackgroundColorMessage( UpdateManager& manager, const Vector4& color )
1020 {
1021   typedef MessageValue1< UpdateManager, Vector4 > LocalType;
1022
1023   // Reserve some memory inside the message queue
1024   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1025
1026   // Construct message in the message queue memory; note that delete should not be called on the return value
1027   new (slot) LocalType( &manager, &UpdateManager::SetBackgroundColor, color );
1028 }
1029
1030 inline void SetDefaultSurfaceRectMessage( UpdateManager& manager, const Rect<int32_t>& rect  )
1031 {
1032   typedef MessageValue1< UpdateManager, Rect<int32_t> > LocalType;
1033
1034   // Reserve some memory inside the message queue
1035   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1036
1037   // Construct message in the message queue memory; note that delete should not be called on the return value
1038   new (slot) LocalType( &manager, &UpdateManager::SetDefaultSurfaceRect, rect );
1039 }
1040
1041 inline void SetDefaultSurfaceOrientationMessage( UpdateManager& manager, int orientation  )
1042 {
1043   typedef MessageValue1< UpdateManager, int > LocalType;
1044
1045   // Reserve some memory inside the message queue
1046   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1047
1048   // Construct message in the message queue memory; note that delete should not be called on the return value
1049   new (slot) LocalType( &manager, &UpdateManager::SetDefaultSurfaceOrientation, orientation );
1050 }
1051
1052 inline void KeepRenderingMessage( UpdateManager& manager, float durationSeconds )
1053 {
1054   typedef MessageValue1< UpdateManager, float > LocalType;
1055
1056   // Reserve some memory inside the message queue
1057   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1058
1059   // Construct message in the message queue memory; note that delete should not be called on the return value
1060   new (slot) LocalType( &manager, &UpdateManager::KeepRendering, durationSeconds );
1061 }
1062
1063 inline void SetRenderingBehaviorMessage( UpdateManager& manager, DevelStage::Rendering renderingBehavior )
1064 {
1065   typedef MessageValue1< UpdateManager, DevelStage::Rendering > LocalType;
1066
1067   // Reserve some memory inside the message queue
1068   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1069
1070   // Construct message in the message queue memory; note that delete should not be called on the return value
1071   new (slot) LocalType( &manager, &UpdateManager::SetRenderingBehavior, renderingBehavior );
1072 }
1073
1074 /**
1075  * Create a message for setting the depth of a layer
1076  * @param[in] manager The update manager
1077  * @param[in] layers list of layers
1078  * @param[in] rootLayer The rool layer
1079  */
1080 inline void SetLayerDepthsMessage( UpdateManager& manager, const std::vector< Layer* >& layers, const Layer* rootLayer )
1081 {
1082   typedef MessageValue2< UpdateManager, std::vector< Layer* >, const Layer* > LocalType;
1083
1084   // Reserve some memory inside the message queue
1085   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1086
1087   // Construct message in the message queue memory; note that delete should not be called on the return value
1088   new (slot) LocalType( &manager, &UpdateManager::SetLayerDepths, layers, rootLayer );
1089 }
1090
1091 inline void AddRendererMessage( UpdateManager& manager, OwnerPointer< Renderer >& object )
1092 {
1093   typedef MessageValue1< UpdateManager, OwnerPointer< Renderer > > LocalType;
1094
1095   // Reserve some memory inside the message queue
1096   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1097   // Construct message in the message queue memory; note that delete should not be called on the return value
1098   new (slot) LocalType( &manager, &UpdateManager::AddRenderer, object );
1099 }
1100
1101 inline void RemoveRendererMessage( UpdateManager& manager, const Renderer& object )
1102 {
1103   typedef MessageValue1< UpdateManager, Renderer* > LocalType;
1104
1105   // Reserve some memory inside the message queue
1106   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1107   // Construct message in the message queue memory; note that delete should not be called on the return value
1108   new (slot) LocalType( &manager, &UpdateManager::RemoveRenderer, const_cast<Renderer*>( &object ) );
1109 }
1110
1111 // The render thread can safely change the Shader
1112 inline void AddTextureSetMessage( UpdateManager& manager, OwnerPointer< TextureSet >& textureSet )
1113 {
1114   typedef MessageValue1< UpdateManager, OwnerPointer< TextureSet > > LocalType;
1115
1116   // Reserve some memory inside the message queue
1117   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1118
1119   // Construct message in the message queue memory; note that delete should not be called on the return value
1120   new (slot) LocalType( &manager, &UpdateManager::AddTextureSet, textureSet );
1121 }
1122
1123 // The render thread can safely change the Shader
1124 inline void RemoveTextureSetMessage( UpdateManager& manager, TextureSet& textureSet )
1125 {
1126   typedef MessageValue1< UpdateManager, TextureSet* > LocalType;
1127
1128   // Reserve some memory inside the message queue
1129   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1130
1131   // Construct message in the message queue memory; note that delete should not be called on the return value
1132   new (slot) LocalType( &manager, &UpdateManager::RemoveTextureSet, &textureSet );
1133 }
1134
1135 inline void AddSamplerMessage( UpdateManager& manager, OwnerPointer< Render::Sampler >& sampler )
1136 {
1137   // Message has ownership of Sampler while in transit from event -> update
1138   typedef MessageValue1< UpdateManager, OwnerPointer< Render::Sampler > > LocalType;
1139
1140   // Reserve some memory inside the message queue
1141   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1142
1143   // Construct message in the message queue memory; note that delete should not be called on the return value
1144   new (slot) LocalType( &manager, &UpdateManager::AddSampler, sampler );
1145 }
1146
1147 inline void RemoveSamplerMessage( UpdateManager& manager, Render::Sampler& sampler )
1148 {
1149   typedef MessageValue1< UpdateManager, Render::Sampler* > LocalType;
1150
1151   // Reserve some memory inside the message queue
1152   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1153
1154   // Construct message in the message queue memory; note that delete should not be called on the return value
1155   new (slot) LocalType( &manager, &UpdateManager::RemoveSampler, &sampler );
1156 }
1157
1158 inline void SetFilterModeMessage( UpdateManager& manager, Render::Sampler& sampler, uint32_t minFilterMode, uint32_t magFilterMode )
1159 {
1160   typedef MessageValue3< UpdateManager, Render::Sampler*, uint32_t, uint32_t > LocalType;
1161
1162   // Reserve some memory inside the message queue
1163   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1164
1165   // Construct message in the message queue memory; note that delete should not be called on the return value
1166   new (slot) LocalType( &manager, &UpdateManager::SetFilterMode, &sampler, minFilterMode, magFilterMode );
1167 }
1168
1169 inline void SetWrapModeMessage( UpdateManager& manager, Render::Sampler& sampler, uint32_t rWrapMode, uint32_t sWrapMode, uint32_t tWrapMode )
1170 {
1171   typedef MessageValue4< UpdateManager, Render::Sampler*, uint32_t, uint32_t, uint32_t > LocalType;
1172
1173   // Reserve some memory inside the message queue
1174   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1175
1176   // Construct message in the message queue memory; note that delete should not be called on the return value
1177   new (slot) LocalType( &manager, &UpdateManager::SetWrapMode, &sampler, rWrapMode, sWrapMode, tWrapMode );
1178 }
1179
1180 inline void AddPropertyBuffer( UpdateManager& manager, OwnerPointer< Render::PropertyBuffer >& propertyBuffer )
1181 {
1182   // Message has ownership of propertyBuffer while in transit from event -> update
1183   typedef MessageValue1< UpdateManager, OwnerPointer< Render::PropertyBuffer > > LocalType;
1184
1185   // Reserve some memory inside the message queue
1186   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1187
1188   // Construct message in the message queue memory; note that delete should not be called on the return value
1189   new (slot) LocalType( &manager, &UpdateManager::AddPropertyBuffer, propertyBuffer );
1190 }
1191
1192 inline void RemovePropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer )
1193 {
1194   typedef MessageValue1< UpdateManager, Render::PropertyBuffer*  > LocalType;
1195
1196   // Reserve some memory inside the message queue
1197   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1198
1199   // Construct message in the message queue memory; note that delete should not be called on the return value
1200   new (slot) LocalType( &manager, &UpdateManager::RemovePropertyBuffer, &propertyBuffer );
1201 }
1202
1203 inline void SetPropertyBufferFormat( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, OwnerPointer< Render::PropertyBuffer::Format>& format )
1204 {
1205   // Message has ownership of PropertyBuffer::Format while in transit from event -> update
1206   typedef MessageValue2< UpdateManager, Render::PropertyBuffer*, OwnerPointer< Render::PropertyBuffer::Format> > LocalType;
1207
1208   // Reserve some memory inside the message queue
1209   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1210
1211   // Construct message in the message queue memory; note that delete should not be called on the return value
1212   new (slot) LocalType( &manager, &UpdateManager::SetPropertyBufferFormat, &propertyBuffer, format );
1213 }
1214
1215 inline void SetPropertyBufferData( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, OwnerPointer< Vector<uint8_t> >& data, uint32_t size )
1216 {
1217   // Message has ownership of PropertyBuffer data while in transit from event -> update
1218   typedef MessageValue3< UpdateManager, Render::PropertyBuffer*, OwnerPointer< Vector<uint8_t> >, uint32_t  > LocalType;
1219
1220   // Reserve some memory inside the message queue
1221   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1222
1223   // Construct message in the message queue memory; note that delete should not be called on the return value
1224   new (slot) LocalType( &manager, &UpdateManager::SetPropertyBufferData, &propertyBuffer, data, size );
1225 }
1226
1227 inline void AddGeometry( UpdateManager& manager, OwnerPointer< Render::Geometry >& geometry )
1228 {
1229   // Message has ownership of Geometry while in transit from event -> update
1230   typedef MessageValue1< UpdateManager, OwnerPointer< Render::Geometry > > LocalType;
1231
1232   // Reserve some memory inside the message queue
1233   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1234
1235   // Construct message in the message queue memory; note that delete should not be called on the return value
1236   new (slot) LocalType( &manager, &UpdateManager::AddGeometry, geometry );
1237 }
1238
1239 inline void RemoveGeometry( UpdateManager& manager, Render::Geometry& geometry )
1240 {
1241   typedef MessageValue1< UpdateManager, Render::Geometry*  > LocalType;
1242
1243   // Reserve some memory inside the message queue
1244   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1245
1246   // Construct message in the message queue memory; note that delete should not be called on the return value
1247   new (slot) LocalType( &manager, &UpdateManager::RemoveGeometry, &geometry );
1248 }
1249
1250 inline void AttachVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer )
1251 {
1252   typedef MessageValue2< UpdateManager, Render::Geometry*, Render::PropertyBuffer* > LocalType;
1253
1254   // Reserve some memory inside the message queue
1255   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1256
1257   // Construct message in the message queue memory; note that delete should not be called on the return value
1258   new (slot) LocalType( &manager, &UpdateManager::AttachVertexBuffer, &geometry, const_cast<Render::PropertyBuffer*>(&vertexBuffer) );
1259 }
1260
1261 inline void RemoveVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer )
1262 {
1263   typedef MessageValue2< UpdateManager, Render::Geometry*, Render::PropertyBuffer* > LocalType;
1264
1265   // Reserve some memory inside the message queue
1266   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1267
1268   // Construct message in the message queue memory; note that delete should not be called on the return value
1269   new (slot) LocalType( &manager, &UpdateManager::RemoveVertexBuffer, &geometry, const_cast<Render::PropertyBuffer*>(&vertexBuffer) );
1270 }
1271
1272 // Custom message type for SetIndexBuffer() used to move data with Vector::Swap()
1273 template< typename T >
1274 class IndexBufferMessage : public MessageBase
1275 {
1276 public:
1277
1278   /**
1279    * Constructor which does a Vector::Swap()
1280    */
1281   IndexBufferMessage( T* manager, Render::Geometry* geometry, Dali::Vector<uint16_t>& indices )
1282   : MessageBase(),
1283     mManager( manager ),
1284     mRenderGeometry( geometry )
1285   {
1286     mIndices.Swap( indices );
1287   }
1288
1289   /**
1290    * Virtual destructor
1291    */
1292   virtual ~IndexBufferMessage()
1293   {
1294   }
1295
1296   /**
1297    * @copydoc MessageBase::Process
1298    */
1299   virtual void Process( BufferIndex /*bufferIndex*/ )
1300   {
1301     DALI_ASSERT_DEBUG( mManager && "Message does not have an object" );
1302     mManager->SetIndexBuffer( mRenderGeometry, mIndices );
1303   }
1304
1305 private:
1306
1307   T* mManager;
1308   Render::Geometry* mRenderGeometry;
1309   Dali::Vector<uint16_t> mIndices;
1310 };
1311
1312 inline void SetIndexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, Dali::Vector<uint16_t>& indices )
1313 {
1314   typedef IndexBufferMessage< UpdateManager > LocalType;
1315
1316   // Reserve some memory inside the message queue
1317   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1318
1319   // Construct message in the message queue memory; note that delete should not be called on the return value
1320   new (slot) LocalType( &manager, &geometry, indices );
1321 }
1322
1323 inline void SetGeometryTypeMessage( UpdateManager& manager, Render::Geometry& geometry, uint32_t geometryType )
1324 {
1325   typedef MessageValue2< UpdateManager, Render::Geometry*, uint32_t > LocalType;
1326
1327   // Reserve some memory inside the message queue
1328   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1329
1330   // Construct message in the message queue memory; note that delete should not be called on the return value
1331   new (slot) LocalType( &manager, &UpdateManager::SetGeometryType, &geometry, geometryType );
1332 }
1333
1334 inline void AddTexture( UpdateManager& manager, OwnerPointer< Render::Texture >& texture )
1335 {
1336   // Message has ownership of Texture while in transit from event -> update
1337   typedef MessageValue1< UpdateManager, OwnerPointer< Render::Texture > > LocalType;
1338
1339   // Reserve some memory inside the message queue
1340   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1341
1342   // Construct message in the message queue memory; note that delete should not be called on the return value
1343   new (slot) LocalType( &manager, &UpdateManager::AddTexture, texture );
1344 }
1345
1346 inline void RemoveTexture( UpdateManager& manager, Render::Texture& texture )
1347 {
1348   typedef MessageValue1< UpdateManager, Render::Texture*  > LocalType;
1349
1350   // Reserve some memory inside the message queue
1351   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1352
1353   // Construct message in the message queue memory; note that delete should not be called on the return value
1354   new (slot) LocalType( &manager, &UpdateManager::RemoveTexture, &texture );
1355 }
1356
1357 inline void UploadTextureMessage( UpdateManager& manager, Render::Texture& texture, PixelDataPtr pixelData, const Texture::UploadParams& params )
1358 {
1359   typedef MessageValue3< UpdateManager, Render::Texture*, PixelDataPtr, Texture::UploadParams > LocalType;
1360
1361   // Reserve some memory inside the message queue
1362   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1363
1364   // Construct message in the message queue memory; note that delete should not be called on the return value
1365   new (slot) LocalType( &manager, &UpdateManager::UploadTexture, &texture, pixelData, params );
1366 }
1367
1368 inline void GenerateMipmapsMessage( UpdateManager& manager, Render::Texture& texture )
1369 {
1370   typedef MessageValue1< UpdateManager, Render::Texture*  > LocalType;
1371
1372   // Reserve some memory inside the message queue
1373   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1374
1375   // Construct message in the message queue memory; note that delete should not be called on the return value
1376   new (slot) LocalType( &manager, &UpdateManager::GenerateMipmaps, &texture );
1377 }
1378
1379
1380 inline void AddFrameBuffer( UpdateManager& manager, OwnerPointer< Render::FrameBuffer >& frameBuffer )
1381 {
1382   typedef MessageValue1< UpdateManager, OwnerPointer< Render::FrameBuffer > > LocalType;
1383
1384   // Reserve some memory inside the message queue
1385   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1386
1387   // Construct message in the message queue memory; note that delete should not be called on the return value
1388   new (slot) LocalType( &manager, &UpdateManager::AddFrameBuffer, frameBuffer );
1389 }
1390
1391 inline void RemoveFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer )
1392 {
1393   typedef MessageValue1< UpdateManager, Render::FrameBuffer*  > LocalType;
1394
1395   // Reserve some memory inside the message queue
1396   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1397
1398   // Construct message in the message queue memory; note that delete should not be called on the return value
1399   new (slot) LocalType( &manager, &UpdateManager::RemoveFrameBuffer, &frameBuffer );
1400 }
1401
1402 inline void AttachColorTextureToFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer, Render::Texture* texture, uint32_t mipmapLevel, uint32_t layer )
1403 {
1404   typedef MessageValue4< UpdateManager, Render::FrameBuffer*, Render::Texture*, uint32_t, uint32_t  > LocalType;
1405
1406   // Reserve some memory inside the message queue
1407   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1408
1409   // Construct message in the message queue memory; note that delete should not be called on the return value
1410   new (slot) LocalType( &manager, &UpdateManager::AttachColorTextureToFrameBuffer, &frameBuffer, texture, mipmapLevel, layer );
1411 }
1412
1413 inline void SetDepthIndicesMessage( UpdateManager& manager, OwnerPointer< NodeDepths >& nodeDepths )
1414 {
1415   typedef MessageValue1< UpdateManager, OwnerPointer< NodeDepths > > LocalType;
1416
1417   // Reserve some memory inside the message queue
1418   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1419
1420   // Construct message in the message queue memory; note that delete should not be called on the return value
1421   new (slot) LocalType( &manager, &UpdateManager::SetDepthIndices, nodeDepths );
1422 }
1423
1424 inline void AddResetterMessage( UpdateManager& manager, OwnerPointer<PropertyResetterBase> resetter )
1425 {
1426   typedef MessageValue1< UpdateManager, OwnerPointer<PropertyResetterBase> > LocalType;
1427
1428   // Reserve some memory inside the message queue
1429   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1430
1431   // Construct message in the message queue memory; note that delete should not be called on the return value
1432   new (slot) LocalType( &manager, &UpdateManager::AddPropertyResetter, resetter );
1433 }
1434
1435 inline void AddFrameCallbackMessage( UpdateManager& manager, OwnerPointer< FrameCallback >& frameCallback, const Node& rootNode )
1436 {
1437   typedef MessageValue2< UpdateManager, OwnerPointer< FrameCallback >, const Node* > LocalType;
1438
1439   // Reserve some memory inside the message queue
1440   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1441
1442   // Construct message in the message queue memory; note that delete should not be called on the return value
1443   new (slot) LocalType( &manager, &UpdateManager::AddFrameCallback, frameCallback, &rootNode );
1444 }
1445
1446 inline void RemoveFrameCallbackMessage( UpdateManager& manager, FrameCallbackInterface& frameCallback )
1447 {
1448   typedef MessageValue1< UpdateManager, FrameCallbackInterface* > LocalType;
1449
1450   // Reserve some memory inside the message queue
1451   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1452
1453   // Construct message in the message queue memory; note that delete should not be called on the return value
1454   new (slot) LocalType( &manager, &UpdateManager::RemoveFrameCallback, &frameCallback );
1455 }
1456
1457 } // namespace SceneGraph
1458
1459 } // namespace Internal
1460
1461 } // namespace Dali
1462
1463 #endif // DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H