1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H__
5 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/common/vector-wrapper.h>
23 #include <dali/public-api/common/dali-common.h>
25 #include <dali/integration-api/resource-declarations.h>
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/scene-graph-buffers.h>
33 #include <dali/internal/update/common/scene-graph-property-notification.h>
34 #include <dali/internal/update/manager/object-owner-container.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>
38 #include <dali/internal/render/shaders/scene-graph-shader.h>
39 #include <dali/internal/render/renderers/render-property-buffer.h>
40 #include <dali/internal/event/rendering/texture-impl.h>
47 class GlSyncAbstraction;
48 class RenderController;
50 } // namespace Integration
55 class PropertyNotifier;
56 class NotificationManager;
57 class CompleteNotificationInterface;
58 class ResourceManager;
66 // value types used by messages
67 template <> struct ParameterType< PropertyNotification::NotifyMode >
68 : public BasicType< PropertyNotification::NotifyMode > {};
79 class TextureCacheDispatcher;
85 * UpdateManager maintains a scene graph i.e. a tree of nodes as well as
86 * other scene graph property owning objects.
87 * It controls the Update traversal, in which nodes are repositioned/animated,
88 * and organizes the the culling and rendering of the scene.
89 * It also maintains the lifecycle of nodes and other property owners that are
90 * disconnected from the scene graph.
92 class UpdateManager : public ShaderSaver
97 * Construct a new UpdateManager.
98 * @param[in] notificationManager This should be notified when animations have finished.
99 * @param[in] animationFinishedNotifier The CompleteNotificationInterface that handles animation completions
100 * @param[in] propertyNotifier The PropertyNotifier
101 * @param[in] resourceManager The resource manager used to load textures etc.
102 * @param[in] discardQueue Nodes are added here when disconnected from the scene-graph.
103 * @param[in] controller After messages are flushed, we request a render from the RenderController.
104 * @param[in] renderManager This is responsible for rendering the results of each "update".
105 * @param[in] renderQueue Used to queue messages for the next render.
106 * @param[in] textureCacheDispatcher Used for sending messages to texture cache.
107 * @param[in] geometryBatcher Used when geometry batching is enabled.
109 UpdateManager( NotificationManager& notificationManager,
110 CompleteNotificationInterface& animationFinishedNotifier,
111 PropertyNotifier& propertyNotifier,
112 ResourceManager& resourceManager,
113 DiscardQueue& discardQueue,
114 Integration::RenderController& controller,
115 RenderManager& renderManager,
116 RenderQueue& renderQueue,
117 TextureCacheDispatcher& textureCacheDispatcher,
118 GeometryBatcher& geometryBatcher );
123 virtual ~UpdateManager();
125 // Node connection methods
128 * Get the scene graph side list of RenderTasks.
129 * @param[in] systemLevel True if using the system-level overlay.
130 * @return The list of render tasks
132 RenderTaskList* GetRenderTaskList( bool systemLevel );
135 * Installs a new layer as the root node.
136 * @pre The UpdateManager does not already have an installed root node.
137 * @pre The layer is of derived Node type Layer.
138 * @pre The layer does not have a parent.
139 * @param[in] layer The new root node.
140 * @param[in] systemLevel True if using the system-level overlay.
141 * @post The node is owned by UpdateManager.
143 void InstallRoot( Layer* layer, bool systemLevel );
146 * Add a Node; UpdateManager takes ownership.
147 * @pre The node does not have a parent.
148 * @param[in] node The node to add.
150 void AddNode( Node* node );
153 * Connect a Node to the scene-graph.
154 * A disconnected Node has has no parent or children, and its properties cannot be animated/constrained.
155 * @pre The node does not already have a parent.
156 * @param[in] parent The new parent node.
158 void ConnectNode( Node* parent, Node* node );
161 * Disconnect a Node from the scene-graph.
162 * A disconnected Node has has no parent or children, and its properties cannot be animated/constrained.
163 * @pre The node has a parent.
164 * @param[in] node The node to disconnect.
166 void DisconnectNode( Node* node );
169 * Destroy a Node owned by UpdateManager.
170 * This is not immediate; Nodes are passed to the RenderQueue to allow GL resources to be deleted.
171 * In the following update, the previously queued Nodes may be deleted.
172 * @pre The node has been disconnected from the scene-graph i.e. has no parent or children.
173 * @param[in] node The node to destroy.
175 void DestroyNode( Node* node );
178 * Add a camera on scene
179 * @param[in] camera to add
181 void AddCamera( Camera* camera );
184 * Remove a camera from scene
185 * @param[in] camera to remove
187 void RemoveCamera( const Camera* camera );
190 * Add a newly created object.
191 * @param[in] object The object to add.
192 * @post The object is owned by UpdateManager.
194 void AddObject( PropertyOwner* object );
198 * @param[in] object The object to remove.
200 void RemoveObject( PropertyOwner* object );
205 * Add a newly created animation.
206 * @param[in] animation The animation to add.
207 * @post The animation is owned by UpdateManager.
209 void AddAnimation( Animation* animation );
213 * @param[in] animation The animation to stop.
215 void StopAnimation( Animation* animation );
218 * Remove an animation.
219 * @param[in] animation The animation to remove.
221 void RemoveAnimation( Animation* animation );
224 * Query whether any animations are currently running.
225 * @return True if any animations are running.
227 bool IsAnimationRunning() const;
229 // Property Notification
232 * Add a newly created property notification
233 * @param[in] propertyNotification The notification to add
234 * @post The propertyNotification is owned by UpdateManager.
236 void AddPropertyNotification( PropertyNotification* propertyNotification );
239 * Remove a property notification
240 * @param[in] propertyNotification The notification to remove
242 void RemovePropertyNotification( PropertyNotification* propertyNotification );
245 * Set Notify state for PropertyNotification
246 * @param[in] propertyNotification The notification to remove
247 * @param[in] notifyMode The notification mode.
249 void PropertyNotificationSetNotify( PropertyNotification* propertyNotification, PropertyNotification::NotifyMode notifyMode );
252 * @brief Get the renderer owner
254 * @return The renderer owner
256 ObjectOwnerContainer< Renderer >& GetRendererOwner();
259 * @brief Get the property buffer owner
261 * @return The property buffer owner
263 ObjectOwnerContainer< PropertyBuffer >& GetPropertyBufferOwner();
269 * Add a newly created shader.
270 * @param[in] shader The shader to add.
271 * @post The shader is owned by the UpdateManager.
273 void AddShader(Shader* shader);
277 * @pre The shader has been added to the UpdateManager.
278 * @param[in] shader The shader to remove.
279 * @post The shader is destroyed.
281 void RemoveShader(Shader* shader);
284 * Add a newly created TextureSet.
285 * @param[in] textureSet The texture set to add.
286 * @post The TextureSet is owned by the UpdateManager.
288 void AddTextureSet(TextureSet* textureSet);
291 * Remove a TextureSet.
292 * @pre The TextureSet has been added to the UpdateManager.
293 * @param[in] textureSet The TextureSet to remove.
294 * @post The TextureSet is destroyed.
296 void RemoveTextureSet(TextureSet* textureSet);
299 * Set the shader program 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 * @param[in] modifiesGeometry True if the vertex shader modifies geometry
304 void SetShaderProgram( Shader* shader, Internal::ShaderDataPtr shaderData, bool modifiesGeometry );
307 * @brief Accept compiled shaders passed back on render thread for saving.
308 * @param[in] shaderData Source code, hash over source, and corresponding compiled binary to be saved.
310 virtual void SaveBinary( Internal::ShaderDataPtr shaderData );
313 * @brief Set the destination for compiled shader binaries to be passed on to.
314 * The dispatcher passed in will be called from the update thread.
315 * @param[in] upstream A sink for ShaderDatas to be passed into.
317 void SetShaderSaver( ShaderSaver& upstream );
322 * Add a newly created gesture.
323 * @param[in] gesture The gesture to add.
324 * @post The gesture is owned by the UpdateManager.
326 void AddGesture( PanGesture* gesture );
330 * @pre The gesture has been added to the UpdateManager.
331 * @param[in] gesture The gesture to remove.
332 * @post The gesture is destroyed.
334 void RemoveGesture( PanGesture* gesture );
336 // Message queue handling
339 * Reserve space for another message in the queue; this must then be initialized by the caller.
340 * The message will be read from the update-thread after the next FlushMessages is called.
341 * @post Calling this method may invalidate any previously returned slots.
342 * @param[in] size The message size with respect to the size of type "char".
343 * @param[in] updateScene A flag, when true denotes that the message will cause the scene-graph node tree to require an update.
344 * @note the default value of updateScene should match that in EventThreadServices::ReserveMessageSlot.
345 * @return A pointer to the first char allocated for the message.
347 unsigned int* ReserveMessageSlot( std::size_t size, bool updateScene = true );
350 * @return the current event-buffer index.
352 BufferIndex GetEventBufferIndex() const
354 // inlined as its called often from event thread
355 return mSceneGraphBuffers.GetEventBufferIndex();
359 * Called by the event-thread to signal that FlushQueue will be called
360 * e.g. when it has finished event processing.
362 void EventProcessingStarted();
365 * Flush the set of messages, which were previously stored with QueueMessage().
366 * Calls to this thread-safe method should be minimized, to avoid thread blocking.
368 * @return True if there are messages to process.
373 * Add a new sampler to RenderManager
374 * @param[in] sampler The sampler to add
375 * @post Sends a message to RenderManager to add the sampler.
376 * The sampler will be owned by RenderManager
378 void AddSampler( Render::Sampler* sampler );
381 * Removes an existing sampler from RenderManager
382 * @param[in] sampler The sampler to remove
383 * @post The sampler will be destroyed in the render thread
385 void RemoveSampler( Render::Sampler* sampler );
388 * Sets the filter modes for an existing sampler
389 * @param[in] sampler The sampler
390 * @param[in] minFilterMode The filter to use under minification
391 * @param[in] magFilterMode The filter to use under magnification
393 void SetFilterMode( Render::Sampler* sampler, unsigned int minFilterMode, unsigned int magFilterMode );
396 * Sets the wrap mode for an existing sampler
397 * @param[in] sampler The sampler
398 * @param[in] rWrapMode Wrapping mode in z direction
399 * @param[in] sWrapMode Wrapping mode in x direction
400 * @param[in] tWrapMode Wrapping mode in y direction
402 void SetWrapMode( Render::Sampler* sampler, unsigned int rWrapMode, unsigned int sWrapMode, unsigned int tWrapMode );
405 * Add a new property buffer to RenderManager
406 * @param[in] propertryBuffer The property buffer to add
407 * @post Sends a message to RenderManager to add the property buffer.
408 * The property buffer will be owned by RenderManager
410 void AddPropertyBuffer( Render::PropertyBuffer* propertryBuffer );
413 * Removes an existing PropertyBuffer from RenderManager
414 * @param[in] propertryBuffer The property buffer to remove
415 * @post The property buffer will be destroyed in the render thread
417 void RemovePropertyBuffer( Render::PropertyBuffer* propertryBuffer );
420 * Sets the format of an existing property buffer
421 * @param[in] propertyBuffer The property buffer.
422 * @param[in] format The new format of the buffer
423 * @post Sends a message to RenderManager to set the new format to the property buffer.
425 void SetPropertyBufferFormat(Render::PropertyBuffer* propertyBuffer, Render::PropertyBuffer::Format* format );
428 * Sets the data of an existing property buffer
429 * @param[in] propertyBuffer The property buffer.
430 * @param[in] data The new data of the buffer
431 * @param[in] size The new size of the buffer
432 * @post Sends a message to RenderManager to set the new data to the property buffer.
434 void SetPropertyBufferData(Render::PropertyBuffer* propertyBuffer, Dali::Vector<char>* data, size_t size);
437 * Adds a geometry to the RenderManager
438 * @param[in] geometry The geometry to add
439 * @post Sends a message to RenderManager to add the Geometry
440 * The geometry will be owned by RenderManager
442 void AddGeometry( Render::Geometry* geometry );
445 * Removes an existing Geometry from RenderManager
446 * @param[in] geometry The geometry to remove
447 * @post The geometry will be destroyed in the render thread
449 void RemoveGeometry( Render::Geometry* geometry );
452 * Sets the geometry type of an existing Geometry
453 * @param[in] geometry The geometry
454 * @param[in] geometryType The type of the geometry
456 void SetGeometryType( Render::Geometry* geometry, unsigned int geometryType );
459 * Sets the index buffer to be used by a geometry
460 * @param[in] geometry The geometry
461 * @param[in] indices A vector containing the indices for the geometry
463 void SetIndexBuffer( Render::Geometry* geometry, Dali::Vector<unsigned short>& indices );
466 * Adds a vertex buffer to a geomtry
467 * @param[in] geometry The geometry
468 * @param[in] propertyBuffer The property buffer
470 void AddVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer );
473 * Removes a vertex buffer from a geometry
474 * @param[in] geometry The geometry
475 * @param[in] propertyBuffer The property buffer
477 void RemoveVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer );
480 * Adds a texture to the render manager
481 * @param[in] texture The texture to add
482 * The texture will be owned by RenderManager
484 void AddTexture( Render::NewTexture* texture );
487 * Removes a texture from the render manager
488 * @param[in] texture The texture to remove
489 * @post The texture will be destroyed in the render thread
491 void RemoveTexture( Render::NewTexture* texture );
494 * Uploads data to a texture owned by the RenderManager
495 * @param[in] texture The texture
496 * @param[in] pixelData The pixel data object
497 * @param[in] params The parameters for the upload
499 void UploadTexture( Render::NewTexture* texture, PixelDataPtr pixelData, const NewTexture::UploadParams& params );
502 * Generates mipmaps for a texture owned by the RenderManager
503 * @param[in] texture The texture
505 void GenerateMipmaps( Render::NewTexture* texture );
508 * Adds a framebuffer to the render manager
509 * @param[in] frameBuffer The framebuffer to add
510 * The framebuffer will be owned by RenderManager
512 void AddFrameBuffer( Render::FrameBuffer* frameBuffer );
515 * Removes a FrameBuffer from the render manager
516 * @param[in] frameBuffer The FrameBuffer to remove
517 * @post The FrameBuffer will be destroyed in the render thread
519 void RemoveFrameBuffer( Render::FrameBuffer* frameBuffer );
522 * Attach a texture as color output to an existing FrameBuffer
523 * @param[in] frameBuffer The FrameBuffer
524 * @param[in] texture The texture that will be used as output when rendering
525 * @param[in] mipmapLevel The mipmap of the texture to be attached
526 * @param[in] layer Indicates which layer of a cube map or array texture to attach. Unused for 2D textures
528 void AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::NewTexture* texture, unsigned int mipmapLevel, unsigned int face );
533 * Performs an Update traversal on the scene-graph.
534 * @param[in] elapsedSeconds The elapsed time that should be applied to animations.
535 * @param[in] lastVSyncTimeMilliseconds The last time, in milliseconds, that we had a VSync.
536 * @param[in] nextVSyncTimeMilliseconds The estimated time, in milliseconds, of the next VSync.
537 * @return True if further updates are required e.g. during animations.
539 unsigned int Update( float elapsedSeconds, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds );
542 * Set the background color i.e. the glClear color used at the beginning of each frame.
543 * @param[in] color The new background color.
545 void SetBackgroundColor(const Vector4& color);
548 * Set the default surface rect.
549 * @param[in] rect The rect value representing the surface.
551 void SetDefaultSurfaceRect( const Rect<int>& rect );
554 * @copydoc Dali::Stage::KeepRendering()
556 void KeepRendering( float durationSeconds );
559 * Sets the depths of all layers.
560 * @param layers The layers in depth order.
561 * @param[in] systemLevel True if using the system-level overlay.
563 void SetLayerDepths( const std::vector< Layer* >& layers, bool systemLevel );
568 UpdateManager(const UpdateManager&);
571 UpdateManager& operator=(const UpdateManager& rhs);
574 * Helper to check whether the update-thread should keep going.
575 * @param[in] elapsedSeconds The time in seconds since the previous update.
576 * @return True if the update-thread should keep going.
578 unsigned int KeepUpdatingCheck( float elapsedSeconds ) const;
581 * Post process resources that have been updated by renderer
583 void PostProcessResources();
586 * Helper to reset all Node properties
587 * @param[in] bufferIndex to use
589 void ResetProperties( BufferIndex bufferIndex );
592 * Perform gesture updates.
593 * @param[in] bufferIndex to use
594 * @param[in] lastVSyncTime The last VSync time in milliseconds.
595 * @param[in] nextVSyncTime The estimated time of the next VSync in milliseconds.
596 * @return true, if any properties were updated.
598 bool ProcessGestures( BufferIndex bufferIndex, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds );
601 * Perform animation updates
602 * @param[in] bufferIndex to use
603 * @param[in] elapsedSeconds time since last frame
605 void Animate( BufferIndex bufferIndex, float elapsedSeconds );
608 * Applies constraints to CustomObjects
609 * @param[in] bufferIndex to use
611 void ConstrainCustomObjects( BufferIndex bufferIndex );
614 * Applies constraints to RenderTasks
615 * @param[in] bufferIndex to use
617 void ConstrainRenderTasks( BufferIndex bufferIndex );
620 * Applies constraints to Shaders
621 * @param[in] bufferIndex to use
623 void ConstrainShaders( BufferIndex bufferIndex );
626 * Perform property notification updates
627 * @param[in] bufferIndex to use
629 void ProcessPropertyNotifications( BufferIndex bufferIndex );
632 * Prepare textures for rendering
634 void PrepareTextureSets( BufferIndex bufferIndex );
637 * Pass shader binaries queued here on to event thread.
639 void ForwardCompiledShadersToEventThread();
642 * Update node shaders, opacity, geometry etc.
643 * @param[in] bufferIndex to use
645 void UpdateNodes( BufferIndex bufferIndex );
649 * @param[in] bufferIndex to use
651 void UpdateRenderers( BufferIndex bufferIndex );
655 // needs to be direct member so that getter for event buffer can be inlined
656 SceneGraphBuffers mSceneGraphBuffers;
663 // Messages for UpdateManager
665 inline void InstallRootMessage( UpdateManager& manager, Layer& root, bool systemLevel )
667 typedef MessageValue2< UpdateManager, Layer*, bool > LocalType;
669 // Reserve some memory inside the message queue
670 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
672 // Construct message in the message queue memory; note that delete should not be called on the return value
673 new (slot) LocalType( &manager, &UpdateManager::InstallRoot, &root, systemLevel );
676 inline void AddNodeMessage( UpdateManager& manager, Node& node )
678 typedef MessageValue1< UpdateManager, OwnerPointer<Node> > LocalType;
680 // Reserve some memory inside the message queue
681 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
683 // Construct message in the message queue memory; note that delete should not be called on the return value
684 new (slot) LocalType( &manager, &UpdateManager::AddNode, &node );
687 inline void ConnectNodeMessage( UpdateManager& manager, const Node& constParent, const Node& constChild )
689 // Update thread can edit the object
690 Node& parent = const_cast< Node& >( constParent );
691 Node& child = const_cast< Node& >( constChild );
693 typedef MessageValue2< UpdateManager, Node*, Node* > LocalType;
695 // Reserve some memory inside the message queue
696 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
698 // Construct message in the message queue memory; note that delete should not be called on the return value
699 new (slot) LocalType( &manager, &UpdateManager::ConnectNode, &parent, &child );
702 inline void DisconnectNodeMessage( UpdateManager& manager, const Node& constNode )
704 // Scene graph thread can modify this object.
705 Node& node = const_cast< Node& >( constNode );
707 typedef MessageValue1< UpdateManager, Node* > LocalType;
709 // Reserve some memory inside the message queue
710 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
712 // Construct message in the message queue memory; note that delete should not be called on the return value
713 new (slot) LocalType( &manager, &UpdateManager::DisconnectNode, &node );
716 inline void DestroyNodeMessage( UpdateManager& manager, const Node& constNode )
718 // Scene graph thread can destroy this object.
719 Node& node = const_cast< Node& >( constNode );
721 typedef MessageValue1< UpdateManager, Node* > LocalType;
723 // Reserve some memory inside the message queue
724 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
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::DestroyNode, &node );
730 inline void AddCameraMessage( UpdateManager& manager, const Camera* constCamera )
732 typedef MessageValue1< UpdateManager, Camera* > LocalType;
734 Camera* camera = const_cast<Camera*>( constCamera );
735 // Reserve some memory inside the message queue
736 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
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::AddCamera, camera );
742 inline void RemoveCameraMessage( UpdateManager& manager, const Camera* camera )
744 typedef MessageValue1< UpdateManager, const Camera* > LocalType;
746 // Reserve some memory inside the message queue
747 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
749 // Construct message in the message queue memory; note that delete should not be called on the return value
750 new (slot) LocalType( &manager, &UpdateManager::RemoveCamera, camera );
753 inline void AddObjectMessage( UpdateManager& manager, PropertyOwner* object )
755 typedef MessageValue1< UpdateManager, OwnerPointer<PropertyOwner> > LocalType;
757 // Reserve some memory inside the message queue
758 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
760 // Construct message in the message queue memory; note that delete should not be called on the return value
761 new (slot) LocalType( &manager, &UpdateManager::AddObject, object );
764 inline void RemoveObjectMessage( UpdateManager& manager, PropertyOwner* object )
766 typedef MessageValue1< UpdateManager, PropertyOwner* > LocalType;
768 // Reserve some memory inside the message queue
769 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
771 // Construct message in the message queue memory; note that delete should not be called on the return value
772 new (slot) LocalType( &manager, &UpdateManager::RemoveObject, object );
775 inline void AddAnimationMessage( UpdateManager& manager, Animation* animation )
777 typedef MessageValue1< UpdateManager, Animation* > LocalType;
779 // Reserve some memory inside the message queue
780 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
782 // Construct message in the message queue memory; note that delete should not be called on the return value
783 new (slot) LocalType( &manager, &UpdateManager::AddAnimation, animation );
786 inline void StopAnimationMessage( UpdateManager& manager, const Animation& constAnimation )
788 // The scene-graph thread owns this object so it can safely edit it.
789 Animation& animation = const_cast< Animation& >( constAnimation );
791 typedef MessageValue1< UpdateManager, Animation* > LocalType;
793 // Reserve some memory inside the message queue
794 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
796 // Construct message in the message queue memory; note that delete should not be called on the return value
797 new (slot) LocalType( &manager, &UpdateManager::StopAnimation, &animation );
800 inline void RemoveAnimationMessage( UpdateManager& manager, const Animation& constAnimation )
802 // The scene-graph thread owns this object so it can safely edit it.
803 Animation& animation = const_cast< Animation& >( constAnimation );
805 typedef MessageValue1< UpdateManager, Animation* > LocalType;
807 // Reserve some memory inside the message queue
808 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
810 // Construct message in the message queue memory; note that delete should not be called on the return value
811 new (slot) LocalType( &manager, &UpdateManager::RemoveAnimation, &animation );
814 inline void AddPropertyNotificationMessage( UpdateManager& manager, PropertyNotification* propertyNotification )
816 typedef MessageValue1< UpdateManager, PropertyNotification* > LocalType;
818 // Reserve some memory inside the message queue
819 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
821 // Construct message in the message queue memory; note that delete should not be called on the return value
822 new (slot) LocalType( &manager, &UpdateManager::AddPropertyNotification, propertyNotification );
825 inline void RemovePropertyNotificationMessage( UpdateManager& manager, const PropertyNotification& constPropertyNotification )
827 // The scene-graph thread owns this object so it can safely edit it.
828 PropertyNotification& propertyNotification = const_cast< PropertyNotification& >( constPropertyNotification );
830 typedef MessageValue1< UpdateManager, PropertyNotification* > LocalType;
832 // Reserve some memory inside the message queue
833 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
835 // Construct message in the message queue memory; note that delete should not be called on the return value
836 new (slot) LocalType( &manager, &UpdateManager::RemovePropertyNotification, &propertyNotification );
839 inline void PropertyNotificationSetNotifyModeMessage( UpdateManager& manager,
840 const PropertyNotification* constPropertyNotification,
841 PropertyNotification::NotifyMode notifyMode )
843 // The scene-graph thread owns this object so it can safely edit it.
844 PropertyNotification* propertyNotification = const_cast< PropertyNotification* >( constPropertyNotification );
846 typedef MessageValue2< UpdateManager, PropertyNotification*, PropertyNotification::NotifyMode > LocalType;
848 // Reserve some memory inside the message queue
849 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
851 // Construct message in the message queue memory; note that delete should not be called on the return value
852 new (slot) LocalType( &manager, &UpdateManager::PropertyNotificationSetNotify, propertyNotification, notifyMode );
855 // The render thread can safely change the Shader
856 inline void AddShaderMessage( UpdateManager& manager, Shader& shader )
858 typedef MessageValue1< UpdateManager, OwnerPointer< Shader > > LocalType;
860 // Reserve some memory inside the message queue
861 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
863 // Construct message in the message queue memory; note that delete should not be called on the return value
864 new (slot) LocalType( &manager, &UpdateManager::AddShader, &shader );
867 // The render thread can safely change the Shader
868 inline void RemoveShaderMessage( UpdateManager& manager, Shader& shader )
870 typedef MessageValue1< UpdateManager, Shader* > LocalType;
872 // Reserve some memory inside the message queue
873 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
875 // Construct message in the message queue memory; note that delete should not be called on the return value
876 new (slot) LocalType( &manager, &UpdateManager::RemoveShader, &shader );
879 inline void SetShaderProgramMessage( UpdateManager& manager,
881 Internal::ShaderDataPtr shaderData,
882 bool modifiesGeometry )
884 typedef MessageValue3< UpdateManager, Shader*, Internal::ShaderDataPtr, bool > LocalType;
886 // Reserve some memory inside the message queue
887 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
889 // Construct message in the message queue memory; note that delete should not be called on the return value
890 new (slot) LocalType( &manager, &UpdateManager::SetShaderProgram, &shader, shaderData, modifiesGeometry );
893 inline void SetBackgroundColorMessage( UpdateManager& manager, const Vector4& color )
895 typedef MessageValue1< UpdateManager, Vector4 > LocalType;
897 // Reserve some memory inside the message queue
898 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
900 // Construct message in the message queue memory; note that delete should not be called on the return value
901 new (slot) LocalType( &manager, &UpdateManager::SetBackgroundColor, color );
904 inline void SetDefaultSurfaceRectMessage( UpdateManager& manager, const Rect<int>& rect )
906 typedef MessageValue1< UpdateManager, Rect<int> > LocalType;
908 // Reserve some memory inside the message queue
909 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
911 // Construct message in the message queue memory; note that delete should not be called on the return value
912 new (slot) LocalType( &manager, &UpdateManager::SetDefaultSurfaceRect, rect );
915 inline void KeepRenderingMessage( UpdateManager& manager, float durationSeconds )
917 typedef MessageValue1< UpdateManager, float > LocalType;
919 // Reserve some memory inside the message queue
920 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
922 // Construct message in the message queue memory; note that delete should not be called on the return value
923 new (slot) LocalType( &manager, &UpdateManager::KeepRendering, durationSeconds );
927 * Create a message for setting the depth of a layer
928 * @param[in] manager The update manager
929 * @param[in] layers list of layers
930 * @param[in] systemLevel True if the layers are added via the SystemOverlay API
932 inline void SetLayerDepthsMessage( UpdateManager& manager, const std::vector< Layer* >& layers, bool systemLevel )
934 typedef MessageValue2< UpdateManager, std::vector< Layer* >, bool > LocalType;
936 // Reserve some memory inside the message queue
937 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
939 // Construct message in the message queue memory; note that delete should not be called on the return value
940 new (slot) LocalType( &manager, &UpdateManager::SetLayerDepths, layers, systemLevel );
943 inline void AddGestureMessage( UpdateManager& manager, PanGesture* gesture )
945 typedef MessageValue1< UpdateManager, PanGesture* > LocalType;
947 // Reserve some memory inside the message queue
948 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
950 // Construct message in the message queue memory; note that delete should not be called on the return value
951 new (slot) LocalType( &manager, &UpdateManager::AddGesture, gesture );
954 inline void RemoveGestureMessage( UpdateManager& manager, PanGesture* gesture )
956 typedef MessageValue1< UpdateManager, PanGesture* > LocalType;
958 // Reserve some memory inside the message queue
959 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
961 // Construct message in the message queue memory; note that delete should not be called on the return value
962 new (slot) LocalType( &manager, &UpdateManager::RemoveGesture, gesture );
965 template< typename T >
966 inline void AddMessage( UpdateManager& manager, ObjectOwnerContainer<T>& owner, T& object )
968 typedef MessageValue1< ObjectOwnerContainer<T>, OwnerPointer< T > > LocalType;
970 // Reserve some memory inside the message queue
971 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
972 // Construct message in the message queue memory; note that delete should not be called on the return value
973 new (slot) LocalType( &owner, &ObjectOwnerContainer<T>::Add, &object );
976 template< typename T >
977 inline void RemoveMessage( UpdateManager& manager, ObjectOwnerContainer<T>& owner, T& object )
979 typedef MessageValue1< ObjectOwnerContainer<T>, T* > LocalType;
981 // Reserve some memory inside the message queue
982 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
983 // Construct message in the message queue memory; note that delete should not be called on the return value
984 new (slot) LocalType( &owner, &ObjectOwnerContainer<T>::Remove, &object );
987 // The render thread can safely change the Shader
988 inline void AddTextureSetMessage( UpdateManager& manager, TextureSet& textureSet )
990 typedef MessageValue1< UpdateManager, OwnerPointer< TextureSet > > LocalType;
992 // Reserve some memory inside the message queue
993 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
995 // Construct message in the message queue memory; note that delete should not be called on the return value
996 new (slot) LocalType( &manager, &UpdateManager::AddTextureSet, &textureSet );
999 // The render thread can safely change the Shader
1000 inline void RemoveTextureSetMessage( UpdateManager& manager, TextureSet& textureSet )
1002 typedef MessageValue1< UpdateManager, TextureSet* > LocalType;
1004 // Reserve some memory inside the message queue
1005 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
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::RemoveTextureSet, &textureSet );
1011 inline void AddSamplerMessage( UpdateManager& manager, Render::Sampler& sampler )
1013 typedef MessageValue1< UpdateManager, Render::Sampler* > LocalType;
1015 // Reserve some memory inside the message queue
1016 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1018 // Construct message in the message queue memory; note that delete should not be called on the return value
1019 new (slot) LocalType( &manager, &UpdateManager::AddSampler, &sampler );
1022 inline void RemoveSamplerMessage( UpdateManager& manager, Render::Sampler& sampler )
1024 typedef MessageValue1< UpdateManager, Render::Sampler* > LocalType;
1026 // Reserve some memory inside the message queue
1027 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1029 // Construct message in the message queue memory; note that delete should not be called on the return value
1030 new (slot) LocalType( &manager, &UpdateManager::RemoveSampler, &sampler );
1033 inline void SetFilterModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int minFilterMode, unsigned int magFilterMode )
1035 typedef MessageValue3< UpdateManager, Render::Sampler*, unsigned int, unsigned int > LocalType;
1037 // Reserve some memory inside the message queue
1038 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1040 // Construct message in the message queue memory; note that delete should not be called on the return value
1041 new (slot) LocalType( &manager, &UpdateManager::SetFilterMode, &sampler, minFilterMode, magFilterMode );
1044 inline void SetWrapModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int rWrapMode, unsigned int sWrapMode, unsigned int tWrapMode )
1046 typedef MessageValue4< UpdateManager, Render::Sampler*, unsigned int, unsigned int, unsigned int > LocalType;
1048 // Reserve some memory inside the message queue
1049 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
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::SetWrapMode, &sampler, rWrapMode, sWrapMode, tWrapMode );
1055 inline void AddPropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer )
1057 typedef MessageValue1< UpdateManager, Render::PropertyBuffer* > LocalType;
1059 // Reserve some memory inside the message queue
1060 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1062 // Construct message in the message queue memory; note that delete should not be called on the return value
1063 new (slot) LocalType( &manager, &UpdateManager::AddPropertyBuffer, &propertyBuffer );
1066 inline void RemovePropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer )
1068 typedef MessageValue1< UpdateManager, Render::PropertyBuffer* > LocalType;
1070 // Reserve some memory inside the message queue
1071 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1073 // Construct message in the message queue memory; note that delete should not be called on the return value
1074 new (slot) LocalType( &manager, &UpdateManager::RemovePropertyBuffer, &propertyBuffer );
1077 inline void SetPropertyBufferFormat( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, Render::PropertyBuffer::Format* format )
1079 typedef MessageValue2< UpdateManager, Render::PropertyBuffer*, Render::PropertyBuffer::Format* > LocalType;
1081 // Reserve some memory inside the message queue
1082 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1084 // Construct message in the message queue memory; note that delete should not be called on the return value
1085 new (slot) LocalType( &manager, &UpdateManager::SetPropertyBufferFormat, &propertyBuffer, format );
1088 inline void SetPropertyBufferData( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, Vector<char>* data, size_t size )
1090 typedef MessageValue3< UpdateManager, Render::PropertyBuffer*, Vector<char>*, size_t > LocalType;
1092 // Reserve some memory inside the message queue
1093 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1095 // Construct message in the message queue memory; note that delete should not be called on the return value
1096 new (slot) LocalType( &manager, &UpdateManager::SetPropertyBufferData, &propertyBuffer, data, size );
1099 inline void AddGeometry( UpdateManager& manager, Render::Geometry& geometry )
1101 typedef MessageValue1< UpdateManager, Render::Geometry* > LocalType;
1103 // Reserve some memory inside the message queue
1104 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1106 // Construct message in the message queue memory; note that delete should not be called on the return value
1107 new (slot) LocalType( &manager, &UpdateManager::AddGeometry, &geometry );
1110 inline void RemoveGeometry( UpdateManager& manager, Render::Geometry& geometry )
1112 typedef MessageValue1< UpdateManager, Render::Geometry* > LocalType;
1114 // Reserve some memory inside the message queue
1115 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1117 // Construct message in the message queue memory; note that delete should not be called on the return value
1118 new (slot) LocalType( &manager, &UpdateManager::RemoveGeometry, &geometry );
1121 inline void AddVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer )
1123 typedef MessageValue2< UpdateManager, Render::Geometry*, Render::PropertyBuffer* > LocalType;
1125 // Reserve some memory inside the message queue
1126 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1128 // Construct message in the message queue memory; note that delete should not be called on the return value
1129 new (slot) LocalType( &manager, &UpdateManager::AddVertexBuffer, &geometry, const_cast<Render::PropertyBuffer*>(&vertexBuffer) );
1132 inline void RemoveVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer )
1134 typedef MessageValue2< UpdateManager, Render::Geometry*, Render::PropertyBuffer* > LocalType;
1136 // Reserve some memory inside the message queue
1137 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1139 // Construct message in the message queue memory; note that delete should not be called on the return value
1140 new (slot) LocalType( &manager, &UpdateManager::RemoveVertexBuffer, &geometry, const_cast<Render::PropertyBuffer*>(&vertexBuffer) );
1143 // Custom message type for SetIndexBuffer() used to move data with Vector::Swap()
1144 template< typename T >
1145 class IndexBufferMessage : public MessageBase
1150 * Constructor which does a Vector::Swap()
1152 IndexBufferMessage( T* manager, Render::Geometry* geometry, Dali::Vector<unsigned short>& indices )
1154 mManager( manager ),
1155 mRenderGeometry( geometry )
1157 mIndices.Swap( indices );
1161 * Virtual destructor
1163 virtual ~IndexBufferMessage()
1168 * @copydoc MessageBase::Process
1170 virtual void Process( BufferIndex /*bufferIndex*/ )
1172 DALI_ASSERT_DEBUG( mManager && "Message does not have an object" );
1173 mManager->SetIndexBuffer( mRenderGeometry, mIndices );
1179 Render::Geometry* mRenderGeometry;
1180 Dali::Vector<unsigned short> mIndices;
1183 inline void SetIndexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, Dali::Vector<unsigned short>& indices )
1185 typedef IndexBufferMessage< UpdateManager > LocalType;
1187 // Reserve some memory inside the message queue
1188 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1190 // Construct message in the message queue memory; note that delete should not be called on the return value
1191 new (slot) LocalType( &manager, &geometry, indices );
1194 inline void SetGeometryTypeMessage( UpdateManager& manager, Render::Geometry& geometry, unsigned int geometryType )
1196 typedef MessageValue2< UpdateManager, Render::Geometry*, unsigned int > LocalType;
1198 // Reserve some memory inside the message queue
1199 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1201 // Construct message in the message queue memory; note that delete should not be called on the return value
1202 new (slot) LocalType( &manager, &UpdateManager::SetGeometryType, &geometry, geometryType );
1205 inline void AddTexture( UpdateManager& manager, Render::NewTexture& texture )
1207 typedef MessageValue1< UpdateManager, Render::NewTexture* > LocalType;
1209 // Reserve some memory inside the message queue
1210 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1212 // Construct message in the message queue memory; note that delete should not be called on the return value
1213 new (slot) LocalType( &manager, &UpdateManager::AddTexture, &texture );
1216 inline void RemoveTexture( UpdateManager& manager, Render::NewTexture& texture )
1218 typedef MessageValue1< UpdateManager, Render::NewTexture* > LocalType;
1220 // Reserve some memory inside the message queue
1221 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1223 // Construct message in the message queue memory; note that delete should not be called on the return value
1224 new (slot) LocalType( &manager, &UpdateManager::RemoveTexture, &texture );
1227 inline void UploadTextureMessage( UpdateManager& manager, Render::NewTexture& texture, PixelDataPtr pixelData, const NewTexture::UploadParams& params )
1229 typedef MessageValue3< UpdateManager, Render::NewTexture*, PixelDataPtr, NewTexture::UploadParams > LocalType;
1231 // Reserve some memory inside the message queue
1232 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1234 // Construct message in the message queue memory; note that delete should not be called on the return value
1235 new (slot) LocalType( &manager, &UpdateManager::UploadTexture, &texture, pixelData, params );
1238 inline void GenerateMipmapsMessage( UpdateManager& manager, Render::NewTexture& texture )
1240 typedef MessageValue1< UpdateManager, Render::NewTexture* > LocalType;
1242 // Reserve some memory inside the message queue
1243 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
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::GenerateMipmaps, &texture );
1250 inline void AddFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer )
1252 typedef MessageValue1< UpdateManager, Render::FrameBuffer* > LocalType;
1254 // Reserve some memory inside the message queue
1255 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
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::AddFrameBuffer, &frameBuffer );
1261 inline void RemoveFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer )
1263 typedef MessageValue1< UpdateManager, Render::FrameBuffer* > LocalType;
1265 // Reserve some memory inside the message queue
1266 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1268 // Construct message in the message queue memory; note that delete should not be called on the return value
1269 new (slot) LocalType( &manager, &UpdateManager::RemoveFrameBuffer, &frameBuffer );
1272 inline void AttachColorTextureToFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer, Render::NewTexture* texture, unsigned int mipmapLevel, unsigned int layer )
1274 typedef MessageValue4< UpdateManager, Render::FrameBuffer*, Render::NewTexture*, unsigned int, unsigned int > LocalType;
1276 // Reserve some memory inside the message queue
1277 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1279 // Construct message in the message queue memory; note that delete should not be called on the return value
1280 new (slot) LocalType( &manager, &UpdateManager::AttachColorTextureToFrameBuffer, &frameBuffer, texture, mipmapLevel, layer );
1283 } // namespace SceneGraph
1285 } // namespace Internal
1289 #endif // __DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H__