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>
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 > {};
77 class RenderTaskProcessor;
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] discardQueue Nodes are added here when disconnected from the scene-graph.
101 * @param[in] controller After messages are flushed, we request a render from the RenderController.
102 * @param[in] renderManager This is responsible for rendering the results of each "update".
103 * @param[in] renderQueue Used to queue messages for the next render.
104 * @param[in] renderTaskProcessor Handles RenderTasks and RenderInstrucitons.
106 UpdateManager( NotificationManager& notificationManager,
107 CompleteNotificationInterface& animationFinishedNotifier,
108 PropertyNotifier& propertyNotifier,
109 DiscardQueue& discardQueue,
110 Integration::RenderController& controller,
111 RenderManager& renderManager,
112 RenderQueue& renderQueue,
113 RenderTaskProcessor& renderTaskProcessor );
118 virtual ~UpdateManager();
120 // Node connection methods
123 * Get the scene graph side list of RenderTasks.
124 * @param[in] systemLevel True if using the system-level overlay.
125 * @return The list of render tasks
127 RenderTaskList* GetRenderTaskList( bool systemLevel );
130 * Installs a new layer as the root node.
131 * @pre The UpdateManager does not already have an installed root node.
132 * @pre The layer is of derived Node type Layer.
133 * @pre The layer does not have a parent.
134 * @param[in] layer The new root node.
135 * @param[in] systemLevel True if using the system-level overlay.
136 * @post The node is owned by UpdateManager.
138 void InstallRoot( Layer* layer, bool systemLevel );
141 * Add a Node; UpdateManager takes ownership.
142 * @pre The node does not have a parent.
143 * @param[in] node The node to add.
145 void AddNode( Node* node );
148 * Connect a Node to the scene-graph.
149 * A disconnected Node has has no parent or children, and its properties cannot be animated/constrained.
150 * @pre The node does not already have a parent.
151 * @param[in] parent The new parent node.
153 void ConnectNode( Node* parent, Node* node );
156 * Disconnect a Node from the scene-graph.
157 * A disconnected Node has has no parent or children, and its properties cannot be animated/constrained.
158 * @pre The node has a parent.
159 * @param[in] node The node to disconnect.
161 void DisconnectNode( Node* node );
164 * Destroy a Node owned by UpdateManager.
165 * This is not immediate; Nodes are passed to the RenderQueue to allow GL resources to be deleted.
166 * In the following update, the previously queued Nodes may be deleted.
167 * @pre The node has been disconnected from the scene-graph i.e. has no parent or children.
168 * @param[in] node The node to destroy.
170 void DestroyNode( Node* node );
173 * Add a camera on scene
174 * @param[in] camera to add
176 void AddCamera( Camera* camera );
179 * Remove a camera from scene
180 * @param[in] camera to remove
182 void RemoveCamera( const Camera* camera );
185 * Add a newly created object.
186 * @param[in] object The object to add.
187 * @post The object is owned by UpdateManager.
189 void AddObject( PropertyOwner* object );
193 * @param[in] object The object to remove.
195 void RemoveObject( PropertyOwner* object );
200 * Add a newly created animation.
201 * @param[in] animation The animation to add.
202 * @post The animation is owned by UpdateManager.
204 void AddAnimation( Animation* animation );
208 * @param[in] animation The animation to stop.
210 void StopAnimation( Animation* animation );
213 * Remove an animation.
214 * @param[in] animation The animation to remove.
216 void RemoveAnimation( Animation* animation );
219 * Query whether any animations are currently running.
220 * @return True if any animations are running.
222 bool IsAnimationRunning() const;
224 // Property Notification
227 * Add a newly created property notification
228 * @param[in] propertyNotification The notification to add
229 * @post The propertyNotification is owned by UpdateManager.
231 void AddPropertyNotification( PropertyNotification* propertyNotification );
234 * Remove a property notification
235 * @param[in] propertyNotification The notification to remove
237 void RemovePropertyNotification( PropertyNotification* propertyNotification );
240 * Set Notify state for PropertyNotification
241 * @param[in] propertyNotification The notification to remove
242 * @param[in] notifyMode The notification mode.
244 void PropertyNotificationSetNotify( PropertyNotification* propertyNotification, PropertyNotification::NotifyMode notifyMode );
247 * @brief Get the renderer owner
249 * @return The renderer owner
251 ObjectOwnerContainer< Renderer >& GetRendererOwner();
254 * @brief Get the property buffer owner
256 * @return The property buffer owner
258 ObjectOwnerContainer< PropertyBuffer >& GetPropertyBufferOwner();
264 * Add a newly created shader.
265 * @param[in] shader The shader to add.
266 * @post The shader is owned by the UpdateManager.
268 void AddShader(Shader* shader);
272 * @pre The shader has been added to the UpdateManager.
273 * @param[in] shader The shader to remove.
274 * @post The shader is destroyed.
276 void RemoveShader(Shader* shader);
279 * Add a newly created TextureSet.
280 * @param[in] textureSet The texture set to add.
281 * @post The TextureSet is owned by the UpdateManager.
283 void AddTextureSet(TextureSet* textureSet);
286 * Remove a TextureSet.
287 * @pre The TextureSet has been added to the UpdateManager.
288 * @param[in] textureSet The TextureSet to remove.
289 * @post The TextureSet is destroyed.
291 void RemoveTextureSet(TextureSet* textureSet);
294 * Set the shader program for a Shader object
295 * @param[in] shader The shader to modify
296 * @param[in] shaderData Source code, hash over source, and optional compiled binary for the shader program
297 * @param[in] modifiesGeometry True if the vertex shader modifies geometry
299 void SetShaderProgram( Shader* shader, Internal::ShaderDataPtr shaderData, bool modifiesGeometry );
302 * @brief Accept compiled shaders passed back on render thread for saving.
303 * @param[in] shaderData Source code, hash over source, and corresponding compiled binary to be saved.
305 virtual void SaveBinary( Internal::ShaderDataPtr shaderData );
308 * @brief Set the destination for compiled shader binaries to be passed on to.
309 * The dispatcher passed in will be called from the update thread.
310 * @param[in] upstream A sink for ShaderDatas to be passed into.
312 void SetShaderSaver( ShaderSaver& upstream );
317 * Add a newly created gesture.
318 * @param[in] gesture The gesture to add.
319 * @post The gesture is owned by the UpdateManager.
321 void AddGesture( PanGesture* gesture );
325 * @pre The gesture has been added to the UpdateManager.
326 * @param[in] gesture The gesture to remove.
327 * @post The gesture is destroyed.
329 void RemoveGesture( PanGesture* gesture );
331 // Message queue handling
334 * Reserve space for another message in the queue; this must then be initialized by the caller.
335 * The message will be read from the update-thread after the next FlushMessages is called.
336 * @post Calling this method may invalidate any previously returned slots.
337 * @param[in] size The message size with respect to the size of type "char".
338 * @param[in] updateScene A flag, when true denotes that the message will cause the scene-graph node tree to require an update.
339 * @note the default value of updateScene should match that in EventThreadServices::ReserveMessageSlot.
340 * @return A pointer to the first char allocated for the message.
342 unsigned int* ReserveMessageSlot( std::size_t size, bool updateScene = true );
345 * @return the current event-buffer index.
347 BufferIndex GetEventBufferIndex() const
349 // inlined as its called often from event thread
350 return mSceneGraphBuffers.GetEventBufferIndex();
354 * Called by the event-thread to signal that FlushQueue will be called
355 * e.g. when it has finished event processing.
357 void EventProcessingStarted();
360 * Flush the set of messages, which were previously stored with QueueMessage().
361 * Calls to this thread-safe method should be minimized, to avoid thread blocking.
363 * @return True if there are messages to process.
368 * Add a new sampler to RenderManager
369 * @param[in] sampler The sampler to add
370 * @post Sends a message to RenderManager to add the sampler.
371 * The sampler will be owned by RenderManager
373 void AddSampler( Render::Sampler* sampler );
376 * Removes an existing sampler from RenderManager
377 * @param[in] sampler The sampler to remove
378 * @post The sampler will be destroyed in the render thread
380 void RemoveSampler( Render::Sampler* sampler );
383 * Sets the filter modes for an existing sampler
384 * @param[in] sampler The sampler
385 * @param[in] minFilterMode The filter to use under minification
386 * @param[in] magFilterMode The filter to use under magnification
388 void SetFilterMode( Render::Sampler* sampler, unsigned int minFilterMode, unsigned int magFilterMode );
391 * Sets the wrap mode for an existing sampler
392 * @param[in] sampler The sampler
393 * @param[in] rWrapMode Wrapping mode in z direction
394 * @param[in] sWrapMode Wrapping mode in x direction
395 * @param[in] tWrapMode Wrapping mode in y direction
397 void SetWrapMode( Render::Sampler* sampler, unsigned int rWrapMode, unsigned int sWrapMode, unsigned int tWrapMode );
400 * Add a new property buffer to RenderManager
401 * @param[in] propertryBuffer The property buffer to add
402 * @post Sends a message to RenderManager to add the property buffer.
403 * The property buffer will be owned by RenderManager
405 void AddPropertyBuffer( Render::PropertyBuffer* propertryBuffer );
408 * Removes an existing PropertyBuffer from RenderManager
409 * @param[in] propertryBuffer The property buffer to remove
410 * @post The property buffer will be destroyed in the render thread
412 void RemovePropertyBuffer( Render::PropertyBuffer* propertryBuffer );
415 * Sets the format of an existing property buffer
416 * @param[in] propertyBuffer The property buffer.
417 * @param[in] format The new format of the buffer
418 * @post Sends a message to RenderManager to set the new format to the property buffer.
420 void SetPropertyBufferFormat(Render::PropertyBuffer* propertyBuffer, Render::PropertyBuffer::Format* format );
423 * Sets the data of an existing property buffer
424 * @param[in] propertyBuffer The property buffer.
425 * @param[in] data The new data of the buffer
426 * @param[in] size The new size of the buffer
427 * @post Sends a message to RenderManager to set the new data to the property buffer.
429 void SetPropertyBufferData(Render::PropertyBuffer* propertyBuffer, Dali::Vector<char>* data, size_t size);
432 * Adds a geometry to the RenderManager
433 * @param[in] geometry The geometry to add
434 * @post Sends a message to RenderManager to add the Geometry
435 * The geometry will be owned by RenderManager
437 void AddGeometry( Render::Geometry* geometry );
440 * Removes an existing Geometry from RenderManager
441 * @param[in] geometry The geometry to remove
442 * @post The geometry will be destroyed in the render thread
444 void RemoveGeometry( Render::Geometry* geometry );
447 * Sets the geometry type of an existing Geometry
448 * @param[in] geometry The geometry
449 * @param[in] geometryType The type of the geometry
451 void SetGeometryType( Render::Geometry* geometry, unsigned int geometryType );
454 * Sets the index buffer to be used by a geometry
455 * @param[in] geometry The geometry
456 * @param[in] indices A vector containing the indices for the geometry
458 void SetIndexBuffer( Render::Geometry* geometry, Dali::Vector<unsigned short>& indices );
461 * Adds a vertex buffer to a geomtry
462 * @param[in] geometry The geometry
463 * @param[in] propertyBuffer The property buffer
465 void AddVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer );
468 * Removes a vertex buffer from a geometry
469 * @param[in] geometry The geometry
470 * @param[in] propertyBuffer The property buffer
472 void RemoveVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer );
475 * Adds a texture to the render manager
476 * @param[in] texture The texture to add
477 * The texture will be owned by RenderManager
479 void AddTexture( Render::Texture* texture );
482 * Removes a texture from the render manager
483 * @param[in] texture The texture to remove
484 * @post The texture will be destroyed in the render thread
486 void RemoveTexture( Render::Texture* texture );
489 * Uploads data to a texture owned by the RenderManager
490 * @param[in] texture The texture
491 * @param[in] pixelData The pixel data object
492 * @param[in] params The parameters for the upload
494 void UploadTexture( Render::Texture* texture, PixelDataPtr pixelData, const Texture::UploadParams& params );
497 * Generates mipmaps for a texture owned by the RenderManager
498 * @param[in] texture The texture
500 void GenerateMipmaps( Render::Texture* texture );
503 * Adds a framebuffer to the render manager
504 * @param[in] frameBuffer The framebuffer to add
505 * The framebuffer will be owned by RenderManager
507 void AddFrameBuffer( Render::FrameBuffer* frameBuffer );
510 * Removes a FrameBuffer from the render manager
511 * @param[in] frameBuffer The FrameBuffer to remove
512 * @post The FrameBuffer will be destroyed in the render thread
514 void RemoveFrameBuffer( Render::FrameBuffer* frameBuffer );
517 * Attach a texture as color output to an existing FrameBuffer
518 * @param[in] frameBuffer The FrameBuffer
519 * @param[in] texture The texture that will be used as output when rendering
520 * @param[in] mipmapLevel The mipmap of the texture to be attached
521 * @param[in] layer Indicates which layer of a cube map or array texture to attach. Unused for 2D textures
523 void AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::Texture* texture, unsigned int mipmapLevel, unsigned int face );
528 * Performs an Update traversal on the scene-graph.
529 * @param[in] elapsedSeconds The elapsed time that should be applied to animations.
530 * @param[in] lastVSyncTimeMilliseconds The last time, in milliseconds, that we had a VSync.
531 * @param[in] nextVSyncTimeMilliseconds The estimated time, in milliseconds, of the next VSync.
532 * @return True if further updates are required e.g. during animations.
534 unsigned int Update( float elapsedSeconds, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds );
537 * Set the background color i.e. the glClear color used at the beginning of each frame.
538 * @param[in] color The new background color.
540 void SetBackgroundColor(const Vector4& color);
543 * Set the default surface rect.
544 * @param[in] rect The rect value representing the surface.
546 void SetDefaultSurfaceRect( const Rect<int>& rect );
549 * @copydoc Dali::Stage::KeepRendering()
551 void KeepRendering( float durationSeconds );
554 * Sets the depths of all layers.
555 * @param layers The layers in depth order.
556 * @param[in] systemLevel True if using the system-level overlay.
558 void SetLayerDepths( const std::vector< Layer* >& layers, bool systemLevel );
563 UpdateManager(const UpdateManager&);
566 UpdateManager& operator=(const UpdateManager& rhs);
569 * Helper to check whether the update-thread should keep going.
570 * @param[in] elapsedSeconds The time in seconds since the previous update.
571 * @return True if the update-thread should keep going.
573 unsigned int KeepUpdatingCheck( float elapsedSeconds ) const;
576 * Post process resources that have been updated by renderer
578 void PostProcessResources();
581 * Helper to reset all Node properties
582 * @param[in] bufferIndex to use
584 void ResetProperties( BufferIndex bufferIndex );
587 * Perform gesture updates.
588 * @param[in] bufferIndex to use
589 * @param[in] lastVSyncTime The last VSync time in milliseconds.
590 * @param[in] nextVSyncTime The estimated time of the next VSync in milliseconds.
591 * @return true, if any properties were updated.
593 bool ProcessGestures( BufferIndex bufferIndex, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds );
596 * Perform animation updates
597 * @param[in] bufferIndex to use
598 * @param[in] elapsedSeconds time since last frame
600 void Animate( BufferIndex bufferIndex, float elapsedSeconds );
603 * Applies constraints to CustomObjects
604 * @param[in] bufferIndex to use
606 void ConstrainCustomObjects( BufferIndex bufferIndex );
609 * Applies constraints to RenderTasks
610 * @param[in] bufferIndex to use
612 void ConstrainRenderTasks( BufferIndex bufferIndex );
615 * Applies constraints to Shaders
616 * @param[in] bufferIndex to use
618 void ConstrainShaders( BufferIndex bufferIndex );
621 * Perform property notification updates
622 * @param[in] bufferIndex to use
624 void ProcessPropertyNotifications( BufferIndex bufferIndex );
627 * Pass shader binaries queued here on to event thread.
629 void ForwardCompiledShadersToEventThread();
632 * Update node shaders, opacity, geometry etc.
633 * @param[in] bufferIndex to use
635 void UpdateNodes( BufferIndex bufferIndex );
639 * @param[in] bufferIndex to use
641 void UpdateRenderers( BufferIndex bufferIndex );
645 // needs to be direct member so that getter for event buffer can be inlined
646 SceneGraphBuffers mSceneGraphBuffers;
653 // Messages for UpdateManager
655 inline void InstallRootMessage( UpdateManager& manager, Layer& root, bool systemLevel )
657 // Message has ownership of Layer while in transit from event -> update
658 typedef MessageValue2< UpdateManager, OwnerPointer<Layer>, bool > LocalType;
660 // Reserve some memory inside the message queue
661 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
663 // Construct message in the message queue memory; note that delete should not be called on the return value
664 new (slot) LocalType( &manager, &UpdateManager::InstallRoot, &root, systemLevel );
667 inline void AddNodeMessage( UpdateManager& manager, Node& node )
669 // Message has ownership of Node while in transit from event -> update
670 typedef MessageValue1< UpdateManager, OwnerPointer<Node> > LocalType;
672 // Reserve some memory inside the message queue
673 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
675 // Construct message in the message queue memory; note that delete should not be called on the return value
676 new (slot) LocalType( &manager, &UpdateManager::AddNode, &node );
679 inline void ConnectNodeMessage( UpdateManager& manager, const Node& constParent, const Node& constChild )
681 // Update thread can edit the object
682 Node& parent = const_cast< Node& >( constParent );
683 Node& child = const_cast< Node& >( constChild );
685 typedef MessageValue2< UpdateManager, Node*, Node* > LocalType;
687 // Reserve some memory inside the message queue
688 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
690 // Construct message in the message queue memory; note that delete should not be called on the return value
691 new (slot) LocalType( &manager, &UpdateManager::ConnectNode, &parent, &child );
694 inline void DisconnectNodeMessage( UpdateManager& manager, const Node& constNode )
696 // Scene graph thread can modify this object.
697 Node& node = const_cast< Node& >( constNode );
699 typedef MessageValue1< UpdateManager, Node* > LocalType;
701 // Reserve some memory inside the message queue
702 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
704 // Construct message in the message queue memory; note that delete should not be called on the return value
705 new (slot) LocalType( &manager, &UpdateManager::DisconnectNode, &node );
708 inline void DestroyNodeMessage( UpdateManager& manager, const Node& constNode )
710 // Scene graph thread can destroy this object.
711 Node& node = const_cast< Node& >( constNode );
713 typedef MessageValue1< UpdateManager, Node* > LocalType;
715 // Reserve some memory inside the message queue
716 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
718 // Construct message in the message queue memory; note that delete should not be called on the return value
719 new (slot) LocalType( &manager, &UpdateManager::DestroyNode, &node );
722 inline void AddCameraMessage( UpdateManager& manager, const Camera* constCamera )
724 typedef MessageValue1< UpdateManager, Camera* > LocalType;
726 Camera* camera = const_cast<Camera*>( constCamera );
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::AddCamera, camera );
734 inline void RemoveCameraMessage( UpdateManager& manager, const Camera* camera )
736 typedef MessageValue1< UpdateManager, const Camera* > LocalType;
738 // Reserve some memory inside the message queue
739 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
741 // Construct message in the message queue memory; note that delete should not be called on the return value
742 new (slot) LocalType( &manager, &UpdateManager::RemoveCamera, camera );
745 inline void AddObjectMessage( UpdateManager& manager, PropertyOwner* object )
747 typedef MessageValue1< UpdateManager, OwnerPointer<PropertyOwner> > 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::AddObject, object );
756 inline void RemoveObjectMessage( UpdateManager& manager, PropertyOwner* object )
758 typedef MessageValue1< UpdateManager, PropertyOwner* > 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::RemoveObject, object );
767 inline void AddAnimationMessage( UpdateManager& manager, Animation* animation )
769 typedef MessageValue1< UpdateManager, Animation* > LocalType;
771 // Reserve some memory inside the message queue
772 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
774 // Construct message in the message queue memory; note that delete should not be called on the return value
775 new (slot) LocalType( &manager, &UpdateManager::AddAnimation, animation );
778 inline void StopAnimationMessage( UpdateManager& manager, const Animation& constAnimation )
780 // The scene-graph thread owns this object so it can safely edit it.
781 Animation& animation = const_cast< Animation& >( constAnimation );
783 typedef MessageValue1< UpdateManager, Animation* > LocalType;
785 // Reserve some memory inside the message queue
786 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
788 // Construct message in the message queue memory; note that delete should not be called on the return value
789 new (slot) LocalType( &manager, &UpdateManager::StopAnimation, &animation );
792 inline void RemoveAnimationMessage( UpdateManager& manager, const Animation& constAnimation )
794 // The scene-graph thread owns this object so it can safely edit it.
795 Animation& animation = const_cast< Animation& >( constAnimation );
797 typedef MessageValue1< UpdateManager, Animation* > LocalType;
799 // Reserve some memory inside the message queue
800 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
802 // Construct message in the message queue memory; note that delete should not be called on the return value
803 new (slot) LocalType( &manager, &UpdateManager::RemoveAnimation, &animation );
806 inline void AddPropertyNotificationMessage( UpdateManager& manager, PropertyNotification* propertyNotification )
808 typedef MessageValue1< UpdateManager, PropertyNotification* > LocalType;
810 // Reserve some memory inside the message queue
811 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
813 // Construct message in the message queue memory; note that delete should not be called on the return value
814 new (slot) LocalType( &manager, &UpdateManager::AddPropertyNotification, propertyNotification );
817 inline void RemovePropertyNotificationMessage( UpdateManager& manager, const PropertyNotification& constPropertyNotification )
819 // The scene-graph thread owns this object so it can safely edit it.
820 PropertyNotification& propertyNotification = const_cast< PropertyNotification& >( constPropertyNotification );
822 typedef MessageValue1< UpdateManager, PropertyNotification* > LocalType;
824 // Reserve some memory inside the message queue
825 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
827 // Construct message in the message queue memory; note that delete should not be called on the return value
828 new (slot) LocalType( &manager, &UpdateManager::RemovePropertyNotification, &propertyNotification );
831 inline void PropertyNotificationSetNotifyModeMessage( UpdateManager& manager,
832 const PropertyNotification* constPropertyNotification,
833 PropertyNotification::NotifyMode notifyMode )
835 // The scene-graph thread owns this object so it can safely edit it.
836 PropertyNotification* propertyNotification = const_cast< PropertyNotification* >( constPropertyNotification );
838 typedef MessageValue2< UpdateManager, PropertyNotification*, PropertyNotification::NotifyMode > LocalType;
840 // Reserve some memory inside the message queue
841 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
843 // Construct message in the message queue memory; note that delete should not be called on the return value
844 new (slot) LocalType( &manager, &UpdateManager::PropertyNotificationSetNotify, propertyNotification, notifyMode );
847 // The render thread can safely change the Shader
848 inline void AddShaderMessage( UpdateManager& manager, Shader& shader )
850 typedef MessageValue1< UpdateManager, OwnerPointer< Shader > > 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::AddShader, &shader );
859 // The render thread can safely change the Shader
860 inline void RemoveShaderMessage( UpdateManager& manager, Shader& shader )
862 typedef MessageValue1< UpdateManager, 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::RemoveShader, &shader );
871 inline void SetShaderProgramMessage( UpdateManager& manager,
873 Internal::ShaderDataPtr shaderData,
874 bool modifiesGeometry )
876 typedef MessageValue3< UpdateManager, Shader*, Internal::ShaderDataPtr, bool > LocalType;
878 // Reserve some memory inside the message queue
879 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
881 // Construct message in the message queue memory; note that delete should not be called on the return value
882 new (slot) LocalType( &manager, &UpdateManager::SetShaderProgram, &shader, shaderData, modifiesGeometry );
885 inline void SetBackgroundColorMessage( UpdateManager& manager, const Vector4& color )
887 typedef MessageValue1< UpdateManager, Vector4 > LocalType;
889 // Reserve some memory inside the message queue
890 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
892 // Construct message in the message queue memory; note that delete should not be called on the return value
893 new (slot) LocalType( &manager, &UpdateManager::SetBackgroundColor, color );
896 inline void SetDefaultSurfaceRectMessage( UpdateManager& manager, const Rect<int>& rect )
898 typedef MessageValue1< UpdateManager, Rect<int> > LocalType;
900 // Reserve some memory inside the message queue
901 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
903 // Construct message in the message queue memory; note that delete should not be called on the return value
904 new (slot) LocalType( &manager, &UpdateManager::SetDefaultSurfaceRect, rect );
907 inline void KeepRenderingMessage( UpdateManager& manager, float durationSeconds )
909 typedef MessageValue1< UpdateManager, float > LocalType;
911 // Reserve some memory inside the message queue
912 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
914 // Construct message in the message queue memory; note that delete should not be called on the return value
915 new (slot) LocalType( &manager, &UpdateManager::KeepRendering, durationSeconds );
919 * Create a message for setting the depth of a layer
920 * @param[in] manager The update manager
921 * @param[in] layers list of layers
922 * @param[in] systemLevel True if the layers are added via the SystemOverlay API
924 inline void SetLayerDepthsMessage( UpdateManager& manager, const std::vector< Layer* >& layers, bool systemLevel )
926 typedef MessageValue2< UpdateManager, std::vector< Layer* >, bool > LocalType;
928 // Reserve some memory inside the message queue
929 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
931 // Construct message in the message queue memory; note that delete should not be called on the return value
932 new (slot) LocalType( &manager, &UpdateManager::SetLayerDepths, layers, systemLevel );
935 inline void AddGestureMessage( UpdateManager& manager, PanGesture* gesture )
937 typedef MessageValue1< UpdateManager, PanGesture* > LocalType;
939 // Reserve some memory inside the message queue
940 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
942 // Construct message in the message queue memory; note that delete should not be called on the return value
943 new (slot) LocalType( &manager, &UpdateManager::AddGesture, gesture );
946 inline void RemoveGestureMessage( UpdateManager& manager, PanGesture* gesture )
948 typedef MessageValue1< UpdateManager, PanGesture* > LocalType;
950 // Reserve some memory inside the message queue
951 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
953 // Construct message in the message queue memory; note that delete should not be called on the return value
954 new (slot) LocalType( &manager, &UpdateManager::RemoveGesture, gesture );
957 template< typename T >
958 inline void AddMessage( UpdateManager& manager, ObjectOwnerContainer<T>& owner, T& object )
960 typedef MessageValue1< ObjectOwnerContainer<T>, OwnerPointer< T > > LocalType;
962 // Reserve some memory inside the message queue
963 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
964 // Construct message in the message queue memory; note that delete should not be called on the return value
965 new (slot) LocalType( &owner, &ObjectOwnerContainer<T>::Add, &object );
968 template< typename T >
969 inline void RemoveMessage( UpdateManager& manager, ObjectOwnerContainer<T>& owner, T& object )
971 typedef MessageValue1< ObjectOwnerContainer<T>, T* > 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( &owner, &ObjectOwnerContainer<T>::Remove, &object );
979 // The render thread can safely change the Shader
980 inline void AddTextureSetMessage( UpdateManager& manager, 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, Render::Sampler& sampler )
1005 typedef MessageValue1< UpdateManager, Render::Sampler* > LocalType;
1007 // Reserve some memory inside the message queue
1008 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1010 // Construct message in the message queue memory; note that delete should not be called on the return value
1011 new (slot) LocalType( &manager, &UpdateManager::AddSampler, &sampler );
1014 inline void RemoveSamplerMessage( UpdateManager& manager, Render::Sampler& sampler )
1016 typedef MessageValue1< UpdateManager, Render::Sampler* > LocalType;
1018 // Reserve some memory inside the message queue
1019 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1021 // Construct message in the message queue memory; note that delete should not be called on the return value
1022 new (slot) LocalType( &manager, &UpdateManager::RemoveSampler, &sampler );
1025 inline void SetFilterModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int minFilterMode, unsigned int magFilterMode )
1027 typedef MessageValue3< UpdateManager, Render::Sampler*, unsigned int, unsigned int > LocalType;
1029 // Reserve some memory inside the message queue
1030 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1032 // Construct message in the message queue memory; note that delete should not be called on the return value
1033 new (slot) LocalType( &manager, &UpdateManager::SetFilterMode, &sampler, minFilterMode, magFilterMode );
1036 inline void SetWrapModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int rWrapMode, unsigned int sWrapMode, unsigned int tWrapMode )
1038 typedef MessageValue4< UpdateManager, Render::Sampler*, unsigned int, unsigned int, unsigned int > LocalType;
1040 // Reserve some memory inside the message queue
1041 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1043 // Construct message in the message queue memory; note that delete should not be called on the return value
1044 new (slot) LocalType( &manager, &UpdateManager::SetWrapMode, &sampler, rWrapMode, sWrapMode, tWrapMode );
1047 inline void AddPropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer )
1049 typedef MessageValue1< UpdateManager, Render::PropertyBuffer* > LocalType;
1051 // Reserve some memory inside the message queue
1052 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1054 // Construct message in the message queue memory; note that delete should not be called on the return value
1055 new (slot) LocalType( &manager, &UpdateManager::AddPropertyBuffer, &propertyBuffer );
1058 inline void RemovePropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer )
1060 typedef MessageValue1< UpdateManager, Render::PropertyBuffer* > LocalType;
1062 // Reserve some memory inside the message queue
1063 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1065 // Construct message in the message queue memory; note that delete should not be called on the return value
1066 new (slot) LocalType( &manager, &UpdateManager::RemovePropertyBuffer, &propertyBuffer );
1069 inline void SetPropertyBufferFormat( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, Render::PropertyBuffer::Format* format )
1071 typedef MessageValue2< UpdateManager, Render::PropertyBuffer*, Render::PropertyBuffer::Format* > LocalType;
1073 // Reserve some memory inside the message queue
1074 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1076 // Construct message in the message queue memory; note that delete should not be called on the return value
1077 new (slot) LocalType( &manager, &UpdateManager::SetPropertyBufferFormat, &propertyBuffer, format );
1080 inline void SetPropertyBufferData( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, Vector<char>* data, size_t size )
1082 typedef MessageValue3< UpdateManager, Render::PropertyBuffer*, Vector<char>*, size_t > LocalType;
1084 // Reserve some memory inside the message queue
1085 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1087 // Construct message in the message queue memory; note that delete should not be called on the return value
1088 new (slot) LocalType( &manager, &UpdateManager::SetPropertyBufferData, &propertyBuffer, data, size );
1091 inline void AddGeometry( UpdateManager& manager, Render::Geometry& geometry )
1093 typedef MessageValue1< UpdateManager, Render::Geometry* > LocalType;
1095 // Reserve some memory inside the message queue
1096 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1098 // Construct message in the message queue memory; note that delete should not be called on the return value
1099 new (slot) LocalType( &manager, &UpdateManager::AddGeometry, &geometry );
1102 inline void RemoveGeometry( UpdateManager& manager, Render::Geometry& geometry )
1104 typedef MessageValue1< UpdateManager, Render::Geometry* > LocalType;
1106 // Reserve some memory inside the message queue
1107 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1109 // Construct message in the message queue memory; note that delete should not be called on the return value
1110 new (slot) LocalType( &manager, &UpdateManager::RemoveGeometry, &geometry );
1113 inline void AddVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer )
1115 typedef MessageValue2< UpdateManager, Render::Geometry*, Render::PropertyBuffer* > LocalType;
1117 // Reserve some memory inside the message queue
1118 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1120 // Construct message in the message queue memory; note that delete should not be called on the return value
1121 new (slot) LocalType( &manager, &UpdateManager::AddVertexBuffer, &geometry, const_cast<Render::PropertyBuffer*>(&vertexBuffer) );
1124 inline void RemoveVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer )
1126 typedef MessageValue2< UpdateManager, Render::Geometry*, Render::PropertyBuffer* > LocalType;
1128 // Reserve some memory inside the message queue
1129 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1131 // Construct message in the message queue memory; note that delete should not be called on the return value
1132 new (slot) LocalType( &manager, &UpdateManager::RemoveVertexBuffer, &geometry, const_cast<Render::PropertyBuffer*>(&vertexBuffer) );
1135 // Custom message type for SetIndexBuffer() used to move data with Vector::Swap()
1136 template< typename T >
1137 class IndexBufferMessage : public MessageBase
1142 * Constructor which does a Vector::Swap()
1144 IndexBufferMessage( T* manager, Render::Geometry* geometry, Dali::Vector<unsigned short>& indices )
1146 mManager( manager ),
1147 mRenderGeometry( geometry )
1149 mIndices.Swap( indices );
1153 * Virtual destructor
1155 virtual ~IndexBufferMessage()
1160 * @copydoc MessageBase::Process
1162 virtual void Process( BufferIndex /*bufferIndex*/ )
1164 DALI_ASSERT_DEBUG( mManager && "Message does not have an object" );
1165 mManager->SetIndexBuffer( mRenderGeometry, mIndices );
1171 Render::Geometry* mRenderGeometry;
1172 Dali::Vector<unsigned short> mIndices;
1175 inline void SetIndexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, Dali::Vector<unsigned short>& indices )
1177 typedef IndexBufferMessage< UpdateManager > LocalType;
1179 // Reserve some memory inside the message queue
1180 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1182 // Construct message in the message queue memory; note that delete should not be called on the return value
1183 new (slot) LocalType( &manager, &geometry, indices );
1186 inline void SetGeometryTypeMessage( UpdateManager& manager, Render::Geometry& geometry, unsigned int geometryType )
1188 typedef MessageValue2< UpdateManager, Render::Geometry*, unsigned int > LocalType;
1190 // Reserve some memory inside the message queue
1191 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1193 // Construct message in the message queue memory; note that delete should not be called on the return value
1194 new (slot) LocalType( &manager, &UpdateManager::SetGeometryType, &geometry, geometryType );
1197 inline void AddTexture( UpdateManager& manager, Render::Texture& texture )
1199 typedef MessageValue1< UpdateManager, Render::Texture* > LocalType;
1201 // Reserve some memory inside the message queue
1202 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1204 // Construct message in the message queue memory; note that delete should not be called on the return value
1205 new (slot) LocalType( &manager, &UpdateManager::AddTexture, &texture );
1208 inline void RemoveTexture( UpdateManager& manager, Render::Texture& texture )
1210 typedef MessageValue1< UpdateManager, Render::Texture* > LocalType;
1212 // Reserve some memory inside the message queue
1213 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1215 // Construct message in the message queue memory; note that delete should not be called on the return value
1216 new (slot) LocalType( &manager, &UpdateManager::RemoveTexture, &texture );
1219 inline void UploadTextureMessage( UpdateManager& manager, Render::Texture& texture, PixelDataPtr pixelData, const Texture::UploadParams& params )
1221 typedef MessageValue3< UpdateManager, Render::Texture*, PixelDataPtr, Texture::UploadParams > LocalType;
1223 // Reserve some memory inside the message queue
1224 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1226 // Construct message in the message queue memory; note that delete should not be called on the return value
1227 new (slot) LocalType( &manager, &UpdateManager::UploadTexture, &texture, pixelData, params );
1230 inline void GenerateMipmapsMessage( UpdateManager& manager, Render::Texture& texture )
1232 typedef MessageValue1< UpdateManager, Render::Texture* > LocalType;
1234 // Reserve some memory inside the message queue
1235 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1237 // Construct message in the message queue memory; note that delete should not be called on the return value
1238 new (slot) LocalType( &manager, &UpdateManager::GenerateMipmaps, &texture );
1242 inline void AddFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer )
1244 typedef MessageValue1< UpdateManager, Render::FrameBuffer* > LocalType;
1246 // Reserve some memory inside the message queue
1247 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1249 // Construct message in the message queue memory; note that delete should not be called on the return value
1250 new (slot) LocalType( &manager, &UpdateManager::AddFrameBuffer, &frameBuffer );
1253 inline void RemoveFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer )
1255 typedef MessageValue1< UpdateManager, Render::FrameBuffer* > LocalType;
1257 // Reserve some memory inside the message queue
1258 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1260 // Construct message in the message queue memory; note that delete should not be called on the return value
1261 new (slot) LocalType( &manager, &UpdateManager::RemoveFrameBuffer, &frameBuffer );
1264 inline void AttachColorTextureToFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer, Render::Texture* texture, unsigned int mipmapLevel, unsigned int layer )
1266 typedef MessageValue4< UpdateManager, Render::FrameBuffer*, Render::Texture*, unsigned int, unsigned int > LocalType;
1268 // Reserve some memory inside the message queue
1269 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
1271 // Construct message in the message queue memory; note that delete should not be called on the return value
1272 new (slot) LocalType( &manager, &UpdateManager::AttachColorTextureToFrameBuffer, &frameBuffer, texture, mipmapLevel, layer );
1276 } // namespace SceneGraph
1278 } // namespace Internal
1282 #endif // DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H