1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H__
5 * Copyright (c) 2014 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/node-attachments/node-attachment.h>
36 #include <dali/internal/update/nodes/node.h>
37 #include <dali/internal/update/nodes/scene-graph-layer.h>
38 #include <dali/internal/update/rendering/scene-graph-renderer.h>
39 #include <dali/internal/render/shaders/scene-graph-shader.h>
40 #include <dali/internal/render/renderers/render-property-buffer.h>
47 class GlSyncAbstraction;
48 class RenderController;
50 } // namespace Integration
55 class PropertyNotifier;
56 class NotificationManager;
57 class CompleteNotificationInterface;
58 class ResourceManager;
65 // value types used by messages
66 template <> struct ParameterType< PropertyNotification::NotifyMode >
67 : public BasicType< PropertyNotification::NotifyMode > {};
83 * UpdateManager maintains a scene graph i.e. a tree of nodes and attachments and
84 * other property owner 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] textureCache Used for caching textures.
105 * @param[in] touchResampler Used for re-sampling touch events.
107 UpdateManager( NotificationManager& notificationManager,
108 CompleteNotificationInterface& animationFinishedNotifier,
109 PropertyNotifier& propertyNotifier,
110 ResourceManager& resourceManager,
111 DiscardQueue& discardQueue,
112 Integration::RenderController& controller,
113 RenderManager& renderManager,
114 RenderQueue& renderQueue,
115 TextureCache& textureCache,
116 TouchResampler& touchResampler );
121 virtual ~UpdateManager();
123 // Node connection methods
126 * Get the scene graph side list of RenderTasks.
127 * @param[in] systemLevel True if using the system-level overlay.
128 * @return The list of render tasks
130 RenderTaskList* GetRenderTaskList( bool systemLevel );
133 * Installs a new layer as the root node.
134 * @pre The UpdateManager does not already have an installed root node.
135 * @pre The layer is of derived Node type Layer.
136 * @pre The layer does not have a parent.
137 * @param[in] layer The new root node.
138 * @param[in] systemLevel True if using the system-level overlay.
139 * @post The node is owned by UpdateManager.
141 void InstallRoot( Layer* layer, bool systemLevel );
144 * Add a Node; UpdateManager takes ownership.
145 * @pre The node does not have a parent.
146 * @param[in] node The node to add.
148 void AddNode( Node* node );
151 * Connect a Node to the scene-graph.
152 * A disconnected Node has has no parent or children, and its properties cannot be animated/constrained.
153 * @pre The node does not already have a parent.
154 * @param[in] parent The new parent node.
156 void ConnectNode( Node* parent, Node* node );
159 * Disconnect a Node from the scene-graph.
160 * A disconnected Node has has no parent or children, and its properties cannot be animated/constrained.
161 * @pre The node has a parent.
162 * @param[in] node The node to disconnect.
164 void DisconnectNode( Node* node );
167 * Destroy a Node owned by UpdateManager.
168 * This is not immediate; Nodes are passed to the RenderQueue to allow GL resources to be deleted.
169 * In the following update, the previously queued Nodes may be deleted.
170 * @pre The node has been disconnected from the scene-graph i.e. has no parent or children.
171 * @param[in] node The node to destroy.
173 void DestroyNode( Node* node );
176 * Attach an object to a Node.
177 * The UpdateManager is responsible for calling NodeAttachment::Initialize().
178 * @param[in] node The node which will own the attachment.
179 * @param[in] attachment The object to attach.
181 void AttachToNode( Node* node, NodeAttachment* attachment );
184 * Add a newly created object.
185 * @param[in] object The object to add.
186 * @post The object is owned by UpdateManager.
188 void AddObject( PropertyOwner* object );
192 * @param[in] object The object to remove.
194 void RemoveObject( PropertyOwner* object );
199 * Add a newly created animation.
200 * @param[in] animation The animation to add.
201 * @post The animation is owned by UpdateManager.
203 void AddAnimation( Animation* animation );
207 * @param[in] animation The animation to stop.
209 void StopAnimation( Animation* animation );
212 * Remove an animation.
213 * @param[in] animation The animation to remove.
215 void RemoveAnimation( Animation* animation );
218 * Query whether any animations are currently running.
219 * @return True if any animations are running.
221 bool IsAnimationRunning() const;
223 // Property Notification
226 * Add a newly created property notification
227 * @param[in] propertyNotification The notification to add
228 * @post The propertyNotification is owned by UpdateManager.
230 void AddPropertyNotification( PropertyNotification* propertyNotification );
233 * Remove a property notification
234 * @param[in] propertyNotification The notification to remove
236 void RemovePropertyNotification( PropertyNotification* propertyNotification );
239 * Set Notify state for PropertyNotification
240 * @param[in] propertyNotification The notification to remove
241 * @param[in] notifyMode The notification mode.
243 void PropertyNotificationSetNotify( PropertyNotification* propertyNotification, PropertyNotification::NotifyMode notifyMode );
246 * @brief Get the renderer owner
248 * @return The renderer owner
250 ObjectOwnerContainer< Renderer >& GetRendererOwner();
253 * @brief Get the property buffer owner
255 * @return The property buffer owner
257 ObjectOwnerContainer< PropertyBuffer >& GetPropertyBufferOwner();
263 * Add a newly created shader.
264 * @param[in] shader The shader to add.
265 * @post The shader is owned by the UpdateManager.
267 void AddShader(Shader* shader);
271 * @pre The shader has been added to the UpdateManager.
272 * @param[in] shader The shader to remove.
273 * @post The shader is destroyed.
275 void RemoveShader(Shader* shader);
278 * Add a newly created TextureSet.
279 * @param[in] textureSet The texture set to add.
280 * @post The TextureSet is owned by the UpdateManager.
282 void AddTextureSet(TextureSet* textureSet);
285 * Remove a TextureSet.
286 * @pre The TextureSet has been added to the UpdateManager.
287 * @param[in] textureSet The TextureSet to remove.
288 * @post The TextureSet is destroyed.
290 void RemoveTextureSet(TextureSet* textureSet);
293 * Set the shader program for a Shader object
294 * @param[in] shader The shader to modify
295 * @param[in] shaderData Source code, hash over source, and optional compiled binary for the shader program
296 * @param[in] modifiesGeometry True if the vertex shader modifies geometry
298 void SetShaderProgram( Shader* shader, Internal::ShaderDataPtr shaderData, bool modifiesGeometry );
301 * @brief Accept compiled shaders passed back on render thread for saving.
302 * @param[in] shaderData Source code, hash over source, and corresponding compiled binary to be saved.
304 virtual void SaveBinary( Internal::ShaderDataPtr shaderData );
307 * @brief Set the destination for compiled shader binaries to be passed on to.
308 * The dispatcher passed in will be called from the update thread.
309 * @param[in] upstream A sink for ShaderDatas to be passed into.
311 void SetShaderSaver( ShaderSaver& upstream );
316 * Add a newly created gesture.
317 * @param[in] gesture The gesture to add.
318 * @post The gesture is owned by the UpdateManager.
320 void AddGesture( PanGesture* gesture );
324 * @pre The gesture has been added to the UpdateManager.
325 * @param[in] gesture The gesture to remove.
326 * @post The gesture is destroyed.
328 void RemoveGesture( PanGesture* gesture );
330 // Message queue handling
333 * Reserve space for another message in the queue; this must then be initialized by the caller.
334 * The message will be read from the update-thread after the next FlushMessages is called.
335 * @post Calling this method may invalidate any previously returned slots.
336 * @param[in] size The message size with respect to the size of type "char".
337 * @param[in] updateScene A flag, when true denotes that the message will cause the scene-graph node tree to require an update.
338 * @note the default value of updateScene should match that in EventThreadServices::ReserveMessageSlot.
339 * @return A pointer to the first char allocated for the message.
341 unsigned int* ReserveMessageSlot( std::size_t size, bool updateScene = true );
344 * @return the current event-buffer index.
346 BufferIndex GetEventBufferIndex() const
348 // inlined as its called often from event thread
349 return mSceneGraphBuffers.GetEventBufferIndex();
353 * Called by the event-thread to signal that FlushQueue will be called
354 * e.g. when it has finished event processing.
356 void EventProcessingStarted();
359 * Flush the set of messages, which were previously stored with QueueMessage().
360 * Calls to this thread-safe method should be minimized, to avoid thread blocking.
362 * @return True if there are messages to process.
367 * Add a new sampler to RenderManager
368 * @param[in] sampler The sampler to add
369 * @post Sends a message to RenderManager to add the sampler.
370 * The sampler will be owned by RenderManager
372 void AddSampler( Render::Sampler* sampler );
375 * Removes an existing sampler from RenderManager
376 * @param[in] sampler The sampler to remove
377 * @post The sampler will be destroyed in the render thread
379 void RemoveSampler( Render::Sampler* sampler );
382 * Sets the filter modes for an existing sampler
383 * @param[in] sampler The sampler
384 * @param[in] minFilterMode The filter to use under minification
385 * @param[in] magFilterMode The filter to use under magnification
387 void SetFilterMode( Render::Sampler* sampler, unsigned int minFilterMode, unsigned int magFilterMode );
390 * Sets the wrap mode for an existing sampler
391 * @param[in] sampler The sampler
392 * @param[in] uWrapMode Wrapping mode in x direction
393 * @param[in] vWrapMode Wrapping mode in y direction
395 void SetWrapMode( Render::Sampler* sampler, unsigned int uWrapMode, unsigned int vWrapMode );
398 * Add a new property buffer to RenderManager
399 * @param[in] propertryBuffer The property buffer to add
400 * @post Sends a message to RenderManager to add the property buffer.
401 * The property buffer will be owned by RenderManager
403 void AddPropertyBuffer( Render::PropertyBuffer* propertryBuffer );
406 * Removes an existing PropertyBuffer from RenderManager
407 * @param[in] propertryBuffer The property buffer to remove
408 * @post The property buffer will be destroyed in the render thread
410 void RemovePropertyBuffer( Render::PropertyBuffer* propertryBuffer );
413 * Sets the format of an existing property buffer
414 * @param[in] propertyBuffer The property buffer.
415 * @param[in] format The new format of the buffer
416 * @post Sends a message to RenderManager to set the new format to the property buffer.
418 void SetPropertyBufferFormat(Render::PropertyBuffer* propertyBuffer, Render::PropertyBuffer::Format* format );
421 * Sets the data of an existing property buffer
422 * @param[in] propertyBuffer The property buffer.
423 * @param[in] data The new data of the buffer
424 * @param[in] size The new size of the buffer
425 * @post Sends a message to RenderManager to set the new data to the property buffer.
427 void SetPropertyBufferData(Render::PropertyBuffer* propertyBuffer, Dali::Vector<char>* data, size_t size);
430 * Adds a geometry to the RenderManager
431 * @param[in] geometry The geometry to add
432 * @post Sends a message to RenderManager to add the Geometry
433 * The geometry will be owned by RenderManager
435 void AddGeometry( Render::Geometry* geometry );
438 * Removes an existing Geometry from RenderManager
439 * @param[in] geometry The geometry to remove
440 * @post The geometry will be destroyed in the render thread
442 void RemoveGeometry( Render::Geometry* geometry );
445 * Sets the geometry type of an existing Geometry
446 * @param[in] geometry The geometry
447 * @param[in] geometryType The type of the geometry
449 void SetGeometryType( Render::Geometry* geometry, unsigned int geometryType );
452 * Sets the index buffer to be used by a geometry
453 * @param[in] geometry The geometry
454 * @param[in] indices A vector containing the indices for the geometry
456 void SetIndexBuffer( Render::Geometry* geometry, Dali::Vector<unsigned short>& indices );
459 * Adds a vertex buffer to a geomtry
460 * @param[in] geometry The geometry
461 * @param[in] propertyBuffer The property buffer
463 void AddVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer );
466 * Removes a vertex buffer from a geometry
467 * @param[in] geometry The geometry
468 * @param[in] propertyBuffer The property buffer
470 void RemoveVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer );
476 * Performs an Update traversal on the scene-graph.
477 * @param[in] elapsedSeconds The elapsed time that should be applied to animations.
478 * @param[in] lastVSyncTimeMilliseconds The last time, in milliseconds, that we had a VSync.
479 * @param[in] nextVSyncTimeMilliseconds The estimated time, in milliseconds, of the next VSync.
480 * @return True if further updates are required e.g. during animations.
482 unsigned int Update( float elapsedSeconds, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds );
485 * Set the background color i.e. the glClear color used at the beginning of each frame.
486 * @param[in] color The new background color.
488 void SetBackgroundColor(const Vector4& color);
491 * Set the default surface rect.
492 * @param[in] rect The rect value representing the surface.
494 void SetDefaultSurfaceRect( const Rect<int>& rect );
497 * @copydoc Dali::Stage::KeepRendering()
499 void KeepRendering( float durationSeconds );
502 * Sets the depths of all layers.
503 * @param layers The layers in depth order.
504 * @param[in] systemLevel True if using the system-level overlay.
506 void SetLayerDepths( const std::vector< Layer* >& layers, bool systemLevel );
511 UpdateManager(const UpdateManager&);
514 UpdateManager& operator=(const UpdateManager& rhs);
517 * Helper to check whether the update-thread should keep going.
518 * @param[in] elapsedSeconds The time in seconds since the previous update.
519 * @return True if the update-thread should keep going.
521 unsigned int KeepUpdatingCheck( float elapsedSeconds ) const;
524 * Helper to calculate new camera setup when root node resizes.
525 * @param[in] updateBuffer The buffer to read the root node size from.
527 void UpdateProjectionAndViewMatrices(int updateBuffer);
530 * Post process resources that have been updated by renderer
532 void PostProcessResources();
535 * Helper to reset all Node properties
536 * @param[in] bufferIndex to use
538 void ResetProperties( BufferIndex bufferIndex );
541 * Perform gesture updates.
542 * @param[in] bufferIndex to use
543 * @param[in] lastVSyncTime The last VSync time in milliseconds.
544 * @param[in] nextVSyncTime The estimated time of the next VSync in milliseconds.
545 * @return true, if any properties were updated.
547 bool ProcessGestures( BufferIndex bufferIndex, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds );
550 * Perform animation updates
551 * @param[in] bufferIndex to use
552 * @param[in] elapsedSeconds time since last frame
554 void Animate( BufferIndex bufferIndex, float elapsedSeconds );
557 * Applies constraints to CustomObjects
558 * @param[in] bufferIndex to use
560 void ConstrainCustomObjects( BufferIndex bufferIndex );
563 * Applies constraints to RenderTasks
564 * @param[in] bufferIndex to use
566 void ConstrainRenderTasks( BufferIndex bufferIndex );
569 * Applies constraints to Shaders
570 * @param[in] bufferIndex to use
572 void ConstrainShaders( BufferIndex bufferIndex );
575 * Perform property notification updates
576 * @param[in] bufferIndex to use
578 void ProcessPropertyNotifications( BufferIndex bufferIndex );
581 * Prepare textures for rendering
583 void PrepareTextureSets( BufferIndex bufferIndex );
586 * Pass shader binaries queued here on to event thread.
588 void ForwardCompiledShadersToEventThread();
591 * Update the default camera.
592 * This must be altered to match the root Node for 2D layouting.
593 * @param[in] updateBuffer The buffer to read the root node size from.
595 void UpdateDefaultCamera( int updateBuffer );
598 * Update node shaders, opacity, geometry etc.
599 * @param[in] bufferIndex to use
601 void UpdateNodes( BufferIndex bufferIndex );
605 * @param[in] bufferIndex to use
607 void UpdateRenderers( BufferIndex bufferIndex );
611 // needs to be direct member so that getter for event buffer can be inlined
612 SceneGraphBuffers mSceneGraphBuffers;
619 // Messages for UpdateManager
621 inline void InstallRootMessage( UpdateManager& manager, Layer& root, bool systemLevel )
623 typedef MessageValue2< UpdateManager, Layer*, bool > 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::InstallRoot, &root, systemLevel );
632 inline void AddNodeMessage( UpdateManager& manager, Node& node )
634 typedef MessageValue1< UpdateManager, OwnerPointer<Node> > LocalType;
636 // Reserve some memory inside the message queue
637 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
639 // Construct message in the message queue memory; note that delete should not be called on the return value
640 new (slot) LocalType( &manager, &UpdateManager::AddNode, &node );
643 inline void ConnectNodeMessage( UpdateManager& manager, const Node& constParent, const Node& constChild )
645 // Update thread can edit the object
646 Node& parent = const_cast< Node& >( constParent );
647 Node& child = const_cast< Node& >( constChild );
649 typedef MessageValue2< UpdateManager, Node*, Node* > LocalType;
651 // Reserve some memory inside the message queue
652 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
654 // Construct message in the message queue memory; note that delete should not be called on the return value
655 new (slot) LocalType( &manager, &UpdateManager::ConnectNode, &parent, &child );
658 inline void DisconnectNodeMessage( UpdateManager& manager, const Node& constNode )
660 // Scene graph thread can modify this object.
661 Node& node = const_cast< Node& >( constNode );
663 typedef MessageValue1< UpdateManager, Node* > LocalType;
665 // Reserve some memory inside the message queue
666 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
668 // Construct message in the message queue memory; note that delete should not be called on the return value
669 new (slot) LocalType( &manager, &UpdateManager::DisconnectNode, &node );
672 inline void DestroyNodeMessage( UpdateManager& manager, const Node& constNode )
674 // Scene graph thread can destroy this object.
675 Node& node = const_cast< Node& >( constNode );
677 typedef MessageValue1< UpdateManager, Node* > LocalType;
679 // Reserve some memory inside the message queue
680 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
682 // Construct message in the message queue memory; note that delete should not be called on the return value
683 new (slot) LocalType( &manager, &UpdateManager::DestroyNode, &node );
686 inline void AttachToNodeMessage( UpdateManager& manager, const Node& constParent, NodeAttachment* attachment )
688 // Scene graph thread can modify this object.
689 Node& parent = const_cast< Node& >( constParent );
691 typedef MessageValue2< UpdateManager, Node*, NodeAttachmentOwner > 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::AttachToNode, &parent, attachment );
700 inline void AddObjectMessage( UpdateManager& manager, PropertyOwner* object )
702 typedef MessageValue1< UpdateManager, OwnerPointer<PropertyOwner> > LocalType;
704 // Reserve some memory inside the message queue
705 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
707 // Construct message in the message queue memory; note that delete should not be called on the return value
708 new (slot) LocalType( &manager, &UpdateManager::AddObject, object );
711 inline void RemoveObjectMessage( UpdateManager& manager, PropertyOwner* object )
713 typedef MessageValue1< UpdateManager, PropertyOwner* > LocalType;
715 // Reserve some memory inside the message queue
716 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
718 // Construct message in the message queue memory; note that delete should not be called on the return value
719 new (slot) LocalType( &manager, &UpdateManager::RemoveObject, object );
722 inline void AddAnimationMessage( UpdateManager& manager, Animation* animation )
724 typedef MessageValue1< UpdateManager, Animation* > LocalType;
726 // Reserve some memory inside the message queue
727 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
729 // Construct message in the message queue memory; note that delete should not be called on the return value
730 new (slot) LocalType( &manager, &UpdateManager::AddAnimation, animation );
733 inline void StopAnimationMessage( UpdateManager& manager, const Animation& constAnimation )
735 // The scene-graph thread owns this object so it can safely edit it.
736 Animation& animation = const_cast< Animation& >( constAnimation );
738 typedef MessageValue1< UpdateManager, Animation* > LocalType;
740 // Reserve some memory inside the message queue
741 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
743 // Construct message in the message queue memory; note that delete should not be called on the return value
744 new (slot) LocalType( &manager, &UpdateManager::StopAnimation, &animation );
747 inline void RemoveAnimationMessage( UpdateManager& manager, const Animation& constAnimation )
749 // The scene-graph thread owns this object so it can safely edit it.
750 Animation& animation = const_cast< Animation& >( constAnimation );
752 typedef MessageValue1< UpdateManager, Animation* > LocalType;
754 // Reserve some memory inside the message queue
755 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
757 // Construct message in the message queue memory; note that delete should not be called on the return value
758 new (slot) LocalType( &manager, &UpdateManager::RemoveAnimation, &animation );
761 inline void AddPropertyNotificationMessage( UpdateManager& manager, PropertyNotification* propertyNotification )
763 typedef MessageValue1< UpdateManager, PropertyNotification* > LocalType;
765 // Reserve some memory inside the message queue
766 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
768 // Construct message in the message queue memory; note that delete should not be called on the return value
769 new (slot) LocalType( &manager, &UpdateManager::AddPropertyNotification, propertyNotification );
772 inline void RemovePropertyNotificationMessage( UpdateManager& manager, const PropertyNotification& constPropertyNotification )
774 // The scene-graph thread owns this object so it can safely edit it.
775 PropertyNotification& propertyNotification = const_cast< PropertyNotification& >( constPropertyNotification );
777 typedef MessageValue1< UpdateManager, PropertyNotification* > 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::RemovePropertyNotification, &propertyNotification );
786 inline void PropertyNotificationSetNotifyModeMessage( UpdateManager& manager,
787 const PropertyNotification* constPropertyNotification,
788 PropertyNotification::NotifyMode notifyMode )
790 // The scene-graph thread owns this object so it can safely edit it.
791 PropertyNotification* propertyNotification = const_cast< PropertyNotification* >( constPropertyNotification );
793 typedef MessageValue2< UpdateManager, PropertyNotification*, PropertyNotification::NotifyMode > LocalType;
795 // Reserve some memory inside the message queue
796 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
798 // Construct message in the message queue memory; note that delete should not be called on the return value
799 new (slot) LocalType( &manager, &UpdateManager::PropertyNotificationSetNotify, propertyNotification, notifyMode );
802 // The render thread can safely change the Shader
803 inline void AddShaderMessage( UpdateManager& manager, Shader& shader )
805 typedef MessageValue1< UpdateManager, OwnerPointer< Shader > > 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::AddShader, &shader );
814 // The render thread can safely change the Shader
815 inline void RemoveShaderMessage( UpdateManager& manager, Shader& shader )
817 typedef MessageValue1< UpdateManager, Shader* > LocalType;
819 // Reserve some memory inside the message queue
820 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
822 // Construct message in the message queue memory; note that delete should not be called on the return value
823 new (slot) LocalType( &manager, &UpdateManager::RemoveShader, &shader );
826 inline void SetShaderProgramMessage( UpdateManager& manager,
828 Internal::ShaderDataPtr shaderData,
829 bool modifiesGeometry )
831 typedef MessageValue3< UpdateManager, Shader*, Internal::ShaderDataPtr, bool > LocalType;
833 // Reserve some memory inside the message queue
834 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
836 // Construct message in the message queue memory; note that delete should not be called on the return value
837 new (slot) LocalType( &manager, &UpdateManager::SetShaderProgram, &shader, shaderData, modifiesGeometry );
840 inline void SetBackgroundColorMessage( UpdateManager& manager, const Vector4& color )
842 typedef MessageValue1< UpdateManager, Vector4 > LocalType;
844 // Reserve some memory inside the message queue
845 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
847 // Construct message in the message queue memory; note that delete should not be called on the return value
848 new (slot) LocalType( &manager, &UpdateManager::SetBackgroundColor, color );
851 inline void SetDefaultSurfaceRectMessage( UpdateManager& manager, const Rect<int>& rect )
853 typedef MessageValue1< UpdateManager, Rect<int> > LocalType;
855 // Reserve some memory inside the message queue
856 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
858 // Construct message in the message queue memory; note that delete should not be called on the return value
859 new (slot) LocalType( &manager, &UpdateManager::SetDefaultSurfaceRect, rect );
862 inline void KeepRenderingMessage( UpdateManager& manager, float durationSeconds )
864 typedef MessageValue1< UpdateManager, float > LocalType;
866 // Reserve some memory inside the message queue
867 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
869 // Construct message in the message queue memory; note that delete should not be called on the return value
870 new (slot) LocalType( &manager, &UpdateManager::KeepRendering, durationSeconds );
874 * Create a message for setting the depth of a layer
875 * @param[in] manager The update manager
876 * @param[in] layers list of layers
877 * @param[in] systemLevel True if the layers are added via the SystemOverlay API
879 inline void SetLayerDepthsMessage( UpdateManager& manager, const std::vector< Layer* >& layers, bool systemLevel )
881 typedef MessageValue2< UpdateManager, std::vector< Layer* >, bool > LocalType;
883 // Reserve some memory inside the message queue
884 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
886 // Construct message in the message queue memory; note that delete should not be called on the return value
887 new (slot) LocalType( &manager, &UpdateManager::SetLayerDepths, layers, systemLevel );
890 inline void AddGestureMessage( UpdateManager& manager, PanGesture* gesture )
892 typedef MessageValue1< UpdateManager, PanGesture* > LocalType;
894 // Reserve some memory inside the message queue
895 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
897 // Construct message in the message queue memory; note that delete should not be called on the return value
898 new (slot) LocalType( &manager, &UpdateManager::AddGesture, gesture );
901 inline void RemoveGestureMessage( UpdateManager& manager, PanGesture* gesture )
903 typedef MessageValue1< UpdateManager, PanGesture* > LocalType;
905 // Reserve some memory inside the message queue
906 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
908 // Construct message in the message queue memory; note that delete should not be called on the return value
909 new (slot) LocalType( &manager, &UpdateManager::RemoveGesture, gesture );
912 template< typename T >
913 inline void AddMessage( UpdateManager& manager, ObjectOwnerContainer<T>& owner, T& object )
915 typedef MessageValue1< ObjectOwnerContainer<T>, OwnerPointer< T > > LocalType;
917 // Reserve some memory inside the message queue
918 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
919 // Construct message in the message queue memory; note that delete should not be called on the return value
920 new (slot) LocalType( &owner, &ObjectOwnerContainer<T>::Add, &object );
923 template< typename T >
924 inline void RemoveMessage( UpdateManager& manager, ObjectOwnerContainer<T>& owner, T& object )
926 typedef MessageValue1< ObjectOwnerContainer<T>, T* > LocalType;
928 // Reserve some memory inside the message queue
929 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
930 // Construct message in the message queue memory; note that delete should not be called on the return value
931 new (slot) LocalType( &owner, &ObjectOwnerContainer<T>::Remove, &object );
934 // The render thread can safely change the Shader
935 inline void AddTextureSetMessage( UpdateManager& manager, TextureSet& textureSet )
937 typedef MessageValue1< UpdateManager, OwnerPointer< TextureSet > > LocalType;
939 // Reserve some memory inside the message queue
940 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
942 // Construct message in the message queue memory; note that delete should not be called on the return value
943 new (slot) LocalType( &manager, &UpdateManager::AddTextureSet, &textureSet );
946 // The render thread can safely change the Shader
947 inline void RemoveTextureSetMessage( UpdateManager& manager, TextureSet& textureSet )
949 typedef MessageValue1< UpdateManager, TextureSet* > LocalType;
951 // Reserve some memory inside the message queue
952 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
954 // Construct message in the message queue memory; note that delete should not be called on the return value
955 new (slot) LocalType( &manager, &UpdateManager::RemoveTextureSet, &textureSet );
958 inline void AddSamplerMessage( UpdateManager& manager, Render::Sampler& sampler )
960 typedef MessageValue1< UpdateManager, Render::Sampler* > LocalType;
962 // Reserve some memory inside the message queue
963 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
965 // Construct message in the message queue memory; note that delete should not be called on the return value
966 new (slot) LocalType( &manager, &UpdateManager::AddSampler, &sampler );
969 inline void RemoveSamplerMessage( UpdateManager& manager, Render::Sampler& sampler )
971 typedef MessageValue1< UpdateManager, Render::Sampler* > LocalType;
973 // Reserve some memory inside the message queue
974 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
976 // Construct message in the message queue memory; note that delete should not be called on the return value
977 new (slot) LocalType( &manager, &UpdateManager::RemoveSampler, &sampler );
980 inline void SetFilterModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int minFilterMode, unsigned int magFilterMode )
982 typedef MessageValue3< UpdateManager, Render::Sampler*, unsigned int, unsigned int > LocalType;
984 // Reserve some memory inside the message queue
985 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
987 // Construct message in the message queue memory; note that delete should not be called on the return value
988 new (slot) LocalType( &manager, &UpdateManager::SetFilterMode, &sampler, minFilterMode, magFilterMode );
991 inline void SetWrapModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int uWrapMode, unsigned int vWrapMode )
993 typedef MessageValue3< UpdateManager, Render::Sampler*, unsigned int, unsigned int > LocalType;
995 // Reserve some memory inside the message queue
996 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
998 // Construct message in the message queue memory; note that delete should not be called on the return value
999 new (slot) LocalType( &manager, &UpdateManager::SetWrapMode, &sampler, uWrapMode, vWrapMode );
1002 inline void AddPropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer )
1004 typedef MessageValue1< UpdateManager, Render::PropertyBuffer* > LocalType;
1006 // Reserve some memory inside the message queue
1007 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1009 // Construct message in the message queue memory; note that delete should not be called on the return value
1010 new (slot) LocalType( &manager, &UpdateManager::AddPropertyBuffer, &propertyBuffer );
1013 inline void RemovePropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer )
1015 typedef MessageValue1< UpdateManager, Render::PropertyBuffer* > LocalType;
1017 // Reserve some memory inside the message queue
1018 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1020 // Construct message in the message queue memory; note that delete should not be called on the return value
1021 new (slot) LocalType( &manager, &UpdateManager::RemovePropertyBuffer, &propertyBuffer );
1024 inline void SetPropertyBufferFormat( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, Render::PropertyBuffer::Format* format )
1026 typedef MessageValue2< UpdateManager, Render::PropertyBuffer*, Render::PropertyBuffer::Format* > LocalType;
1028 // Reserve some memory inside the message queue
1029 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1031 // Construct message in the message queue memory; note that delete should not be called on the return value
1032 new (slot) LocalType( &manager, &UpdateManager::SetPropertyBufferFormat, &propertyBuffer, format );
1035 inline void SetPropertyBufferData( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, Vector<char>* data, size_t size )
1037 typedef MessageValue3< UpdateManager, Render::PropertyBuffer*, Vector<char>*, size_t > LocalType;
1039 // Reserve some memory inside the message queue
1040 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1042 // Construct message in the message queue memory; note that delete should not be called on the return value
1043 new (slot) LocalType( &manager, &UpdateManager::SetPropertyBufferData, &propertyBuffer, data, size );
1046 inline void AddGeometry( UpdateManager& manager, Render::Geometry& geometry )
1048 typedef MessageValue1< UpdateManager, Render::Geometry* > LocalType;
1050 // Reserve some memory inside the message queue
1051 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1053 // Construct message in the message queue memory; note that delete should not be called on the return value
1054 new (slot) LocalType( &manager, &UpdateManager::AddGeometry, &geometry );
1057 inline void RemoveGeometry( UpdateManager& manager, Render::Geometry& geometry )
1059 typedef MessageValue1< UpdateManager, Render::Geometry* > LocalType;
1061 // Reserve some memory inside the message queue
1062 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1064 // Construct message in the message queue memory; note that delete should not be called on the return value
1065 new (slot) LocalType( &manager, &UpdateManager::RemoveGeometry, &geometry );
1068 inline void AddVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer )
1070 typedef MessageValue2< UpdateManager, Render::Geometry*, Render::PropertyBuffer* > LocalType;
1072 // Reserve some memory inside the message queue
1073 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1075 // Construct message in the message queue memory; note that delete should not be called on the return value
1076 new (slot) LocalType( &manager, &UpdateManager::AddVertexBuffer, &geometry, const_cast<Render::PropertyBuffer*>(&vertexBuffer) );
1079 inline void RemoveVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer )
1081 typedef MessageValue2< UpdateManager, Render::Geometry*, Render::PropertyBuffer* > LocalType;
1083 // Reserve some memory inside the message queue
1084 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1086 // Construct message in the message queue memory; note that delete should not be called on the return value
1087 new (slot) LocalType( &manager, &UpdateManager::RemoveVertexBuffer, &geometry, const_cast<Render::PropertyBuffer*>(&vertexBuffer) );
1090 // Custom message type for SetIndexBuffer() used to move data with Vector::Swap()
1091 template< typename T >
1092 class IndexBufferMessage : public MessageBase
1097 * Constructor which does a Vector::Swap()
1099 IndexBufferMessage( T* manager, Render::Geometry* geometry, Dali::Vector<unsigned short>& indices )
1101 mManager( manager ),
1102 mRenderGeometry( geometry )
1104 mIndices.Swap( indices );
1108 * Virtual destructor
1110 virtual ~IndexBufferMessage()
1115 * @copydoc MessageBase::Process
1117 virtual void Process( BufferIndex /*bufferIndex*/ )
1119 DALI_ASSERT_DEBUG( mManager && "Message does not have an object" );
1120 mManager->SetIndexBuffer( mRenderGeometry, mIndices );
1126 Render::Geometry* mRenderGeometry;
1127 Dali::Vector<unsigned short> mIndices;
1130 inline void SetIndexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, Dali::Vector<unsigned short>& indices )
1132 typedef IndexBufferMessage< UpdateManager > 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, &geometry, indices );
1141 inline void SetGeometryTypeMessage( UpdateManager& manager, Render::Geometry& geometry, unsigned int geometryType )
1143 typedef MessageValue2< UpdateManager, Render::Geometry*, unsigned int > LocalType;
1145 // Reserve some memory inside the message queue
1146 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1148 // Construct message in the message queue memory; note that delete should not be called on the return value
1149 new (slot) LocalType( &manager, &UpdateManager::SetGeometryType, &geometry, geometryType );
1152 } // namespace SceneGraph
1154 } // namespace Internal
1158 #endif // __DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H__