1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/common/vector-wrapper.h>
23 #include <dali/public-api/common/dali-common.h>
25 #include <dali/integration-api/resource-declarations.h>
27 #include <dali/internal/common/message.h>
28 #include <dali/internal/common/type-abstraction-enums.h>
29 #include <dali/internal/common/shader-saver.h>
30 #include <dali/internal/event/common/event-thread-services.h>
31 #include <dali/internal/update/animation/scene-graph-animation.h>
32 #include <dali/internal/update/common/scene-graph-buffers.h>
33 #include <dali/internal/update/common/scene-graph-property-notification.h>
34 #include <dali/internal/update/manager/object-owner-container.h>
35 #include <dali/internal/update/node-attachments/node-attachment.h>
36 #include <dali/internal/update/nodes/node.h>
37 #include <dali/internal/update/nodes/scene-graph-layer.h>
38 #include <dali/internal/update/rendering/scene-graph-renderer.h>
39 #include <dali/internal/render/shaders/scene-graph-shader.h>
40 #include <dali/internal/render/renderers/render-property-buffer.h>
47 class GlSyncAbstraction;
48 class RenderController;
50 } // namespace Integration
55 class PropertyNotifier;
56 class NotificationManager;
57 class CompleteNotificationInterface;
58 class ResourceManager;
65 // value types used by messages
66 template <> struct ParameterType< PropertyNotification::NotifyMode >
67 : public BasicType< PropertyNotification::NotifyMode > {};
84 * UpdateManager maintains a scene graph i.e. a tree of nodes and attachments and
85 * other property owner 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] textureCache Used for caching textures.
106 * @param[in] touchResampler Used for re-sampling touch events.
108 UpdateManager( NotificationManager& notificationManager,
109 CompleteNotificationInterface& animationFinishedNotifier,
110 PropertyNotifier& propertyNotifier,
111 ResourceManager& resourceManager,
112 DiscardQueue& discardQueue,
113 Integration::RenderController& controller,
114 RenderManager& renderManager,
115 RenderQueue& renderQueue,
116 TextureCache& textureCache,
117 TouchResampler& touchResampler );
122 virtual ~UpdateManager();
124 // Node connection methods
127 * Get the scene graph side list of RenderTasks.
128 * @param[in] systemLevel True if using the system-level overlay.
129 * @return The list of render tasks
131 RenderTaskList* GetRenderTaskList( bool systemLevel );
134 * Installs a new layer as the root node.
135 * @pre The UpdateManager does not already have an installed root node.
136 * @pre The layer is of derived Node type Layer.
137 * @pre The layer does not have a parent.
138 * @param[in] layer The new root node.
139 * @param[in] systemLevel True if using the system-level overlay.
140 * @post The node is owned by UpdateManager.
142 void InstallRoot( Layer* layer, bool systemLevel );
145 * Add a Node; UpdateManager takes ownership.
146 * @pre The node does not have a parent.
147 * @param[in] node The node to add.
149 void AddNode( Node* node );
152 * Connect a Node to the scene-graph.
153 * A disconnected Node has has no parent or children, and its properties cannot be animated/constrained.
154 * @pre The node does not already have a parent.
155 * @param[in] parent The new parent node.
157 void ConnectNode( Node* parent, Node* node );
160 * Disconnect a Node from the scene-graph.
161 * A disconnected Node has has no parent or children, and its properties cannot be animated/constrained.
162 * @pre The node has a parent.
163 * @param[in] node The node to disconnect.
165 void DisconnectNode( Node* node );
168 * Destroy a Node owned by UpdateManager.
169 * This is not immediate; Nodes are passed to the RenderQueue to allow GL resources to be deleted.
170 * In the following update, the previously queued Nodes may be deleted.
171 * @pre The node has been disconnected from the scene-graph i.e. has no parent or children.
172 * @param[in] node The node to destroy.
174 void DestroyNode( Node* node );
177 * Attach an object to a Node.
178 * The UpdateManager is responsible for calling NodeAttachment::Initialize().
179 * @param[in] node The node which will own the attachment.
180 * @param[in] attachment The object to attach.
182 void AttachToNode( Node* node, NodeAttachment* attachment );
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 geometry owner
249 * @return The geometry owner
251 ObjectOwnerContainer< Geometry >& GetGeometryOwner();
253 ObjectOwnerContainer< Renderer >& GetRendererOwner();
255 * @brief Get the material owner
257 * @return The material owner
259 ObjectOwnerContainer< Material >& GetMaterialOwner();
262 * @brief Get the property buffer owner
264 * @return The property buffer owner
266 ObjectOwnerContainer< PropertyBuffer >& GetPropertyBufferOwner();
272 * Add a newly created shader.
273 * @param[in] shader The shader to add.
274 * @post The shader is owned by the UpdateManager.
276 void AddShader(Shader* shader);
280 * @pre The shader has been added to the UpdateManager.
281 * @param[in] shader The shader to remove.
282 * @post The shader is destroyed.
284 void RemoveShader(Shader* shader);
287 * Set the shader program for a Shader object
288 * @param[in] shader The shader to modify
289 * @param[in] shaderData Source code, hash over source, and optional compiled binary for the shader program
290 * @param[in] modifiesGeometry True if the vertex shader modifies geometry
292 void SetShaderProgram( Shader* shader, Internal::ShaderDataPtr shaderData, bool modifiesGeometry );
295 * @brief Accept compiled shaders passed back on render thread for saving.
296 * @param[in] shaderData Source code, hash over source, and corresponding compiled binary to be saved.
298 virtual void SaveBinary( Internal::ShaderDataPtr shaderData );
301 * @brief Set the destination for compiled shader binaries to be passed on to.
302 * The dispatcher passed in will be called from the update thread.
303 * @param[in] upstream A sink for ShaderDatas to be passed into.
305 void SetShaderSaver( ShaderSaver& upstream );
310 * Add a newly created gesture.
311 * @param[in] gesture The gesture to add.
312 * @post The gesture is owned by the UpdateManager.
314 void AddGesture( PanGesture* gesture );
318 * @pre The gesture has been added to the UpdateManager.
319 * @param[in] gesture The gesture to remove.
320 * @post The gesture is destroyed.
322 void RemoveGesture( PanGesture* gesture );
324 // Message queue handling
327 * Reserve space for another message in the queue; this must then be initialized by the caller.
328 * The message will be read from the update-thread after the next FlushMessages is called.
329 * @post Calling this method may invalidate any previously returned slots.
330 * @param[in] size The message size with respect to the size of type "char".
331 * @param[in] updateScene A flag, when true denotes that the message will cause the scene-graph node tree to require an update.
332 * @note the default value of updateScene should match that in EventThreadServices::ReserveMessageSlot.
333 * @return A pointer to the first char allocated for the message.
335 unsigned int* ReserveMessageSlot( std::size_t size, bool updateScene = true );
338 * @return the current event-buffer index.
340 BufferIndex GetEventBufferIndex() const
342 // inlined as its called often from event thread
343 return mSceneGraphBuffers.GetEventBufferIndex();
347 * Called by the event-thread to signal that FlushQueue will be called
348 * e.g. when it has finished event processing.
350 void EventProcessingStarted();
353 * Flush the set of messages, which were previously stored with QueueMessage().
354 * Calls to this thread-safe method should be minimized, to avoid thread blocking.
356 * @return True if there are messages to process.
361 * Add a new sampler to RenderManager
362 * @param[in] sampler The sampler to add
363 * @post Sends a message to RenderManager to add the sampler.
364 * The sampler will be owned by RenderManager
366 void AddSampler( Render::Sampler* sampler );
369 * Removes an existing sampler from RenderManager
370 * @param[in] sampler The sampler to remove
371 * @post The sampler will be destroyed in the render thread
373 void RemoveSampler( Render::Sampler* sampler );
376 * Sets the filter modes for an existing sampler
377 * @param[in] sampler The sampler
378 * @param[in] minFilterMode The filter to use under minification
379 * @param[in] magFilterMode The filter to use under magnification
381 void SetFilterMode( Render::Sampler* sampler, unsigned int minFilterMode, unsigned int magFilterMode );
384 * Sets the wrap mode for an existing sampler
385 * @param[in] sampler The sampler
386 * @param[in] uWrapMode Wrapping mode in x direction
387 * @param[in] vWrapMode Wrapping mode in y direction
389 void SetWrapMode( Render::Sampler* sampler, unsigned int uWrapMode, unsigned int vWrapMode );
392 * Add a new sampler to RenderManager
393 * @param[in] propertryBuffer The property buffer to add
394 * @post Sends a message to RenderManager to add the property buffer.
395 * The property buffer will be owned by RenderManager
397 void AddPropertyBuffer( Render::PropertyBuffer* propertryBuffer );
400 * Removes an existing PropertyBuffer from RenderManager
401 * @param[in] propertryBuffer The property buffer to remove
402 * @post The property buffer will be destroyed in the render thread
404 void RemovePropertyBuffer( Render::PropertyBuffer* propertryBuffer );
407 * Sets the format of an existing property buffer
408 * @param[in] propertyBuffer The property buffer.
409 * @param[in] format The new format of the buffer
410 * @post Sends a message to RenderManager to set the new format to the property buffer.
412 void SetPropertyBufferFormat(Render::PropertyBuffer* propertyBuffer, Render::PropertyBuffer::Format* format );
415 * Sets the data of an existing property buffer
416 * @param[in] propertyBuffer The property buffer.
417 * @param[in] data The new data of the buffer
418 * @param[in] size The new size of the buffer
419 * @post Sends a message to RenderManager to set the new data to the property buffer.
421 void SetPropertyBufferData(Render::PropertyBuffer* propertyBuffer, Dali::Vector<char>* data, size_t size);
426 * Performs an Update traversal on the scene-graph.
427 * @param[in] elapsedSeconds The elapsed time that should be applied to animations.
428 * @param[in] lastVSyncTimeMilliseconds The last time, in milliseconds, that we had a VSync.
429 * @param[in] nextVSyncTimeMilliseconds The estimated time, in milliseconds, of the next VSync.
430 * @return True if further updates are required e.g. during animations.
432 unsigned int Update( float elapsedSeconds, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds );
435 * Set the background color i.e. the glClear color used at the beginning of each frame.
436 * @param[in] color The new background color.
438 void SetBackgroundColor(const Vector4& color);
441 * Set the default surface rect.
442 * @param[in] rect The rect value representing the surface.
444 void SetDefaultSurfaceRect( const Rect<int>& rect );
447 * @copydoc Dali::Stage::KeepRendering()
449 void KeepRendering( float durationSeconds );
452 * Sets the depths of all layers.
453 * @param layers The layers in depth order.
454 * @param[in] systemLevel True if using the system-level overlay.
456 void SetLayerDepths( const std::vector< Layer* >& layers, bool systemLevel );
461 UpdateManager(const UpdateManager&);
464 UpdateManager& operator=(const UpdateManager& rhs);
467 * Helper to check whether the update-thread should keep going.
468 * @param[in] elapsedSeconds The time in seconds since the previous update.
469 * @return True if the update-thread should keep going.
471 unsigned int KeepUpdatingCheck( float elapsedSeconds ) const;
474 * Helper to calculate new camera setup when root node resizes.
475 * @param[in] updateBuffer The buffer to read the root node size from.
477 void UpdateProjectionAndViewMatrices(int updateBuffer);
480 * Post process resources that have been updated by renderer
482 void PostProcessResources();
485 * Helper to reset all Node properties
486 * @param[in] bufferIndex to use
488 void ResetProperties( BufferIndex bufferIndex );
491 * Perform gesture updates.
492 * @param[in] bufferIndex to use
493 * @param[in] lastVSyncTime The last VSync time in milliseconds.
494 * @param[in] nextVSyncTime The estimated time of the next VSync in milliseconds.
495 * @return true, if any properties were updated.
497 bool ProcessGestures( BufferIndex bufferIndex, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds );
500 * Perform animation updates
501 * @param[in] bufferIndex to use
502 * @param[in] elapsedSeconds time since last frame
504 void Animate( BufferIndex bufferIndex, float elapsedSeconds );
507 * Applies constraints to CustomObjects
508 * @param[in] bufferIndex to use
510 void ConstrainCustomObjects( BufferIndex bufferIndex );
513 * Applies constraints to RenderTasks
514 * @param[in] bufferIndex to use
516 void ConstrainRenderTasks( BufferIndex bufferIndex );
519 * Applies constraints to Shaders
520 * @param[in] bufferIndex to use
522 void ConstrainShaders( BufferIndex bufferIndex );
525 * Perform property notification updates
526 * @param[in] bufferIndex to use
528 void ProcessPropertyNotifications( BufferIndex bufferIndex );
531 * Prepare materials for rendering
533 void PrepareMaterials( BufferIndex bufferIndex );
536 * Pass shader binaries queued here on to event thread.
538 void ForwardCompiledShadersToEventThread();
541 * Update the default camera.
542 * This must be altered to match the root Node for 2D layouting.
543 * @param[in] updateBuffer The buffer to read the root node size from.
545 void UpdateDefaultCamera( int updateBuffer );
548 * Update node shaders, opacity, geometry etc.
549 * @param[in] bufferIndex to use
551 void UpdateNodes( BufferIndex bufferIndex );
555 * @param[in] bufferIndex to use
557 void UpdateRenderers( BufferIndex bufferIndex );
561 // needs to be direct member so that getter for event buffer can be inlined
562 SceneGraphBuffers mSceneGraphBuffers;
569 // Messages for UpdateManager
571 inline void InstallRootMessage( UpdateManager& manager, Layer& root, bool systemLevel )
573 typedef MessageValue2< UpdateManager, Layer*, bool > LocalType;
575 // Reserve some memory inside the message queue
576 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
578 // Construct message in the message queue memory; note that delete should not be called on the return value
579 new (slot) LocalType( &manager, &UpdateManager::InstallRoot, &root, systemLevel );
582 inline void AddNodeMessage( UpdateManager& manager, Node& node )
584 typedef MessageValue1< UpdateManager, OwnerPointer<Node> > LocalType;
586 // Reserve some memory inside the message queue
587 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
589 // Construct message in the message queue memory; note that delete should not be called on the return value
590 new (slot) LocalType( &manager, &UpdateManager::AddNode, &node );
593 inline void ConnectNodeMessage( UpdateManager& manager, const Node& constParent, const Node& constChild )
595 // Update thread can edit the object
596 Node& parent = const_cast< Node& >( constParent );
597 Node& child = const_cast< Node& >( constChild );
599 typedef MessageValue2< UpdateManager, Node*, Node* > LocalType;
601 // Reserve some memory inside the message queue
602 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
604 // Construct message in the message queue memory; note that delete should not be called on the return value
605 new (slot) LocalType( &manager, &UpdateManager::ConnectNode, &parent, &child );
608 inline void DisconnectNodeMessage( UpdateManager& manager, const Node& constNode )
610 // Scene graph thread can modify this object.
611 Node& node = const_cast< Node& >( constNode );
613 typedef MessageValue1< UpdateManager, Node* > LocalType;
615 // Reserve some memory inside the message queue
616 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
618 // Construct message in the message queue memory; note that delete should not be called on the return value
619 new (slot) LocalType( &manager, &UpdateManager::DisconnectNode, &node );
622 inline void DestroyNodeMessage( UpdateManager& manager, const Node& constNode )
624 // Scene graph thread can destroy this object.
625 Node& node = const_cast< Node& >( constNode );
627 typedef MessageValue1< UpdateManager, Node* > LocalType;
629 // Reserve some memory inside the message queue
630 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
632 // Construct message in the message queue memory; note that delete should not be called on the return value
633 new (slot) LocalType( &manager, &UpdateManager::DestroyNode, &node );
636 inline void AttachToNodeMessage( UpdateManager& manager, const Node& constParent, NodeAttachment* attachment )
638 // Scene graph thread can modify this object.
639 Node& parent = const_cast< Node& >( constParent );
641 typedef MessageValue2< UpdateManager, Node*, NodeAttachmentOwner > LocalType;
643 // Reserve some memory inside the message queue
644 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
646 // Construct message in the message queue memory; note that delete should not be called on the return value
647 new (slot) LocalType( &manager, &UpdateManager::AttachToNode, &parent, attachment );
650 inline void AddObjectMessage( UpdateManager& manager, PropertyOwner* object )
652 typedef MessageValue1< UpdateManager, OwnerPointer<PropertyOwner> > LocalType;
654 // Reserve some memory inside the message queue
655 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
657 // Construct message in the message queue memory; note that delete should not be called on the return value
658 new (slot) LocalType( &manager, &UpdateManager::AddObject, object );
661 inline void RemoveObjectMessage( UpdateManager& manager, PropertyOwner* object )
663 typedef MessageValue1< UpdateManager, PropertyOwner* > LocalType;
665 // Reserve some memory inside the message queue
666 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
668 // Construct message in the message queue memory; note that delete should not be called on the return value
669 new (slot) LocalType( &manager, &UpdateManager::RemoveObject, object );
672 inline void AddAnimationMessage( UpdateManager& manager, Animation* animation )
674 typedef MessageValue1< UpdateManager, Animation* > LocalType;
676 // Reserve some memory inside the message queue
677 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
679 // Construct message in the message queue memory; note that delete should not be called on the return value
680 new (slot) LocalType( &manager, &UpdateManager::AddAnimation, animation );
683 inline void StopAnimationMessage( UpdateManager& manager, const Animation& constAnimation )
685 // The scene-graph thread owns this object so it can safely edit it.
686 Animation& animation = const_cast< Animation& >( constAnimation );
688 typedef MessageValue1< UpdateManager, Animation* > LocalType;
690 // Reserve some memory inside the message queue
691 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
693 // Construct message in the message queue memory; note that delete should not be called on the return value
694 new (slot) LocalType( &manager, &UpdateManager::StopAnimation, &animation );
697 inline void RemoveAnimationMessage( UpdateManager& manager, const Animation& constAnimation )
699 // The scene-graph thread owns this object so it can safely edit it.
700 Animation& animation = const_cast< Animation& >( constAnimation );
702 typedef MessageValue1< UpdateManager, Animation* > LocalType;
704 // Reserve some memory inside the message queue
705 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
707 // Construct message in the message queue memory; note that delete should not be called on the return value
708 new (slot) LocalType( &manager, &UpdateManager::RemoveAnimation, &animation );
711 inline void AddPropertyNotificationMessage( UpdateManager& manager, PropertyNotification* propertyNotification )
713 typedef MessageValue1< UpdateManager, PropertyNotification* > 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::AddPropertyNotification, propertyNotification );
722 inline void RemovePropertyNotificationMessage( UpdateManager& manager, const PropertyNotification& constPropertyNotification )
724 // The scene-graph thread owns this object so it can safely edit it.
725 PropertyNotification& propertyNotification = const_cast< PropertyNotification& >( constPropertyNotification );
727 typedef MessageValue1< UpdateManager, PropertyNotification* > LocalType;
729 // Reserve some memory inside the message queue
730 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
732 // Construct message in the message queue memory; note that delete should not be called on the return value
733 new (slot) LocalType( &manager, &UpdateManager::RemovePropertyNotification, &propertyNotification );
736 inline void PropertyNotificationSetNotifyModeMessage( UpdateManager& manager,
737 const PropertyNotification* constPropertyNotification,
738 PropertyNotification::NotifyMode notifyMode )
740 // The scene-graph thread owns this object so it can safely edit it.
741 PropertyNotification* propertyNotification = const_cast< PropertyNotification* >( constPropertyNotification );
743 typedef MessageValue2< UpdateManager, PropertyNotification*, PropertyNotification::NotifyMode > LocalType;
745 // Reserve some memory inside the message queue
746 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
748 // Construct message in the message queue memory; note that delete should not be called on the return value
749 new (slot) LocalType( &manager, &UpdateManager::PropertyNotificationSetNotify, propertyNotification, notifyMode );
752 // The render thread can safely change the Shader
753 inline void AddShaderMessage( UpdateManager& manager, Shader& shader )
755 typedef MessageValue1< UpdateManager, OwnerPointer< Shader > > LocalType;
757 // Reserve some memory inside the message queue
758 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
760 // Construct message in the message queue memory; note that delete should not be called on the return value
761 new (slot) LocalType( &manager, &UpdateManager::AddShader, &shader );
764 // The render thread can safely change the Shader
765 inline void RemoveShaderMessage( UpdateManager& manager, Shader& shader )
767 typedef MessageValue1< UpdateManager, Shader* > LocalType;
769 // Reserve some memory inside the message queue
770 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
772 // Construct message in the message queue memory; note that delete should not be called on the return value
773 new (slot) LocalType( &manager, &UpdateManager::RemoveShader, &shader );
776 inline void SetShaderProgramMessage( UpdateManager& manager,
778 Internal::ShaderDataPtr shaderData,
779 bool modifiesGeometry )
781 typedef MessageValue3< UpdateManager, Shader*, Internal::ShaderDataPtr, bool > 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::SetShaderProgram, &shader, shaderData, modifiesGeometry );
790 inline void SetBackgroundColorMessage( UpdateManager& manager, const Vector4& color )
792 typedef MessageValue1< UpdateManager, Vector4 > LocalType;
794 // Reserve some memory inside the message queue
795 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
797 // Construct message in the message queue memory; note that delete should not be called on the return value
798 new (slot) LocalType( &manager, &UpdateManager::SetBackgroundColor, color );
801 inline void SetDefaultSurfaceRectMessage( UpdateManager& manager, const Rect<int>& rect )
803 typedef MessageValue1< UpdateManager, Rect<int> > LocalType;
805 // Reserve some memory inside the message queue
806 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
808 // Construct message in the message queue memory; note that delete should not be called on the return value
809 new (slot) LocalType( &manager, &UpdateManager::SetDefaultSurfaceRect, rect );
812 inline void KeepRenderingMessage( UpdateManager& manager, float durationSeconds )
814 typedef MessageValue1< UpdateManager, float > LocalType;
816 // Reserve some memory inside the message queue
817 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
819 // Construct message in the message queue memory; note that delete should not be called on the return value
820 new (slot) LocalType( &manager, &UpdateManager::KeepRendering, durationSeconds );
824 * Create a message for setting the depth of a layer
825 * @param[in] manager The update manager
826 * @param[in] layers list of layers
827 * @param[in] systemLevel True if the layers are added via the SystemOverlay API
829 inline void SetLayerDepthsMessage( UpdateManager& manager, const std::vector< Layer* >& layers, bool systemLevel )
831 typedef MessageValue2< UpdateManager, std::vector< Layer* >, bool > LocalType;
833 // Reserve some memory inside the message queue
834 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
836 // Construct message in the message queue memory; note that delete should not be called on the return value
837 new (slot) LocalType( &manager, &UpdateManager::SetLayerDepths, layers, systemLevel );
840 inline void AddGestureMessage( UpdateManager& manager, PanGesture* gesture )
842 typedef MessageValue1< UpdateManager, PanGesture* > LocalType;
844 // Reserve some memory inside the message queue
845 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
847 // Construct message in the message queue memory; note that delete should not be called on the return value
848 new (slot) LocalType( &manager, &UpdateManager::AddGesture, gesture );
851 inline void RemoveGestureMessage( UpdateManager& manager, PanGesture* gesture )
853 typedef MessageValue1< UpdateManager, PanGesture* > LocalType;
855 // Reserve some memory inside the message queue
856 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
858 // Construct message in the message queue memory; note that delete should not be called on the return value
859 new (slot) LocalType( &manager, &UpdateManager::RemoveGesture, gesture );
862 template< typename T >
863 inline void AddMessage( UpdateManager& manager, ObjectOwnerContainer<T>& owner, T& object )
865 typedef MessageValue1< ObjectOwnerContainer<T>, OwnerPointer< T > > LocalType;
867 // Reserve some memory inside the message queue
868 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
869 // Construct message in the message queue memory; note that delete should not be called on the return value
870 new (slot) LocalType( &owner, &ObjectOwnerContainer<T>::Add, &object );
873 template< typename T >
874 inline void RemoveMessage( UpdateManager& manager, ObjectOwnerContainer<T>& owner, T& object )
876 typedef MessageValue1< ObjectOwnerContainer<T>, T* > LocalType;
878 // Reserve some memory inside the message queue
879 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
880 // Construct message in the message queue memory; note that delete should not be called on the return value
881 new (slot) LocalType( &owner, &ObjectOwnerContainer<T>::Remove, &object );
884 inline void AddSamplerMessage( UpdateManager& manager, Render::Sampler& sampler )
886 typedef MessageValue1< UpdateManager, Render::Sampler* > LocalType;
888 // Reserve some memory inside the message queue
889 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
891 // Construct message in the message queue memory; note that delete should not be called on the return value
892 new (slot) LocalType( &manager, &UpdateManager::AddSampler, &sampler );
895 inline void RemoveSamplerMessage( UpdateManager& manager, Render::Sampler& sampler )
897 typedef MessageValue1< UpdateManager, Render::Sampler* > LocalType;
899 // Reserve some memory inside the message queue
900 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
902 // Construct message in the message queue memory; note that delete should not be called on the return value
903 new (slot) LocalType( &manager, &UpdateManager::RemoveSampler, &sampler );
906 inline void SetFilterModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int minFilterMode, unsigned int magFilterMode )
908 typedef MessageValue3< UpdateManager, Render::Sampler*, unsigned int, unsigned int > LocalType;
910 // Reserve some memory inside the message queue
911 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
913 // Construct message in the message queue memory; note that delete should not be called on the return value
914 new (slot) LocalType( &manager, &UpdateManager::SetFilterMode, &sampler, minFilterMode, magFilterMode );
917 inline void SetWrapModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int uWrapMode, unsigned int vWrapMode )
919 typedef MessageValue3< UpdateManager, Render::Sampler*, unsigned int, unsigned int > LocalType;
921 // Reserve some memory inside the message queue
922 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
924 // Construct message in the message queue memory; note that delete should not be called on the return value
925 new (slot) LocalType( &manager, &UpdateManager::SetWrapMode, &sampler, uWrapMode, vWrapMode );
928 inline void AddPropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer )
930 typedef MessageValue1< UpdateManager, Render::PropertyBuffer* > LocalType;
932 // Reserve some memory inside the message queue
933 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
935 // Construct message in the message queue memory; note that delete should not be called on the return value
936 new (slot) LocalType( &manager, &UpdateManager::AddPropertyBuffer, &propertyBuffer );
939 inline void RemovePropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer )
941 typedef MessageValue1< UpdateManager, Render::PropertyBuffer* > LocalType;
943 // Reserve some memory inside the message queue
944 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
946 // Construct message in the message queue memory; note that delete should not be called on the return value
947 new (slot) LocalType( &manager, &UpdateManager::RemovePropertyBuffer, &propertyBuffer );
950 inline void SetPropertyBufferFormat( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, Render::PropertyBuffer::Format* format )
952 typedef MessageValue2< UpdateManager, Render::PropertyBuffer*, Render::PropertyBuffer::Format* > LocalType;
954 // Reserve some memory inside the message queue
955 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
957 // Construct message in the message queue memory; note that delete should not be called on the return value
958 new (slot) LocalType( &manager, &UpdateManager::SetPropertyBufferFormat, &propertyBuffer, format );
961 inline void SetPropertyBufferData( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, Vector<char>* data, size_t size )
963 typedef MessageValue3< UpdateManager, Render::PropertyBuffer*, Vector<char>*, size_t > LocalType;
965 // Reserve some memory inside the message queue
966 unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
968 // Construct message in the message queue memory; note that delete should not be called on the return value
969 new (slot) LocalType( &manager, &UpdateManager::SetPropertyBufferData, &propertyBuffer, data, size );
972 } // namespace SceneGraph
974 } // namespace Internal
978 #endif // __DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H__