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>
46 class GlSyncAbstraction;
47 class RenderController;
49 } // namespace Integration
54 class PropertyNotifier;
55 class NotificationManager;
56 class CompleteNotificationInterface;
57 class ResourceManager;
64 // value types used by messages
65 template <> struct ParameterType< PropertyNotification::NotifyMode >
66 : public BasicType< PropertyNotification::NotifyMode > {};
77 class TextureCacheDispatcher;
83 * UpdateManager maintains a scene graph i.e. a tree of nodes as well as
84 * other scene graph property owning objects.
85 * It controls the Update traversal, in which nodes are repositioned/animated,
86 * and organizes the the culling and rendering of the scene.
87 * It also maintains the lifecycle of nodes and other property owners that are
88 * disconnected from the scene graph.
90 class UpdateManager : public ShaderSaver
95 * Construct a new UpdateManager.
96 * @param[in] notificationManager This should be notified when animations have finished.
97 * @param[in] animationFinishedNotifier The CompleteNotificationInterface that handles animation completions
98 * @param[in] propertyNotifier The PropertyNotifier
99 * @param[in] resourceManager The resource manager used to load textures etc.
100 * @param[in] discardQueue Nodes are added here when disconnected from the scene-graph.
101 * @param[in] controller After messages are flushed, we request a render from the RenderController.
102 * @param[in] renderManager This is responsible for rendering the results of each "update".
103 * @param[in] renderQueue Used to queue messages for the next render.
104 * @param[in] textureCacheDispatcher Used for sending messages to texture cache.
106 UpdateManager( NotificationManager& notificationManager,
107 CompleteNotificationInterface& animationFinishedNotifier,
108 PropertyNotifier& propertyNotifier,
109 ResourceManager& resourceManager,
110 DiscardQueue& discardQueue,
111 Integration::RenderController& controller,
112 RenderManager& renderManager,
113 RenderQueue& renderQueue,
114 TextureCacheDispatcher& textureCacheDispatcher );
119 virtual ~UpdateManager();
121 // Node connection methods
124 * Get the scene graph side list of RenderTasks.
125 * @param[in] systemLevel True if using the system-level overlay.
126 * @return The list of render tasks
128 RenderTaskList* GetRenderTaskList( bool systemLevel );
131 * Installs a new layer as the root node.
132 * @pre The UpdateManager does not already have an installed root node.
133 * @pre The layer is of derived Node type Layer.
134 * @pre The layer does not have a parent.
135 * @param[in] layer The new root node.
136 * @param[in] systemLevel True if using the system-level overlay.
137 * @post The node is owned by UpdateManager.
139 void InstallRoot( Layer* layer, bool systemLevel );
142 * Add a Node; UpdateManager takes ownership.
143 * @pre The node does not have a parent.
144 * @param[in] node The node to add.
146 void AddNode( Node* node );
149 * Connect a Node to the scene-graph.
150 * A disconnected Node has has no parent or children, and its properties cannot be animated/constrained.
151 * @pre The node does not already have a parent.
152 * @param[in] parent The new parent node.
154 void ConnectNode( Node* parent, Node* node );
157 * Disconnect a Node from the scene-graph.
158 * A disconnected Node has has no parent or children, and its properties cannot be animated/constrained.
159 * @pre The node has a parent.
160 * @param[in] node The node to disconnect.
162 void DisconnectNode( Node* node );
165 * Destroy a Node owned by UpdateManager.
166 * This is not immediate; Nodes are passed to the RenderQueue to allow GL resources to be deleted.
167 * In the following update, the previously queued Nodes may be deleted.
168 * @pre The node has been disconnected from the scene-graph i.e. has no parent or children.
169 * @param[in] node The node to destroy.
171 void DestroyNode( Node* node );
174 * Add a camera on scene
175 * @param[in] camera to add
177 void AddCamera( Camera* camera );
180 * Remove a camera from scene
181 * @param[in] camera to remove
183 void RemoveCamera( const Camera* camera );
186 * Add a newly created object.
187 * @param[in] object The object to add.
188 * @post The object is owned by UpdateManager.
190 void AddObject( PropertyOwner* object );
194 * @param[in] object The object to remove.
196 void RemoveObject( PropertyOwner* object );
201 * Add a newly created animation.
202 * @param[in] animation The animation to add.
203 * @post The animation is owned by UpdateManager.
205 void AddAnimation( Animation* animation );
209 * @param[in] animation The animation to stop.
211 void StopAnimation( Animation* animation );
214 * Remove an animation.
215 * @param[in] animation The animation to remove.
217 void RemoveAnimation( Animation* animation );
220 * Query whether any animations are currently running.
221 * @return True if any animations are running.
223 bool IsAnimationRunning() const;
225 // Property Notification
228 * Add a newly created property notification
229 * @param[in] propertyNotification The notification to add
230 * @post The propertyNotification is owned by UpdateManager.
232 void AddPropertyNotification( PropertyNotification* propertyNotification );
235 * Remove a property notification
236 * @param[in] propertyNotification The notification to remove
238 void RemovePropertyNotification( PropertyNotification* propertyNotification );
241 * Set Notify state for PropertyNotification
242 * @param[in] propertyNotification The notification to remove
243 * @param[in] notifyMode The notification mode.
245 void PropertyNotificationSetNotify( PropertyNotification* propertyNotification, PropertyNotification::NotifyMode notifyMode );
248 * @brief Get the renderer owner
250 * @return The renderer owner
252 ObjectOwnerContainer< Renderer >& GetRendererOwner();
255 * @brief Get the property buffer owner
257 * @return The property buffer owner
259 ObjectOwnerContainer< PropertyBuffer >& GetPropertyBufferOwner();
265 * Add a newly created shader.
266 * @param[in] shader The shader to add.
267 * @post The shader is owned by the UpdateManager.
269 void AddShader(Shader* shader);
273 * @pre The shader has been added to the UpdateManager.
274 * @param[in] shader The shader to remove.
275 * @post The shader is destroyed.
277 void RemoveShader(Shader* shader);
280 * Add a newly created TextureSet.
281 * @param[in] textureSet The texture set to add.
282 * @post The TextureSet is owned by the UpdateManager.
284 void AddTextureSet(TextureSet* textureSet);
287 * Remove a TextureSet.
288 * @pre The TextureSet has been added to the UpdateManager.
289 * @param[in] textureSet The TextureSet to remove.
290 * @post The TextureSet is destroyed.
292 void RemoveTextureSet(TextureSet* textureSet);
295 * Set the shader program for a Shader object
296 * @param[in] shader The shader to modify
297 * @param[in] shaderData Source code, hash over source, and optional compiled binary for the shader program
298 * @param[in] modifiesGeometry True if the vertex shader modifies geometry
300 void SetShaderProgram( Shader* shader, Internal::ShaderDataPtr shaderData, bool modifiesGeometry );
303 * @brief Accept compiled shaders passed back on render thread for saving.
304 * @param[in] shaderData Source code, hash over source, and corresponding compiled binary to be saved.
306 virtual void SaveBinary( Internal::ShaderDataPtr shaderData );
309 * @brief Set the destination for compiled shader binaries to be passed on to.
310 * The dispatcher passed in will be called from the update thread.
311 * @param[in] upstream A sink for ShaderDatas to be passed into.
313 void SetShaderSaver( ShaderSaver& upstream );
318 * Add a newly created gesture.
319 * @param[in] gesture The gesture to add.
320 * @post The gesture is owned by the UpdateManager.
322 void AddGesture( PanGesture* gesture );
326 * @pre The gesture has been added to the UpdateManager.
327 * @param[in] gesture The gesture to remove.
328 * @post The gesture is destroyed.
330 void RemoveGesture( PanGesture* gesture );
332 // Message queue handling
335 * Reserve space for another message in the queue; this must then be initialized by the caller.
336 * The message will be read from the update-thread after the next FlushMessages is called.
337 * @post Calling this method may invalidate any previously returned slots.
338 * @param[in] size The message size with respect to the size of type "char".
339 * @param[in] updateScene A flag, when true denotes that the message will cause the scene-graph node tree to require an update.
340 * @note the default value of updateScene should match that in EventThreadServices::ReserveMessageSlot.
341 * @return A pointer to the first char allocated for the message.
343 unsigned int* ReserveMessageSlot( std::size_t size, bool updateScene = true );
346 * @return the current event-buffer index.
348 BufferIndex GetEventBufferIndex() const
350 // inlined as its called often from event thread
351 return mSceneGraphBuffers.GetEventBufferIndex();
355 * Called by the event-thread to signal that FlushQueue will be called
356 * e.g. when it has finished event processing.
358 void EventProcessingStarted();
361 * Flush the set of messages, which were previously stored with QueueMessage().
362 * Calls to this thread-safe method should be minimized, to avoid thread blocking.
364 * @return True if there are messages to process.
369 * Add a new sampler to RenderManager
370 * @param[in] sampler The sampler to add
371 * @post Sends a message to RenderManager to add the sampler.
372 * The sampler will be owned by RenderManager
374 void AddSampler( Render::Sampler* sampler );
377 * Removes an existing sampler from RenderManager
378 * @param[in] sampler The sampler to remove
379 * @post The sampler will be destroyed in the render thread
381 void RemoveSampler( Render::Sampler* sampler );
384 * Sets the filter modes for an existing sampler
385 * @param[in] sampler The sampler
386 * @param[in] minFilterMode The filter to use under minification
387 * @param[in] magFilterMode The filter to use under magnification
389 void SetFilterMode( Render::Sampler* sampler, unsigned int minFilterMode, unsigned int magFilterMode );
392 * Sets the wrap mode for an existing sampler
393 * @param[in] sampler The sampler
394 * @param[in] uWrapMode Wrapping mode in x direction
395 * @param[in] vWrapMode Wrapping mode in y direction
397 void SetWrapMode( Render::Sampler* sampler, unsigned int uWrapMode, unsigned int vWrapMode );
400 * Add a new property buffer to RenderManager
401 * @param[in] propertryBuffer The property buffer to add
402 * @post Sends a message to RenderManager to add the property buffer.
403 * The property buffer will be owned by RenderManager
405 void AddPropertyBuffer( Render::PropertyBuffer* propertryBuffer );
408 * Removes an existing PropertyBuffer from RenderManager
409 * @param[in] propertryBuffer The property buffer to remove
410 * @post The property buffer will be destroyed in the render thread
412 void RemovePropertyBuffer( Render::PropertyBuffer* propertryBuffer );
415 * Sets the format of an existing property buffer
416 * @param[in] propertyBuffer The property buffer.
417 * @param[in] format The new format of the buffer
418 * @post Sends a message to RenderManager to set the new format to the property buffer.
420 void SetPropertyBufferFormat(Render::PropertyBuffer* propertyBuffer, Render::PropertyBuffer::Format* format );
423 * Sets the data of an existing property buffer
424 * @param[in] propertyBuffer The property buffer.
425 * @param[in] data The new data of the buffer
426 * @param[in] size The new size of the buffer
427 * @post Sends a message to RenderManager to set the new data to the property buffer.
429 void SetPropertyBufferData(Render::PropertyBuffer* propertyBuffer, Dali::Vector<char>* data, size_t size);
432 * Adds a geometry to the RenderManager
433 * @param[in] geometry The geometry to add
434 * @post Sends a message to RenderManager to add the Geometry
435 * The geometry will be owned by RenderManager
437 void AddGeometry( Render::Geometry* geometry );
440 * Removes an existing Geometry from RenderManager
441 * @param[in] geometry The geometry to remove
442 * @post The geometry will be destroyed in the render thread
444 void RemoveGeometry( Render::Geometry* geometry );
447 * Sets the geometry type of an existing Geometry
448 * @param[in] geometry The geometry
449 * @param[in] geometryType The type of the geometry
451 void SetGeometryType( Render::Geometry* geometry, unsigned int geometryType );
454 * Sets the index buffer to be used by a geometry
455 * @param[in] geometry The geometry
456 * @param[in] indices A vector containing the indices for the geometry
458 void SetIndexBuffer( Render::Geometry* geometry, Dali::Vector<unsigned short>& indices );
461 * Adds a vertex buffer to a geomtry
462 * @param[in] geometry The geometry
463 * @param[in] propertyBuffer The property buffer
465 void AddVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer );
468 * Removes a vertex buffer from a geometry
469 * @param[in] geometry The geometry
470 * @param[in] propertyBuffer The property buffer
472 void RemoveVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer );
478 * Performs an Update traversal on the scene-graph.
479 * @param[in] elapsedSeconds The elapsed time that should be applied to animations.
480 * @param[in] lastVSyncTimeMilliseconds The last time, in milliseconds, that we had a VSync.
481 * @param[in] nextVSyncTimeMilliseconds The estimated time, in milliseconds, of the next VSync.
482 * @return True if further updates are required e.g. during animations.
484 unsigned int Update( float elapsedSeconds, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds );
487 * Set the background color i.e. the glClear color used at the beginning of each frame.
488 * @param[in] color The new background color.
490 void SetBackgroundColor(const Vector4& color);
493 * Set the default surface rect.
494 * @param[in] rect The rect value representing the surface.
496 void SetDefaultSurfaceRect( const Rect<int>& rect );
499 * @copydoc Dali::Stage::KeepRendering()
501 void KeepRendering( float durationSeconds );
504 * Sets the depths of all layers.
505 * @param layers The layers in depth order.
506 * @param[in] systemLevel True if using the system-level overlay.
508 void SetLayerDepths( const std::vector< Layer* >& layers, bool systemLevel );
513 UpdateManager(const UpdateManager&);
516 UpdateManager& operator=(const UpdateManager& rhs);
519 * Helper to check whether the update-thread should keep going.
520 * @param[in] elapsedSeconds The time in seconds since the previous update.
521 * @return True if the update-thread should keep going.
523 unsigned int KeepUpdatingCheck( float elapsedSeconds ) const;
526 * Post process resources that have been updated by renderer
528 void PostProcessResources();
531 * Helper to reset all Node properties
532 * @param[in] bufferIndex to use
534 void ResetProperties( BufferIndex bufferIndex );
537 * Perform gesture updates.
538 * @param[in] bufferIndex to use
539 * @param[in] lastVSyncTime The last VSync time in milliseconds.
540 * @param[in] nextVSyncTime The estimated time of the next VSync in milliseconds.
541 * @return true, if any properties were updated.
543 bool ProcessGestures( BufferIndex bufferIndex, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds );
546 * Perform animation updates
547 * @param[in] bufferIndex to use
548 * @param[in] elapsedSeconds time since last frame
550 void Animate( BufferIndex bufferIndex, float elapsedSeconds );
553 * Applies constraints to CustomObjects
554 * @param[in] bufferIndex to use
556 void ConstrainCustomObjects( BufferIndex bufferIndex );
559 * Applies constraints to RenderTasks
560 * @param[in] bufferIndex to use
562 void ConstrainRenderTasks( BufferIndex bufferIndex );
565 * Applies constraints to Shaders
566 * @param[in] bufferIndex to use
568 void ConstrainShaders( BufferIndex bufferIndex );
571 * Perform property notification updates
572 * @param[in] bufferIndex to use
574 void ProcessPropertyNotifications( BufferIndex bufferIndex );
577 * Prepare textures for rendering
579 void PrepareTextureSets( BufferIndex bufferIndex );
582 * Pass shader binaries queued here on to event thread.
584 void ForwardCompiledShadersToEventThread();
587 * Update node shaders, opacity, geometry etc.
588 * @param[in] bufferIndex to use
590 void UpdateNodes( BufferIndex bufferIndex );
594 * @param[in] bufferIndex to use
596 void UpdateRenderers( BufferIndex bufferIndex );
600 // needs to be direct member so that getter for event buffer can be inlined
601 SceneGraphBuffers mSceneGraphBuffers;
608 // Messages for UpdateManager
610 inline void InstallRootMessage( UpdateManager& manager, Layer& root, bool systemLevel )
612 typedef MessageValue2< UpdateManager, Layer*, bool > LocalType;
614 // Reserve some memory inside the message queue
615 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
617 // Construct message in the message queue memory; note that delete should not be called on the return value
618 new (slot) LocalType( &manager, &UpdateManager::InstallRoot, &root, systemLevel );
621 inline void AddNodeMessage( UpdateManager& manager, Node& node )
623 typedef MessageValue1< UpdateManager, OwnerPointer<Node> > LocalType;
625 // Reserve some memory inside the message queue
626 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
628 // Construct message in the message queue memory; note that delete should not be called on the return value
629 new (slot) LocalType( &manager, &UpdateManager::AddNode, &node );
632 inline void ConnectNodeMessage( UpdateManager& manager, const Node& constParent, const Node& constChild )
634 // Update thread can edit the object
635 Node& parent = const_cast< Node& >( constParent );
636 Node& child = const_cast< Node& >( constChild );
638 typedef MessageValue2< UpdateManager, Node*, Node* > LocalType;
640 // Reserve some memory inside the message queue
641 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
643 // Construct message in the message queue memory; note that delete should not be called on the return value
644 new (slot) LocalType( &manager, &UpdateManager::ConnectNode, &parent, &child );
647 inline void DisconnectNodeMessage( UpdateManager& manager, const Node& constNode )
649 // Scene graph thread can modify this object.
650 Node& node = const_cast< Node& >( constNode );
652 typedef MessageValue1< UpdateManager, Node* > LocalType;
654 // Reserve some memory inside the message queue
655 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
657 // Construct message in the message queue memory; note that delete should not be called on the return value
658 new (slot) LocalType( &manager, &UpdateManager::DisconnectNode, &node );
661 inline void DestroyNodeMessage( UpdateManager& manager, const Node& constNode )
663 // Scene graph thread can destroy this object.
664 Node& node = const_cast< Node& >( constNode );
666 typedef MessageValue1< UpdateManager, Node* > LocalType;
668 // Reserve some memory inside the message queue
669 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
671 // Construct message in the message queue memory; note that delete should not be called on the return value
672 new (slot) LocalType( &manager, &UpdateManager::DestroyNode, &node );
675 inline void AddCameraMessage( UpdateManager& manager, const Camera* constCamera )
677 typedef MessageValue1< UpdateManager, Camera* > LocalType;
679 Camera* camera = const_cast<Camera*>( constCamera );
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::AddCamera, camera );
687 inline void RemoveCameraMessage( UpdateManager& manager, const Camera* camera )
689 typedef MessageValue1< UpdateManager, const Camera* > LocalType;
691 // Reserve some memory inside the message queue
692 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
694 // Construct message in the message queue memory; note that delete should not be called on the return value
695 new (slot) LocalType( &manager, &UpdateManager::RemoveCamera, camera );
698 inline void AddObjectMessage( UpdateManager& manager, PropertyOwner* object )
700 typedef MessageValue1< UpdateManager, OwnerPointer<PropertyOwner> > LocalType;
702 // Reserve some memory inside the message queue
703 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
705 // Construct message in the message queue memory; note that delete should not be called on the return value
706 new (slot) LocalType( &manager, &UpdateManager::AddObject, object );
709 inline void RemoveObjectMessage( UpdateManager& manager, PropertyOwner* object )
711 typedef MessageValue1< UpdateManager, PropertyOwner* > LocalType;
713 // Reserve some memory inside the message queue
714 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
716 // Construct message in the message queue memory; note that delete should not be called on the return value
717 new (slot) LocalType( &manager, &UpdateManager::RemoveObject, object );
720 inline void AddAnimationMessage( UpdateManager& manager, Animation* animation )
722 typedef MessageValue1< UpdateManager, Animation* > LocalType;
724 // Reserve some memory inside the message queue
725 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
727 // Construct message in the message queue memory; note that delete should not be called on the return value
728 new (slot) LocalType( &manager, &UpdateManager::AddAnimation, animation );
731 inline void StopAnimationMessage( UpdateManager& manager, const Animation& constAnimation )
733 // The scene-graph thread owns this object so it can safely edit it.
734 Animation& animation = const_cast< Animation& >( constAnimation );
736 typedef MessageValue1< UpdateManager, Animation* > LocalType;
738 // Reserve some memory inside the message queue
739 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
741 // Construct message in the message queue memory; note that delete should not be called on the return value
742 new (slot) LocalType( &manager, &UpdateManager::StopAnimation, &animation );
745 inline void RemoveAnimationMessage( UpdateManager& manager, const Animation& constAnimation )
747 // The scene-graph thread owns this object so it can safely edit it.
748 Animation& animation = const_cast< Animation& >( constAnimation );
750 typedef MessageValue1< UpdateManager, Animation* > LocalType;
752 // Reserve some memory inside the message queue
753 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
755 // Construct message in the message queue memory; note that delete should not be called on the return value
756 new (slot) LocalType( &manager, &UpdateManager::RemoveAnimation, &animation );
759 inline void AddPropertyNotificationMessage( UpdateManager& manager, PropertyNotification* propertyNotification )
761 typedef MessageValue1< UpdateManager, PropertyNotification* > LocalType;
763 // Reserve some memory inside the message queue
764 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
766 // Construct message in the message queue memory; note that delete should not be called on the return value
767 new (slot) LocalType( &manager, &UpdateManager::AddPropertyNotification, propertyNotification );
770 inline void RemovePropertyNotificationMessage( UpdateManager& manager, const PropertyNotification& constPropertyNotification )
772 // The scene-graph thread owns this object so it can safely edit it.
773 PropertyNotification& propertyNotification = const_cast< PropertyNotification& >( constPropertyNotification );
775 typedef MessageValue1< UpdateManager, PropertyNotification* > 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::RemovePropertyNotification, &propertyNotification );
784 inline void PropertyNotificationSetNotifyModeMessage( UpdateManager& manager,
785 const PropertyNotification* constPropertyNotification,
786 PropertyNotification::NotifyMode notifyMode )
788 // The scene-graph thread owns this object so it can safely edit it.
789 PropertyNotification* propertyNotification = const_cast< PropertyNotification* >( constPropertyNotification );
791 typedef MessageValue2< UpdateManager, PropertyNotification*, PropertyNotification::NotifyMode > 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::PropertyNotificationSetNotify, propertyNotification, notifyMode );
800 // The render thread can safely change the Shader
801 inline void AddShaderMessage( UpdateManager& manager, Shader& shader )
803 typedef MessageValue1< UpdateManager, OwnerPointer< Shader > > 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::AddShader, &shader );
812 // The render thread can safely change the Shader
813 inline void RemoveShaderMessage( UpdateManager& manager, Shader& shader )
815 typedef MessageValue1< UpdateManager, Shader* > LocalType;
817 // Reserve some memory inside the message queue
818 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
820 // Construct message in the message queue memory; note that delete should not be called on the return value
821 new (slot) LocalType( &manager, &UpdateManager::RemoveShader, &shader );
824 inline void SetShaderProgramMessage( UpdateManager& manager,
826 Internal::ShaderDataPtr shaderData,
827 bool modifiesGeometry )
829 typedef MessageValue3< UpdateManager, Shader*, Internal::ShaderDataPtr, bool > LocalType;
831 // Reserve some memory inside the message queue
832 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
834 // Construct message in the message queue memory; note that delete should not be called on the return value
835 new (slot) LocalType( &manager, &UpdateManager::SetShaderProgram, &shader, shaderData, modifiesGeometry );
838 inline void SetBackgroundColorMessage( UpdateManager& manager, const Vector4& color )
840 typedef MessageValue1< UpdateManager, Vector4 > LocalType;
842 // Reserve some memory inside the message queue
843 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
845 // Construct message in the message queue memory; note that delete should not be called on the return value
846 new (slot) LocalType( &manager, &UpdateManager::SetBackgroundColor, color );
849 inline void SetDefaultSurfaceRectMessage( UpdateManager& manager, const Rect<int>& rect )
851 typedef MessageValue1< UpdateManager, Rect<int> > LocalType;
853 // Reserve some memory inside the message queue
854 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
856 // Construct message in the message queue memory; note that delete should not be called on the return value
857 new (slot) LocalType( &manager, &UpdateManager::SetDefaultSurfaceRect, rect );
860 inline void KeepRenderingMessage( UpdateManager& manager, float durationSeconds )
862 typedef MessageValue1< UpdateManager, float > LocalType;
864 // Reserve some memory inside the message queue
865 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
867 // Construct message in the message queue memory; note that delete should not be called on the return value
868 new (slot) LocalType( &manager, &UpdateManager::KeepRendering, durationSeconds );
872 * Create a message for setting the depth of a layer
873 * @param[in] manager The update manager
874 * @param[in] layers list of layers
875 * @param[in] systemLevel True if the layers are added via the SystemOverlay API
877 inline void SetLayerDepthsMessage( UpdateManager& manager, const std::vector< Layer* >& layers, bool systemLevel )
879 typedef MessageValue2< UpdateManager, std::vector< Layer* >, bool > LocalType;
881 // Reserve some memory inside the message queue
882 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
884 // Construct message in the message queue memory; note that delete should not be called on the return value
885 new (slot) LocalType( &manager, &UpdateManager::SetLayerDepths, layers, systemLevel );
888 inline void AddGestureMessage( UpdateManager& manager, PanGesture* gesture )
890 typedef MessageValue1< UpdateManager, PanGesture* > LocalType;
892 // Reserve some memory inside the message queue
893 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
895 // Construct message in the message queue memory; note that delete should not be called on the return value
896 new (slot) LocalType( &manager, &UpdateManager::AddGesture, gesture );
899 inline void RemoveGestureMessage( UpdateManager& manager, PanGesture* gesture )
901 typedef MessageValue1< UpdateManager, PanGesture* > LocalType;
903 // Reserve some memory inside the message queue
904 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
906 // Construct message in the message queue memory; note that delete should not be called on the return value
907 new (slot) LocalType( &manager, &UpdateManager::RemoveGesture, gesture );
910 template< typename T >
911 inline void AddMessage( UpdateManager& manager, ObjectOwnerContainer<T>& owner, T& object )
913 typedef MessageValue1< ObjectOwnerContainer<T>, OwnerPointer< T > > LocalType;
915 // Reserve some memory inside the message queue
916 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
917 // Construct message in the message queue memory; note that delete should not be called on the return value
918 new (slot) LocalType( &owner, &ObjectOwnerContainer<T>::Add, &object );
921 template< typename T >
922 inline void RemoveMessage( UpdateManager& manager, ObjectOwnerContainer<T>& owner, T& object )
924 typedef MessageValue1< ObjectOwnerContainer<T>, T* > LocalType;
926 // Reserve some memory inside the message queue
927 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
928 // Construct message in the message queue memory; note that delete should not be called on the return value
929 new (slot) LocalType( &owner, &ObjectOwnerContainer<T>::Remove, &object );
932 // The render thread can safely change the Shader
933 inline void AddTextureSetMessage( UpdateManager& manager, TextureSet& textureSet )
935 typedef MessageValue1< UpdateManager, OwnerPointer< TextureSet > > LocalType;
937 // Reserve some memory inside the message queue
938 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
940 // Construct message in the message queue memory; note that delete should not be called on the return value
941 new (slot) LocalType( &manager, &UpdateManager::AddTextureSet, &textureSet );
944 // The render thread can safely change the Shader
945 inline void RemoveTextureSetMessage( UpdateManager& manager, TextureSet& textureSet )
947 typedef MessageValue1< UpdateManager, TextureSet* > LocalType;
949 // Reserve some memory inside the message queue
950 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
952 // Construct message in the message queue memory; note that delete should not be called on the return value
953 new (slot) LocalType( &manager, &UpdateManager::RemoveTextureSet, &textureSet );
956 inline void AddSamplerMessage( UpdateManager& manager, Render::Sampler& sampler )
958 typedef MessageValue1< UpdateManager, Render::Sampler* > LocalType;
960 // Reserve some memory inside the message queue
961 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
963 // Construct message in the message queue memory; note that delete should not be called on the return value
964 new (slot) LocalType( &manager, &UpdateManager::AddSampler, &sampler );
967 inline void RemoveSamplerMessage( UpdateManager& manager, Render::Sampler& sampler )
969 typedef MessageValue1< UpdateManager, Render::Sampler* > LocalType;
971 // Reserve some memory inside the message queue
972 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
974 // Construct message in the message queue memory; note that delete should not be called on the return value
975 new (slot) LocalType( &manager, &UpdateManager::RemoveSampler, &sampler );
978 inline void SetFilterModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int minFilterMode, unsigned int magFilterMode )
980 typedef MessageValue3< UpdateManager, Render::Sampler*, unsigned int, unsigned int > LocalType;
982 // Reserve some memory inside the message queue
983 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
985 // Construct message in the message queue memory; note that delete should not be called on the return value
986 new (slot) LocalType( &manager, &UpdateManager::SetFilterMode, &sampler, minFilterMode, magFilterMode );
989 inline void SetWrapModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int uWrapMode, unsigned int vWrapMode )
991 typedef MessageValue3< UpdateManager, Render::Sampler*, unsigned int, unsigned int > LocalType;
993 // Reserve some memory inside the message queue
994 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
996 // Construct message in the message queue memory; note that delete should not be called on the return value
997 new (slot) LocalType( &manager, &UpdateManager::SetWrapMode, &sampler, uWrapMode, vWrapMode );
1000 inline void AddPropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer )
1002 typedef MessageValue1< UpdateManager, Render::PropertyBuffer* > 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::AddPropertyBuffer, &propertyBuffer );
1011 inline void RemovePropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer )
1013 typedef MessageValue1< UpdateManager, Render::PropertyBuffer* > 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::RemovePropertyBuffer, &propertyBuffer );
1022 inline void SetPropertyBufferFormat( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, Render::PropertyBuffer::Format* format )
1024 typedef MessageValue2< UpdateManager, Render::PropertyBuffer*, Render::PropertyBuffer::Format* > 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::SetPropertyBufferFormat, &propertyBuffer, format );
1033 inline void SetPropertyBufferData( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, Vector<char>* data, size_t size )
1035 typedef MessageValue3< UpdateManager, Render::PropertyBuffer*, Vector<char>*, size_t > 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::SetPropertyBufferData, &propertyBuffer, data, size );
1044 inline void AddGeometry( UpdateManager& manager, Render::Geometry& geometry )
1046 typedef MessageValue1< UpdateManager, Render::Geometry* > 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::AddGeometry, &geometry );
1055 inline void RemoveGeometry( UpdateManager& manager, Render::Geometry& geometry )
1057 typedef MessageValue1< UpdateManager, Render::Geometry* > 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::RemoveGeometry, &geometry );
1066 inline void AddVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer )
1068 typedef MessageValue2< UpdateManager, Render::Geometry*, 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::AddVertexBuffer, &geometry, const_cast<Render::PropertyBuffer*>(&vertexBuffer) );
1077 inline void RemoveVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer )
1079 typedef MessageValue2< UpdateManager, Render::Geometry*, Render::PropertyBuffer* > 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::RemoveVertexBuffer, &geometry, const_cast<Render::PropertyBuffer*>(&vertexBuffer) );
1088 // Custom message type for SetIndexBuffer() used to move data with Vector::Swap()
1089 template< typename T >
1090 class IndexBufferMessage : public MessageBase
1095 * Constructor which does a Vector::Swap()
1097 IndexBufferMessage( T* manager, Render::Geometry* geometry, Dali::Vector<unsigned short>& indices )
1099 mManager( manager ),
1100 mRenderGeometry( geometry )
1102 mIndices.Swap( indices );
1106 * Virtual destructor
1108 virtual ~IndexBufferMessage()
1113 * @copydoc MessageBase::Process
1115 virtual void Process( BufferIndex /*bufferIndex*/ )
1117 DALI_ASSERT_DEBUG( mManager && "Message does not have an object" );
1118 mManager->SetIndexBuffer( mRenderGeometry, mIndices );
1124 Render::Geometry* mRenderGeometry;
1125 Dali::Vector<unsigned short> mIndices;
1128 inline void SetIndexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, Dali::Vector<unsigned short>& indices )
1130 typedef IndexBufferMessage< UpdateManager > LocalType;
1132 // Reserve some memory inside the message queue
1133 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1135 // Construct message in the message queue memory; note that delete should not be called on the return value
1136 new (slot) LocalType( &manager, &geometry, indices );
1139 inline void SetGeometryTypeMessage( UpdateManager& manager, Render::Geometry& geometry, unsigned int geometryType )
1141 typedef MessageValue2< UpdateManager, Render::Geometry*, unsigned int > LocalType;
1143 // Reserve some memory inside the message queue
1144 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1146 // Construct message in the message queue memory; note that delete should not be called on the return value
1147 new (slot) LocalType( &manager, &UpdateManager::SetGeometryType, &geometry, geometryType );
1150 } // namespace SceneGraph
1152 } // namespace Internal
1156 #endif // __DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H__