1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H__
5 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/common/vector-wrapper.h>
23 #include <dali/public-api/common/dali-common.h>
25 #include <dali/integration-api/resource-declarations.h>
27 #include <dali/internal/common/message.h>
28 #include <dali/internal/common/type-abstraction-enums.h>
29 #include <dali/internal/common/shader-saver.h>
30 #include <dali/internal/event/common/event-thread-services.h>
31 #include <dali/internal/update/animation/scene-graph-animation.h>
32 #include <dali/internal/update/common/scene-graph-buffers.h>
33 #include <dali/internal/update/common/scene-graph-property-notification.h>
34 #include <dali/internal/update/manager/object-owner-container.h>
35 #include <dali/internal/update/nodes/node.h>
36 #include <dali/internal/update/nodes/scene-graph-layer.h>
37 #include <dali/internal/update/rendering/scene-graph-renderer.h>
38 #include <dali/internal/render/shaders/scene-graph-shader.h>
39 #include <dali/internal/render/renderers/render-property-buffer.h>
46 class GlSyncAbstraction;
47 class RenderController;
49 } // namespace Integration
54 class PropertyNotifier;
55 class NotificationManager;
56 class CompleteNotificationInterface;
57 class ResourceManager;
65 // value types used by messages
66 template <> struct ParameterType< PropertyNotification::NotifyMode >
67 : public BasicType< PropertyNotification::NotifyMode > {};
78 class TextureCacheDispatcher;
84 * UpdateManager maintains a scene graph i.e. a tree of nodes as well as
85 * other scene graph property owning objects.
86 * It controls the Update traversal, in which nodes are repositioned/animated,
87 * and organizes the the culling and rendering of the scene.
88 * It also maintains the lifecycle of nodes and other property owners that are
89 * disconnected from the scene graph.
91 class UpdateManager : public ShaderSaver
96 * Construct a new UpdateManager.
97 * @param[in] notificationManager This should be notified when animations have finished.
98 * @param[in] animationFinishedNotifier The CompleteNotificationInterface that handles animation completions
99 * @param[in] propertyNotifier The PropertyNotifier
100 * @param[in] resourceManager The resource manager used to load textures etc.
101 * @param[in] discardQueue Nodes are added here when disconnected from the scene-graph.
102 * @param[in] controller After messages are flushed, we request a render from the RenderController.
103 * @param[in] renderManager This is responsible for rendering the results of each "update".
104 * @param[in] renderQueue Used to queue messages for the next render.
105 * @param[in] textureCacheDispatcher Used for sending messages to texture cache.
107 UpdateManager( NotificationManager& notificationManager,
108 CompleteNotificationInterface& animationFinishedNotifier,
109 PropertyNotifier& propertyNotifier,
110 ResourceManager& resourceManager,
111 DiscardQueue& discardQueue,
112 Integration::RenderController& controller,
113 RenderManager& renderManager,
114 RenderQueue& renderQueue,
115 TextureCacheDispatcher& textureCacheDispatcher );
120 virtual ~UpdateManager();
122 // Node connection methods
125 * Get the scene graph side list of RenderTasks.
126 * @param[in] systemLevel True if using the system-level overlay.
127 * @return The list of render tasks
129 RenderTaskList* GetRenderTaskList( bool systemLevel );
132 * Installs a new layer as the root node.
133 * @pre The UpdateManager does not already have an installed root node.
134 * @pre The layer is of derived Node type Layer.
135 * @pre The layer does not have a parent.
136 * @param[in] layer The new root node.
137 * @param[in] systemLevel True if using the system-level overlay.
138 * @post The node is owned by UpdateManager.
140 void InstallRoot( Layer* layer, bool systemLevel );
143 * Add a Node; UpdateManager takes ownership.
144 * @pre The node does not have a parent.
145 * @param[in] node The node to add.
147 void AddNode( Node* node );
150 * Connect a Node to the scene-graph.
151 * A disconnected Node has has no parent or children, and its properties cannot be animated/constrained.
152 * @pre The node does not already have a parent.
153 * @param[in] parent The new parent node.
155 void ConnectNode( Node* parent, Node* node );
158 * Disconnect a Node from the scene-graph.
159 * A disconnected Node has has no parent or children, and its properties cannot be animated/constrained.
160 * @pre The node has a parent.
161 * @param[in] node The node to disconnect.
163 void DisconnectNode( Node* node );
166 * Destroy a Node owned by UpdateManager.
167 * This is not immediate; Nodes are passed to the RenderQueue to allow GL resources to be deleted.
168 * In the following update, the previously queued Nodes may be deleted.
169 * @pre The node has been disconnected from the scene-graph i.e. has no parent or children.
170 * @param[in] node The node to destroy.
172 void DestroyNode( Node* node );
175 * Add a camera on scene
176 * @param[in] camera to add
178 void AddCamera( Camera* camera );
181 * Remove a camera from scene
182 * @param[in] camera to remove
184 void RemoveCamera( const Camera* camera );
187 * Add a newly created object.
188 * @param[in] object The object to add.
189 * @post The object is owned by UpdateManager.
191 void AddObject( PropertyOwner* object );
195 * @param[in] object The object to remove.
197 void RemoveObject( PropertyOwner* object );
202 * Add a newly created animation.
203 * @param[in] animation The animation to add.
204 * @post The animation is owned by UpdateManager.
206 void AddAnimation( Animation* animation );
210 * @param[in] animation The animation to stop.
212 void StopAnimation( Animation* animation );
215 * Remove an animation.
216 * @param[in] animation The animation to remove.
218 void RemoveAnimation( Animation* animation );
221 * Query whether any animations are currently running.
222 * @return True if any animations are running.
224 bool IsAnimationRunning() const;
226 // Property Notification
229 * Add a newly created property notification
230 * @param[in] propertyNotification The notification to add
231 * @post The propertyNotification is owned by UpdateManager.
233 void AddPropertyNotification( PropertyNotification* propertyNotification );
236 * Remove a property notification
237 * @param[in] propertyNotification The notification to remove
239 void RemovePropertyNotification( PropertyNotification* propertyNotification );
242 * Set Notify state for PropertyNotification
243 * @param[in] propertyNotification The notification to remove
244 * @param[in] notifyMode The notification mode.
246 void PropertyNotificationSetNotify( PropertyNotification* propertyNotification, PropertyNotification::NotifyMode notifyMode );
249 * @brief Get the renderer owner
251 * @return The renderer owner
253 ObjectOwnerContainer< Renderer >& GetRendererOwner();
256 * @brief Get the property buffer owner
258 * @return The property buffer owner
260 ObjectOwnerContainer< PropertyBuffer >& GetPropertyBufferOwner();
266 * Add a newly created shader.
267 * @param[in] shader The shader to add.
268 * @post The shader is owned by the UpdateManager.
270 void AddShader(Shader* shader);
274 * @pre The shader has been added to the UpdateManager.
275 * @param[in] shader The shader to remove.
276 * @post The shader is destroyed.
278 void RemoveShader(Shader* shader);
281 * Add a newly created TextureSet.
282 * @param[in] textureSet The texture set to add.
283 * @post The TextureSet is owned by the UpdateManager.
285 void AddTextureSet(TextureSet* textureSet);
288 * Remove a TextureSet.
289 * @pre The TextureSet has been added to the UpdateManager.
290 * @param[in] textureSet The TextureSet to remove.
291 * @post The TextureSet is destroyed.
293 void RemoveTextureSet(TextureSet* textureSet);
296 * Set the shader program for a Shader object
297 * @param[in] shader The shader to modify
298 * @param[in] shaderData Source code, hash over source, and optional compiled binary for the shader program
299 * @param[in] modifiesGeometry True if the vertex shader modifies geometry
301 void SetShaderProgram( Shader* shader, Internal::ShaderDataPtr shaderData, bool modifiesGeometry );
304 * @brief Accept compiled shaders passed back on render thread for saving.
305 * @param[in] shaderData Source code, hash over source, and corresponding compiled binary to be saved.
307 virtual void SaveBinary( Internal::ShaderDataPtr shaderData );
310 * @brief Set the destination for compiled shader binaries to be passed on to.
311 * The dispatcher passed in will be called from the update thread.
312 * @param[in] upstream A sink for ShaderDatas to be passed into.
314 void SetShaderSaver( ShaderSaver& upstream );
319 * Add a newly created gesture.
320 * @param[in] gesture The gesture to add.
321 * @post The gesture is owned by the UpdateManager.
323 void AddGesture( PanGesture* gesture );
327 * @pre The gesture has been added to the UpdateManager.
328 * @param[in] gesture The gesture to remove.
329 * @post The gesture is destroyed.
331 void RemoveGesture( PanGesture* gesture );
333 // Message queue handling
336 * Reserve space for another message in the queue; this must then be initialized by the caller.
337 * The message will be read from the update-thread after the next FlushMessages is called.
338 * @post Calling this method may invalidate any previously returned slots.
339 * @param[in] size The message size with respect to the size of type "char".
340 * @param[in] updateScene A flag, when true denotes that the message will cause the scene-graph node tree to require an update.
341 * @note the default value of updateScene should match that in EventThreadServices::ReserveMessageSlot.
342 * @return A pointer to the first char allocated for the message.
344 unsigned int* ReserveMessageSlot( std::size_t size, bool updateScene = true );
347 * @return the current event-buffer index.
349 BufferIndex GetEventBufferIndex() const
351 // inlined as its called often from event thread
352 return mSceneGraphBuffers.GetEventBufferIndex();
356 * Called by the event-thread to signal that FlushQueue will be called
357 * e.g. when it has finished event processing.
359 void EventProcessingStarted();
362 * Flush the set of messages, which were previously stored with QueueMessage().
363 * Calls to this thread-safe method should be minimized, to avoid thread blocking.
365 * @return True if there are messages to process.
370 * Add a new sampler to RenderManager
371 * @param[in] sampler The sampler to add
372 * @post Sends a message to RenderManager to add the sampler.
373 * The sampler will be owned by RenderManager
375 void AddSampler( Render::Sampler* sampler );
378 * Removes an existing sampler from RenderManager
379 * @param[in] sampler The sampler to remove
380 * @post The sampler will be destroyed in the render thread
382 void RemoveSampler( Render::Sampler* sampler );
385 * Sets the filter modes for an existing sampler
386 * @param[in] sampler The sampler
387 * @param[in] minFilterMode The filter to use under minification
388 * @param[in] magFilterMode The filter to use under magnification
390 void SetFilterMode( Render::Sampler* sampler, unsigned int minFilterMode, unsigned int magFilterMode );
393 * Sets the wrap mode for an existing sampler
394 * @param[in] sampler The sampler
395 * @param[in] rWrapMode Wrapping mode in z direction
396 * @param[in] sWrapMode Wrapping mode in x direction
397 * @param[in] tWrapMode Wrapping mode in y direction
399 void SetWrapMode( Render::Sampler* sampler, unsigned int rWrapMode, unsigned int sWrapMode, unsigned int tWrapMode );
402 * Add a new property buffer to RenderManager
403 * @param[in] propertryBuffer The property buffer to add
404 * @post Sends a message to RenderManager to add the property buffer.
405 * The property buffer will be owned by RenderManager
407 void AddPropertyBuffer( Render::PropertyBuffer* propertryBuffer );
410 * Removes an existing PropertyBuffer from RenderManager
411 * @param[in] propertryBuffer The property buffer to remove
412 * @post The property buffer will be destroyed in the render thread
414 void RemovePropertyBuffer( Render::PropertyBuffer* propertryBuffer );
417 * Sets the format of an existing property buffer
418 * @param[in] propertyBuffer The property buffer.
419 * @param[in] format The new format of the buffer
420 * @post Sends a message to RenderManager to set the new format to the property buffer.
422 void SetPropertyBufferFormat(Render::PropertyBuffer* propertyBuffer, Render::PropertyBuffer::Format* format );
425 * Sets the data of an existing property buffer
426 * @param[in] propertyBuffer The property buffer.
427 * @param[in] data The new data of the buffer
428 * @param[in] size The new size of the buffer
429 * @post Sends a message to RenderManager to set the new data to the property buffer.
431 void SetPropertyBufferData(Render::PropertyBuffer* propertyBuffer, Dali::Vector<char>* data, size_t size);
434 * Adds a geometry to the RenderManager
435 * @param[in] geometry The geometry to add
436 * @post Sends a message to RenderManager to add the Geometry
437 * The geometry will be owned by RenderManager
439 void AddGeometry( Render::Geometry* geometry );
442 * Removes an existing Geometry from RenderManager
443 * @param[in] geometry The geometry to remove
444 * @post The geometry will be destroyed in the render thread
446 void RemoveGeometry( Render::Geometry* geometry );
449 * Sets the geometry type of an existing Geometry
450 * @param[in] geometry The geometry
451 * @param[in] geometryType The type of the geometry
453 void SetGeometryType( Render::Geometry* geometry, unsigned int geometryType );
456 * Sets the index buffer to be used by a geometry
457 * @param[in] geometry The geometry
458 * @param[in] indices A vector containing the indices for the geometry
460 void SetIndexBuffer( Render::Geometry* geometry, Dali::Vector<unsigned short>& indices );
463 * Adds a vertex buffer to a geomtry
464 * @param[in] geometry The geometry
465 * @param[in] propertyBuffer The property buffer
467 void AddVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer );
470 * Removes a vertex buffer from a geometry
471 * @param[in] geometry The geometry
472 * @param[in] propertyBuffer The property buffer
474 void RemoveVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer );
477 * Adds a texture to the render manager
478 * @param[in] texture The texture to add
479 * The texture will be owned by RenderManager
481 void AddTexture( Render::NewTexture* texture );
484 * Removes a texture from the render manager
485 * @param[in] texture The texture to remove
486 * @post The texture will be destroyed in the render thread
488 void RemoveTexture( Render::NewTexture* texture );
491 * Uploads data to a texture owned by the RenderManager
492 * @param[in] texture The texture
493 * @param[in] buffer Vector with the data to be uploaded
494 * @param[in] params The parameters for the upload
496 void UploadTexture( Render::NewTexture* texture, Vector<unsigned char>& buffer, const TextureUploadParams& params );
499 * Generates mipmaps for a texture owned by the RenderManager
500 * @param[in] texture The texture
502 void GenerateMipmaps( Render::NewTexture* texture );
505 * Adds a framebuffer to the render manager
506 * @param[in] frameBuffer The framebuffer to add
507 * The framebuffer will be owned by RenderManager
509 void AddFrameBuffer( Render::FrameBuffer* frameBuffer );
512 * Removes a FrameBuffer from the render manager
513 * @param[in] frameBuffer The FrameBuffer to remove
514 * @post The FrameBuffer will be destroyed in the render thread
516 void RemoveFrameBuffer( Render::FrameBuffer* frameBuffer );
519 * Attach a texture as color output to an existing FrameBuffer
520 * @param[in] frameBuffer The FrameBuffer
521 * @param[in] texture The texture that will be used as output when rendering
522 * @param[in] mipmapLevel The mipmap of the texture to be attached
523 * @param[in] layer Indicates which layer of a cube map or array texture to attach. Unused for 2D textures
525 void AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::NewTexture* texture, unsigned int mipmapLevel, unsigned int face );
528 * Attach a texture as depth-stencil to an existing FrameBuffer
529 * @param[in] frameBuffer The FrameBuffer
530 * @param[in] texture The texture that will be used as depth-stencil buffer when rendering
532 void AttachDepthStencilTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::NewTexture* texture );
537 * Performs an Update traversal on the scene-graph.
538 * @param[in] elapsedSeconds The elapsed time that should be applied to animations.
539 * @param[in] lastVSyncTimeMilliseconds The last time, in milliseconds, that we had a VSync.
540 * @param[in] nextVSyncTimeMilliseconds The estimated time, in milliseconds, of the next VSync.
541 * @return True if further updates are required e.g. during animations.
543 unsigned int Update( float elapsedSeconds, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds );
546 * Set the background color i.e. the glClear color used at the beginning of each frame.
547 * @param[in] color The new background color.
549 void SetBackgroundColor(const Vector4& color);
552 * Set the default surface rect.
553 * @param[in] rect The rect value representing the surface.
555 void SetDefaultSurfaceRect( const Rect<int>& rect );
558 * @copydoc Dali::Stage::KeepRendering()
560 void KeepRendering( float durationSeconds );
563 * Sets the depths of all layers.
564 * @param layers The layers in depth order.
565 * @param[in] systemLevel True if using the system-level overlay.
567 void SetLayerDepths( const std::vector< Layer* >& layers, bool systemLevel );
572 UpdateManager(const UpdateManager&);
575 UpdateManager& operator=(const UpdateManager& rhs);
578 * Helper to check whether the update-thread should keep going.
579 * @param[in] elapsedSeconds The time in seconds since the previous update.
580 * @return True if the update-thread should keep going.
582 unsigned int KeepUpdatingCheck( float elapsedSeconds ) const;
585 * Post process resources that have been updated by renderer
587 void PostProcessResources();
590 * Helper to reset all Node properties
591 * @param[in] bufferIndex to use
593 void ResetProperties( BufferIndex bufferIndex );
596 * Perform gesture updates.
597 * @param[in] bufferIndex to use
598 * @param[in] lastVSyncTime The last VSync time in milliseconds.
599 * @param[in] nextVSyncTime The estimated time of the next VSync in milliseconds.
600 * @return true, if any properties were updated.
602 bool ProcessGestures( BufferIndex bufferIndex, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds );
605 * Perform animation updates
606 * @param[in] bufferIndex to use
607 * @param[in] elapsedSeconds time since last frame
609 void Animate( BufferIndex bufferIndex, float elapsedSeconds );
612 * Applies constraints to CustomObjects
613 * @param[in] bufferIndex to use
615 void ConstrainCustomObjects( BufferIndex bufferIndex );
618 * Applies constraints to RenderTasks
619 * @param[in] bufferIndex to use
621 void ConstrainRenderTasks( BufferIndex bufferIndex );
624 * Applies constraints to Shaders
625 * @param[in] bufferIndex to use
627 void ConstrainShaders( BufferIndex bufferIndex );
630 * Perform property notification updates
631 * @param[in] bufferIndex to use
633 void ProcessPropertyNotifications( BufferIndex bufferIndex );
636 * Prepare textures for rendering
638 void PrepareTextureSets( BufferIndex bufferIndex );
641 * Pass shader binaries queued here on to event thread.
643 void ForwardCompiledShadersToEventThread();
646 * Update node shaders, opacity, geometry etc.
647 * @param[in] bufferIndex to use
649 void UpdateNodes( BufferIndex bufferIndex );
653 * @param[in] bufferIndex to use
655 void UpdateRenderers( BufferIndex bufferIndex );
659 // needs to be direct member so that getter for event buffer can be inlined
660 SceneGraphBuffers mSceneGraphBuffers;
667 // Messages for UpdateManager
669 inline void InstallRootMessage( UpdateManager& manager, Layer& root, bool systemLevel )
671 typedef MessageValue2< UpdateManager, Layer*, bool > LocalType;
673 // Reserve some memory inside the message queue
674 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
676 // Construct message in the message queue memory; note that delete should not be called on the return value
677 new (slot) LocalType( &manager, &UpdateManager::InstallRoot, &root, systemLevel );
680 inline void AddNodeMessage( UpdateManager& manager, Node& node )
682 typedef MessageValue1< UpdateManager, OwnerPointer<Node> > LocalType;
684 // Reserve some memory inside the message queue
685 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
687 // Construct message in the message queue memory; note that delete should not be called on the return value
688 new (slot) LocalType( &manager, &UpdateManager::AddNode, &node );
691 inline void ConnectNodeMessage( UpdateManager& manager, const Node& constParent, const Node& constChild )
693 // Update thread can edit the object
694 Node& parent = const_cast< Node& >( constParent );
695 Node& child = const_cast< Node& >( constChild );
697 typedef MessageValue2< UpdateManager, Node*, Node* > LocalType;
699 // Reserve some memory inside the message queue
700 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
702 // Construct message in the message queue memory; note that delete should not be called on the return value
703 new (slot) LocalType( &manager, &UpdateManager::ConnectNode, &parent, &child );
706 inline void DisconnectNodeMessage( UpdateManager& manager, const Node& constNode )
708 // Scene graph thread can modify this object.
709 Node& node = const_cast< Node& >( constNode );
711 typedef MessageValue1< UpdateManager, Node* > LocalType;
713 // Reserve some memory inside the message queue
714 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
716 // Construct message in the message queue memory; note that delete should not be called on the return value
717 new (slot) LocalType( &manager, &UpdateManager::DisconnectNode, &node );
720 inline void DestroyNodeMessage( UpdateManager& manager, const Node& constNode )
722 // Scene graph thread can destroy this object.
723 Node& node = const_cast< Node& >( constNode );
725 typedef MessageValue1< UpdateManager, Node* > LocalType;
727 // Reserve some memory inside the message queue
728 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
730 // Construct message in the message queue memory; note that delete should not be called on the return value
731 new (slot) LocalType( &manager, &UpdateManager::DestroyNode, &node );
734 inline void AddCameraMessage( UpdateManager& manager, const Camera* constCamera )
736 typedef MessageValue1< UpdateManager, Camera* > LocalType;
738 Camera* camera = const_cast<Camera*>( constCamera );
739 // Reserve some memory inside the message queue
740 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
742 // Construct message in the message queue memory; note that delete should not be called on the return value
743 new (slot) LocalType( &manager, &UpdateManager::AddCamera, camera );
746 inline void RemoveCameraMessage( UpdateManager& manager, const Camera* camera )
748 typedef MessageValue1< UpdateManager, const Camera* > LocalType;
750 // Reserve some memory inside the message queue
751 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
753 // Construct message in the message queue memory; note that delete should not be called on the return value
754 new (slot) LocalType( &manager, &UpdateManager::RemoveCamera, camera );
757 inline void AddObjectMessage( UpdateManager& manager, PropertyOwner* object )
759 typedef MessageValue1< UpdateManager, OwnerPointer<PropertyOwner> > LocalType;
761 // Reserve some memory inside the message queue
762 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
764 // Construct message in the message queue memory; note that delete should not be called on the return value
765 new (slot) LocalType( &manager, &UpdateManager::AddObject, object );
768 inline void RemoveObjectMessage( UpdateManager& manager, PropertyOwner* object )
770 typedef MessageValue1< UpdateManager, 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::RemoveObject, object );
779 inline void AddAnimationMessage( UpdateManager& manager, Animation* animation )
781 typedef MessageValue1< UpdateManager, Animation* > 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::AddAnimation, animation );
790 inline void StopAnimationMessage( UpdateManager& manager, const Animation& constAnimation )
792 // The scene-graph thread owns this object so it can safely edit it.
793 Animation& animation = const_cast< Animation& >( constAnimation );
795 typedef MessageValue1< UpdateManager, Animation* > LocalType;
797 // Reserve some memory inside the message queue
798 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
800 // Construct message in the message queue memory; note that delete should not be called on the return value
801 new (slot) LocalType( &manager, &UpdateManager::StopAnimation, &animation );
804 inline void RemoveAnimationMessage( UpdateManager& manager, const Animation& constAnimation )
806 // The scene-graph thread owns this object so it can safely edit it.
807 Animation& animation = const_cast< Animation& >( constAnimation );
809 typedef MessageValue1< UpdateManager, Animation* > LocalType;
811 // Reserve some memory inside the message queue
812 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
814 // Construct message in the message queue memory; note that delete should not be called on the return value
815 new (slot) LocalType( &manager, &UpdateManager::RemoveAnimation, &animation );
818 inline void AddPropertyNotificationMessage( UpdateManager& manager, PropertyNotification* propertyNotification )
820 typedef MessageValue1< UpdateManager, PropertyNotification* > 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::AddPropertyNotification, propertyNotification );
829 inline void RemovePropertyNotificationMessage( UpdateManager& manager, const PropertyNotification& constPropertyNotification )
831 // The scene-graph thread owns this object so it can safely edit it.
832 PropertyNotification& propertyNotification = const_cast< PropertyNotification& >( constPropertyNotification );
834 typedef MessageValue1< UpdateManager, PropertyNotification* > LocalType;
836 // Reserve some memory inside the message queue
837 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
839 // Construct message in the message queue memory; note that delete should not be called on the return value
840 new (slot) LocalType( &manager, &UpdateManager::RemovePropertyNotification, &propertyNotification );
843 inline void PropertyNotificationSetNotifyModeMessage( UpdateManager& manager,
844 const PropertyNotification* constPropertyNotification,
845 PropertyNotification::NotifyMode notifyMode )
847 // The scene-graph thread owns this object so it can safely edit it.
848 PropertyNotification* propertyNotification = const_cast< PropertyNotification* >( constPropertyNotification );
850 typedef MessageValue2< UpdateManager, PropertyNotification*, PropertyNotification::NotifyMode > LocalType;
852 // Reserve some memory inside the message queue
853 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
855 // Construct message in the message queue memory; note that delete should not be called on the return value
856 new (slot) LocalType( &manager, &UpdateManager::PropertyNotificationSetNotify, propertyNotification, notifyMode );
859 // The render thread can safely change the Shader
860 inline void AddShaderMessage( UpdateManager& manager, Shader& shader )
862 typedef MessageValue1< UpdateManager, OwnerPointer< Shader > > 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::AddShader, &shader );
871 // The render thread can safely change the Shader
872 inline void RemoveShaderMessage( UpdateManager& manager, Shader& shader )
874 typedef MessageValue1< UpdateManager, 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::RemoveShader, &shader );
883 inline void SetShaderProgramMessage( UpdateManager& manager,
885 Internal::ShaderDataPtr shaderData,
886 bool modifiesGeometry )
888 typedef MessageValue3< UpdateManager, Shader*, Internal::ShaderDataPtr, bool > LocalType;
890 // Reserve some memory inside the message queue
891 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
893 // Construct message in the message queue memory; note that delete should not be called on the return value
894 new (slot) LocalType( &manager, &UpdateManager::SetShaderProgram, &shader, shaderData, modifiesGeometry );
897 inline void SetBackgroundColorMessage( UpdateManager& manager, const Vector4& color )
899 typedef MessageValue1< UpdateManager, Vector4 > LocalType;
901 // Reserve some memory inside the message queue
902 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
904 // Construct message in the message queue memory; note that delete should not be called on the return value
905 new (slot) LocalType( &manager, &UpdateManager::SetBackgroundColor, color );
908 inline void SetDefaultSurfaceRectMessage( UpdateManager& manager, const Rect<int>& rect )
910 typedef MessageValue1< UpdateManager, Rect<int> > LocalType;
912 // Reserve some memory inside the message queue
913 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
915 // Construct message in the message queue memory; note that delete should not be called on the return value
916 new (slot) LocalType( &manager, &UpdateManager::SetDefaultSurfaceRect, rect );
919 inline void KeepRenderingMessage( UpdateManager& manager, float durationSeconds )
921 typedef MessageValue1< UpdateManager, float > LocalType;
923 // Reserve some memory inside the message queue
924 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
926 // Construct message in the message queue memory; note that delete should not be called on the return value
927 new (slot) LocalType( &manager, &UpdateManager::KeepRendering, durationSeconds );
931 * Create a message for setting the depth of a layer
932 * @param[in] manager The update manager
933 * @param[in] layers list of layers
934 * @param[in] systemLevel True if the layers are added via the SystemOverlay API
936 inline void SetLayerDepthsMessage( UpdateManager& manager, const std::vector< Layer* >& layers, bool systemLevel )
938 typedef MessageValue2< UpdateManager, std::vector< Layer* >, bool > LocalType;
940 // Reserve some memory inside the message queue
941 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
943 // Construct message in the message queue memory; note that delete should not be called on the return value
944 new (slot) LocalType( &manager, &UpdateManager::SetLayerDepths, layers, systemLevel );
947 inline void AddGestureMessage( UpdateManager& manager, PanGesture* gesture )
949 typedef MessageValue1< UpdateManager, PanGesture* > LocalType;
951 // Reserve some memory inside the message queue
952 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
954 // Construct message in the message queue memory; note that delete should not be called on the return value
955 new (slot) LocalType( &manager, &UpdateManager::AddGesture, gesture );
958 inline void RemoveGestureMessage( UpdateManager& manager, PanGesture* gesture )
960 typedef MessageValue1< UpdateManager, PanGesture* > LocalType;
962 // Reserve some memory inside the message queue
963 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
965 // Construct message in the message queue memory; note that delete should not be called on the return value
966 new (slot) LocalType( &manager, &UpdateManager::RemoveGesture, gesture );
969 template< typename T >
970 inline void AddMessage( UpdateManager& manager, ObjectOwnerContainer<T>& owner, T& object )
972 typedef MessageValue1< ObjectOwnerContainer<T>, OwnerPointer< T > > LocalType;
974 // Reserve some memory inside the message queue
975 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
976 // Construct message in the message queue memory; note that delete should not be called on the return value
977 new (slot) LocalType( &owner, &ObjectOwnerContainer<T>::Add, &object );
980 template< typename T >
981 inline void RemoveMessage( UpdateManager& manager, ObjectOwnerContainer<T>& owner, T& object )
983 typedef MessageValue1< ObjectOwnerContainer<T>, T* > LocalType;
985 // Reserve some memory inside the message queue
986 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( &owner, &ObjectOwnerContainer<T>::Remove, &object );
991 // The render thread can safely change the Shader
992 inline void AddTextureSetMessage( UpdateManager& manager, TextureSet& textureSet )
994 typedef MessageValue1< UpdateManager, OwnerPointer< 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::AddTextureSet, &textureSet );
1003 // The render thread can safely change the Shader
1004 inline void RemoveTextureSetMessage( UpdateManager& manager, TextureSet& textureSet )
1006 typedef MessageValue1< UpdateManager, TextureSet* > 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::RemoveTextureSet, &textureSet );
1015 inline void AddSamplerMessage( 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::AddSampler, &sampler );
1026 inline void RemoveSamplerMessage( UpdateManager& manager, Render::Sampler& sampler )
1028 typedef MessageValue1< UpdateManager, Render::Sampler* > 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::RemoveSampler, &sampler );
1037 inline void SetFilterModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int minFilterMode, unsigned int magFilterMode )
1039 typedef MessageValue3< UpdateManager, Render::Sampler*, 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::SetFilterMode, &sampler, minFilterMode, magFilterMode );
1048 inline void SetWrapModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int rWrapMode, unsigned int sWrapMode, unsigned int tWrapMode )
1050 typedef MessageValue4< UpdateManager, Render::Sampler*, unsigned int, unsigned int, unsigned int > LocalType;
1052 // Reserve some memory inside the message queue
1053 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1055 // Construct message in the message queue memory; note that delete should not be called on the return value
1056 new (slot) LocalType( &manager, &UpdateManager::SetWrapMode, &sampler, rWrapMode, sWrapMode, tWrapMode );
1059 inline void AddPropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer )
1061 typedef MessageValue1< UpdateManager, Render::PropertyBuffer* > LocalType;
1063 // Reserve some memory inside the message queue
1064 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1066 // Construct message in the message queue memory; note that delete should not be called on the return value
1067 new (slot) LocalType( &manager, &UpdateManager::AddPropertyBuffer, &propertyBuffer );
1070 inline void RemovePropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer )
1072 typedef MessageValue1< UpdateManager, Render::PropertyBuffer* > LocalType;
1074 // Reserve some memory inside the message queue
1075 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1077 // Construct message in the message queue memory; note that delete should not be called on the return value
1078 new (slot) LocalType( &manager, &UpdateManager::RemovePropertyBuffer, &propertyBuffer );
1081 inline void SetPropertyBufferFormat( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, Render::PropertyBuffer::Format* format )
1083 typedef MessageValue2< UpdateManager, Render::PropertyBuffer*, Render::PropertyBuffer::Format* > LocalType;
1085 // Reserve some memory inside the message queue
1086 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1088 // Construct message in the message queue memory; note that delete should not be called on the return value
1089 new (slot) LocalType( &manager, &UpdateManager::SetPropertyBufferFormat, &propertyBuffer, format );
1092 inline void SetPropertyBufferData( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, Vector<char>* data, size_t size )
1094 typedef MessageValue3< UpdateManager, Render::PropertyBuffer*, Vector<char>*, size_t > LocalType;
1096 // Reserve some memory inside the message queue
1097 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1099 // Construct message in the message queue memory; note that delete should not be called on the return value
1100 new (slot) LocalType( &manager, &UpdateManager::SetPropertyBufferData, &propertyBuffer, data, size );
1103 inline void AddGeometry( UpdateManager& manager, Render::Geometry& geometry )
1105 typedef MessageValue1< UpdateManager, Render::Geometry* > LocalType;
1107 // Reserve some memory inside the message queue
1108 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1110 // Construct message in the message queue memory; note that delete should not be called on the return value
1111 new (slot) LocalType( &manager, &UpdateManager::AddGeometry, &geometry );
1114 inline void RemoveGeometry( UpdateManager& manager, Render::Geometry& geometry )
1116 typedef MessageValue1< UpdateManager, Render::Geometry* > LocalType;
1118 // Reserve some memory inside the message queue
1119 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1121 // Construct message in the message queue memory; note that delete should not be called on the return value
1122 new (slot) LocalType( &manager, &UpdateManager::RemoveGeometry, &geometry );
1125 inline void AddVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer )
1127 typedef MessageValue2< UpdateManager, Render::Geometry*, Render::PropertyBuffer* > LocalType;
1129 // Reserve some memory inside the message queue
1130 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1132 // Construct message in the message queue memory; note that delete should not be called on the return value
1133 new (slot) LocalType( &manager, &UpdateManager::AddVertexBuffer, &geometry, const_cast<Render::PropertyBuffer*>(&vertexBuffer) );
1136 inline void RemoveVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer )
1138 typedef MessageValue2< UpdateManager, Render::Geometry*, Render::PropertyBuffer* > LocalType;
1140 // Reserve some memory inside the message queue
1141 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1143 // Construct message in the message queue memory; note that delete should not be called on the return value
1144 new (slot) LocalType( &manager, &UpdateManager::RemoveVertexBuffer, &geometry, const_cast<Render::PropertyBuffer*>(&vertexBuffer) );
1147 // Custom message type for SetIndexBuffer() used to move data with Vector::Swap()
1148 template< typename T >
1149 class IndexBufferMessage : public MessageBase
1154 * Constructor which does a Vector::Swap()
1156 IndexBufferMessage( T* manager, Render::Geometry* geometry, Dali::Vector<unsigned short>& indices )
1158 mManager( manager ),
1159 mRenderGeometry( geometry )
1161 mIndices.Swap( indices );
1165 * Virtual destructor
1167 virtual ~IndexBufferMessage()
1172 * @copydoc MessageBase::Process
1174 virtual void Process( BufferIndex /*bufferIndex*/ )
1176 DALI_ASSERT_DEBUG( mManager && "Message does not have an object" );
1177 mManager->SetIndexBuffer( mRenderGeometry, mIndices );
1183 Render::Geometry* mRenderGeometry;
1184 Dali::Vector<unsigned short> mIndices;
1187 inline void SetIndexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, Dali::Vector<unsigned short>& indices )
1189 typedef IndexBufferMessage< UpdateManager > LocalType;
1191 // Reserve some memory inside the message queue
1192 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1194 // Construct message in the message queue memory; note that delete should not be called on the return value
1195 new (slot) LocalType( &manager, &geometry, indices );
1198 inline void SetGeometryTypeMessage( UpdateManager& manager, Render::Geometry& geometry, unsigned int geometryType )
1200 typedef MessageValue2< UpdateManager, Render::Geometry*, unsigned int > LocalType;
1202 // Reserve some memory inside the message queue
1203 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1205 // Construct message in the message queue memory; note that delete should not be called on the return value
1206 new (slot) LocalType( &manager, &UpdateManager::SetGeometryType, &geometry, geometryType );
1209 inline void AddTexture( UpdateManager& manager, Render::NewTexture& texture )
1211 typedef MessageValue1< UpdateManager, Render::NewTexture* > LocalType;
1213 // Reserve some memory inside the message queue
1214 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1216 // Construct message in the message queue memory; note that delete should not be called on the return value
1217 new (slot) LocalType( &manager, &UpdateManager::AddTexture, &texture );
1220 inline void RemoveTexture( UpdateManager& manager, Render::NewTexture& texture )
1222 typedef MessageValue1< UpdateManager, Render::NewTexture* > LocalType;
1224 // Reserve some memory inside the message queue
1225 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1227 // Construct message in the message queue memory; note that delete should not be called on the return value
1228 new (slot) LocalType( &manager, &UpdateManager::RemoveTexture, &texture );
1231 template< typename T >
1232 class UploadTextureDataMessage : public MessageBase
1237 * Constructor which does a Vector::Swap()
1239 UploadTextureDataMessage( T* manager, Render::NewTexture* texture, Dali::Vector<unsigned char>& data, const Dali::TextureUploadParams& params )
1241 mManager( manager ),
1242 mRenderTexture( texture ),
1249 * Virtual destructor
1251 virtual ~UploadTextureDataMessage()
1256 * @copydoc MessageBase::Process
1258 virtual void Process( BufferIndex /*bufferIndex*/ )
1260 DALI_ASSERT_DEBUG( mManager && "Message does not have an object" );
1261 mManager->UploadTexture( mRenderTexture, mData, mParams );
1267 Render::NewTexture* mRenderTexture;
1268 Dali::Vector<unsigned char> mData;
1269 Dali::TextureUploadParams mParams;
1272 inline void UploadTextureMessage( UpdateManager& manager, Render::NewTexture& texture, Dali::Vector<unsigned char>& data, const Dali::TextureUploadParams& params )
1274 typedef UploadTextureDataMessage< UpdateManager > 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, &texture, data, params );
1283 inline void GenerateMipmapsMessage( UpdateManager& manager, Render::NewTexture& texture )
1285 typedef MessageValue1< UpdateManager, Render::NewTexture* > LocalType;
1287 // Reserve some memory inside the message queue
1288 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1290 // Construct message in the message queue memory; note that delete should not be called on the return value
1291 new (slot) LocalType( &manager, &UpdateManager::GenerateMipmaps, &texture );
1295 inline void AddFrameBuffer( 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::AddFrameBuffer, &frameBuffer );
1306 inline void RemoveFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer )
1308 typedef MessageValue1< UpdateManager, Render::FrameBuffer* > 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::RemoveFrameBuffer, &frameBuffer );
1317 inline void AttachColorTextureToFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer, Render::NewTexture* texture, unsigned int mipmapLevel, unsigned int layer )
1319 typedef MessageValue4< UpdateManager, Render::FrameBuffer*, Render::NewTexture*, unsigned int, unsigned int > 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::AttachColorTextureToFrameBuffer, &frameBuffer, texture, mipmapLevel, layer );
1328 } // namespace SceneGraph
1330 } // namespace Internal
1334 #endif // __DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H__