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