2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/update/manager/update-manager.h>
22 #include <dali/integration-api/core.h>
24 #include <dali/internal/event/common/notification-manager.h>
25 #include <dali/internal/event/common/property-notifier.h>
26 #include <dali/internal/event/effects/shader-factory.h>
27 #include <dali/internal/event/animation/animation-playlist.h>
29 #include <dali/internal/update/common/discard-queue.h>
30 #include <dali/internal/update/controllers/render-message-dispatcher.h>
31 #include <dali/internal/update/controllers/scene-controller-impl.h>
32 #include <dali/internal/update/manager/frame-callback-processor.h>
33 #include <dali/internal/update/manager/render-task-processor.h>
34 #include <dali/internal/update/manager/update-algorithms.h>
35 #include <dali/internal/update/manager/update-manager-debug.h>
36 #include <dali/internal/update/manager/transform-manager.h>
37 #include <dali/internal/update/nodes/node.h>
38 #include <dali/internal/update/queue/update-message-queue.h>
40 #include <dali/internal/render/common/render-manager.h>
41 #include <dali/internal/render/queue/render-queue.h>
43 // Un-comment to enable node tree debug logging
44 //#define NODE_TREE_LOGGING 1
46 #if ( defined( DEBUG_ENABLED ) && defined( NODE_TREE_LOGGING ) )
47 #define SNAPSHOT_NODE_LOGGING \
48 const uint32_t FRAME_COUNT_TRIGGER = 16;\
49 if( mImpl->frameCounter >= FRAME_COUNT_TRIGGER )\
51 for( auto&& scene : mImpl->scenes )
53 if ( scene && scene->root )\
55 mImpl->frameCounter = 0;\
56 PrintNodeTree( *scene->root, mSceneGraphBuffers.GetUpdateBufferIndex(), "" );\
60 mImpl->frameCounter++;
62 #define SNAPSHOT_NODE_LOGGING
65 #if defined(DEBUG_ENABLED)
66 extern Debug::Filter* gRenderTaskLogFilter;
69 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_UPDATE_MANAGER" );
70 } // unnamed namespace
74 using namespace Dali::Integration;
75 using Dali::Internal::Update::MessageQueue;
89 * Helper to Erase an object from OwnerContainer using discard queue
90 * @param container to remove from
91 * @param object to remove
92 * @param discardQueue to put the object to
93 * @param updateBufferIndex to use
96 inline void EraseUsingDiscardQueue( OwnerContainer<T*>& container, T* object, DiscardQueue& discardQueue, BufferIndex updateBufferIndex )
98 DALI_ASSERT_DEBUG( object && "NULL object not allowed" );
100 // need to use the reference version of auto as we need the pointer to the pointer for the Release call below
101 for( auto&& iter : container )
103 if ( iter == object )
105 // Transfer ownership to the discard queue, this keeps the object alive, until the render-thread has finished with it
106 discardQueue.Add( updateBufferIndex, container.Release( &iter ) ); // take the address of the reference to a pointer (iter)
107 return; // return as we only ever remove one object. Iterators to container are now invalidated as well so cannot continue
113 * Descends into node's hierarchy and sorts the children of each child according to their depth-index.
114 * @param[in] node The node whose hierarchy to descend
116 void SortSiblingNodesRecursively( Node& node )
118 NodeContainer& container = node.GetChildren();
119 std::sort( container.Begin(), container.End(),
120 []( Node* a, Node* b ) { return a->GetDepthIndex() < b->GetDepthIndex(); } );
122 // Descend tree and sort as well
123 for( auto&& iter : container )
125 SortSiblingNodesRecursively( *iter );
129 } // unnamed namespace
132 * Structure to contain UpdateManager internal data
134 struct UpdateManager::Impl
136 // SceneInfo keeps the root node of the Scene, its scene graph render task list, and the list of Layer pointers sorted by depth
139 SceneInfo( Layer* root ) ///< Constructor
144 ~SceneInfo() = default; ///< Default non-virtual destructor
145 SceneInfo( SceneInfo&& rhs ) = default; ///< Move constructor
146 SceneInfo& operator=( SceneInfo&& rhs ) = default; ///< Move assignment operator
147 SceneInfo& operator=( const SceneInfo& rhs ) = delete; ///< Assignment operator
148 SceneInfo( const SceneInfo& rhs ) = delete; ///< Copy constructor
150 Layer* root{ nullptr }; ///< Root node (root is a layer). The layer is not stored in the node memory pool.
151 OwnerPointer< RenderTaskList > taskList; ///< Scene graph render task list
152 SortedLayerPointers sortedLayerList; ///< List of Layer pointers sorted by depth (one list of sorted layers per root)
153 OwnerPointer< Scene > scene; ///< Scene graph object of the scene
156 Impl( NotificationManager& notificationManager,
157 CompleteNotificationInterface& animationPlaylist,
158 PropertyNotifier& propertyNotifier,
159 DiscardQueue& discardQueue,
160 RenderController& renderController,
161 RenderManager& renderManager,
162 RenderQueue& renderQueue,
163 SceneGraphBuffers& sceneGraphBuffers,
164 RenderTaskProcessor& renderTaskProcessor )
165 : renderMessageDispatcher( renderManager, renderQueue, sceneGraphBuffers ),
166 notificationManager( notificationManager ),
168 animationPlaylist( animationPlaylist ),
169 propertyNotifier( propertyNotifier ),
171 discardQueue( discardQueue ),
172 renderController( renderController ),
173 sceneController( NULL ),
174 renderManager( renderManager ),
175 renderQueue( renderQueue ),
176 renderTaskProcessor( renderTaskProcessor ),
177 backgroundColor( Dali::Stage::DEFAULT_BACKGROUND_COLOR ),
181 panGestureProcessor( NULL ),
182 messageQueue( renderController, sceneGraphBuffers ),
183 frameCallbackProcessor( NULL ),
184 keepRenderingSeconds( 0.0f ),
185 nodeDirtyFlags( NodePropertyFlags::TRANSFORM ), // set to TransformFlag to ensure full update the first time through Update()
187 renderingBehavior( DevelStage::Rendering::IF_REQUIRED ),
188 animationFinishedDuringUpdate( false ),
189 previousUpdateScene( false ),
190 renderTaskWaiting( false ),
191 renderersAdded( false ),
192 surfaceRectChanged( false )
194 sceneController = new SceneControllerImpl( renderMessageDispatcher, renderQueue, discardQueue );
196 // create first 'dummy' node
202 // Disconnect render tasks from nodes, before destroying the nodes
203 for( auto&& scene : scenes )
205 if ( scene && scene->taskList )
207 RenderTaskList::RenderTaskContainer& tasks = scene->taskList->GetTasks();
208 for ( auto&& task : tasks )
210 task->SetSourceNode( NULL );
215 // UpdateManager owns the Nodes. Although Nodes are pool allocated they contain heap allocated parts
216 // like custom properties, which get released here
217 Vector<Node*>::Iterator iter = nodes.Begin()+1;
218 Vector<Node*>::Iterator endIter = nodes.End();
219 for(;iter!=endIter;++iter)
221 (*iter)->OnDestroy();
225 for( auto&& scene : scenes )
227 if ( scene && scene->root )
229 scene->root->OnDestroy();
230 Node::Delete( scene->root );
235 delete sceneController;
239 * Lazy init for FrameCallbackProcessor.
240 * @param[in] updateManager A reference to the update-manager
242 FrameCallbackProcessor& GetFrameCallbackProcessor( UpdateManager& updateManager )
244 if( ! frameCallbackProcessor )
246 frameCallbackProcessor = new FrameCallbackProcessor( updateManager, transformManager );
248 return *frameCallbackProcessor;
251 SceneGraphBuffers sceneGraphBuffers; ///< Used to keep track of which buffers are being written or read
252 RenderMessageDispatcher renderMessageDispatcher; ///< Used for passing messages to the render-thread
253 NotificationManager& notificationManager; ///< Queues notification messages for the event-thread.
254 TransformManager transformManager; ///< Used to update the transformation matrices of the nodes
255 CompleteNotificationInterface& animationPlaylist; ///< Holds handles to all the animations
256 PropertyNotifier& propertyNotifier; ///< Provides notification to applications when properties are modified.
257 ShaderSaver* shaderSaver; ///< Saves shader binaries.
258 DiscardQueue& discardQueue; ///< Nodes are added here when disconnected from the scene-graph.
259 RenderController& renderController; ///< render controller
260 SceneControllerImpl* sceneController; ///< scene controller
261 RenderManager& renderManager; ///< This is responsible for rendering the results of each "update"
262 RenderQueue& renderQueue; ///< Used to queue messages for the next render
263 RenderTaskProcessor& renderTaskProcessor; ///< Handles RenderTasks and RenderInstrucitons
265 Vector4 backgroundColor; ///< The glClear color used at the beginning of each frame.
267 using SceneInfoPtr = std::unique_ptr< SceneInfo >;
268 std::vector< SceneInfoPtr > scenes; ///< A container of SceneInfo.
270 Vector<Node*> nodes; ///< A container of all instantiated nodes
272 OwnerContainer< Camera* > cameras; ///< A container of cameras
273 OwnerContainer< PropertyOwner* > customObjects; ///< A container of owned objects (with custom properties)
275 OwnerContainer< PropertyResetterBase* > propertyResetters; ///< A container of property resetters
276 OwnerContainer< Animation* > animations; ///< A container of owned animations
277 PropertyNotificationContainer propertyNotifications; ///< A container of owner property notifications.
278 OwnerContainer< Renderer* > renderers; ///< A container of owned renderers
279 OwnerContainer< TextureSet* > textureSets; ///< A container of owned texture sets
280 OwnerContainer< Shader* > shaders; ///< A container of owned shaders
281 OwnerPointer< PanGesture > panGestureProcessor; ///< Owned pan gesture processor; it lives for the lifecycle of UpdateManager
283 MessageQueue messageQueue; ///< The messages queued from the event-thread
284 std::vector<Internal::ShaderDataPtr> renderCompiledShaders; ///< Shaders compiled on Render thread are inserted here for update thread to pass on to event thread.
285 std::vector<Internal::ShaderDataPtr> updateCompiledShaders; ///< Shaders to be sent from Update to Event
286 Mutex compiledShaderMutex; ///< lock to ensure no corruption on the renderCompiledShaders
288 OwnerPointer<FrameCallbackProcessor> frameCallbackProcessor; ///< Owned FrameCallbackProcessor, only created if required.
290 float keepRenderingSeconds; ///< Set via Dali::Stage::KeepRendering
291 NodePropertyFlags nodeDirtyFlags; ///< cumulative node dirty flags from previous frame
292 uint32_t frameCounter; ///< Frame counter used in debugging to choose which frame to debug and which to ignore.
294 DevelStage::Rendering renderingBehavior; ///< Set via DevelStage::SetRenderingBehavior
296 bool animationFinishedDuringUpdate; ///< Flag whether any animations finished during the Update()
297 bool previousUpdateScene; ///< True if the scene was updated in the previous frame (otherwise it was optimized out)
298 bool renderTaskWaiting; ///< A REFRESH_ONCE render task is waiting to be rendered
299 bool renderersAdded; ///< Flag to keep track when renderers have been added to avoid unnecessary processing
300 bool surfaceRectChanged; ///< True if the default surface rect is changed
304 Impl( const Impl& ); ///< Undefined
305 Impl& operator=( const Impl& ); ///< Undefined
308 UpdateManager::UpdateManager( NotificationManager& notificationManager,
309 CompleteNotificationInterface& animationFinishedNotifier,
310 PropertyNotifier& propertyNotifier,
311 DiscardQueue& discardQueue,
312 RenderController& controller,
313 RenderManager& renderManager,
314 RenderQueue& renderQueue,
315 RenderTaskProcessor& renderTaskProcessor )
318 mImpl = new Impl( notificationManager,
319 animationFinishedNotifier,
326 renderTaskProcessor );
330 UpdateManager::~UpdateManager()
335 void UpdateManager::InstallRoot( OwnerPointer<Layer>& layer )
337 DALI_ASSERT_DEBUG( layer->IsLayer() );
338 DALI_ASSERT_DEBUG( layer->GetParent() == NULL);
340 Layer* rootLayer = layer.Release();
342 DALI_ASSERT_DEBUG( std::find_if( mImpl->scenes.begin(), mImpl->scenes.end(),
343 [rootLayer]( Impl::SceneInfoPtr& scene )
345 return scene && scene->root == rootLayer;
347 ) == mImpl->scenes.end() && "Root Node already installed" );
349 rootLayer->CreateTransform( &mImpl->transformManager );
350 rootLayer->SetRoot(true);
352 mImpl->scenes.emplace_back( new Impl::SceneInfo( rootLayer ) );
355 void UpdateManager::UninstallRoot( Layer* layer )
357 DALI_ASSERT_DEBUG( layer->IsLayer() );
358 DALI_ASSERT_DEBUG( layer->GetParent() == NULL );
360 for (auto iter = mImpl->scenes.begin(); iter != mImpl->scenes.end(); ++iter)
362 if( (*iter) && (*iter)->root == layer )
364 mImpl->scenes.erase( iter );
369 mImpl->discardQueue.Add( mSceneGraphBuffers.GetUpdateBufferIndex(), layer );
371 // Notify the layer about impending destruction
375 void UpdateManager::AddNode( OwnerPointer<Node>& node )
377 DALI_ASSERT_ALWAYS( NULL == node->GetParent() ); // Should not have a parent yet
379 // Nodes must be sorted by pointer
380 Node* rawNode = node.Release();
381 DALI_LOG_INFO( gLogFilter, Debug::General, "[%x] AddNode\n", rawNode );
383 Vector<Node*>::Iterator begin = mImpl->nodes.Begin();
384 for( Vector<Node*>::Iterator iter = mImpl->nodes.End()-1; iter >= begin; --iter )
386 if( rawNode > (*iter) )
388 mImpl->nodes.Insert((iter+1), rawNode );
389 rawNode->CreateTransform( &mImpl->transformManager );
395 void UpdateManager::ConnectNode( Node* parent, Node* node )
397 DALI_ASSERT_ALWAYS( NULL != parent );
398 DALI_ASSERT_ALWAYS( NULL != node );
399 DALI_ASSERT_ALWAYS( NULL == node->GetParent() ); // Should not have a parent yet
401 DALI_LOG_INFO( gLogFilter, Debug::General, "[%x] ConnectNode\n", node );
403 parent->ConnectChild( node );
405 // Inform the frame-callback-processor, if set, about the node-hierarchy changing
406 if( mImpl->frameCallbackProcessor )
408 mImpl->frameCallbackProcessor->NodeHierarchyChanged();
412 void UpdateManager::DisconnectNode( Node* node )
414 DALI_LOG_INFO( gLogFilter, Debug::General, "[%x] DisconnectNode\n", node );
416 Node* parent = node->GetParent();
417 DALI_ASSERT_ALWAYS( NULL != parent );
418 parent->SetDirtyFlag( NodePropertyFlags::CHILD_DELETED ); // make parent dirty so that render items dont get reused
420 parent->DisconnectChild( mSceneGraphBuffers.GetUpdateBufferIndex(), *node );
422 // Inform the frame-callback-processor, if set, about the node-hierarchy changing
423 if( mImpl->frameCallbackProcessor )
425 mImpl->frameCallbackProcessor->NodeHierarchyChanged();
429 void UpdateManager::DestroyNode( Node* node )
431 DALI_ASSERT_ALWAYS( NULL != node );
432 DALI_ASSERT_ALWAYS( NULL == node->GetParent() ); // Should have been disconnected
434 DALI_LOG_INFO( gLogFilter, Debug::General, "[%x] DestroyNode\n", node );
436 Vector<Node*>::Iterator iter = mImpl->nodes.Begin()+1;
437 Vector<Node*>::Iterator endIter = mImpl->nodes.End();
438 for(;iter!=endIter;++iter)
442 mImpl->nodes.Erase(iter);
447 mImpl->discardQueue.Add( mSceneGraphBuffers.GetUpdateBufferIndex(), node );
449 // Notify the Node about impending destruction
453 void UpdateManager::AddCamera( OwnerPointer< Camera >& camera )
455 mImpl->cameras.PushBack( camera.Release() ); // takes ownership
458 void UpdateManager::RemoveCamera( Camera* camera )
460 // Find the camera and destroy it
461 EraseUsingDiscardQueue( mImpl->cameras, camera, mImpl->discardQueue, mSceneGraphBuffers.GetUpdateBufferIndex() );
464 void UpdateManager::AddObject( OwnerPointer<PropertyOwner>& object )
466 mImpl->customObjects.PushBack( object.Release() );
469 void UpdateManager::RemoveObject( PropertyOwner* object )
471 mImpl->customObjects.EraseObject( object );
474 void UpdateManager::AddRenderTaskList( OwnerPointer<RenderTaskList>& taskList )
476 RenderTaskList* taskListPointer = taskList.Release();
477 taskListPointer->SetRenderMessageDispatcher( &mImpl->renderMessageDispatcher );
479 mImpl->scenes.back()->taskList = taskListPointer;
482 void UpdateManager::RemoveRenderTaskList( RenderTaskList* taskList )
484 for ( auto&& scene : mImpl->scenes )
486 if ( scene && scene->taskList == taskList )
488 scene->taskList.Reset();
494 void UpdateManager::AddScene( OwnerPointer< Scene >& scene )
496 mImpl->scenes.back()->scene = scene.Release();
498 // Initialize the context from render manager
499 typedef MessageValue1< RenderManager, SceneGraph::Scene* > DerivedType;
501 // Reserve some memory inside the render queue
502 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
504 // Construct message in the render queue memory; note that delete should not be called on the return value
505 SceneGraph::Scene& sceneObject = *mImpl->scenes.back()->scene;
506 new (slot) DerivedType( &mImpl->renderManager, &RenderManager::InitializeScene, &sceneObject );
509 void UpdateManager::RemoveScene( Scene* scene )
511 // Initialize the context from render manager
512 typedef MessageValue1< RenderManager, SceneGraph::Scene* > DerivedType;
514 // Reserve some memory inside the render queue
515 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
517 // Construct message in the render queue memory; note that delete should not be called on the return value
518 new (slot) DerivedType( &mImpl->renderManager, &RenderManager::UninitializeScene, scene );
520 for ( auto&& sceneInfo : mImpl->scenes )
522 if ( sceneInfo && sceneInfo->scene && sceneInfo->scene.Get() == scene )
524 mImpl->discardQueue.Add( mSceneGraphBuffers.GetUpdateBufferIndex(), sceneInfo->scene.Release() ); // take the address of the reference to a pointer
530 void UpdateManager::AddAnimation( OwnerPointer< SceneGraph::Animation >& animation )
532 mImpl->animations.PushBack( animation.Release() );
535 void UpdateManager::StopAnimation( Animation* animation )
537 DALI_ASSERT_DEBUG( animation && "NULL animation called to stop" );
539 bool animationFinished = animation->Stop( mSceneGraphBuffers.GetUpdateBufferIndex() );
541 mImpl->animationFinishedDuringUpdate = mImpl->animationFinishedDuringUpdate || animationFinished;
544 void UpdateManager::RemoveAnimation( Animation* animation )
546 DALI_ASSERT_DEBUG( animation && "NULL animation called to remove" );
548 animation->OnDestroy( mSceneGraphBuffers.GetUpdateBufferIndex() );
550 DALI_ASSERT_DEBUG( animation->GetState() == Animation::Destroyed );
553 bool UpdateManager::IsAnimationRunning() const
555 // Find any animation that isn't stopped or paused
556 for ( auto&& iter : mImpl->animations )
558 const Animation::State state = iter->GetState();
560 if (state != Animation::Stopped &&
561 state != Animation::Paused)
563 return true; // stop iteration as soon as first one is found
570 void UpdateManager::AddPropertyResetter( OwnerPointer<PropertyResetterBase>& propertyResetter )
572 propertyResetter->Initialize();
573 mImpl->propertyResetters.PushBack( propertyResetter.Release() );
576 void UpdateManager::AddPropertyNotification( OwnerPointer< PropertyNotification >& propertyNotification )
578 mImpl->propertyNotifications.PushBack( propertyNotification.Release() );
581 void UpdateManager::RemovePropertyNotification( PropertyNotification* propertyNotification )
583 mImpl->propertyNotifications.EraseObject( propertyNotification );
586 void UpdateManager::PropertyNotificationSetNotify( PropertyNotification* propertyNotification, PropertyNotification::NotifyMode notifyMode )
588 DALI_ASSERT_DEBUG( propertyNotification && "propertyNotification scene graph object missing" );
589 propertyNotification->SetNotifyMode( notifyMode );
592 void UpdateManager::AddShader( OwnerPointer< Shader >& shader )
594 mImpl->shaders.PushBack( shader.Release() );
597 void UpdateManager::RemoveShader( Shader* shader )
599 // Find the shader and destroy it
600 EraseUsingDiscardQueue( mImpl->shaders, shader, mImpl->discardQueue, mSceneGraphBuffers.GetUpdateBufferIndex() );
603 void UpdateManager::SetShaderProgram( Shader* shader,
604 Internal::ShaderDataPtr shaderData, bool modifiesGeometry )
609 typedef MessageValue3< Shader, Internal::ShaderDataPtr, ProgramCache*, bool> DerivedType;
611 // Reserve some memory inside the render queue
612 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
614 // Construct message in the render queue memory; note that delete should not be called on the return value
615 new (slot) DerivedType( shader, &Shader::SetProgram, shaderData, mImpl->renderManager.GetProgramCache(), modifiesGeometry );
619 void UpdateManager::SaveBinary( Internal::ShaderDataPtr shaderData )
621 DALI_ASSERT_DEBUG( shaderData && "No NULL shader data pointers please." );
622 DALI_ASSERT_DEBUG( shaderData->GetBufferSize() > 0 && "Shader binary empty so nothing to save." );
624 // lock as update might be sending previously compiled shaders to event thread
625 Mutex::ScopedLock lock( mImpl->compiledShaderMutex );
626 mImpl->renderCompiledShaders.push_back( shaderData );
630 void UpdateManager::SetShaderSaver( ShaderSaver& upstream )
632 mImpl->shaderSaver = &upstream;
635 void UpdateManager::AddRenderer( OwnerPointer< Renderer >& renderer )
637 DALI_LOG_INFO( gLogFilter, Debug::General, "[%x] AddRenderer\n", renderer.Get() );
639 renderer->ConnectToSceneGraph( *mImpl->sceneController, mSceneGraphBuffers.GetUpdateBufferIndex() );
640 mImpl->renderers.PushBack( renderer.Release() );
641 mImpl->renderersAdded = true;
644 void UpdateManager::RemoveRenderer( Renderer* renderer )
646 DALI_LOG_INFO( gLogFilter, Debug::General, "[%x] RemoveRenderer\n", renderer );
648 // Find the renderer and destroy it
649 EraseUsingDiscardQueue( mImpl->renderers, renderer, mImpl->discardQueue, mSceneGraphBuffers.GetUpdateBufferIndex() );
650 // Need to remove the render object as well
651 renderer->DisconnectFromSceneGraph( *mImpl->sceneController, mSceneGraphBuffers.GetUpdateBufferIndex() );
654 void UpdateManager::SetPanGestureProcessor( PanGesture* panGestureProcessor )
656 DALI_ASSERT_DEBUG( NULL != panGestureProcessor );
658 mImpl->panGestureProcessor = panGestureProcessor;
661 void UpdateManager::AddTextureSet( OwnerPointer< TextureSet >& textureSet )
663 mImpl->textureSets.PushBack( textureSet.Release() );
666 void UpdateManager::RemoveTextureSet( TextureSet* textureSet )
668 mImpl->textureSets.EraseObject( textureSet );
671 uint32_t* UpdateManager::ReserveMessageSlot( uint32_t size, bool updateScene )
673 return mImpl->messageQueue.ReserveMessageSlot( size, updateScene );
676 void UpdateManager::EventProcessingStarted()
678 mImpl->messageQueue.EventProcessingStarted();
681 bool UpdateManager::FlushQueue()
683 return mImpl->messageQueue.FlushQueue();
686 void UpdateManager::ResetProperties( BufferIndex bufferIndex )
688 // Clear the "animations finished" flag; This should be set if any (previously playing) animation is stopped
689 mImpl->animationFinishedDuringUpdate = false;
691 // Reset all animating / constrained properties
692 std::vector<PropertyResetterBase*>toDelete;
693 for( auto&& element : mImpl->propertyResetters )
695 element->ResetToBaseValue( bufferIndex );
696 if( element->IsFinished() )
698 toDelete.push_back( element );
702 // If a resetter is no longer required (the animator or constraint has been removed), delete it.
703 for( auto&& elementPtr : toDelete )
705 mImpl->propertyResetters.EraseObject( elementPtr );
708 // Clear all root nodes dirty flags
709 for( auto& scene : mImpl->scenes )
711 auto root = scene->root;
712 root->ResetDirtyFlags( bufferIndex );
715 // Clear node dirty flags
716 Vector<Node*>::Iterator iter = mImpl->nodes.Begin()+1;
717 Vector<Node*>::Iterator endIter = mImpl->nodes.End();
718 for( ;iter != endIter; ++iter )
720 (*iter)->ResetDirtyFlags( bufferIndex );
724 bool UpdateManager::ProcessGestures( BufferIndex bufferIndex, uint32_t lastVSyncTimeMilliseconds, uint32_t nextVSyncTimeMilliseconds )
726 bool gestureUpdated( false );
728 if( mImpl->panGestureProcessor )
730 // gesture processor only supports default properties
731 mImpl->panGestureProcessor->ResetDefaultProperties( bufferIndex ); // Needs to be done every time as gesture data is written directly to an update-buffer rather than via a message
732 gestureUpdated |= mImpl->panGestureProcessor->UpdateProperties( lastVSyncTimeMilliseconds, nextVSyncTimeMilliseconds );
735 return gestureUpdated;
738 void UpdateManager::Animate( BufferIndex bufferIndex, float elapsedSeconds )
740 auto&& iter = mImpl->animations.Begin();
741 bool animationLooped = false;
743 while ( iter != mImpl->animations.End() )
745 Animation* animation = *iter;
746 bool finished = false;
748 bool progressMarkerReached = false;
749 animation->Update( bufferIndex, elapsedSeconds, looped, finished, progressMarkerReached );
751 if ( progressMarkerReached )
753 mImpl->notificationManager.QueueMessage( Internal::NotifyProgressReachedMessage( mImpl->animationPlaylist, animation ) );
756 mImpl->animationFinishedDuringUpdate = mImpl->animationFinishedDuringUpdate || finished;
757 animationLooped = animationLooped || looped;
759 // Remove animations that had been destroyed but were still waiting for an update
760 if (animation->GetState() == Animation::Destroyed)
762 iter = mImpl->animations.Erase(iter);
770 // queue the notification on finished or looped (to update loop count)
771 if ( mImpl->animationFinishedDuringUpdate || animationLooped )
773 // The application should be notified by NotificationManager, in another thread
774 mImpl->notificationManager.QueueCompleteNotification( &mImpl->animationPlaylist );
778 void UpdateManager::ConstrainCustomObjects( BufferIndex bufferIndex )
780 //Constrain custom objects (in construction order)
781 for ( auto&& object : mImpl->customObjects )
783 ConstrainPropertyOwner( *object, bufferIndex );
787 void UpdateManager::ConstrainRenderTasks( BufferIndex bufferIndex )
789 // Constrain render-tasks
790 for ( auto&& scene : mImpl->scenes )
792 if ( scene && scene->taskList )
794 RenderTaskList::RenderTaskContainer& tasks = scene->taskList->GetTasks();
795 for ( auto&& task : tasks )
797 ConstrainPropertyOwner( *task, bufferIndex );
803 void UpdateManager::ConstrainShaders( BufferIndex bufferIndex )
805 // constrain shaders... (in construction order)
806 for ( auto&& shader : mImpl->shaders )
808 ConstrainPropertyOwner( *shader, bufferIndex );
812 void UpdateManager::ProcessPropertyNotifications( BufferIndex bufferIndex )
814 for( auto&& notification : mImpl->propertyNotifications )
816 bool valid = notification->Check( bufferIndex );
819 mImpl->notificationManager.QueueMessage( PropertyChangedMessage( mImpl->propertyNotifier, notification, notification->GetValidity() ) );
824 void UpdateManager::ForwardCompiledShadersToEventThread()
826 DALI_ASSERT_DEBUG( (mImpl->shaderSaver != 0) && "shaderSaver should be wired-up during startup." );
827 if( mImpl->shaderSaver )
829 // lock and swap the queues
831 // render might be attempting to send us more binaries at the same time
832 Mutex::ScopedLock lock( mImpl->compiledShaderMutex );
833 mImpl->renderCompiledShaders.swap( mImpl->updateCompiledShaders );
836 if( mImpl->updateCompiledShaders.size() > 0 )
838 ShaderSaver& factory = *mImpl->shaderSaver;
839 for( auto&& shader : mImpl->updateCompiledShaders )
841 mImpl->notificationManager.QueueMessage( ShaderCompiledMessage( factory, shader ) );
843 // we don't need them in update anymore
844 mImpl->updateCompiledShaders.clear();
849 void UpdateManager::UpdateRenderers( BufferIndex bufferIndex )
851 for( auto&& renderer : mImpl->renderers )
854 ConstrainPropertyOwner( *renderer, bufferIndex );
856 renderer->PrepareRender( bufferIndex );
860 void UpdateManager::UpdateNodes( BufferIndex bufferIndex )
862 mImpl->nodeDirtyFlags = NodePropertyFlags::NOTHING;
864 for ( auto&& scene : mImpl->scenes )
866 if ( scene && scene->root )
868 // Prepare resources, update shaders, for each node
869 // And add the renderers to the sorted layers. Start from root, which is also a layer
870 mImpl->nodeDirtyFlags |= UpdateNodeTree( *scene->root,
872 mImpl->renderQueue );
877 uint32_t UpdateManager::Update( float elapsedSeconds,
878 uint32_t lastVSyncTimeMilliseconds,
879 uint32_t nextVSyncTimeMilliseconds,
880 bool renderToFboEnabled,
881 bool isRenderingToFbo )
883 const BufferIndex bufferIndex = mSceneGraphBuffers.GetUpdateBufferIndex();
885 //Clear nodes/resources which were previously discarded
886 mImpl->discardQueue.Clear( bufferIndex );
888 //Process Touches & Gestures
889 const bool gestureUpdated = ProcessGestures( bufferIndex, lastVSyncTimeMilliseconds, nextVSyncTimeMilliseconds );
891 bool updateScene = // The scene-graph requires an update if..
892 (mImpl->nodeDirtyFlags & RenderableUpdateFlags) || // ..nodes were dirty in previous frame OR
893 IsAnimationRunning() || // ..at least one animation is running OR
894 mImpl->messageQueue.IsSceneUpdateRequired() || // ..a message that modifies the scene graph node tree is queued OR
895 gestureUpdated; // ..a gesture property was updated
897 bool keepRendererRendering = false;
899 // Although the scene-graph may not require an update, we still need to synchronize double-buffered
900 // values if the scene was updated in the previous frame.
901 if( updateScene || mImpl->previousUpdateScene )
903 //Reset properties from the previous update
904 ResetProperties( bufferIndex );
905 mImpl->transformManager.ResetToBaseValue();
908 // Process the queued scene messages. Note, MessageQueue::FlushQueue may be called
909 // between calling IsSceneUpdateRequired() above and here, so updateScene should
911 updateScene |= mImpl->messageQueue.ProcessMessages( bufferIndex );
913 //Forward compiled shader programs to event thread for saving
914 ForwardCompiledShadersToEventThread();
916 // Although the scene-graph may not require an update, we still need to synchronize double-buffered
917 // renderer lists if the scene was updated in the previous frame.
918 // We should not start skipping update steps or reusing lists until there has been two frames where nothing changes
919 if( updateScene || mImpl->previousUpdateScene )
922 Animate( bufferIndex, elapsedSeconds );
924 //Constraint custom objects
925 ConstrainCustomObjects( bufferIndex );
927 //Clear the lists of renderers from the previous update
928 for( auto&& scene : mImpl->scenes )
932 for( auto&& layer : scene->sortedLayerList )
936 layer->ClearRenderables();
942 // Call the frame-callback-processor if set
943 if( mImpl->frameCallbackProcessor )
945 mImpl->frameCallbackProcessor->Update( bufferIndex, elapsedSeconds );
948 //Update node hierarchy, apply constraints and perform sorting / culling.
949 //This will populate each Layer with a list of renderers which are ready.
950 UpdateNodes( bufferIndex );
952 //Apply constraints to RenderTasks, shaders
953 ConstrainRenderTasks( bufferIndex );
954 ConstrainShaders( bufferIndex );
956 //Update renderers and apply constraints
957 UpdateRenderers( bufferIndex );
959 //Update the transformations of all the nodes
960 mImpl->transformManager.Update();
962 //Process Property Notifications
963 ProcessPropertyNotifications( bufferIndex );
966 for( auto&& cameraIterator : mImpl->cameras )
968 cameraIterator->Update( bufferIndex );
971 //Process the RenderTasks if renderers exist. This creates the instructions for rendering the next frame.
972 //reset the update buffer index and make sure there is enough room in the instruction container
973 if( mImpl->renderersAdded )
975 // Calculate how many render tasks we have in total
976 std::size_t numberOfRenderTasks = 0;
977 for (auto&& scene : mImpl->scenes )
979 if ( scene && scene->taskList )
981 numberOfRenderTasks += scene->taskList->GetTasks().Count();
986 std::size_t numberOfRenderInstructions = 0;
987 for ( auto&& scene : mImpl->scenes )
989 if ( scene && scene->root && scene->taskList && scene->scene )
991 scene->scene->GetRenderInstructions().ResetAndReserve( bufferIndex,
992 static_cast<uint32_t>( scene->taskList->GetTasks().Count() ) );
994 keepRendererRendering |= mImpl->renderTaskProcessor.Process( bufferIndex,
997 scene->sortedLayerList,
998 *scene->scene->GetContext(),
999 scene->scene->GetRenderInstructions(),
1003 numberOfRenderInstructions += scene->scene->GetRenderInstructions().Count( bufferIndex );
1007 DALI_LOG_INFO( gLogFilter, Debug::General,
1008 "Update: numberOfRenderTasks(%d), Render Instructions(%d)\n",
1009 numberOfRenderTasks, numberOfRenderInstructions );
1013 for ( auto&& scene : mImpl->scenes )
1015 if ( scene && scene->root && scene->taskList )
1017 RenderTaskList::RenderTaskContainer& tasks = scene->taskList->GetTasks();
1019 // check the countdown and notify
1020 bool doRenderOnceNotify = false;
1021 mImpl->renderTaskWaiting = false;
1022 for ( auto&& renderTask : tasks )
1024 renderTask->UpdateState();
1026 if( renderTask->IsWaitingToRender() &&
1027 renderTask->ReadyToRender( bufferIndex ) /*avoid updating forever when source actor is off-stage*/ )
1029 mImpl->renderTaskWaiting = true; // keep update/render threads alive
1032 if( renderTask->HasRendered() )
1034 doRenderOnceNotify = true;
1038 if( doRenderOnceNotify )
1040 DALI_LOG_INFO(gRenderTaskLogFilter, Debug::General, "Notify a render task has finished\n");
1041 mImpl->notificationManager.QueueCompleteNotification( scene->taskList->GetCompleteNotificationInterface() );
1046 // Macro is undefined in release build.
1047 SNAPSHOT_NODE_LOGGING;
1049 // A ResetProperties() may be required in the next frame
1050 mImpl->previousUpdateScene = updateScene;
1052 // Check whether further updates are required
1053 uint32_t keepUpdating = KeepUpdatingCheck( elapsedSeconds );
1055 if( keepRendererRendering )
1057 keepUpdating |= KeepUpdating::STAGE_KEEP_RENDERING;
1059 // Set dirty flags for next frame to continue rendering
1060 mImpl->nodeDirtyFlags |= RenderableUpdateFlags;
1063 // tell the update manager that we're done so the queue can be given to event thread
1064 mImpl->notificationManager.UpdateCompleted();
1066 // The update has finished; swap the double-buffering indices
1067 mSceneGraphBuffers.Swap();
1069 return keepUpdating;
1072 uint32_t UpdateManager::KeepUpdatingCheck( float elapsedSeconds ) const
1074 // Update the duration set via Stage::KeepRendering()
1075 if ( mImpl->keepRenderingSeconds > 0.0f )
1077 mImpl->keepRenderingSeconds -= elapsedSeconds;
1080 uint32_t keepUpdatingRequest = KeepUpdating::NOT_REQUESTED;
1082 // If the rendering behavior is set to continuously render, then continue to render.
1083 // If Stage::KeepRendering() has been called, then continue until the duration has elapsed.
1084 // Keep updating until no messages are received and no animations are running.
1085 // If an animation has just finished, update at least once more for Discard end-actions.
1086 // No need to check for renderQueue as there is always a render after update and if that
1087 // render needs another update it will tell the adaptor to call update again
1089 if ( ( mImpl->renderingBehavior == DevelStage::Rendering::CONTINUOUSLY ) ||
1090 ( mImpl->keepRenderingSeconds > 0.0f ) )
1092 keepUpdatingRequest |= KeepUpdating::STAGE_KEEP_RENDERING;
1095 if ( IsAnimationRunning() ||
1096 mImpl->animationFinishedDuringUpdate )
1098 keepUpdatingRequest |= KeepUpdating::ANIMATIONS_RUNNING;
1101 if ( mImpl->renderTaskWaiting )
1103 keepUpdatingRequest |= KeepUpdating::RENDER_TASK_SYNC;
1106 return keepUpdatingRequest;
1109 void UpdateManager::SetDefaultSurfaceRect( const Rect<int32_t>& rect )
1111 mImpl->surfaceRectChanged = true;
1113 typedef MessageValue1< RenderManager, Rect<int32_t> > DerivedType;
1115 // Reserve some memory inside the render queue
1116 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
1118 // Construct message in the render queue memory; note that delete should not be called on the return value
1119 new (slot) DerivedType( &mImpl->renderManager, &RenderManager::SetDefaultSurfaceRect, rect );
1122 void UpdateManager::SurfaceReplaced( Scene* scene )
1124 typedef MessageValue1< RenderManager, Scene* > DerivedType;
1126 // Reserve some memory inside the render queue
1127 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
1129 // Construct message in the render queue memory; note that delete should not be called on the return value
1130 new (slot) DerivedType( &mImpl->renderManager, &RenderManager::SurfaceReplaced, scene );
1133 void UpdateManager::SetDefaultSurfaceOrientation( int orientation )
1135 typedef MessageValue1< RenderManager, int > DerivedType;
1137 // Reserve some memory inside the render queue
1138 unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
1140 // Construct message in the render queue memory; note that delete should not be called on the return value
1141 new (slot) DerivedType( &mImpl->renderManager, &RenderManager::SetDefaultSurfaceOrientation, orientation );
1144 void UpdateManager::KeepRendering( float durationSeconds )
1146 mImpl->keepRenderingSeconds = std::max( mImpl->keepRenderingSeconds, durationSeconds );
1149 void UpdateManager::SetRenderingBehavior( DevelStage::Rendering renderingBehavior )
1151 mImpl->renderingBehavior = renderingBehavior;
1154 void UpdateManager::SetLayerDepths( const SortedLayerPointers& layers, const Layer* rootLayer )
1156 for ( auto&& scene : mImpl->scenes )
1158 if ( scene && scene->root == rootLayer )
1160 scene->sortedLayerList = layers;
1166 void UpdateManager::SetDepthIndices( OwnerPointer< NodeDepths >& nodeDepths )
1168 // note,this vector is already in depth order. It could be used as-is to
1169 // remove sorting in update algorithm. However, it lacks layer boundary markers.
1170 for( auto&& iter : nodeDepths->nodeDepths )
1172 iter.node->SetDepthIndex( iter.sortedDepth );
1175 for ( auto&& scene : mImpl->scenes )
1179 // Go through node hierarchy and rearrange siblings according to depth-index
1180 SortSiblingNodesRecursively( *scene->root );
1185 bool UpdateManager::IsDefaultSurfaceRectChanged()
1187 bool surfaceRectChanged = mImpl->surfaceRectChanged;
1190 mImpl->surfaceRectChanged = false;
1192 return surfaceRectChanged;
1195 void UpdateManager::AddFrameCallback( OwnerPointer< FrameCallback >& frameCallback, const Node* rootNode )
1197 mImpl->GetFrameCallbackProcessor( *this ).AddFrameCallback( frameCallback, rootNode );
1200 void UpdateManager::RemoveFrameCallback( FrameCallbackInterface* frameCallback )
1202 mImpl->GetFrameCallbackProcessor( *this ).RemoveFrameCallback( frameCallback );
1205 void UpdateManager::AddSampler( OwnerPointer< Render::Sampler >& sampler )
1207 // Message has ownership of Sampler while in transit from update to render
1208 typedef MessageValue1< RenderManager, OwnerPointer< Render::Sampler > > DerivedType;
1210 // Reserve some memory inside the render queue
1211 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
1213 // Construct message in the render queue memory; note that delete should not be called on the return value
1214 new (slot) DerivedType( &mImpl->renderManager, &RenderManager::AddSampler, sampler );
1217 void UpdateManager::RemoveSampler( Render::Sampler* sampler )
1219 typedef MessageValue1< RenderManager, Render::Sampler* > DerivedType;
1221 // Reserve some memory inside the render queue
1222 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
1224 // Construct message in the render queue memory; note that delete should not be called on the return value
1225 new (slot) DerivedType( &mImpl->renderManager, &RenderManager::RemoveSampler, sampler );
1228 void UpdateManager::SetFilterMode( Render::Sampler* sampler, uint32_t minFilterMode, uint32_t magFilterMode )
1230 typedef MessageValue3< RenderManager, Render::Sampler*, uint32_t, uint32_t > DerivedType;
1232 // Reserve some memory inside the render queue
1233 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
1235 // Construct message in the render queue memory; note that delete should not be called on the return value
1236 new (slot) DerivedType( &mImpl->renderManager, &RenderManager::SetFilterMode, sampler, minFilterMode, magFilterMode );
1239 void UpdateManager::SetWrapMode( Render::Sampler* sampler, uint32_t rWrapMode, uint32_t sWrapMode, uint32_t tWrapMode )
1241 typedef MessageValue4< RenderManager, Render::Sampler*, uint32_t, uint32_t, uint32_t > DerivedType;
1243 // Reserve some memory inside the render queue
1244 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
1246 // Construct message in the render queue memory; note that delete should not be called on the return value
1247 new (slot) DerivedType( &mImpl->renderManager, &RenderManager::SetWrapMode, sampler, rWrapMode, sWrapMode, tWrapMode );
1250 void UpdateManager::AddPropertyBuffer( OwnerPointer< Render::PropertyBuffer >& propertyBuffer )
1252 // Message has ownership of format while in transit from update -> render
1253 typedef MessageValue1< RenderManager, OwnerPointer< Render::PropertyBuffer > > DerivedType;
1255 // Reserve some memory inside the render queue
1256 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
1258 // Construct message in the render queue memory; note that delete should not be called on the return value
1259 new (slot) DerivedType( &mImpl->renderManager, &RenderManager::AddPropertyBuffer, propertyBuffer );
1262 void UpdateManager::RemovePropertyBuffer( Render::PropertyBuffer* propertyBuffer )
1264 typedef MessageValue1< RenderManager, Render::PropertyBuffer* > DerivedType;
1266 // Reserve some memory inside the render queue
1267 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
1269 // Construct message in the render queue memory; note that delete should not be called on the return value
1270 new (slot) DerivedType( &mImpl->renderManager, &RenderManager::RemovePropertyBuffer, propertyBuffer );
1273 void UpdateManager::SetPropertyBufferFormat( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Render::PropertyBuffer::Format>& format )
1275 // Message has ownership of format while in transit from update -> render
1276 typedef MessageValue2< RenderManager, Render::PropertyBuffer*, OwnerPointer< Render::PropertyBuffer::Format > > DerivedType;
1278 // Reserve some memory inside the render queue
1279 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
1281 // Construct message in the render queue memory; note that delete should not be called on the return value
1282 new (slot) DerivedType( &mImpl->renderManager, &RenderManager::SetPropertyBufferFormat, propertyBuffer, format );
1285 void UpdateManager::SetPropertyBufferData( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Vector<uint8_t> >& data, uint32_t size )
1287 // Message has ownership of format while in transit from update -> render
1288 typedef MessageValue3< RenderManager, Render::PropertyBuffer*, OwnerPointer< Dali::Vector<uint8_t> >, uint32_t > DerivedType;
1290 // Reserve some memory inside the render queue
1291 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
1293 // Construct message in the render queue memory; note that delete should not be called on the return value
1294 new (slot) DerivedType( &mImpl->renderManager, &RenderManager::SetPropertyBufferData, propertyBuffer, data, size );
1297 void UpdateManager::AddGeometry( OwnerPointer< Render::Geometry >& geometry )
1299 // Message has ownership of format while in transit from update -> render
1300 typedef MessageValue1< RenderManager, OwnerPointer< Render::Geometry > > DerivedType;
1302 // Reserve some memory inside the render queue
1303 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
1305 // Construct message in the render queue memory; note that delete should not be called on the return value
1306 new (slot) DerivedType( &mImpl->renderManager, &RenderManager::AddGeometry, geometry );
1309 void UpdateManager::RemoveGeometry( Render::Geometry* geometry )
1311 typedef MessageValue1< RenderManager, Render::Geometry* > DerivedType;
1313 // Reserve some memory inside the render queue
1314 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
1316 // Construct message in the render queue memory; note that delete should not be called on the return value
1317 new (slot) DerivedType( &mImpl->renderManager, &RenderManager::RemoveGeometry, geometry );
1320 void UpdateManager::SetGeometryType( Render::Geometry* geometry, uint32_t geometryType )
1322 typedef MessageValue2< RenderManager, Render::Geometry*, uint32_t > DerivedType;
1324 // Reserve some memory inside the render queue
1325 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
1327 // Construct message in the render queue memory; note that delete should not be called on the return value
1328 new (slot) DerivedType( &mImpl->renderManager, &RenderManager::SetGeometryType, geometry, geometryType );
1331 void UpdateManager::SetIndexBuffer( Render::Geometry* geometry, Dali::Vector<uint16_t>& indices )
1333 typedef IndexBufferMessage< RenderManager > DerivedType;
1335 // Reserve some memory inside the render queue
1336 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
1338 // Construct message in the render queue memory; note that delete should not be called on the return value
1339 new (slot) DerivedType( &mImpl->renderManager, geometry, indices );
1342 void UpdateManager::RemoveVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer )
1344 typedef MessageValue2< RenderManager, Render::Geometry*, Render::PropertyBuffer* > DerivedType;
1346 // Reserve some memory inside the render queue
1347 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
1349 // Construct message in the render queue memory; note that delete should not be called on the return value
1350 new (slot) DerivedType( &mImpl->renderManager, &RenderManager::RemoveVertexBuffer, geometry, propertyBuffer );
1353 void UpdateManager::AttachVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer )
1355 typedef MessageValue2< RenderManager, Render::Geometry*, Render::PropertyBuffer* > DerivedType;
1357 // Reserve some memory inside the render queue
1358 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
1360 // Construct message in the render queue memory; note that delete should not be called on the return value
1361 new (slot) DerivedType( &mImpl->renderManager, &RenderManager::AttachVertexBuffer, geometry, propertyBuffer );
1364 void UpdateManager::AddTexture( OwnerPointer< Render::Texture >& texture )
1366 // Message has ownership of Texture while in transit from update -> render
1367 typedef MessageValue1< RenderManager, OwnerPointer< Render::Texture > > DerivedType;
1369 // Reserve some memory inside the render queue
1370 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
1372 // Construct message in the render queue memory; note that delete should not be called on the return value
1373 new (slot) DerivedType( &mImpl->renderManager, &RenderManager::AddTexture, texture );
1376 void UpdateManager::RemoveTexture( Render::Texture* texture)
1378 typedef MessageValue1< RenderManager, Render::Texture* > DerivedType;
1380 // Reserve some memory inside the render queue
1381 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
1383 // Construct message in the render queue memory; note that delete should not be called on the return value
1384 new (slot) DerivedType( &mImpl->renderManager, &RenderManager::RemoveTexture, texture );
1387 void UpdateManager::UploadTexture( Render::Texture* texture, PixelDataPtr pixelData, const Texture::UploadParams& params )
1389 typedef MessageValue3< RenderManager, Render::Texture*, PixelDataPtr, Texture::UploadParams > DerivedType;
1391 // Reserve some memory inside the message queue
1392 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
1394 // Construct message in the message queue memory; note that delete should not be called on the return value
1395 new (slot) DerivedType( &mImpl->renderManager, &RenderManager::UploadTexture, texture, pixelData, params );
1398 void UpdateManager::GenerateMipmaps( Render::Texture* texture )
1400 typedef MessageValue1< RenderManager, Render::Texture* > DerivedType;
1402 // Reserve some memory inside the render queue
1403 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
1405 // Construct message in the render queue memory; note that delete should not be called on the return value
1406 new (slot) DerivedType( &mImpl->renderManager, &RenderManager::GenerateMipmaps, texture );
1409 void UpdateManager::AddFrameBuffer( OwnerPointer< Render::FrameBuffer >& frameBuffer )
1411 typedef MessageValue1< RenderManager, OwnerPointer< Render::FrameBuffer > > DerivedType;
1413 // Reserve some memory inside the render queue
1414 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
1416 // Construct message in the render queue memory; note that delete should not be called on the return value
1417 new (slot) DerivedType( &mImpl->renderManager, &RenderManager::AddFrameBuffer, frameBuffer );
1420 void UpdateManager::RemoveFrameBuffer( Render::FrameBuffer* frameBuffer)
1422 typedef MessageValue1< RenderManager, Render::FrameBuffer* > DerivedType;
1424 // Reserve some memory inside the render queue
1425 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
1427 // Construct message in the render queue memory; note that delete should not be called on the return value
1428 new (slot) DerivedType( &mImpl->renderManager, &RenderManager::RemoveFrameBuffer, frameBuffer );
1431 void UpdateManager::AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::Texture* texture, uint32_t mipmapLevel, uint32_t layer )
1433 typedef MessageValue4< RenderManager, Render::FrameBuffer*, Render::Texture*, uint32_t, uint32_t > DerivedType;
1435 // Reserve some memory inside the render queue
1436 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
1438 // Construct message in the render queue memory; note that delete should not be called on the return value
1439 new (slot) DerivedType( &mImpl->renderManager, &RenderManager::AttachColorTextureToFrameBuffer, frameBuffer, texture, mipmapLevel, layer );
1442 void UpdateManager::AttachDepthTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::Texture* texture, uint32_t mipmapLevel )
1444 typedef MessageValue3< RenderManager, Render::FrameBuffer*, Render::Texture*, uint32_t > DerivedType;
1446 // Reserve some memory inside the render queue
1447 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
1449 // Construct message in the render queue memory; note that delete should not be called on the return value
1450 new (slot) DerivedType( &mImpl->renderManager, &RenderManager::AttachDepthTextureToFrameBuffer, frameBuffer, texture, mipmapLevel );
1453 void UpdateManager::AttachDepthStencilTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::Texture* texture, uint32_t mipmapLevel )
1455 typedef MessageValue3< RenderManager, Render::FrameBuffer*, Render::Texture*, uint32_t > DerivedType;
1457 // Reserve some memory inside the render queue
1458 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
1460 // Construct message in the render queue memory; note that delete should not be called on the return value
1461 new (slot) DerivedType( &mImpl->renderManager, &RenderManager::AttachDepthStencilTextureToFrameBuffer, frameBuffer, texture, mipmapLevel );
1464 } // namespace SceneGraph
1466 } // namespace Internal