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 > {};
78 class RenderTaskProcessor;
80 class TextureCacheDispatcher;
86 * UpdateManager maintains a scene graph i.e. a tree of nodes as well as
87 * other scene graph property owning objects.
88 * It controls the Update traversal, in which nodes are repositioned/animated,
89 * and organizes the the culling and rendering of the scene.
90 * It also maintains the lifecycle of nodes and other property owners that are
91 * disconnected from the scene graph.
93 class UpdateManager : public ShaderSaver
98 * Construct a new UpdateManager.
99 * @param[in] notificationManager This should be notified when animations have finished.
100 * @param[in] animationFinishedNotifier The CompleteNotificationInterface that handles animation completions
101 * @param[in] propertyNotifier The PropertyNotifier
102 * @param[in] resourceManager The resource manager used to load textures etc.
103 * @param[in] discardQueue Nodes are added here when disconnected from the scene-graph.
104 * @param[in] controller After messages are flushed, we request a render from the RenderController.
105 * @param[in] renderManager This is responsible for rendering the results of each "update".
106 * @param[in] renderQueue Used to queue messages for the next render.
107 * @param[in] textureCacheDispatcher Used for sending messages to texture cache.
108 * @param[in] geometryBatcher Used when geometry batching is enabled.
109 * @param[in] renderTaskProcessor Handles RenderTasks and RenderInstrucitons.
111 UpdateManager( NotificationManager& notificationManager,
112 CompleteNotificationInterface& animationFinishedNotifier,
113 PropertyNotifier& propertyNotifier,
114 ResourceManager& resourceManager,
115 DiscardQueue& discardQueue,
116 Integration::RenderController& controller,
117 RenderManager& renderManager,
118 RenderQueue& renderQueue,
119 TextureCacheDispatcher& textureCacheDispatcher,
120 GeometryBatcher& geometryBatcher,
121 RenderTaskProcessor& renderTaskProcessor );
126 virtual ~UpdateManager();
128 // Node connection methods
131 * Get the scene graph side list of RenderTasks.
132 * @param[in] systemLevel True if using the system-level overlay.
133 * @return The list of render tasks
135 RenderTaskList* GetRenderTaskList( bool systemLevel );
138 * Installs a new layer as the root node.
139 * @pre The UpdateManager does not already have an installed root node.
140 * @pre The layer is of derived Node type Layer.
141 * @pre The layer does not have a parent.
142 * @param[in] layer The new root node.
143 * @param[in] systemLevel True if using the system-level overlay.
144 * @post The node is owned by UpdateManager.
146 void InstallRoot( Layer* layer, bool systemLevel );
149 * Add a Node; UpdateManager takes ownership.
150 * @pre The node does not have a parent.
151 * @param[in] node The node to add.
153 void AddNode( Node* node );
156 * Connect a Node to the scene-graph.
157 * A disconnected Node has has no parent or children, and its properties cannot be animated/constrained.
158 * @pre The node does not already have a parent.
159 * @param[in] parent The new parent node.
161 void ConnectNode( Node* parent, Node* node );
164 * Disconnect a Node from the scene-graph.
165 * A disconnected Node has has no parent or children, and its properties cannot be animated/constrained.
166 * @pre The node has a parent.
167 * @param[in] node The node to disconnect.
169 void DisconnectNode( Node* node );
172 * Destroy a Node owned by UpdateManager.
173 * This is not immediate; Nodes are passed to the RenderQueue to allow GL resources to be deleted.
174 * In the following update, the previously queued Nodes may be deleted.
175 * @pre The node has been disconnected from the scene-graph i.e. has no parent or children.
176 * @param[in] node The node to destroy.
178 void DestroyNode( Node* node );
181 * Add a camera on scene
182 * @param[in] camera to add
184 void AddCamera( Camera* camera );
187 * Remove a camera from scene
188 * @param[in] camera to remove
190 void RemoveCamera( const Camera* camera );
193 * Add a newly created object.
194 * @param[in] object The object to add.
195 * @post The object is owned by UpdateManager.
197 void AddObject( PropertyOwner* object );
201 * @param[in] object The object to remove.
203 void RemoveObject( PropertyOwner* object );
208 * Add a newly created animation.
209 * @param[in] animation The animation to add.
210 * @post The animation is owned by UpdateManager.
212 void AddAnimation( Animation* animation );
216 * @param[in] animation The animation to stop.
218 void StopAnimation( Animation* animation );
221 * Remove an animation.
222 * @param[in] animation The animation to remove.
224 void RemoveAnimation( Animation* animation );
227 * Query whether any animations are currently running.
228 * @return True if any animations are running.
230 bool IsAnimationRunning() const;
232 // Property Notification
235 * Add a newly created property notification
236 * @param[in] propertyNotification The notification to add
237 * @post The propertyNotification is owned by UpdateManager.
239 void AddPropertyNotification( PropertyNotification* propertyNotification );
242 * Remove a property notification
243 * @param[in] propertyNotification The notification to remove
245 void RemovePropertyNotification( PropertyNotification* propertyNotification );
248 * Set Notify state for PropertyNotification
249 * @param[in] propertyNotification The notification to remove
250 * @param[in] notifyMode The notification mode.
252 void PropertyNotificationSetNotify( PropertyNotification* propertyNotification, PropertyNotification::NotifyMode notifyMode );
255 * @brief Get the renderer owner
257 * @return The renderer owner
259 ObjectOwnerContainer< Renderer >& GetRendererOwner();
262 * @brief Get the property buffer owner
264 * @return The property buffer owner
266 ObjectOwnerContainer< PropertyBuffer >& GetPropertyBufferOwner();
272 * Add a newly created shader.
273 * @param[in] shader The shader to add.
274 * @post The shader is owned by the UpdateManager.
276 void AddShader(Shader* shader);
280 * @pre The shader has been added to the UpdateManager.
281 * @param[in] shader The shader to remove.
282 * @post The shader is destroyed.
284 void RemoveShader(Shader* shader);
287 * Add a newly created TextureSet.
288 * @param[in] textureSet The texture set to add.
289 * @post The TextureSet is owned by the UpdateManager.
291 void AddTextureSet(TextureSet* textureSet);
294 * Remove a TextureSet.
295 * @pre The TextureSet has been added to the UpdateManager.
296 * @param[in] textureSet The TextureSet to remove.
297 * @post The TextureSet is destroyed.
299 void RemoveTextureSet(TextureSet* textureSet);
302 * Set the shader program for a Shader object
303 * @param[in] shader The shader to modify
304 * @param[in] shaderData Source code, hash over source, and optional compiled binary for the shader program
305 * @param[in] modifiesGeometry True if the vertex shader modifies geometry
307 void SetShaderProgram( Shader* shader, Internal::ShaderDataPtr shaderData, bool modifiesGeometry );
310 * @brief Accept compiled shaders passed back on render thread for saving.
311 * @param[in] shaderData Source code, hash over source, and corresponding compiled binary to be saved.
313 virtual void SaveBinary( Internal::ShaderDataPtr shaderData );
316 * @brief Set the destination for compiled shader binaries to be passed on to.
317 * The dispatcher passed in will be called from the update thread.
318 * @param[in] upstream A sink for ShaderDatas to be passed into.
320 void SetShaderSaver( ShaderSaver& upstream );
325 * Add a newly created gesture.
326 * @param[in] gesture The gesture to add.
327 * @post The gesture is owned by the UpdateManager.
329 void AddGesture( PanGesture* gesture );
333 * @pre The gesture has been added to the UpdateManager.
334 * @param[in] gesture The gesture to remove.
335 * @post The gesture is destroyed.
337 void RemoveGesture( PanGesture* gesture );
339 // Message queue handling
342 * Reserve space for another message in the queue; this must then be initialized by the caller.
343 * The message will be read from the update-thread after the next FlushMessages is called.
344 * @post Calling this method may invalidate any previously returned slots.
345 * @param[in] size The message size with respect to the size of type "char".
346 * @param[in] updateScene A flag, when true denotes that the message will cause the scene-graph node tree to require an update.
347 * @note the default value of updateScene should match that in EventThreadServices::ReserveMessageSlot.
348 * @return A pointer to the first char allocated for the message.
350 unsigned int* ReserveMessageSlot( std::size_t size, bool updateScene = true );
353 * @return the current event-buffer index.
355 BufferIndex GetEventBufferIndex() const
357 // inlined as its called often from event thread
358 return mSceneGraphBuffers.GetEventBufferIndex();
362 * Called by the event-thread to signal that FlushQueue will be called
363 * e.g. when it has finished event processing.
365 void EventProcessingStarted();
368 * Flush the set of messages, which were previously stored with QueueMessage().
369 * Calls to this thread-safe method should be minimized, to avoid thread blocking.
371 * @return True if there are messages to process.
376 * Add a new sampler to RenderManager
377 * @param[in] sampler The sampler to add
378 * @post Sends a message to RenderManager to add the sampler.
379 * The sampler will be owned by RenderManager
381 void AddSampler( Render::Sampler* sampler );
384 * Removes an existing sampler from RenderManager
385 * @param[in] sampler The sampler to remove
386 * @post The sampler will be destroyed in the render thread
388 void RemoveSampler( Render::Sampler* sampler );
391 * Sets the filter modes for an existing sampler
392 * @param[in] sampler The sampler
393 * @param[in] minFilterMode The filter to use under minification
394 * @param[in] magFilterMode The filter to use under magnification
396 void SetFilterMode( Render::Sampler* sampler, unsigned int minFilterMode, unsigned int magFilterMode );
399 * Sets the wrap mode for an existing sampler
400 * @param[in] sampler The sampler
401 * @param[in] rWrapMode Wrapping mode in z direction
402 * @param[in] sWrapMode Wrapping mode in x direction
403 * @param[in] tWrapMode Wrapping mode in y direction
405 void SetWrapMode( Render::Sampler* sampler, unsigned int rWrapMode, unsigned int sWrapMode, unsigned int tWrapMode );
408 * Add a new property buffer to RenderManager
409 * @param[in] propertryBuffer The property buffer to add
410 * @post Sends a message to RenderManager to add the property buffer.
411 * The property buffer will be owned by RenderManager
413 void AddPropertyBuffer( Render::PropertyBuffer* propertryBuffer );
416 * Removes an existing PropertyBuffer from RenderManager
417 * @param[in] propertryBuffer The property buffer to remove
418 * @post The property buffer will be destroyed in the render thread
420 void RemovePropertyBuffer( Render::PropertyBuffer* propertryBuffer );
423 * Sets the format of an existing property buffer
424 * @param[in] propertyBuffer The property buffer.
425 * @param[in] format The new format of the buffer
426 * @post Sends a message to RenderManager to set the new format to the property buffer.
428 void SetPropertyBufferFormat(Render::PropertyBuffer* propertyBuffer, Render::PropertyBuffer::Format* format );
431 * Sets the data of an existing property buffer
432 * @param[in] propertyBuffer The property buffer.
433 * @param[in] data The new data of the buffer
434 * @param[in] size The new size of the buffer
435 * @post Sends a message to RenderManager to set the new data to the property buffer.
437 void SetPropertyBufferData(Render::PropertyBuffer* propertyBuffer, Dali::Vector<char>* data, size_t size);
440 * Adds a geometry to the RenderManager
441 * @param[in] geometry The geometry to add
442 * @post Sends a message to RenderManager to add the Geometry
443 * The geometry will be owned by RenderManager
445 void AddGeometry( Render::Geometry* geometry );
448 * Removes an existing Geometry from RenderManager
449 * @param[in] geometry The geometry to remove
450 * @post The geometry will be destroyed in the render thread
452 void RemoveGeometry( Render::Geometry* geometry );
455 * Sets the geometry type of an existing Geometry
456 * @param[in] geometry The geometry
457 * @param[in] geometryType The type of the geometry
459 void SetGeometryType( Render::Geometry* geometry, unsigned int geometryType );
462 * Sets the index buffer to be used by a geometry
463 * @param[in] geometry The geometry
464 * @param[in] indices A vector containing the indices for the geometry
466 void SetIndexBuffer( Render::Geometry* geometry, Dali::Vector<unsigned short>& indices );
469 * Adds a vertex buffer to a geomtry
470 * @param[in] geometry The geometry
471 * @param[in] propertyBuffer The property buffer
473 void AddVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer );
476 * Removes a vertex buffer from a geometry
477 * @param[in] geometry The geometry
478 * @param[in] propertyBuffer The property buffer
480 void RemoveVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer );
483 * Adds a texture to the render manager
484 * @param[in] texture The texture to add
485 * The texture will be owned by RenderManager
487 void AddTexture( Render::NewTexture* texture );
490 * Removes a texture from the render manager
491 * @param[in] texture The texture to remove
492 * @post The texture will be destroyed in the render thread
494 void RemoveTexture( Render::NewTexture* texture );
497 * Uploads data to a texture owned by the RenderManager
498 * @param[in] texture The texture
499 * @param[in] pixelData The pixel data object
500 * @param[in] params The parameters for the upload
502 void UploadTexture( Render::NewTexture* texture, PixelDataPtr pixelData, const NewTexture::UploadParams& params );
505 * Generates mipmaps for a texture owned by the RenderManager
506 * @param[in] texture The texture
508 void GenerateMipmaps( Render::NewTexture* texture );
511 * Adds a framebuffer to the render manager
512 * @param[in] frameBuffer The framebuffer to add
513 * The framebuffer will be owned by RenderManager
515 void AddFrameBuffer( Render::FrameBuffer* frameBuffer );
518 * Removes a FrameBuffer from the render manager
519 * @param[in] frameBuffer The FrameBuffer to remove
520 * @post The FrameBuffer will be destroyed in the render thread
522 void RemoveFrameBuffer( Render::FrameBuffer* frameBuffer );
525 * Attach a texture as color output to an existing FrameBuffer
526 * @param[in] frameBuffer The FrameBuffer
527 * @param[in] texture The texture that will be used as output when rendering
528 * @param[in] mipmapLevel The mipmap of the texture to be attached
529 * @param[in] layer Indicates which layer of a cube map or array texture to attach. Unused for 2D textures
531 void AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::NewTexture* texture, unsigned int mipmapLevel, unsigned int face );
536 * Performs an Update traversal on the scene-graph.
537 * @param[in] elapsedSeconds The elapsed time that should be applied to animations.
538 * @param[in] lastVSyncTimeMilliseconds The last time, in milliseconds, that we had a VSync.
539 * @param[in] nextVSyncTimeMilliseconds The estimated time, in milliseconds, of the next VSync.
540 * @return True if further updates are required e.g. during animations.
542 unsigned int Update( float elapsedSeconds, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds );
545 * Set the background color i.e. the glClear color used at the beginning of each frame.
546 * @param[in] color The new background color.
548 void SetBackgroundColor(const Vector4& color);
551 * Set the default surface rect.
552 * @param[in] rect The rect value representing the surface.
554 void SetDefaultSurfaceRect( const Rect<int>& rect );
557 * @copydoc Dali::Stage::KeepRendering()
559 void KeepRendering( float durationSeconds );
562 * Sets the depths of all layers.
563 * @param layers The layers in depth order.
564 * @param[in] systemLevel True if using the system-level overlay.
566 void SetLayerDepths( const std::vector< Layer* >& layers, bool systemLevel );
571 UpdateManager(const UpdateManager&);
574 UpdateManager& operator=(const UpdateManager& rhs);
577 * Helper to check whether the update-thread should keep going.
578 * @param[in] elapsedSeconds The time in seconds since the previous update.
579 * @return True if the update-thread should keep going.
581 unsigned int KeepUpdatingCheck( float elapsedSeconds ) const;
584 * Post process resources that have been updated by renderer
586 void PostProcessResources();
589 * Helper to reset all Node properties
590 * @param[in] bufferIndex to use
592 void ResetProperties( BufferIndex bufferIndex );
595 * Perform gesture updates.
596 * @param[in] bufferIndex to use
597 * @param[in] lastVSyncTime The last VSync time in milliseconds.
598 * @param[in] nextVSyncTime The estimated time of the next VSync in milliseconds.
599 * @return true, if any properties were updated.
601 bool ProcessGestures( BufferIndex bufferIndex, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds );
604 * Perform animation updates
605 * @param[in] bufferIndex to use
606 * @param[in] elapsedSeconds time since last frame
608 void Animate( BufferIndex bufferIndex, float elapsedSeconds );
611 * Applies constraints to CustomObjects
612 * @param[in] bufferIndex to use
614 void ConstrainCustomObjects( BufferIndex bufferIndex );
617 * Applies constraints to RenderTasks
618 * @param[in] bufferIndex to use
620 void ConstrainRenderTasks( BufferIndex bufferIndex );
623 * Applies constraints to Shaders
624 * @param[in] bufferIndex to use
626 void ConstrainShaders( BufferIndex bufferIndex );
629 * Perform property notification updates
630 * @param[in] bufferIndex to use
632 void ProcessPropertyNotifications( BufferIndex bufferIndex );
635 * Pass shader binaries queued here on to event thread.
637 void ForwardCompiledShadersToEventThread();
640 * Update node shaders, opacity, geometry etc.
641 * @param[in] bufferIndex to use
643 void UpdateNodes( BufferIndex bufferIndex );
647 * @param[in] bufferIndex to use
649 void UpdateRenderers( BufferIndex bufferIndex );
653 // needs to be direct member so that getter for event buffer can be inlined
654 SceneGraphBuffers mSceneGraphBuffers;
661 // Messages for UpdateManager
663 inline void InstallRootMessage( UpdateManager& manager, Layer& root, bool systemLevel )
665 typedef MessageValue2< UpdateManager, Layer*, bool > LocalType;
667 // Reserve some memory inside the message queue
668 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
670 // Construct message in the message queue memory; note that delete should not be called on the return value
671 new (slot) LocalType( &manager, &UpdateManager::InstallRoot, &root, systemLevel );
674 inline void AddNodeMessage( UpdateManager& manager, Node& node )
676 typedef MessageValue1< UpdateManager, OwnerPointer<Node> > LocalType;
678 // Reserve some memory inside the message queue
679 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
681 // Construct message in the message queue memory; note that delete should not be called on the return value
682 new (slot) LocalType( &manager, &UpdateManager::AddNode, &node );
685 inline void ConnectNodeMessage( UpdateManager& manager, const Node& constParent, const Node& constChild )
687 // Update thread can edit the object
688 Node& parent = const_cast< Node& >( constParent );
689 Node& child = const_cast< Node& >( constChild );
691 typedef MessageValue2< UpdateManager, Node*, Node* > LocalType;
693 // Reserve some memory inside the message queue
694 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
696 // Construct message in the message queue memory; note that delete should not be called on the return value
697 new (slot) LocalType( &manager, &UpdateManager::ConnectNode, &parent, &child );
700 inline void DisconnectNodeMessage( UpdateManager& manager, const Node& constNode )
702 // Scene graph thread can modify this object.
703 Node& node = const_cast< Node& >( constNode );
705 typedef MessageValue1< UpdateManager, Node* > LocalType;
707 // Reserve some memory inside the message queue
708 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
710 // Construct message in the message queue memory; note that delete should not be called on the return value
711 new (slot) LocalType( &manager, &UpdateManager::DisconnectNode, &node );
714 inline void DestroyNodeMessage( UpdateManager& manager, const Node& constNode )
716 // Scene graph thread can destroy this object.
717 Node& node = const_cast< Node& >( constNode );
719 typedef MessageValue1< UpdateManager, Node* > LocalType;
721 // Reserve some memory inside the message queue
722 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
724 // Construct message in the message queue memory; note that delete should not be called on the return value
725 new (slot) LocalType( &manager, &UpdateManager::DestroyNode, &node );
728 inline void AddCameraMessage( UpdateManager& manager, const Camera* constCamera )
730 typedef MessageValue1< UpdateManager, Camera* > LocalType;
732 Camera* camera = const_cast<Camera*>( constCamera );
733 // Reserve some memory inside the message queue
734 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
736 // Construct message in the message queue memory; note that delete should not be called on the return value
737 new (slot) LocalType( &manager, &UpdateManager::AddCamera, camera );
740 inline void RemoveCameraMessage( UpdateManager& manager, const Camera* camera )
742 typedef MessageValue1< UpdateManager, const Camera* > LocalType;
744 // Reserve some memory inside the message queue
745 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
747 // Construct message in the message queue memory; note that delete should not be called on the return value
748 new (slot) LocalType( &manager, &UpdateManager::RemoveCamera, camera );
751 inline void AddObjectMessage( UpdateManager& manager, PropertyOwner* object )
753 typedef MessageValue1< UpdateManager, OwnerPointer<PropertyOwner> > LocalType;
755 // Reserve some memory inside the message queue
756 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
758 // Construct message in the message queue memory; note that delete should not be called on the return value
759 new (slot) LocalType( &manager, &UpdateManager::AddObject, object );
762 inline void RemoveObjectMessage( UpdateManager& manager, PropertyOwner* object )
764 typedef MessageValue1< UpdateManager, PropertyOwner* > LocalType;
766 // Reserve some memory inside the message queue
767 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
769 // Construct message in the message queue memory; note that delete should not be called on the return value
770 new (slot) LocalType( &manager, &UpdateManager::RemoveObject, object );
773 inline void AddAnimationMessage( UpdateManager& manager, Animation* animation )
775 typedef MessageValue1< UpdateManager, Animation* > LocalType;
777 // Reserve some memory inside the message queue
778 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
780 // Construct message in the message queue memory; note that delete should not be called on the return value
781 new (slot) LocalType( &manager, &UpdateManager::AddAnimation, animation );
784 inline void StopAnimationMessage( UpdateManager& manager, const Animation& constAnimation )
786 // The scene-graph thread owns this object so it can safely edit it.
787 Animation& animation = const_cast< Animation& >( constAnimation );
789 typedef MessageValue1< UpdateManager, Animation* > LocalType;
791 // Reserve some memory inside the message queue
792 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
794 // Construct message in the message queue memory; note that delete should not be called on the return value
795 new (slot) LocalType( &manager, &UpdateManager::StopAnimation, &animation );
798 inline void RemoveAnimationMessage( UpdateManager& manager, const Animation& constAnimation )
800 // The scene-graph thread owns this object so it can safely edit it.
801 Animation& animation = const_cast< Animation& >( constAnimation );
803 typedef MessageValue1< UpdateManager, Animation* > LocalType;
805 // Reserve some memory inside the message queue
806 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
808 // Construct message in the message queue memory; note that delete should not be called on the return value
809 new (slot) LocalType( &manager, &UpdateManager::RemoveAnimation, &animation );
812 inline void AddPropertyNotificationMessage( UpdateManager& manager, PropertyNotification* propertyNotification )
814 typedef MessageValue1< UpdateManager, PropertyNotification* > LocalType;
816 // Reserve some memory inside the message queue
817 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
819 // Construct message in the message queue memory; note that delete should not be called on the return value
820 new (slot) LocalType( &manager, &UpdateManager::AddPropertyNotification, propertyNotification );
823 inline void RemovePropertyNotificationMessage( UpdateManager& manager, const PropertyNotification& constPropertyNotification )
825 // The scene-graph thread owns this object so it can safely edit it.
826 PropertyNotification& propertyNotification = const_cast< PropertyNotification& >( constPropertyNotification );
828 typedef MessageValue1< UpdateManager, PropertyNotification* > LocalType;
830 // Reserve some memory inside the message queue
831 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
833 // Construct message in the message queue memory; note that delete should not be called on the return value
834 new (slot) LocalType( &manager, &UpdateManager::RemovePropertyNotification, &propertyNotification );
837 inline void PropertyNotificationSetNotifyModeMessage( UpdateManager& manager,
838 const PropertyNotification* constPropertyNotification,
839 PropertyNotification::NotifyMode notifyMode )
841 // The scene-graph thread owns this object so it can safely edit it.
842 PropertyNotification* propertyNotification = const_cast< PropertyNotification* >( constPropertyNotification );
844 typedef MessageValue2< UpdateManager, PropertyNotification*, PropertyNotification::NotifyMode > LocalType;
846 // Reserve some memory inside the message queue
847 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
849 // Construct message in the message queue memory; note that delete should not be called on the return value
850 new (slot) LocalType( &manager, &UpdateManager::PropertyNotificationSetNotify, propertyNotification, notifyMode );
853 // The render thread can safely change the Shader
854 inline void AddShaderMessage( UpdateManager& manager, Shader& shader )
856 typedef MessageValue1< UpdateManager, OwnerPointer< Shader > > LocalType;
858 // Reserve some memory inside the message queue
859 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
861 // Construct message in the message queue memory; note that delete should not be called on the return value
862 new (slot) LocalType( &manager, &UpdateManager::AddShader, &shader );
865 // The render thread can safely change the Shader
866 inline void RemoveShaderMessage( UpdateManager& manager, Shader& shader )
868 typedef MessageValue1< UpdateManager, Shader* > LocalType;
870 // Reserve some memory inside the message queue
871 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
873 // Construct message in the message queue memory; note that delete should not be called on the return value
874 new (slot) LocalType( &manager, &UpdateManager::RemoveShader, &shader );
877 inline void SetShaderProgramMessage( UpdateManager& manager,
879 Internal::ShaderDataPtr shaderData,
880 bool modifiesGeometry )
882 typedef MessageValue3< UpdateManager, Shader*, Internal::ShaderDataPtr, bool > LocalType;
884 // Reserve some memory inside the message queue
885 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
887 // Construct message in the message queue memory; note that delete should not be called on the return value
888 new (slot) LocalType( &manager, &UpdateManager::SetShaderProgram, &shader, shaderData, modifiesGeometry );
891 inline void SetBackgroundColorMessage( UpdateManager& manager, const Vector4& color )
893 typedef MessageValue1< UpdateManager, Vector4 > LocalType;
895 // Reserve some memory inside the message queue
896 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
898 // Construct message in the message queue memory; note that delete should not be called on the return value
899 new (slot) LocalType( &manager, &UpdateManager::SetBackgroundColor, color );
902 inline void SetDefaultSurfaceRectMessage( UpdateManager& manager, const Rect<int>& rect )
904 typedef MessageValue1< UpdateManager, Rect<int> > LocalType;
906 // Reserve some memory inside the message queue
907 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
909 // Construct message in the message queue memory; note that delete should not be called on the return value
910 new (slot) LocalType( &manager, &UpdateManager::SetDefaultSurfaceRect, rect );
913 inline void KeepRenderingMessage( UpdateManager& manager, float durationSeconds )
915 typedef MessageValue1< UpdateManager, float > LocalType;
917 // Reserve some memory inside the message queue
918 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
920 // Construct message in the message queue memory; note that delete should not be called on the return value
921 new (slot) LocalType( &manager, &UpdateManager::KeepRendering, durationSeconds );
925 * Create a message for setting the depth of a layer
926 * @param[in] manager The update manager
927 * @param[in] layers list of layers
928 * @param[in] systemLevel True if the layers are added via the SystemOverlay API
930 inline void SetLayerDepthsMessage( UpdateManager& manager, const std::vector< Layer* >& layers, bool systemLevel )
932 typedef MessageValue2< UpdateManager, std::vector< Layer* >, bool > LocalType;
934 // Reserve some memory inside the message queue
935 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
937 // Construct message in the message queue memory; note that delete should not be called on the return value
938 new (slot) LocalType( &manager, &UpdateManager::SetLayerDepths, layers, systemLevel );
941 inline void AddGestureMessage( UpdateManager& manager, PanGesture* gesture )
943 typedef MessageValue1< UpdateManager, PanGesture* > LocalType;
945 // Reserve some memory inside the message queue
946 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
948 // Construct message in the message queue memory; note that delete should not be called on the return value
949 new (slot) LocalType( &manager, &UpdateManager::AddGesture, gesture );
952 inline void RemoveGestureMessage( UpdateManager& manager, PanGesture* gesture )
954 typedef MessageValue1< UpdateManager, PanGesture* > LocalType;
956 // Reserve some memory inside the message queue
957 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
959 // Construct message in the message queue memory; note that delete should not be called on the return value
960 new (slot) LocalType( &manager, &UpdateManager::RemoveGesture, gesture );
963 template< typename T >
964 inline void AddMessage( UpdateManager& manager, ObjectOwnerContainer<T>& owner, T& object )
966 typedef MessageValue1< ObjectOwnerContainer<T>, OwnerPointer< T > > LocalType;
968 // Reserve some memory inside the message queue
969 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
970 // Construct message in the message queue memory; note that delete should not be called on the return value
971 new (slot) LocalType( &owner, &ObjectOwnerContainer<T>::Add, &object );
974 template< typename T >
975 inline void RemoveMessage( UpdateManager& manager, ObjectOwnerContainer<T>& owner, T& object )
977 typedef MessageValue1< ObjectOwnerContainer<T>, T* > LocalType;
979 // Reserve some memory inside the message queue
980 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
981 // Construct message in the message queue memory; note that delete should not be called on the return value
982 new (slot) LocalType( &owner, &ObjectOwnerContainer<T>::Remove, &object );
985 // The render thread can safely change the Shader
986 inline void AddTextureSetMessage( UpdateManager& manager, TextureSet& textureSet )
988 typedef MessageValue1< UpdateManager, OwnerPointer< TextureSet > > LocalType;
990 // Reserve some memory inside the message queue
991 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
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::AddTextureSet, &textureSet );
997 // The render thread can safely change the Shader
998 inline void RemoveTextureSetMessage( UpdateManager& manager, TextureSet& textureSet )
1000 typedef MessageValue1< UpdateManager, TextureSet* > LocalType;
1002 // Reserve some memory inside the message queue
1003 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1005 // Construct message in the message queue memory; note that delete should not be called on the return value
1006 new (slot) LocalType( &manager, &UpdateManager::RemoveTextureSet, &textureSet );
1009 inline void AddSamplerMessage( UpdateManager& manager, Render::Sampler& sampler )
1011 typedef MessageValue1< UpdateManager, Render::Sampler* > LocalType;
1013 // Reserve some memory inside the message queue
1014 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1016 // Construct message in the message queue memory; note that delete should not be called on the return value
1017 new (slot) LocalType( &manager, &UpdateManager::AddSampler, &sampler );
1020 inline void RemoveSamplerMessage( UpdateManager& manager, Render::Sampler& sampler )
1022 typedef MessageValue1< UpdateManager, Render::Sampler* > LocalType;
1024 // Reserve some memory inside the message queue
1025 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1027 // Construct message in the message queue memory; note that delete should not be called on the return value
1028 new (slot) LocalType( &manager, &UpdateManager::RemoveSampler, &sampler );
1031 inline void SetFilterModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int minFilterMode, unsigned int magFilterMode )
1033 typedef MessageValue3< UpdateManager, Render::Sampler*, unsigned int, unsigned int > LocalType;
1035 // Reserve some memory inside the message queue
1036 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1038 // Construct message in the message queue memory; note that delete should not be called on the return value
1039 new (slot) LocalType( &manager, &UpdateManager::SetFilterMode, &sampler, minFilterMode, magFilterMode );
1042 inline void SetWrapModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int rWrapMode, unsigned int sWrapMode, unsigned int tWrapMode )
1044 typedef MessageValue4< UpdateManager, Render::Sampler*, unsigned int, unsigned int, unsigned int > LocalType;
1046 // Reserve some memory inside the message queue
1047 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1049 // Construct message in the message queue memory; note that delete should not be called on the return value
1050 new (slot) LocalType( &manager, &UpdateManager::SetWrapMode, &sampler, rWrapMode, sWrapMode, tWrapMode );
1053 inline void AddPropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer )
1055 typedef MessageValue1< UpdateManager, Render::PropertyBuffer* > LocalType;
1057 // Reserve some memory inside the message queue
1058 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1060 // Construct message in the message queue memory; note that delete should not be called on the return value
1061 new (slot) LocalType( &manager, &UpdateManager::AddPropertyBuffer, &propertyBuffer );
1064 inline void RemovePropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer )
1066 typedef MessageValue1< UpdateManager, Render::PropertyBuffer* > LocalType;
1068 // Reserve some memory inside the message queue
1069 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1071 // Construct message in the message queue memory; note that delete should not be called on the return value
1072 new (slot) LocalType( &manager, &UpdateManager::RemovePropertyBuffer, &propertyBuffer );
1075 inline void SetPropertyBufferFormat( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, Render::PropertyBuffer::Format* format )
1077 typedef MessageValue2< UpdateManager, Render::PropertyBuffer*, Render::PropertyBuffer::Format* > LocalType;
1079 // Reserve some memory inside the message queue
1080 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1082 // Construct message in the message queue memory; note that delete should not be called on the return value
1083 new (slot) LocalType( &manager, &UpdateManager::SetPropertyBufferFormat, &propertyBuffer, format );
1086 inline void SetPropertyBufferData( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, Vector<char>* data, size_t size )
1088 typedef MessageValue3< UpdateManager, Render::PropertyBuffer*, Vector<char>*, size_t > LocalType;
1090 // Reserve some memory inside the message queue
1091 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1093 // Construct message in the message queue memory; note that delete should not be called on the return value
1094 new (slot) LocalType( &manager, &UpdateManager::SetPropertyBufferData, &propertyBuffer, data, size );
1097 inline void AddGeometry( UpdateManager& manager, Render::Geometry& geometry )
1099 typedef MessageValue1< UpdateManager, Render::Geometry* > LocalType;
1101 // Reserve some memory inside the message queue
1102 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1104 // Construct message in the message queue memory; note that delete should not be called on the return value
1105 new (slot) LocalType( &manager, &UpdateManager::AddGeometry, &geometry );
1108 inline void RemoveGeometry( UpdateManager& manager, Render::Geometry& geometry )
1110 typedef MessageValue1< UpdateManager, Render::Geometry* > LocalType;
1112 // Reserve some memory inside the message queue
1113 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1115 // Construct message in the message queue memory; note that delete should not be called on the return value
1116 new (slot) LocalType( &manager, &UpdateManager::RemoveGeometry, &geometry );
1119 inline void AddVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer )
1121 typedef MessageValue2< UpdateManager, Render::Geometry*, Render::PropertyBuffer* > LocalType;
1123 // Reserve some memory inside the message queue
1124 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1126 // Construct message in the message queue memory; note that delete should not be called on the return value
1127 new (slot) LocalType( &manager, &UpdateManager::AddVertexBuffer, &geometry, const_cast<Render::PropertyBuffer*>(&vertexBuffer) );
1130 inline void RemoveVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer )
1132 typedef MessageValue2< UpdateManager, Render::Geometry*, Render::PropertyBuffer* > LocalType;
1134 // Reserve some memory inside the message queue
1135 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1137 // Construct message in the message queue memory; note that delete should not be called on the return value
1138 new (slot) LocalType( &manager, &UpdateManager::RemoveVertexBuffer, &geometry, const_cast<Render::PropertyBuffer*>(&vertexBuffer) );
1141 // Custom message type for SetIndexBuffer() used to move data with Vector::Swap()
1142 template< typename T >
1143 class IndexBufferMessage : public MessageBase
1148 * Constructor which does a Vector::Swap()
1150 IndexBufferMessage( T* manager, Render::Geometry* geometry, Dali::Vector<unsigned short>& indices )
1152 mManager( manager ),
1153 mRenderGeometry( geometry )
1155 mIndices.Swap( indices );
1159 * Virtual destructor
1161 virtual ~IndexBufferMessage()
1166 * @copydoc MessageBase::Process
1168 virtual void Process( BufferIndex /*bufferIndex*/ )
1170 DALI_ASSERT_DEBUG( mManager && "Message does not have an object" );
1171 mManager->SetIndexBuffer( mRenderGeometry, mIndices );
1177 Render::Geometry* mRenderGeometry;
1178 Dali::Vector<unsigned short> mIndices;
1181 inline void SetIndexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, Dali::Vector<unsigned short>& indices )
1183 typedef IndexBufferMessage< UpdateManager > LocalType;
1185 // Reserve some memory inside the message queue
1186 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1188 // Construct message in the message queue memory; note that delete should not be called on the return value
1189 new (slot) LocalType( &manager, &geometry, indices );
1192 inline void SetGeometryTypeMessage( UpdateManager& manager, Render::Geometry& geometry, unsigned int geometryType )
1194 typedef MessageValue2< UpdateManager, Render::Geometry*, unsigned int > LocalType;
1196 // Reserve some memory inside the message queue
1197 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
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::SetGeometryType, &geometry, geometryType );
1203 inline void AddTexture( UpdateManager& manager, Render::NewTexture& texture )
1205 typedef MessageValue1< UpdateManager, Render::NewTexture* > LocalType;
1207 // Reserve some memory inside the message queue
1208 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
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::AddTexture, &texture );
1214 inline void RemoveTexture( UpdateManager& manager, Render::NewTexture& texture )
1216 typedef MessageValue1< UpdateManager, Render::NewTexture* > LocalType;
1218 // Reserve some memory inside the message queue
1219 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1221 // Construct message in the message queue memory; note that delete should not be called on the return value
1222 new (slot) LocalType( &manager, &UpdateManager::RemoveTexture, &texture );
1225 inline void UploadTextureMessage( UpdateManager& manager, Render::NewTexture& texture, PixelDataPtr pixelData, const NewTexture::UploadParams& params )
1227 typedef MessageValue3< UpdateManager, Render::NewTexture*, PixelDataPtr, NewTexture::UploadParams > LocalType;
1229 // Reserve some memory inside the message queue
1230 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1232 // Construct message in the message queue memory; note that delete should not be called on the return value
1233 new (slot) LocalType( &manager, &UpdateManager::UploadTexture, &texture, pixelData, params );
1236 inline void GenerateMipmapsMessage( UpdateManager& manager, Render::NewTexture& texture )
1238 typedef MessageValue1< UpdateManager, Render::NewTexture* > LocalType;
1240 // Reserve some memory inside the message queue
1241 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1243 // Construct message in the message queue memory; note that delete should not be called on the return value
1244 new (slot) LocalType( &manager, &UpdateManager::GenerateMipmaps, &texture );
1248 inline void AddFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer )
1250 typedef MessageValue1< UpdateManager, Render::FrameBuffer* > LocalType;
1252 // Reserve some memory inside the message queue
1253 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1255 // Construct message in the message queue memory; note that delete should not be called on the return value
1256 new (slot) LocalType( &manager, &UpdateManager::AddFrameBuffer, &frameBuffer );
1259 inline void RemoveFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer )
1261 typedef MessageValue1< UpdateManager, Render::FrameBuffer* > LocalType;
1263 // Reserve some memory inside the message queue
1264 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1266 // Construct message in the message queue memory; note that delete should not be called on the return value
1267 new (slot) LocalType( &manager, &UpdateManager::RemoveFrameBuffer, &frameBuffer );
1270 inline void AttachColorTextureToFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer, Render::NewTexture* texture, unsigned int mipmapLevel, unsigned int layer )
1272 typedef MessageValue4< UpdateManager, Render::FrameBuffer*, Render::NewTexture*, unsigned int, unsigned int > LocalType;
1274 // Reserve some memory inside the message queue
1275 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1277 // Construct message in the message queue memory; note that delete should not be called on the return value
1278 new (slot) LocalType( &manager, &UpdateManager::AttachColorTextureToFrameBuffer, &frameBuffer, texture, mipmapLevel, layer );
1282 } // namespace SceneGraph
1284 } // namespace Internal
1288 #endif // DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H