1 #ifndef DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H
2 #define DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H
5 * Copyright (c) 2017 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/internal/common/message.h>
26 #include <dali/internal/common/type-abstraction-enums.h>
27 #include <dali/internal/common/shader-saver.h>
28 #include <dali/internal/event/common/event-thread-services.h>
29 #include <dali/internal/update/animation/scene-graph-animation.h>
30 #include <dali/internal/update/common/scene-graph-buffers.h>
31 #include <dali/internal/update/common/scene-graph-property-notification.h>
32 #include <dali/internal/update/nodes/node.h>
33 #include <dali/internal/update/nodes/scene-graph-layer.h>
34 #include <dali/internal/update/rendering/scene-graph-renderer.h> // for OwnerPointer< Renderer >
35 #include <dali/internal/update/rendering/scene-graph-texture-set.h> // for OwnerPointer< TextureSet >
36 #include <dali/internal/update/gestures/scene-graph-pan-gesture.h>
37 #include <dali/internal/update/render-tasks/scene-graph-camera.h>
38 #include <dali/internal/render/shaders/scene-graph-shader.h> // for OwnerPointer< Shader >
39 #include <dali/internal/render/renderers/render-property-buffer.h>
40 #include <dali/internal/event/rendering/texture-impl.h>
47 class GlSyncAbstraction;
48 class RenderController;
50 } // namespace Integration
55 class PropertyNotifier;
56 class NotificationManager;
57 class CompleteNotificationInterface;
65 // value types used by messages
66 template <> struct ParameterType< PropertyNotification::NotifyMode >
67 : public BasicType< PropertyNotification::NotifyMode > {};
76 class RenderTaskProcessor;
82 SceneGraph::Node* node;
84 NodeDepthPair( SceneGraph::Node* node, uint32_t sortedDepth )
86 sortedDepth(sortedDepth)
93 NodeDepths( int reserveSize )
95 nodeDepths.reserve(reserveSize);
98 void Add( SceneGraph::Node* node, uint32_t sortedDepth )
100 nodeDepths.push_back( NodeDepthPair( node, sortedDepth ) );
103 std::vector<NodeDepthPair> nodeDepths;
108 * UpdateManager maintains a scene graph i.e. a tree of nodes as well as
109 * other scene graph property owning objects.
110 * It controls the Update traversal, in which nodes are repositioned/animated,
111 * and organizes the the culling and rendering of the scene.
112 * It also maintains the lifecycle of nodes and other property owners that are
113 * disconnected from the scene graph.
115 class UpdateManager : public ShaderSaver
120 * Construct a new UpdateManager.
121 * @param[in] notificationManager This should be notified when animations have finished.
122 * @param[in] animationFinishedNotifier The CompleteNotificationInterface that handles animation completions
123 * @param[in] propertyNotifier The PropertyNotifier
124 * @param[in] discardQueue Nodes are added here when disconnected from the scene-graph.
125 * @param[in] controller After messages are flushed, we request a render from the RenderController.
126 * @param[in] renderManager This is responsible for rendering the results of each "update".
127 * @param[in] renderQueue Used to queue messages for the next render.
128 * @param[in] renderTaskProcessor Handles RenderTasks and RenderInstrucitons.
130 UpdateManager( NotificationManager& notificationManager,
131 CompleteNotificationInterface& animationFinishedNotifier,
132 PropertyNotifier& propertyNotifier,
133 DiscardQueue& discardQueue,
134 Integration::RenderController& controller,
135 RenderManager& renderManager,
136 RenderQueue& renderQueue,
137 RenderTaskProcessor& renderTaskProcessor );
142 virtual ~UpdateManager();
144 // Node connection methods
147 * Installs a new layer as the root node.
148 * @pre The UpdateManager does not already have an installed root node.
149 * @pre The layer is of derived Node type Layer.
150 * @pre The layer does not have a parent.
151 * @param[in] layer The new root node.
152 * @param[in] systemLevel True if using the system-level overlay.
153 * @post The node is owned by UpdateManager.
155 void InstallRoot( OwnerPointer<Layer>& layer, bool systemLevel );
158 * Add a Node; UpdateManager takes ownership.
159 * @pre The node does not have a parent.
160 * @note even though nodes are pool allocated, they also contain other heap allocated data, thus using OwnerPointer when transferring the data
161 * @param[in] node The node to add.
163 void AddNode( OwnerPointer<Node>& node );
166 * Connect a Node to the scene-graph.
167 * A disconnected Node has has no parent or children, and its properties cannot be animated/constrained.
168 * @pre The node does not already have a parent.
169 * @param[in] parent The new parent node.
171 void ConnectNode( Node* parent, Node* node );
174 * Disconnect a Node from the scene-graph.
175 * A disconnected Node has has no parent or children, and its properties cannot be animated/constrained.
176 * @pre The node has a parent.
177 * @param[in] node The node to disconnect.
179 void DisconnectNode( Node* node );
182 * Destroy a Node owned by UpdateManager.
183 * This is not immediate; Nodes are passed to the RenderQueue to allow GL resources to be deleted.
184 * In the following update, the previously queued Nodes may be deleted.
185 * @pre The node has been disconnected from the scene-graph i.e. has no parent or children.
186 * @param[in] node The node to destroy.
188 void DestroyNode( Node* node );
191 * Add a camera on scene
192 * @param[in] camera to add
194 void AddCamera( OwnerPointer< Camera >& camera );
197 * Remove a camera from scene
198 * @param[in] camera to remove
200 void RemoveCamera( const Camera* camera );
203 * Add a newly created object.
204 * @param[in] object The object to add.
205 * @post The object is owned by UpdateManager.
207 void AddObject( OwnerPointer<PropertyOwner>& object );
211 * @param[in] object The object to remove.
213 void RemoveObject( PropertyOwner* object );
218 * Add a newly created animation.
219 * @param[in] animation The animation to add.
220 * @post The animation is owned by UpdateManager.
222 void AddAnimation( OwnerPointer< SceneGraph::Animation >& animation );
226 * @param[in] animation The animation to stop.
228 void StopAnimation( Animation* animation );
231 * Remove an animation.
232 * @param[in] animation The animation to remove.
234 void RemoveAnimation( Animation* animation );
237 * Query whether any animations are currently running.
238 * @return True if any animations are running.
240 bool IsAnimationRunning() const;
242 // Property Notification
245 * Add a newly created property notification
246 * @param[in] propertyNotification The notification to add
247 * @post The propertyNotification is owned by UpdateManager.
249 void AddPropertyNotification( OwnerPointer< PropertyNotification >& propertyNotification );
252 * Remove a property notification
253 * @param[in] propertyNotification The notification to remove
255 void RemovePropertyNotification( PropertyNotification* propertyNotification );
258 * Set Notify state for PropertyNotification
259 * @param[in] propertyNotification The notification to remove
260 * @param[in] notifyMode The notification mode.
262 void PropertyNotificationSetNotify( PropertyNotification* propertyNotification, PropertyNotification::NotifyMode notifyMode );
267 * Add a newly created shader.
268 * @param[in] shader The shader to add.
269 * @post The shader is owned by the UpdateManager.
271 void AddShader( OwnerPointer< Shader >& shader );
275 * @pre The shader has been added to the UpdateManager.
276 * @param[in] shader The shader to remove.
277 * @post The shader is destroyed.
279 void RemoveShader( Shader* shader );
282 * Set the shader program for a Shader object
283 * @param[in] shader The shader to modify
284 * @param[in] shaderData Source code, hash over source, and optional compiled binary for the shader program
285 * @param[in] modifiesGeometry True if the vertex shader modifies geometry
287 void SetShaderProgram( Shader* shader, Internal::ShaderDataPtr shaderData, bool modifiesGeometry );
290 * @brief Accept compiled shaders passed back on render thread for saving.
291 * @param[in] shaderData Source code, hash over source, and corresponding compiled binary to be saved.
293 virtual void SaveBinary( Internal::ShaderDataPtr shaderData );
296 * @brief Set the destination for compiled shader binaries to be passed on to.
297 * The dispatcher passed in will be called from the update thread.
298 * @param[in] upstream A sink for ShaderDatas to be passed into.
300 void SetShaderSaver( ShaderSaver& upstream );
305 * Add a new renderer to scene
306 * @param renderer to add
308 void AddRenderer( OwnerPointer< Renderer >& renderer );
311 * Add a renderer from scene
312 * @param renderer to remove
314 void RemoveRenderer( Renderer* renderer );
319 * Set the pan gesture processor.
320 * Pan Gesture processor lives for the lifetime of UpdateManager
321 * @param[in] gesture The gesture processor.
322 * @post The gestureProcessor is owned by the UpdateManager.
324 void SetPanGestureProcessor( PanGesture* gestureProcessor );
329 * Add a newly created TextureSet.
330 * @param[in] textureSet The texture set to add.
331 * @post The TextureSet is owned by the UpdateManager.
333 void AddTextureSet( OwnerPointer< TextureSet >& textureSet );
336 * Remove a TextureSet.
337 * @pre The TextureSet has been added to the UpdateManager.
338 * @param[in] textureSet The TextureSet to remove.
339 * @post The TextureSet is destroyed.
341 void RemoveTextureSet( TextureSet* textureSet );
346 * Get the scene graph side list of RenderTasks.
347 * @param[in] systemLevel True if using the system-level overlay.
348 * @return The list of render tasks
350 RenderTaskList* GetRenderTaskList( bool systemLevel );
352 // Message queue handling
355 * Reserve space for another message in the queue; this must then be initialized by the caller.
356 * The message will be read from the update-thread after the next FlushMessages is called.
357 * @post Calling this method may invalidate any previously returned slots.
358 * @param[in] size The message size with respect to the size of type "char".
359 * @param[in] updateScene A flag, when true denotes that the message will cause the scene-graph node tree to require an update.
360 * @note the default value of updateScene should match that in EventThreadServices::ReserveMessageSlot.
361 * @return A pointer to the first char allocated for the message.
363 unsigned int* ReserveMessageSlot( std::size_t size, bool updateScene = true );
366 * @return the current event-buffer index.
368 BufferIndex GetEventBufferIndex() const
370 // inlined as its called often from event thread
371 return mSceneGraphBuffers.GetEventBufferIndex();
375 * Called by the event-thread to signal that FlushQueue will be called
376 * e.g. when it has finished event processing.
378 void EventProcessingStarted();
381 * Flush the set of messages, which were previously stored with QueueMessage().
382 * Calls to this thread-safe method should be minimized, to avoid thread blocking.
384 * @return True if there are messages to process.
389 * Add a new sampler to RenderManager
390 * @param[in] sampler The sampler to add
391 * @post Sends a message to RenderManager to add the sampler.
392 * The sampler will be owned by RenderManager
394 void AddSampler( OwnerPointer< Render::Sampler >& sampler );
397 * Removes an existing sampler from RenderManager
398 * @param[in] sampler The sampler to remove
399 * @post The sampler will be destroyed in the render thread
401 void RemoveSampler( Render::Sampler* sampler );
404 * Sets the filter modes for an existing sampler
405 * @param[in] sampler The sampler
406 * @param[in] minFilterMode The filter to use under minification
407 * @param[in] magFilterMode The filter to use under magnification
409 void SetFilterMode( Render::Sampler* sampler, unsigned int minFilterMode, unsigned int magFilterMode );
412 * Sets the wrap mode for an existing sampler
413 * @param[in] sampler The sampler
414 * @param[in] rWrapMode Wrapping mode in z direction
415 * @param[in] sWrapMode Wrapping mode in x direction
416 * @param[in] tWrapMode Wrapping mode in y direction
418 void SetWrapMode( Render::Sampler* sampler, unsigned int rWrapMode, unsigned int sWrapMode, unsigned int tWrapMode );
421 * Add a new property buffer to RenderManager
422 * @param[in] propertryBuffer The property buffer to add
423 * @post Sends a message to RenderManager to add the property buffer.
424 * The property buffer will be owned by RenderManager
426 void AddPropertyBuffer( OwnerPointer< Render::PropertyBuffer >& propertryBuffer );
429 * Removes an existing PropertyBuffer from RenderManager
430 * @param[in] propertryBuffer The property buffer to remove
431 * @post The property buffer will be destroyed in the render thread
433 void RemovePropertyBuffer( Render::PropertyBuffer* propertryBuffer );
436 * Sets the format of an existing property buffer
437 * @param[in] propertyBuffer The property buffer.
438 * @param[in] format The new format of the buffer
439 * @post Sends a message to RenderManager to set the new format to the property buffer.
441 void SetPropertyBufferFormat( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Render::PropertyBuffer::Format>& format );
444 * Sets the data of an existing property buffer
445 * @param[in] propertyBuffer The property buffer.
446 * @param[in] data The new data of the buffer
447 * @param[in] size The new size of the buffer
448 * @post Sends a message to RenderManager to set the new data to the property buffer.
450 void SetPropertyBufferData( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Vector<char> >& data, size_t size );
453 * Adds a geometry to the RenderManager
454 * @param[in] geometry The geometry to add
455 * @post Sends a message to RenderManager to add the Geometry
456 * The geometry will be owned by RenderManager
458 void AddGeometry( OwnerPointer< Render::Geometry >& geometry );
461 * Removes an existing Geometry from RenderManager
462 * @param[in] geometry The geometry to remove
463 * @post The geometry will be destroyed in the render thread
465 void RemoveGeometry( Render::Geometry* geometry );
468 * Sets the geometry type of an existing Geometry
469 * @param[in] geometry The geometry
470 * @param[in] geometryType The type of the geometry
472 void SetGeometryType( Render::Geometry* geometry, unsigned int geometryType );
475 * Sets the index buffer to be used by a geometry
476 * @param[in] geometry The geometry
477 * @param[in] indices A vector containing the indices for the geometry
479 void SetIndexBuffer( Render::Geometry* geometry, Dali::Vector<unsigned short>& indices );
482 * Adds a vertex buffer to a geometry
483 * @param[in] geometry The geometry
484 * @param[in] propertyBuffer The property buffer
486 void AttachVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer );
489 * Removes a vertex buffer from a geometry
490 * @param[in] geometry The geometry
491 * @param[in] propertyBuffer The property buffer
493 void RemoveVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer );
496 * Adds a texture to the render manager
497 * @param[in] texture The texture to add
498 * The texture will be owned by RenderManager
500 void AddTexture( OwnerPointer< Render::Texture >& texture );
503 * Removes a texture from the render manager
504 * @param[in] texture The texture to remove
505 * @post The texture will be destroyed in the render thread
507 void RemoveTexture( Render::Texture* texture );
510 * Uploads data to a texture owned by the RenderManager
511 * @param[in] texture The texture
512 * @param[in] pixelData The pixel data object
513 * @param[in] params The parameters for the upload
515 void UploadTexture( Render::Texture* texture, PixelDataPtr pixelData, const Texture::UploadParams& params );
518 * Generates mipmaps for a texture owned by the RenderManager
519 * @param[in] texture The texture
521 void GenerateMipmaps( Render::Texture* texture );
524 * Adds a framebuffer to the render manager
525 * @param[in] frameBuffer The framebuffer to add
526 * The framebuffer will be owned by RenderManager
528 void AddFrameBuffer( Render::FrameBuffer* frameBuffer );
531 * Removes a FrameBuffer from the render manager
532 * @param[in] frameBuffer The FrameBuffer to remove
533 * @post The FrameBuffer will be destroyed in the render thread
535 void RemoveFrameBuffer( Render::FrameBuffer* frameBuffer );
538 * Attach a texture as color output to an existing FrameBuffer
539 * @param[in] frameBuffer The FrameBuffer
540 * @param[in] texture The texture that will be used as output when rendering
541 * @param[in] mipmapLevel The mipmap of the texture to be attached
542 * @param[in] layer Indicates which layer of a cube map or array texture to attach. Unused for 2D textures
544 void AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::Texture* texture, unsigned int mipmapLevel, unsigned int face );
549 * Performs an Update traversal on the scene-graph.
550 * @param[in] elapsedSeconds The elapsed time that should be applied to animations.
551 * @param[in] lastVSyncTimeMilliseconds The last time, in milliseconds, that we had a VSync.
552 * @param[in] nextVSyncTimeMilliseconds The estimated time, in milliseconds, of the next VSync.
553 * @return True if further updates are required e.g. during animations.
555 unsigned int Update( float elapsedSeconds, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds );
558 * Set the background color i.e. the glClear color used at the beginning of each frame.
559 * @param[in] color The new background color.
561 void SetBackgroundColor(const Vector4& color);
564 * Set the default surface rect.
565 * @param[in] rect The rect value representing the surface.
567 void SetDefaultSurfaceRect( const Rect<int>& rect );
570 * @copydoc Dali::Stage::KeepRendering()
572 void KeepRendering( float durationSeconds );
575 * Sets the depths of all layers.
576 * @param layers The layers in depth order.
577 * @param[in] systemLevel True if using the system-level overlay.
579 void SetLayerDepths( const std::vector< Layer* >& layers, bool systemLevel );
582 * Set the depth indices of all nodes (in LayerUI's)
583 * @param[in] nodeDepths A vector of nodes and associated depth indices
585 void SetDepthIndices( OwnerPointer< NodeDepths >& nodeDepths );
590 UpdateManager(const UpdateManager&);
593 UpdateManager& operator=(const UpdateManager& rhs);
596 * Helper to check whether the update-thread should keep going.
597 * @param[in] elapsedSeconds The time in seconds since the previous update.
598 * @return True if the update-thread should keep going.
600 unsigned int KeepUpdatingCheck( float elapsedSeconds ) const;
603 * Helper to reset all Node properties
604 * @param[in] bufferIndex to use
606 void ResetProperties( BufferIndex bufferIndex );
609 * Perform gesture updates.
610 * @param[in] bufferIndex to use
611 * @param[in] lastVSyncTime The last VSync time in milliseconds.
612 * @param[in] nextVSyncTime The estimated time of the next VSync in milliseconds.
613 * @return true, if any properties were updated.
615 bool ProcessGestures( BufferIndex bufferIndex, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds );
618 * Perform animation updates
619 * @param[in] bufferIndex to use
620 * @param[in] elapsedSeconds time since last frame
622 void Animate( BufferIndex bufferIndex, float elapsedSeconds );
625 * Applies constraints to CustomObjects
626 * @param[in] bufferIndex to use
628 void ConstrainCustomObjects( BufferIndex bufferIndex );
631 * Applies constraints to RenderTasks
632 * @param[in] bufferIndex to use
634 void ConstrainRenderTasks( BufferIndex bufferIndex );
637 * Applies constraints to Shaders
638 * @param[in] bufferIndex to use
640 void ConstrainShaders( BufferIndex bufferIndex );
643 * Perform property notification updates
644 * @param[in] bufferIndex to use
646 void ProcessPropertyNotifications( BufferIndex bufferIndex );
649 * Pass shader binaries queued here on to event thread.
651 void ForwardCompiledShadersToEventThread();
654 * Update node shaders, opacity, geometry etc.
655 * @param[in] bufferIndex to use
657 void UpdateNodes( BufferIndex bufferIndex );
661 * @param[in] bufferIndex to use
663 void UpdateRenderers( BufferIndex bufferIndex );
667 // needs to be direct member so that getter for event buffer can be inlined
668 SceneGraphBuffers mSceneGraphBuffers;
675 // Messages for UpdateManager
677 inline void InstallRootMessage( UpdateManager& manager, OwnerPointer<Layer>& root, bool systemLevel )
679 // Message has ownership of Layer while in transit from event -> update
680 typedef MessageValue2< UpdateManager, OwnerPointer<Layer>, bool > LocalType;
682 // Reserve some memory inside the message queue
683 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
685 // Construct message in the message queue memory; note that delete should not be called on the return value
686 new (slot) LocalType( &manager, &UpdateManager::InstallRoot, root, systemLevel );
689 inline void AddNodeMessage( UpdateManager& manager, OwnerPointer<Node>& node )
691 // Message has ownership of Node while in transit from event -> update
692 typedef MessageValue1< UpdateManager, OwnerPointer<Node> > LocalType;
694 // Reserve some memory inside the message queue
695 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
697 // Construct message in the message queue memory; note that delete should not be called on the return value
698 new (slot) LocalType( &manager, &UpdateManager::AddNode, node );
701 inline void ConnectNodeMessage( UpdateManager& manager, const Node& constParent, const Node& constChild )
703 // Update thread can edit the object
704 Node& parent = const_cast< Node& >( constParent );
705 Node& child = const_cast< Node& >( constChild );
707 typedef MessageValue2< UpdateManager, Node*, Node* > LocalType;
709 // Reserve some memory inside the message queue
710 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
712 // Construct message in the message queue memory; note that delete should not be called on the return value
713 new (slot) LocalType( &manager, &UpdateManager::ConnectNode, &parent, &child );
716 inline void DisconnectNodeMessage( UpdateManager& manager, const Node& constNode )
718 // Scene graph thread can modify this object.
719 Node& node = const_cast< Node& >( constNode );
721 typedef MessageValue1< UpdateManager, Node* > LocalType;
723 // Reserve some memory inside the message queue
724 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
726 // Construct message in the message queue memory; note that delete should not be called on the return value
727 new (slot) LocalType( &manager, &UpdateManager::DisconnectNode, &node );
730 inline void DestroyNodeMessage( UpdateManager& manager, const Node& constNode )
732 // Scene graph thread can destroy this object.
733 Node& node = const_cast< Node& >( constNode );
735 typedef MessageValue1< UpdateManager, Node* > LocalType;
737 // Reserve some memory inside the message queue
738 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
740 // Construct message in the message queue memory; note that delete should not be called on the return value
741 new (slot) LocalType( &manager, &UpdateManager::DestroyNode, &node );
744 inline void AddCameraMessage( UpdateManager& manager, OwnerPointer< Camera >& camera )
746 // Message has ownership of Camera while in transit from event -> update
747 typedef MessageValue1< UpdateManager, OwnerPointer< Camera > > LocalType;
749 // Reserve some memory inside the message queue
750 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
752 // Construct message in the message queue memory; note that delete should not be called on the return value
753 new (slot) LocalType( &manager, &UpdateManager::AddCamera, camera );
756 inline void RemoveCameraMessage( UpdateManager& manager, const Camera* camera )
758 typedef MessageValue1< UpdateManager, const Camera* > LocalType;
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::RemoveCamera, camera );
767 inline void AddObjectMessage( UpdateManager& manager, OwnerPointer<PropertyOwner>& object )
769 // Message has ownership of object while in transit from event -> update
770 typedef MessageValue1< UpdateManager, OwnerPointer<PropertyOwner> > LocalType;
772 // Reserve some memory inside the message queue
773 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
775 // Construct message in the message queue memory; note that delete should not be called on the return value
776 new (slot) LocalType( &manager, &UpdateManager::AddObject, object );
779 inline void RemoveObjectMessage( UpdateManager& manager, PropertyOwner* object )
781 typedef MessageValue1< UpdateManager, 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::RemoveObject, object );
790 inline void AddAnimationMessage( UpdateManager& manager, OwnerPointer< SceneGraph::Animation >& animation )
792 typedef MessageValue1< UpdateManager, OwnerPointer< SceneGraph::Animation > > 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::AddAnimation, animation );
801 inline void StopAnimationMessage( UpdateManager& manager, const Animation& constAnimation )
803 // The scene-graph thread owns this object so it can safely edit it.
804 Animation& animation = const_cast< Animation& >( constAnimation );
806 typedef MessageValue1< UpdateManager, Animation* > LocalType;
808 // Reserve some memory inside the message queue
809 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
811 // Construct message in the message queue memory; note that delete should not be called on the return value
812 new (slot) LocalType( &manager, &UpdateManager::StopAnimation, &animation );
815 inline void RemoveAnimationMessage( UpdateManager& manager, const Animation& constAnimation )
817 // The scene-graph thread owns this object so it can safely edit it.
818 Animation& animation = const_cast< Animation& >( constAnimation );
820 typedef MessageValue1< UpdateManager, Animation* > LocalType;
822 // Reserve some memory inside the message queue
823 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
825 // Construct message in the message queue memory; note that delete should not be called on the return value
826 new (slot) LocalType( &manager, &UpdateManager::RemoveAnimation, &animation );
829 inline void AddPropertyNotificationMessage( UpdateManager& manager, OwnerPointer< PropertyNotification >& propertyNotification )
831 // Message has ownership of PropertyNotification while in transit from event -> update
832 typedef MessageValue1< UpdateManager, OwnerPointer< PropertyNotification > > LocalType;
834 // Reserve some memory inside the message queue
835 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
837 // Construct message in the message queue memory; note that delete should not be called on the return value
838 new (slot) LocalType( &manager, &UpdateManager::AddPropertyNotification, propertyNotification );
841 inline void RemovePropertyNotificationMessage( UpdateManager& manager, const PropertyNotification& constPropertyNotification )
843 // The scene-graph thread owns this object so it can safely edit it.
844 PropertyNotification& propertyNotification = const_cast< PropertyNotification& >( constPropertyNotification );
846 typedef MessageValue1< UpdateManager, PropertyNotification* > LocalType;
848 // Reserve some memory inside the message queue
849 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
851 // Construct message in the message queue memory; note that delete should not be called on the return value
852 new (slot) LocalType( &manager, &UpdateManager::RemovePropertyNotification, &propertyNotification );
855 inline void PropertyNotificationSetNotifyModeMessage( UpdateManager& manager,
856 const PropertyNotification* constPropertyNotification,
857 PropertyNotification::NotifyMode notifyMode )
859 // The scene-graph thread owns this object so it can safely edit it.
860 PropertyNotification* propertyNotification = const_cast< PropertyNotification* >( constPropertyNotification );
862 typedef MessageValue2< UpdateManager, PropertyNotification*, PropertyNotification::NotifyMode > LocalType;
864 // Reserve some memory inside the message queue
865 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
867 // Construct message in the message queue memory; note that delete should not be called on the return value
868 new (slot) LocalType( &manager, &UpdateManager::PropertyNotificationSetNotify, propertyNotification, notifyMode );
871 // The render thread can safely change the Shader
872 inline void AddShaderMessage( UpdateManager& manager, OwnerPointer< Shader >& shader )
874 typedef MessageValue1< UpdateManager, OwnerPointer< Shader > > LocalType;
876 // Reserve some memory inside the message queue
877 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
879 // Construct message in the message queue memory; note that delete should not be called on the return value
880 new (slot) LocalType( &manager, &UpdateManager::AddShader, shader );
883 // The render thread can safely change the Shader
884 inline void RemoveShaderMessage( UpdateManager& manager, Shader& shader )
886 typedef MessageValue1< UpdateManager, Shader* > LocalType;
888 // Reserve some memory inside the message queue
889 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
891 // Construct message in the message queue memory; note that delete should not be called on the return value
892 new (slot) LocalType( &manager, &UpdateManager::RemoveShader, &shader );
895 inline void SetShaderProgramMessage( UpdateManager& manager,
897 Internal::ShaderDataPtr shaderData,
898 bool modifiesGeometry )
900 typedef MessageValue3< UpdateManager, Shader*, Internal::ShaderDataPtr, bool > LocalType;
902 // Reserve some memory inside the message queue
903 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
905 // Construct message in the message queue memory; note that delete should not be called on the return value
906 new (slot) LocalType( &manager, &UpdateManager::SetShaderProgram, &shader, shaderData, modifiesGeometry );
909 inline void SetBackgroundColorMessage( UpdateManager& manager, const Vector4& color )
911 typedef MessageValue1< UpdateManager, Vector4 > 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::SetBackgroundColor, color );
920 inline void SetDefaultSurfaceRectMessage( UpdateManager& manager, const Rect<int>& rect )
922 typedef MessageValue1< UpdateManager, Rect<int> > 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::SetDefaultSurfaceRect, rect );
931 inline void KeepRenderingMessage( UpdateManager& manager, float durationSeconds )
933 typedef MessageValue1< UpdateManager, float > 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::KeepRendering, durationSeconds );
943 * Create a message for setting the depth of a layer
944 * @param[in] manager The update manager
945 * @param[in] layers list of layers
946 * @param[in] systemLevel True if the layers are added via the SystemOverlay API
948 inline void SetLayerDepthsMessage( UpdateManager& manager, const std::vector< Layer* >& layers, bool systemLevel )
950 typedef MessageValue2< UpdateManager, std::vector< Layer* >, bool > LocalType;
952 // Reserve some memory inside the message queue
953 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
955 // Construct message in the message queue memory; note that delete should not be called on the return value
956 new (slot) LocalType( &manager, &UpdateManager::SetLayerDepths, layers, systemLevel );
959 inline void AddRendererMessage( UpdateManager& manager, OwnerPointer< Renderer >& object )
961 typedef MessageValue1< UpdateManager, OwnerPointer< Renderer > > LocalType;
963 // Reserve some memory inside the message queue
964 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::AddRenderer, object );
969 inline void RemoveRendererMessage( UpdateManager& manager, Renderer& object )
971 typedef MessageValue1< UpdateManager, Renderer* > LocalType;
973 // Reserve some memory inside the message queue
974 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
975 // Construct message in the message queue memory; note that delete should not be called on the return value
976 new (slot) LocalType( &manager, &UpdateManager::RemoveRenderer, &object );
979 // The render thread can safely change the Shader
980 inline void AddTextureSetMessage( UpdateManager& manager, OwnerPointer< TextureSet >& textureSet )
982 typedef MessageValue1< UpdateManager, OwnerPointer< TextureSet > > 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::AddTextureSet, textureSet );
991 // The render thread can safely change the Shader
992 inline void RemoveTextureSetMessage( UpdateManager& manager, TextureSet& textureSet )
994 typedef MessageValue1< UpdateManager, TextureSet* > LocalType;
996 // Reserve some memory inside the message queue
997 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
999 // Construct message in the message queue memory; note that delete should not be called on the return value
1000 new (slot) LocalType( &manager, &UpdateManager::RemoveTextureSet, &textureSet );
1003 inline void AddSamplerMessage( UpdateManager& manager, OwnerPointer< Render::Sampler >& sampler )
1005 // Message has ownership of Sampler while in transit from event -> update
1006 typedef MessageValue1< UpdateManager, OwnerPointer< Render::Sampler > > LocalType;
1008 // Reserve some memory inside the message queue
1009 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( &manager, &UpdateManager::AddSampler, sampler );
1015 inline void RemoveSamplerMessage( UpdateManager& manager, Render::Sampler& sampler )
1017 typedef MessageValue1< UpdateManager, Render::Sampler* > LocalType;
1019 // Reserve some memory inside the message queue
1020 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1022 // Construct message in the message queue memory; note that delete should not be called on the return value
1023 new (slot) LocalType( &manager, &UpdateManager::RemoveSampler, &sampler );
1026 inline void SetFilterModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int minFilterMode, unsigned int magFilterMode )
1028 typedef MessageValue3< UpdateManager, Render::Sampler*, unsigned int, unsigned int > LocalType;
1030 // Reserve some memory inside the message queue
1031 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1033 // Construct message in the message queue memory; note that delete should not be called on the return value
1034 new (slot) LocalType( &manager, &UpdateManager::SetFilterMode, &sampler, minFilterMode, magFilterMode );
1037 inline void SetWrapModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int rWrapMode, unsigned int sWrapMode, unsigned int tWrapMode )
1039 typedef MessageValue4< UpdateManager, Render::Sampler*, unsigned int, unsigned int, unsigned int > LocalType;
1041 // Reserve some memory inside the message queue
1042 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1044 // Construct message in the message queue memory; note that delete should not be called on the return value
1045 new (slot) LocalType( &manager, &UpdateManager::SetWrapMode, &sampler, rWrapMode, sWrapMode, tWrapMode );
1048 inline void AddPropertyBuffer( UpdateManager& manager, OwnerPointer< Render::PropertyBuffer >& propertyBuffer )
1050 // Message has ownership of propertyBuffer while in transit from event -> update
1051 typedef MessageValue1< UpdateManager, OwnerPointer< Render::PropertyBuffer > > LocalType;
1053 // Reserve some memory inside the message queue
1054 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1056 // Construct message in the message queue memory; note that delete should not be called on the return value
1057 new (slot) LocalType( &manager, &UpdateManager::AddPropertyBuffer, propertyBuffer );
1060 inline void RemovePropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer )
1062 typedef MessageValue1< UpdateManager, Render::PropertyBuffer* > LocalType;
1064 // Reserve some memory inside the message queue
1065 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1067 // Construct message in the message queue memory; note that delete should not be called on the return value
1068 new (slot) LocalType( &manager, &UpdateManager::RemovePropertyBuffer, &propertyBuffer );
1071 inline void SetPropertyBufferFormat( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, OwnerPointer< Render::PropertyBuffer::Format>& format )
1073 // Message has ownership of PropertyBuffer::Format while in transit from event -> update
1074 typedef MessageValue2< UpdateManager, Render::PropertyBuffer*, OwnerPointer< Render::PropertyBuffer::Format> > LocalType;
1076 // Reserve some memory inside the message queue
1077 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1079 // Construct message in the message queue memory; note that delete should not be called on the return value
1080 new (slot) LocalType( &manager, &UpdateManager::SetPropertyBufferFormat, &propertyBuffer, format );
1083 inline void SetPropertyBufferData( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, OwnerPointer< Vector<char> >& data, size_t size )
1085 // Message has ownership of PropertyBuffer data while in transit from event -> update
1086 typedef MessageValue3< UpdateManager, Render::PropertyBuffer*, OwnerPointer< Vector<char> >, size_t > LocalType;
1088 // Reserve some memory inside the message queue
1089 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1091 // Construct message in the message queue memory; note that delete should not be called on the return value
1092 new (slot) LocalType( &manager, &UpdateManager::SetPropertyBufferData, &propertyBuffer, data, size );
1095 inline void AddGeometry( UpdateManager& manager, OwnerPointer< Render::Geometry >& geometry )
1097 // Message has ownership of Geometry while in transit from event -> update
1098 typedef MessageValue1< UpdateManager, OwnerPointer< Render::Geometry > > 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::AddGeometry, geometry );
1107 inline void RemoveGeometry( UpdateManager& manager, Render::Geometry& geometry )
1109 typedef MessageValue1< UpdateManager, Render::Geometry* > LocalType;
1111 // Reserve some memory inside the message queue
1112 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1114 // Construct message in the message queue memory; note that delete should not be called on the return value
1115 new (slot) LocalType( &manager, &UpdateManager::RemoveGeometry, &geometry );
1118 inline void AttachVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer )
1120 typedef MessageValue2< UpdateManager, Render::Geometry*, Render::PropertyBuffer* > LocalType;
1122 // Reserve some memory inside the message queue
1123 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1125 // Construct message in the message queue memory; note that delete should not be called on the return value
1126 new (slot) LocalType( &manager, &UpdateManager::AttachVertexBuffer, &geometry, const_cast<Render::PropertyBuffer*>(&vertexBuffer) );
1129 inline void RemoveVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer )
1131 typedef MessageValue2< UpdateManager, Render::Geometry*, Render::PropertyBuffer* > LocalType;
1133 // Reserve some memory inside the message queue
1134 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1136 // Construct message in the message queue memory; note that delete should not be called on the return value
1137 new (slot) LocalType( &manager, &UpdateManager::RemoveVertexBuffer, &geometry, const_cast<Render::PropertyBuffer*>(&vertexBuffer) );
1140 // Custom message type for SetIndexBuffer() used to move data with Vector::Swap()
1141 template< typename T >
1142 class IndexBufferMessage : public MessageBase
1147 * Constructor which does a Vector::Swap()
1149 IndexBufferMessage( T* manager, Render::Geometry* geometry, Dali::Vector<unsigned short>& indices )
1151 mManager( manager ),
1152 mRenderGeometry( geometry )
1154 mIndices.Swap( indices );
1158 * Virtual destructor
1160 virtual ~IndexBufferMessage()
1165 * @copydoc MessageBase::Process
1167 virtual void Process( BufferIndex /*bufferIndex*/ )
1169 DALI_ASSERT_DEBUG( mManager && "Message does not have an object" );
1170 mManager->SetIndexBuffer( mRenderGeometry, mIndices );
1176 Render::Geometry* mRenderGeometry;
1177 Dali::Vector<unsigned short> mIndices;
1180 inline void SetIndexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, Dali::Vector<unsigned short>& indices )
1182 typedef IndexBufferMessage< UpdateManager > LocalType;
1184 // Reserve some memory inside the message queue
1185 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1187 // Construct message in the message queue memory; note that delete should not be called on the return value
1188 new (slot) LocalType( &manager, &geometry, indices );
1191 inline void SetGeometryTypeMessage( UpdateManager& manager, Render::Geometry& geometry, unsigned int geometryType )
1193 typedef MessageValue2< UpdateManager, Render::Geometry*, unsigned int > LocalType;
1195 // Reserve some memory inside the message queue
1196 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1198 // Construct message in the message queue memory; note that delete should not be called on the return value
1199 new (slot) LocalType( &manager, &UpdateManager::SetGeometryType, &geometry, geometryType );
1202 inline void AddTexture( UpdateManager& manager, OwnerPointer< Render::Texture >& texture )
1204 // Message has ownership of Texture while in transit from event -> update
1205 typedef MessageValue1< UpdateManager, OwnerPointer< Render::Texture > > LocalType;
1207 // Reserve some memory inside the message queue
1208 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1210 // Construct message in the message queue memory; note that delete should not be called on the return value
1211 new (slot) LocalType( &manager, &UpdateManager::AddTexture, texture );
1214 inline void RemoveTexture( UpdateManager& manager, Render::Texture& texture )
1216 typedef MessageValue1< UpdateManager, Render::Texture* > LocalType;
1218 // Reserve some memory inside the message queue
1219 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1221 // Construct message in the message queue memory; note that delete should not be called on the return value
1222 new (slot) LocalType( &manager, &UpdateManager::RemoveTexture, &texture );
1225 inline void UploadTextureMessage( UpdateManager& manager, Render::Texture& texture, PixelDataPtr pixelData, const Texture::UploadParams& params )
1227 typedef MessageValue3< UpdateManager, Render::Texture*, PixelDataPtr, Texture::UploadParams > LocalType;
1229 // Reserve some memory inside the message queue
1230 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1232 // Construct message in the message queue memory; note that delete should not be called on the return value
1233 new (slot) LocalType( &manager, &UpdateManager::UploadTexture, &texture, pixelData, params );
1236 inline void GenerateMipmapsMessage( UpdateManager& manager, Render::Texture& texture )
1238 typedef MessageValue1< UpdateManager, Render::Texture* > LocalType;
1240 // Reserve some memory inside the message queue
1241 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1243 // Construct message in the message queue memory; note that delete should not be called on the return value
1244 new (slot) LocalType( &manager, &UpdateManager::GenerateMipmaps, &texture );
1248 inline void AddFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer )
1250 typedef MessageValue1< UpdateManager, Render::FrameBuffer* > LocalType;
1252 // Reserve some memory inside the message queue
1253 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1255 // Construct message in the message queue memory; note that delete should not be called on the return value
1256 new (slot) LocalType( &manager, &UpdateManager::AddFrameBuffer, &frameBuffer );
1259 inline void RemoveFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer )
1261 typedef MessageValue1< UpdateManager, Render::FrameBuffer* > LocalType;
1263 // Reserve some memory inside the message queue
1264 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1266 // Construct message in the message queue memory; note that delete should not be called on the return value
1267 new (slot) LocalType( &manager, &UpdateManager::RemoveFrameBuffer, &frameBuffer );
1270 inline void AttachColorTextureToFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer, Render::Texture* texture, unsigned int mipmapLevel, unsigned int layer )
1272 typedef MessageValue4< UpdateManager, Render::FrameBuffer*, Render::Texture*, unsigned int, unsigned int > LocalType;
1274 // Reserve some memory inside the message queue
1275 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1277 // Construct message in the message queue memory; note that delete should not be called on the return value
1278 new (slot) LocalType( &manager, &UpdateManager::AttachColorTextureToFrameBuffer, &frameBuffer, texture, mipmapLevel, layer );
1281 inline void SetDepthIndicesMessage( UpdateManager& manager, OwnerPointer< NodeDepths >& nodeDepths )
1283 typedef MessageValue1< UpdateManager, OwnerPointer< NodeDepths > > LocalType;
1285 // Reserve some memory inside the message queue
1286 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1288 // Construct message in the message queue memory; note that delete should not be called on the return value
1289 new (slot) LocalType( &manager, &UpdateManager::SetDepthIndices, nodeDepths );
1292 } // namespace SceneGraph
1294 } // namespace Internal
1298 #endif // DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H