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