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/update/gestures/scene-graph-pan-gesture.h>
39 #include <dali/internal/update/render-tasks/scene-graph-camera.h>
40 #include <dali/internal/render/shaders/scene-graph-shader.h>
41 #include <dali/internal/render/renderers/render-property-buffer.h>
42 #include <dali/internal/event/rendering/texture-impl.h>
49 class GlSyncAbstraction;
50 class RenderController;
52 } // namespace Integration
57 class PropertyNotifier;
58 class NotificationManager;
59 class CompleteNotificationInterface;
67 // value types used by messages
68 template <> struct ParameterType< PropertyNotification::NotifyMode >
69 : public BasicType< PropertyNotification::NotifyMode > {};
78 class RenderTaskProcessor;
85 SceneGraph::Node* node;
87 NodeDepthPair( SceneGraph::Node* node, uint32_t sortedDepth )
89 sortedDepth(sortedDepth)
96 std::vector<NodeDepthPair> nodeDepths;
97 NodeDepths( int reserveSize )
99 nodeDepths.reserve(reserveSize);
102 void Add( SceneGraph::Node* node, uint32_t sortedDepth )
104 nodeDepths.push_back( NodeDepthPair( node, sortedDepth ) );
110 * UpdateManager maintains a scene graph i.e. a tree of nodes as well as
111 * other scene graph property owning objects.
112 * It controls the Update traversal, in which nodes are repositioned/animated,
113 * and organizes the the culling and rendering of the scene.
114 * It also maintains the lifecycle of nodes and other property owners that are
115 * disconnected from the scene graph.
117 class UpdateManager : public ShaderSaver
122 * Construct a new UpdateManager.
123 * @param[in] notificationManager This should be notified when animations have finished.
124 * @param[in] animationFinishedNotifier The CompleteNotificationInterface that handles animation completions
125 * @param[in] propertyNotifier The PropertyNotifier
126 * @param[in] discardQueue Nodes are added here when disconnected from the scene-graph.
127 * @param[in] controller After messages are flushed, we request a render from the RenderController.
128 * @param[in] renderManager This is responsible for rendering the results of each "update".
129 * @param[in] renderQueue Used to queue messages for the next render.
130 * @param[in] renderTaskProcessor Handles RenderTasks and RenderInstrucitons.
132 UpdateManager( NotificationManager& notificationManager,
133 CompleteNotificationInterface& animationFinishedNotifier,
134 PropertyNotifier& propertyNotifier,
135 DiscardQueue& discardQueue,
136 Integration::RenderController& controller,
137 RenderManager& renderManager,
138 RenderQueue& renderQueue,
139 RenderTaskProcessor& renderTaskProcessor );
144 virtual ~UpdateManager();
146 // Node connection methods
149 * Get the scene graph side list of RenderTasks.
150 * @param[in] systemLevel True if using the system-level overlay.
151 * @return The list of render tasks
153 RenderTaskList* GetRenderTaskList( bool systemLevel );
156 * Installs a new layer as the root node.
157 * @pre The UpdateManager does not already have an installed root node.
158 * @pre The layer is of derived Node type Layer.
159 * @pre The layer does not have a parent.
160 * @param[in] layer The new root node.
161 * @param[in] systemLevel True if using the system-level overlay.
162 * @post The node is owned by UpdateManager.
164 void InstallRoot( Layer* layer, bool systemLevel );
167 * Add a Node; UpdateManager takes ownership.
168 * @pre The node does not have a parent.
169 * @param[in] node The node to add.
171 void AddNode( Node* node );
174 * Connect a Node to the scene-graph.
175 * A disconnected Node has has no parent or children, and its properties cannot be animated/constrained.
176 * @pre The node does not already have a parent.
177 * @param[in] parent The new parent node.
179 void ConnectNode( Node* parent, Node* node );
182 * Disconnect a Node from the scene-graph.
183 * A disconnected Node has has no parent or children, and its properties cannot be animated/constrained.
184 * @pre The node has a parent.
185 * @param[in] node The node to disconnect.
187 void DisconnectNode( Node* node );
190 * Destroy a Node owned by UpdateManager.
191 * This is not immediate; Nodes are passed to the RenderQueue to allow GL resources to be deleted.
192 * In the following update, the previously queued Nodes may be deleted.
193 * @pre The node has been disconnected from the scene-graph i.e. has no parent or children.
194 * @param[in] node The node to destroy.
196 void DestroyNode( Node* node );
199 * Add a camera on scene
200 * @param[in] camera to add
202 void AddCamera( Camera* camera );
205 * Remove a camera from scene
206 * @param[in] camera to remove
208 void RemoveCamera( const Camera* camera );
211 * Add a newly created object.
212 * @param[in] object The object to add.
213 * @post The object is owned by UpdateManager.
215 void AddObject( PropertyOwner* object );
219 * @param[in] object The object to remove.
221 void RemoveObject( PropertyOwner* object );
226 * Add a newly created animation.
227 * @param[in] animation The animation to add.
228 * @post The animation is owned by UpdateManager.
230 void AddAnimation( Animation* animation );
234 * @param[in] animation The animation to stop.
236 void StopAnimation( Animation* animation );
239 * Remove an animation.
240 * @param[in] animation The animation to remove.
242 void RemoveAnimation( Animation* animation );
245 * Query whether any animations are currently running.
246 * @return True if any animations are running.
248 bool IsAnimationRunning() const;
250 // Property Notification
253 * Add a newly created property notification
254 * @param[in] propertyNotification The notification to add
255 * @post The propertyNotification is owned by UpdateManager.
257 void AddPropertyNotification( PropertyNotification* propertyNotification );
260 * Remove a property notification
261 * @param[in] propertyNotification The notification to remove
263 void RemovePropertyNotification( PropertyNotification* propertyNotification );
266 * Set Notify state for PropertyNotification
267 * @param[in] propertyNotification The notification to remove
268 * @param[in] notifyMode The notification mode.
270 void PropertyNotificationSetNotify( PropertyNotification* propertyNotification, PropertyNotification::NotifyMode notifyMode );
273 * @brief Get the renderer owner
275 * @return The renderer owner
277 ObjectOwnerContainer< Renderer >& GetRendererOwner();
280 * @brief Get the property buffer owner
282 * @return The property buffer owner
284 ObjectOwnerContainer< PropertyBuffer >& GetPropertyBufferOwner();
290 * Add a newly created shader.
291 * @param[in] shader The shader to add.
292 * @post The shader is owned by the UpdateManager.
294 void AddShader(Shader* shader);
298 * @pre The shader has been added to the UpdateManager.
299 * @param[in] shader The shader to remove.
300 * @post The shader is destroyed.
302 void RemoveShader(Shader* shader);
305 * Add a newly created TextureSet.
306 * @param[in] textureSet The texture set to add.
307 * @post The TextureSet is owned by the UpdateManager.
309 void AddTextureSet(TextureSet* textureSet);
312 * Remove a TextureSet.
313 * @pre The TextureSet has been added to the UpdateManager.
314 * @param[in] textureSet The TextureSet to remove.
315 * @post The TextureSet is destroyed.
317 void RemoveTextureSet(TextureSet* textureSet);
320 * Set the shader program for a Shader object
321 * @param[in] shader The shader to modify
322 * @param[in] shaderData Source code, hash over source, and optional compiled binary for the shader program
323 * @param[in] modifiesGeometry True if the vertex shader modifies geometry
325 void SetShaderProgram( Shader* shader, Internal::ShaderDataPtr shaderData, bool modifiesGeometry );
328 * @brief Accept compiled shaders passed back on render thread for saving.
329 * @param[in] shaderData Source code, hash over source, and corresponding compiled binary to be saved.
331 virtual void SaveBinary( Internal::ShaderDataPtr shaderData );
334 * @brief Set the destination for compiled shader binaries to be passed on to.
335 * The dispatcher passed in will be called from the update thread.
336 * @param[in] upstream A sink for ShaderDatas to be passed into.
338 void SetShaderSaver( ShaderSaver& upstream );
343 * Add a newly created gesture.
344 * @param[in] gesture The gesture to add.
345 * @post The gesture is owned by the UpdateManager.
347 void AddGesture( PanGesture* gesture );
351 * @pre The gesture has been added to the UpdateManager.
352 * @param[in] gesture The gesture to remove.
353 * @post The gesture is destroyed.
355 void RemoveGesture( PanGesture* gesture );
357 // Message queue handling
360 * Reserve space for another message in the queue; this must then be initialized by the caller.
361 * The message will be read from the update-thread after the next FlushMessages is called.
362 * @post Calling this method may invalidate any previously returned slots.
363 * @param[in] size The message size with respect to the size of type "char".
364 * @param[in] updateScene A flag, when true denotes that the message will cause the scene-graph node tree to require an update.
365 * @note the default value of updateScene should match that in EventThreadServices::ReserveMessageSlot.
366 * @return A pointer to the first char allocated for the message.
368 unsigned int* ReserveMessageSlot( std::size_t size, bool updateScene = true );
371 * @return the current event-buffer index.
373 BufferIndex GetEventBufferIndex() const
375 // inlined as its called often from event thread
376 return mSceneGraphBuffers.GetEventBufferIndex();
380 * Called by the event-thread to signal that FlushQueue will be called
381 * e.g. when it has finished event processing.
383 void EventProcessingStarted();
386 * Flush the set of messages, which were previously stored with QueueMessage().
387 * Calls to this thread-safe method should be minimized, to avoid thread blocking.
389 * @return True if there are messages to process.
394 * Add a new sampler to RenderManager
395 * @param[in] sampler The sampler to add
396 * @post Sends a message to RenderManager to add the sampler.
397 * The sampler will be owned by RenderManager
399 void AddSampler( Render::Sampler* sampler );
402 * Removes an existing sampler from RenderManager
403 * @param[in] sampler The sampler to remove
404 * @post The sampler will be destroyed in the render thread
406 void RemoveSampler( Render::Sampler* sampler );
409 * Sets the filter modes for an existing sampler
410 * @param[in] sampler The sampler
411 * @param[in] minFilterMode The filter to use under minification
412 * @param[in] magFilterMode The filter to use under magnification
414 void SetFilterMode( Render::Sampler* sampler, unsigned int minFilterMode, unsigned int magFilterMode );
417 * Sets the wrap mode for an existing sampler
418 * @param[in] sampler The sampler
419 * @param[in] rWrapMode Wrapping mode in z direction
420 * @param[in] sWrapMode Wrapping mode in x direction
421 * @param[in] tWrapMode Wrapping mode in y direction
423 void SetWrapMode( Render::Sampler* sampler, unsigned int rWrapMode, unsigned int sWrapMode, unsigned int tWrapMode );
426 * Add a new property buffer to RenderManager
427 * @param[in] propertryBuffer The property buffer to add
428 * @post Sends a message to RenderManager to add the property buffer.
429 * The property buffer will be owned by RenderManager
431 void AddPropertyBuffer( Render::PropertyBuffer* propertryBuffer );
434 * Removes an existing PropertyBuffer from RenderManager
435 * @param[in] propertryBuffer The property buffer to remove
436 * @post The property buffer will be destroyed in the render thread
438 void RemovePropertyBuffer( Render::PropertyBuffer* propertryBuffer );
441 * Sets the format of an existing property buffer
442 * @param[in] propertyBuffer The property buffer.
443 * @param[in] format The new format of the buffer
444 * @post Sends a message to RenderManager to set the new format to the property buffer.
446 void SetPropertyBufferFormat(Render::PropertyBuffer* propertyBuffer, Render::PropertyBuffer::Format* format );
449 * Sets the data of an existing property buffer
450 * @param[in] propertyBuffer The property buffer.
451 * @param[in] data The new data of the buffer
452 * @param[in] size The new size of the buffer
453 * @post Sends a message to RenderManager to set the new data to the property buffer.
455 void SetPropertyBufferData(Render::PropertyBuffer* propertyBuffer, Dali::Vector<char>* data, size_t size);
458 * Adds a geometry to the RenderManager
459 * @param[in] geometry The geometry to add
460 * @post Sends a message to RenderManager to add the Geometry
461 * The geometry will be owned by RenderManager
463 void AddGeometry( Render::Geometry* geometry );
466 * Removes an existing Geometry from RenderManager
467 * @param[in] geometry The geometry to remove
468 * @post The geometry will be destroyed in the render thread
470 void RemoveGeometry( Render::Geometry* geometry );
473 * Sets the geometry type of an existing Geometry
474 * @param[in] geometry The geometry
475 * @param[in] geometryType The type of the geometry
477 void SetGeometryType( Render::Geometry* geometry, unsigned int geometryType );
480 * Sets the index buffer to be used by a geometry
481 * @param[in] geometry The geometry
482 * @param[in] indices A vector containing the indices for the geometry
484 void SetIndexBuffer( Render::Geometry* geometry, Dali::Vector<unsigned short>& indices );
487 * Adds a vertex buffer to a geomtry
488 * @param[in] geometry The geometry
489 * @param[in] propertyBuffer The property buffer
491 void AddVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer );
494 * Removes a vertex buffer from a geometry
495 * @param[in] geometry The geometry
496 * @param[in] propertyBuffer The property buffer
498 void RemoveVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer );
501 * Adds a texture to the render manager
502 * @param[in] texture The texture to add
503 * The texture will be owned by RenderManager
505 void AddTexture( Render::Texture* texture );
508 * Removes a texture from the render manager
509 * @param[in] texture The texture to remove
510 * @post The texture will be destroyed in the render thread
512 void RemoveTexture( Render::Texture* texture );
515 * Uploads data to a texture owned by the RenderManager
516 * @param[in] texture The texture
517 * @param[in] pixelData The pixel data object
518 * @param[in] params The parameters for the upload
520 void UploadTexture( Render::Texture* texture, PixelDataPtr pixelData, const Texture::UploadParams& params );
523 * Generates mipmaps for a texture owned by the RenderManager
524 * @param[in] texture The texture
526 void GenerateMipmaps( Render::Texture* texture );
529 * Adds a framebuffer to the render manager
530 * @param[in] frameBuffer The framebuffer to add
531 * The framebuffer will be owned by RenderManager
533 void AddFrameBuffer( Render::FrameBuffer* frameBuffer );
536 * Removes a FrameBuffer from the render manager
537 * @param[in] frameBuffer The FrameBuffer to remove
538 * @post The FrameBuffer will be destroyed in the render thread
540 void RemoveFrameBuffer( Render::FrameBuffer* frameBuffer );
543 * Attach a texture as color output to an existing FrameBuffer
544 * @param[in] frameBuffer The FrameBuffer
545 * @param[in] texture The texture that will be used as output when rendering
546 * @param[in] mipmapLevel The mipmap of the texture to be attached
547 * @param[in] layer Indicates which layer of a cube map or array texture to attach. Unused for 2D textures
549 void AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::Texture* texture, unsigned int mipmapLevel, unsigned int face );
554 * Performs an Update traversal on the scene-graph.
555 * @param[in] elapsedSeconds The elapsed time that should be applied to animations.
556 * @param[in] lastVSyncTimeMilliseconds The last time, in milliseconds, that we had a VSync.
557 * @param[in] nextVSyncTimeMilliseconds The estimated time, in milliseconds, of the next VSync.
558 * @return True if further updates are required e.g. during animations.
560 unsigned int Update( float elapsedSeconds, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds );
563 * Set the background color i.e. the glClear color used at the beginning of each frame.
564 * @param[in] color The new background color.
566 void SetBackgroundColor(const Vector4& color);
569 * Set the default surface rect.
570 * @param[in] rect The rect value representing the surface.
572 void SetDefaultSurfaceRect( const Rect<int>& rect );
575 * @copydoc Dali::Stage::KeepRendering()
577 void KeepRendering( float durationSeconds );
580 * Sets the depths of all layers.
581 * @param layers The layers in depth order.
582 * @param[in] systemLevel True if using the system-level overlay.
584 void SetLayerDepths( const std::vector< Layer* >& layers, bool systemLevel );
587 * Set the depth indices of all nodes (in LayerUI's)
588 * @param[in] nodeDepths A vector of nodes and associated depth indices
590 void SetDepthIndices( NodeDepths* nodeDepths );
595 UpdateManager(const UpdateManager&);
598 UpdateManager& operator=(const UpdateManager& rhs);
601 * Helper to check whether the update-thread should keep going.
602 * @param[in] elapsedSeconds The time in seconds since the previous update.
603 * @return True if the update-thread should keep going.
605 unsigned int KeepUpdatingCheck( float elapsedSeconds ) const;
608 * Post process resources that have been updated by renderer
610 void PostProcessResources();
613 * Helper to reset all Node properties
614 * @param[in] bufferIndex to use
616 void ResetProperties( BufferIndex bufferIndex );
619 * Perform gesture updates.
620 * @param[in] bufferIndex to use
621 * @param[in] lastVSyncTime The last VSync time in milliseconds.
622 * @param[in] nextVSyncTime The estimated time of the next VSync in milliseconds.
623 * @return true, if any properties were updated.
625 bool ProcessGestures( BufferIndex bufferIndex, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds );
628 * Perform animation updates
629 * @param[in] bufferIndex to use
630 * @param[in] elapsedSeconds time since last frame
632 void Animate( BufferIndex bufferIndex, float elapsedSeconds );
635 * Applies constraints to CustomObjects
636 * @param[in] bufferIndex to use
638 void ConstrainCustomObjects( BufferIndex bufferIndex );
641 * Applies constraints to RenderTasks
642 * @param[in] bufferIndex to use
644 void ConstrainRenderTasks( BufferIndex bufferIndex );
647 * Applies constraints to Shaders
648 * @param[in] bufferIndex to use
650 void ConstrainShaders( BufferIndex bufferIndex );
653 * Perform property notification updates
654 * @param[in] bufferIndex to use
656 void ProcessPropertyNotifications( BufferIndex bufferIndex );
659 * Pass shader binaries queued here on to event thread.
661 void ForwardCompiledShadersToEventThread();
664 * Update node shaders, opacity, geometry etc.
665 * @param[in] bufferIndex to use
667 void UpdateNodes( BufferIndex bufferIndex );
671 * @param[in] bufferIndex to use
673 void UpdateRenderers( BufferIndex bufferIndex );
677 // needs to be direct member so that getter for event buffer can be inlined
678 SceneGraphBuffers mSceneGraphBuffers;
685 // Messages for UpdateManager
687 inline void InstallRootMessage( UpdateManager& manager, Layer& root, bool systemLevel )
689 // Message has ownership of Layer while in transit from event -> update
690 typedef MessageValue2< UpdateManager, OwnerPointer<Layer>, bool > LocalType;
692 // Reserve some memory inside the message queue
693 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
695 // Construct message in the message queue memory; note that delete should not be called on the return value
696 new (slot) LocalType( &manager, &UpdateManager::InstallRoot, &root, systemLevel );
699 inline void AddNodeMessage( UpdateManager& manager, Node& node )
701 // Message has ownership of Node while in transit from event -> update
702 typedef MessageValue1< UpdateManager, OwnerPointer<Node> > 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::AddNode, &node );
711 inline void ConnectNodeMessage( UpdateManager& manager, const Node& constParent, const Node& constChild )
713 // Update thread can edit the object
714 Node& parent = const_cast< Node& >( constParent );
715 Node& child = const_cast< Node& >( constChild );
717 typedef MessageValue2< UpdateManager, Node*, Node* > LocalType;
719 // Reserve some memory inside the message queue
720 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
722 // Construct message in the message queue memory; note that delete should not be called on the return value
723 new (slot) LocalType( &manager, &UpdateManager::ConnectNode, &parent, &child );
726 inline void DisconnectNodeMessage( UpdateManager& manager, const Node& constNode )
728 // Scene graph thread can modify this object.
729 Node& node = const_cast< Node& >( constNode );
731 typedef MessageValue1< UpdateManager, Node* > LocalType;
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::DisconnectNode, &node );
740 inline void DestroyNodeMessage( UpdateManager& manager, const Node& constNode )
742 // Scene graph thread can destroy this object.
743 Node& node = const_cast< Node& >( constNode );
745 typedef MessageValue1< UpdateManager, Node* > LocalType;
747 // Reserve some memory inside the message queue
748 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
750 // Construct message in the message queue memory; note that delete should not be called on the return value
751 new (slot) LocalType( &manager, &UpdateManager::DestroyNode, &node );
754 inline void AddCameraMessage( UpdateManager& manager, const Camera* constCamera )
756 // Message has ownership of Camera while in transit from event -> update
757 typedef MessageValue1< UpdateManager, OwnerPointer< Camera > > LocalType;
759 Camera* camera = const_cast<Camera*>( constCamera );
760 // Reserve some memory inside the message queue
761 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
763 // Construct message in the message queue memory; note that delete should not be called on the return value
764 new (slot) LocalType( &manager, &UpdateManager::AddCamera, camera );
767 inline void RemoveCameraMessage( UpdateManager& manager, const Camera* camera )
769 typedef MessageValue1< UpdateManager, const Camera* > LocalType;
771 // Reserve some memory inside the message queue
772 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
774 // Construct message in the message queue memory; note that delete should not be called on the return value
775 new (slot) LocalType( &manager, &UpdateManager::RemoveCamera, camera );
778 inline void AddObjectMessage( UpdateManager& manager, PropertyOwner* object )
780 // Message has ownership of object while in transit from event -> update
781 typedef MessageValue1< UpdateManager, OwnerPointer<PropertyOwner> > LocalType;
783 // Reserve some memory inside the message queue
784 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
786 // Construct message in the message queue memory; note that delete should not be called on the return value
787 new (slot) LocalType( &manager, &UpdateManager::AddObject, object );
790 inline void RemoveObjectMessage( UpdateManager& manager, PropertyOwner* object )
792 typedef MessageValue1< UpdateManager, PropertyOwner* > LocalType;
794 // Reserve some memory inside the message queue
795 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
797 // Construct message in the message queue memory; note that delete should not be called on the return value
798 new (slot) LocalType( &manager, &UpdateManager::RemoveObject, object );
801 inline void AddAnimationMessage( UpdateManager& manager, Animation* animation )
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::AddAnimation, animation );
812 inline void StopAnimationMessage( UpdateManager& manager, const Animation& constAnimation )
814 // The scene-graph thread owns this object so it can safely edit it.
815 Animation& animation = const_cast< Animation& >( constAnimation );
817 typedef MessageValue1< UpdateManager, Animation* > 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::StopAnimation, &animation );
826 inline void RemoveAnimationMessage( UpdateManager& manager, const Animation& constAnimation )
828 // The scene-graph thread owns this object so it can safely edit it.
829 Animation& animation = const_cast< Animation& >( constAnimation );
831 typedef MessageValue1< UpdateManager, Animation* > 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::RemoveAnimation, &animation );
840 inline void AddPropertyNotificationMessage( UpdateManager& manager, PropertyNotification* propertyNotification )
842 // Message has ownership of PropertyNotification while in transit from event -> update
843 typedef MessageValue1< UpdateManager, OwnerPointer< PropertyNotification > > LocalType;
845 // Reserve some memory inside the message queue
846 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
848 // Construct message in the message queue memory; note that delete should not be called on the return value
849 new (slot) LocalType( &manager, &UpdateManager::AddPropertyNotification, propertyNotification );
852 inline void RemovePropertyNotificationMessage( UpdateManager& manager, const PropertyNotification& constPropertyNotification )
854 // The scene-graph thread owns this object so it can safely edit it.
855 PropertyNotification& propertyNotification = const_cast< PropertyNotification& >( constPropertyNotification );
857 typedef MessageValue1< UpdateManager, PropertyNotification* > LocalType;
859 // Reserve some memory inside the message queue
860 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
862 // Construct message in the message queue memory; note that delete should not be called on the return value
863 new (slot) LocalType( &manager, &UpdateManager::RemovePropertyNotification, &propertyNotification );
866 inline void PropertyNotificationSetNotifyModeMessage( UpdateManager& manager,
867 const PropertyNotification* constPropertyNotification,
868 PropertyNotification::NotifyMode notifyMode )
870 // The scene-graph thread owns this object so it can safely edit it.
871 PropertyNotification* propertyNotification = const_cast< PropertyNotification* >( constPropertyNotification );
873 typedef MessageValue2< UpdateManager, PropertyNotification*, PropertyNotification::NotifyMode > LocalType;
875 // Reserve some memory inside the message queue
876 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
878 // Construct message in the message queue memory; note that delete should not be called on the return value
879 new (slot) LocalType( &manager, &UpdateManager::PropertyNotificationSetNotify, propertyNotification, notifyMode );
882 // The render thread can safely change the Shader
883 inline void AddShaderMessage( UpdateManager& manager, Shader& shader )
885 typedef MessageValue1< UpdateManager, OwnerPointer< Shader > > LocalType;
887 // Reserve some memory inside the message queue
888 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
890 // Construct message in the message queue memory; note that delete should not be called on the return value
891 new (slot) LocalType( &manager, &UpdateManager::AddShader, &shader );
894 // The render thread can safely change the Shader
895 inline void RemoveShaderMessage( UpdateManager& manager, Shader& shader )
897 typedef MessageValue1< UpdateManager, Shader* > LocalType;
899 // Reserve some memory inside the message queue
900 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
902 // Construct message in the message queue memory; note that delete should not be called on the return value
903 new (slot) LocalType( &manager, &UpdateManager::RemoveShader, &shader );
906 inline void SetShaderProgramMessage( UpdateManager& manager,
908 Internal::ShaderDataPtr shaderData,
909 bool modifiesGeometry )
911 typedef MessageValue3< UpdateManager, Shader*, Internal::ShaderDataPtr, bool > LocalType;
913 // Reserve some memory inside the message queue
914 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
916 // Construct message in the message queue memory; note that delete should not be called on the return value
917 new (slot) LocalType( &manager, &UpdateManager::SetShaderProgram, &shader, shaderData, modifiesGeometry );
920 inline void SetBackgroundColorMessage( UpdateManager& manager, const Vector4& color )
922 typedef MessageValue1< UpdateManager, Vector4 > LocalType;
924 // Reserve some memory inside the message queue
925 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
927 // Construct message in the message queue memory; note that delete should not be called on the return value
928 new (slot) LocalType( &manager, &UpdateManager::SetBackgroundColor, color );
931 inline void SetDefaultSurfaceRectMessage( UpdateManager& manager, const Rect<int>& rect )
933 typedef MessageValue1< UpdateManager, Rect<int> > LocalType;
935 // Reserve some memory inside the message queue
936 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
938 // Construct message in the message queue memory; note that delete should not be called on the return value
939 new (slot) LocalType( &manager, &UpdateManager::SetDefaultSurfaceRect, rect );
942 inline void KeepRenderingMessage( UpdateManager& manager, float durationSeconds )
944 typedef MessageValue1< UpdateManager, float > LocalType;
946 // Reserve some memory inside the message queue
947 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
949 // Construct message in the message queue memory; note that delete should not be called on the return value
950 new (slot) LocalType( &manager, &UpdateManager::KeepRendering, durationSeconds );
954 * Create a message for setting the depth of a layer
955 * @param[in] manager The update manager
956 * @param[in] layers list of layers
957 * @param[in] systemLevel True if the layers are added via the SystemOverlay API
959 inline void SetLayerDepthsMessage( UpdateManager& manager, const std::vector< Layer* >& layers, bool systemLevel )
961 typedef MessageValue2< UpdateManager, std::vector< Layer* >, bool > LocalType;
963 // Reserve some memory inside the message queue
964 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
966 // Construct message in the message queue memory; note that delete should not be called on the return value
967 new (slot) LocalType( &manager, &UpdateManager::SetLayerDepths, layers, systemLevel );
970 inline void AddGestureMessage( UpdateManager& manager, PanGesture* gesture )
972 // Message has ownership of PanGesture while in transit from event -> update
973 typedef MessageValue1< UpdateManager, OwnerPointer< PanGesture > > LocalType;
975 // Reserve some memory inside the message queue
976 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
978 // Construct message in the message queue memory; note that delete should not be called on the return value
979 new (slot) LocalType( &manager, &UpdateManager::AddGesture, gesture );
982 inline void RemoveGestureMessage( UpdateManager& manager, PanGesture* gesture )
984 typedef MessageValue1< UpdateManager, PanGesture* > LocalType;
986 // Reserve some memory inside the message queue
987 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
989 // Construct message in the message queue memory; note that delete should not be called on the return value
990 new (slot) LocalType( &manager, &UpdateManager::RemoveGesture, gesture );
993 template< typename T >
994 inline void AddMessage( UpdateManager& manager, ObjectOwnerContainer<T>& owner, T& object )
996 typedef MessageValue1< ObjectOwnerContainer<T>, OwnerPointer< T > > LocalType;
998 // Reserve some memory inside the message queue
999 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1000 // Construct message in the message queue memory; note that delete should not be called on the return value
1001 new (slot) LocalType( &owner, &ObjectOwnerContainer<T>::Add, &object );
1004 template< typename T >
1005 inline void RemoveMessage( UpdateManager& manager, ObjectOwnerContainer<T>& owner, T& object )
1007 typedef MessageValue1< ObjectOwnerContainer<T>, T* > LocalType;
1009 // Reserve some memory inside the message queue
1010 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1011 // Construct message in the message queue memory; note that delete should not be called on the return value
1012 new (slot) LocalType( &owner, &ObjectOwnerContainer<T>::Remove, &object );
1015 // The render thread can safely change the Shader
1016 inline void AddTextureSetMessage( UpdateManager& manager, TextureSet& textureSet )
1018 typedef MessageValue1< UpdateManager, OwnerPointer< TextureSet > > LocalType;
1020 // Reserve some memory inside the message queue
1021 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1023 // Construct message in the message queue memory; note that delete should not be called on the return value
1024 new (slot) LocalType( &manager, &UpdateManager::AddTextureSet, &textureSet );
1027 // The render thread can safely change the Shader
1028 inline void RemoveTextureSetMessage( UpdateManager& manager, TextureSet& textureSet )
1030 typedef MessageValue1< UpdateManager, TextureSet* > LocalType;
1032 // Reserve some memory inside the message queue
1033 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1035 // Construct message in the message queue memory; note that delete should not be called on the return value
1036 new (slot) LocalType( &manager, &UpdateManager::RemoveTextureSet, &textureSet );
1039 inline void AddSamplerMessage( UpdateManager& manager, Render::Sampler& sampler )
1041 // Message has ownership of Sampler while in transit from event -> update
1042 typedef MessageValue1< UpdateManager, OwnerPointer< Render::Sampler > > LocalType;
1044 // Reserve some memory inside the message queue
1045 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1047 // Construct message in the message queue memory; note that delete should not be called on the return value
1048 new (slot) LocalType( &manager, &UpdateManager::AddSampler, &sampler );
1051 inline void RemoveSamplerMessage( UpdateManager& manager, Render::Sampler& sampler )
1053 typedef MessageValue1< UpdateManager, Render::Sampler* > LocalType;
1055 // Reserve some memory inside the message queue
1056 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1058 // Construct message in the message queue memory; note that delete should not be called on the return value
1059 new (slot) LocalType( &manager, &UpdateManager::RemoveSampler, &sampler );
1062 inline void SetFilterModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int minFilterMode, unsigned int magFilterMode )
1064 typedef MessageValue3< UpdateManager, Render::Sampler*, unsigned int, unsigned int > LocalType;
1066 // Reserve some memory inside the message queue
1067 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1069 // Construct message in the message queue memory; note that delete should not be called on the return value
1070 new (slot) LocalType( &manager, &UpdateManager::SetFilterMode, &sampler, minFilterMode, magFilterMode );
1073 inline void SetWrapModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int rWrapMode, unsigned int sWrapMode, unsigned int tWrapMode )
1075 typedef MessageValue4< UpdateManager, Render::Sampler*, unsigned int, unsigned int, unsigned int > LocalType;
1077 // Reserve some memory inside the message queue
1078 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1080 // Construct message in the message queue memory; note that delete should not be called on the return value
1081 new (slot) LocalType( &manager, &UpdateManager::SetWrapMode, &sampler, rWrapMode, sWrapMode, tWrapMode );
1084 inline void AddPropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer )
1086 // Message has ownership of propertyBuffer while in transit from event -> update
1087 typedef MessageValue1< UpdateManager, OwnerPointer< Render::PropertyBuffer > > LocalType;
1089 // Reserve some memory inside the message queue
1090 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1092 // Construct message in the message queue memory; note that delete should not be called on the return value
1093 new (slot) LocalType( &manager, &UpdateManager::AddPropertyBuffer, &propertyBuffer );
1096 inline void RemovePropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer )
1098 typedef MessageValue1< UpdateManager, Render::PropertyBuffer* > LocalType;
1100 // Reserve some memory inside the message queue
1101 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1103 // Construct message in the message queue memory; note that delete should not be called on the return value
1104 new (slot) LocalType( &manager, &UpdateManager::RemovePropertyBuffer, &propertyBuffer );
1107 inline void SetPropertyBufferFormat( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, Render::PropertyBuffer::Format* format )
1109 // Message has ownership of PropertyBuffer::Format while in transit from event -> update
1110 typedef MessageValue2< UpdateManager, Render::PropertyBuffer*, OwnerPointer< Render::PropertyBuffer::Format> > 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::SetPropertyBufferFormat, &propertyBuffer, format );
1119 inline void SetPropertyBufferData( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, Vector<char>* data, size_t size )
1121 // Message has ownership of PropertyBuffer data while in transit from event -> update
1122 typedef MessageValue3< UpdateManager, Render::PropertyBuffer*, OwnerPointer< Vector<char> >, size_t > LocalType;
1124 // Reserve some memory inside the message queue
1125 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1127 // Construct message in the message queue memory; note that delete should not be called on the return value
1128 new (slot) LocalType( &manager, &UpdateManager::SetPropertyBufferData, &propertyBuffer, data, size );
1131 inline void AddGeometry( UpdateManager& manager, Render::Geometry& geometry )
1133 // Message has ownership of Geometry while in transit from event -> update
1134 typedef MessageValue1< UpdateManager, OwnerPointer< Render::Geometry > > LocalType;
1136 // Reserve some memory inside the message queue
1137 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1139 // Construct message in the message queue memory; note that delete should not be called on the return value
1140 new (slot) LocalType( &manager, &UpdateManager::AddGeometry, &geometry );
1143 inline void RemoveGeometry( UpdateManager& manager, Render::Geometry& geometry )
1145 typedef MessageValue1< UpdateManager, Render::Geometry* > LocalType;
1147 // Reserve some memory inside the message queue
1148 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1150 // Construct message in the message queue memory; note that delete should not be called on the return value
1151 new (slot) LocalType( &manager, &UpdateManager::RemoveGeometry, &geometry );
1154 inline void AddVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer )
1156 typedef MessageValue2< UpdateManager, Render::Geometry*, Render::PropertyBuffer* > LocalType;
1158 // Reserve some memory inside the message queue
1159 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1161 // Construct message in the message queue memory; note that delete should not be called on the return value
1162 new (slot) LocalType( &manager, &UpdateManager::AddVertexBuffer, &geometry, const_cast<Render::PropertyBuffer*>(&vertexBuffer) );
1165 inline void RemoveVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer )
1167 typedef MessageValue2< UpdateManager, Render::Geometry*, Render::PropertyBuffer* > LocalType;
1169 // Reserve some memory inside the message queue
1170 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1172 // Construct message in the message queue memory; note that delete should not be called on the return value
1173 new (slot) LocalType( &manager, &UpdateManager::RemoveVertexBuffer, &geometry, const_cast<Render::PropertyBuffer*>(&vertexBuffer) );
1176 // Custom message type for SetIndexBuffer() used to move data with Vector::Swap()
1177 template< typename T >
1178 class IndexBufferMessage : public MessageBase
1183 * Constructor which does a Vector::Swap()
1185 IndexBufferMessage( T* manager, Render::Geometry* geometry, Dali::Vector<unsigned short>& indices )
1187 mManager( manager ),
1188 mRenderGeometry( geometry )
1190 mIndices.Swap( indices );
1194 * Virtual destructor
1196 virtual ~IndexBufferMessage()
1201 * @copydoc MessageBase::Process
1203 virtual void Process( BufferIndex /*bufferIndex*/ )
1205 DALI_ASSERT_DEBUG( mManager && "Message does not have an object" );
1206 mManager->SetIndexBuffer( mRenderGeometry, mIndices );
1212 Render::Geometry* mRenderGeometry;
1213 Dali::Vector<unsigned short> mIndices;
1216 inline void SetIndexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, Dali::Vector<unsigned short>& indices )
1218 typedef IndexBufferMessage< UpdateManager > LocalType;
1220 // Reserve some memory inside the message queue
1221 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1223 // Construct message in the message queue memory; note that delete should not be called on the return value
1224 new (slot) LocalType( &manager, &geometry, indices );
1227 inline void SetGeometryTypeMessage( UpdateManager& manager, Render::Geometry& geometry, unsigned int geometryType )
1229 typedef MessageValue2< UpdateManager, Render::Geometry*, unsigned int > LocalType;
1231 // Reserve some memory inside the message queue
1232 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1234 // Construct message in the message queue memory; note that delete should not be called on the return value
1235 new (slot) LocalType( &manager, &UpdateManager::SetGeometryType, &geometry, geometryType );
1238 inline void AddTexture( UpdateManager& manager, Render::Texture& texture )
1240 // Message has ownership of Texture while in transit from event -> update
1241 typedef MessageValue1< UpdateManager, OwnerPointer< Render::Texture > > LocalType;
1243 // Reserve some memory inside the message queue
1244 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1246 // Construct message in the message queue memory; note that delete should not be called on the return value
1247 new (slot) LocalType( &manager, &UpdateManager::AddTexture, &texture );
1250 inline void RemoveTexture( UpdateManager& manager, Render::Texture& texture )
1252 typedef MessageValue1< UpdateManager, Render::Texture* > LocalType;
1254 // Reserve some memory inside the message queue
1255 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1257 // Construct message in the message queue memory; note that delete should not be called on the return value
1258 new (slot) LocalType( &manager, &UpdateManager::RemoveTexture, &texture );
1261 inline void UploadTextureMessage( UpdateManager& manager, Render::Texture& texture, PixelDataPtr pixelData, const Texture::UploadParams& params )
1263 typedef MessageValue3< UpdateManager, Render::Texture*, PixelDataPtr, Texture::UploadParams > LocalType;
1265 // Reserve some memory inside the message queue
1266 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1268 // Construct message in the message queue memory; note that delete should not be called on the return value
1269 new (slot) LocalType( &manager, &UpdateManager::UploadTexture, &texture, pixelData, params );
1272 inline void GenerateMipmapsMessage( UpdateManager& manager, Render::Texture& texture )
1274 typedef MessageValue1< UpdateManager, Render::Texture* > LocalType;
1276 // Reserve some memory inside the message queue
1277 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1279 // Construct message in the message queue memory; note that delete should not be called on the return value
1280 new (slot) LocalType( &manager, &UpdateManager::GenerateMipmaps, &texture );
1284 inline void AddFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer )
1286 typedef MessageValue1< UpdateManager, Render::FrameBuffer* > LocalType;
1288 // Reserve some memory inside the message queue
1289 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1291 // Construct message in the message queue memory; note that delete should not be called on the return value
1292 new (slot) LocalType( &manager, &UpdateManager::AddFrameBuffer, &frameBuffer );
1295 inline void RemoveFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer )
1297 typedef MessageValue1< UpdateManager, Render::FrameBuffer* > LocalType;
1299 // Reserve some memory inside the message queue
1300 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1302 // Construct message in the message queue memory; note that delete should not be called on the return value
1303 new (slot) LocalType( &manager, &UpdateManager::RemoveFrameBuffer, &frameBuffer );
1306 inline void AttachColorTextureToFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer, Render::Texture* texture, unsigned int mipmapLevel, unsigned int layer )
1308 typedef MessageValue4< UpdateManager, Render::FrameBuffer*, Render::Texture*, unsigned int, unsigned int > LocalType;
1310 // Reserve some memory inside the message queue
1311 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1313 // Construct message in the message queue memory; note that delete should not be called on the return value
1314 new (slot) LocalType( &manager, &UpdateManager::AttachColorTextureToFrameBuffer, &frameBuffer, texture, mipmapLevel, layer );
1317 inline void SetDepthIndicesMessage( UpdateManager& manager, NodeDepths* nodeDepths )
1319 typedef MessageValue1< UpdateManager, OwnerPointer< NodeDepths > > LocalType;
1321 // Reserve some memory inside the message queue
1322 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1324 // Construct message in the message queue memory; note that delete should not be called on the return value
1325 new (slot) LocalType( &manager, &UpdateManager::SetDepthIndices, nodeDepths );
1329 } // namespace SceneGraph
1331 } // namespace Internal
1335 #endif // DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H