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