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