2 * Copyright (c) 2021 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/animation/animation-playlist.h>
25 #include <dali/internal/event/common/notification-manager.h>
26 #include <dali/internal/event/common/property-notifier.h>
27 #include <dali/internal/event/effects/shader-factory.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/transform-manager.h>
35 #include <dali/internal/update/manager/update-algorithms.h>
36 #include <dali/internal/update/manager/update-manager-debug.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
73 using namespace Dali::Integration;
74 using Dali::Internal::Update::MessageQueue;
85 * Helper to Erase an object from OwnerContainer using discard queue
86 * @param container to remove from
87 * @param object to remove
88 * @param discardQueue to put the object to
89 * @param updateBufferIndex to use
92 inline void EraseUsingDiscardQueue(OwnerContainer<T*>& container, T* object, DiscardQueue& discardQueue, BufferIndex updateBufferIndex)
94 DALI_ASSERT_DEBUG(object && "NULL object not allowed");
96 // need to use the reference version of auto as we need the pointer to the pointer for the Release call below
97 for(auto&& iter : container)
101 // Transfer ownership to the discard queue, this keeps the object alive, until the render-thread has finished with it
102 discardQueue.Add(updateBufferIndex, container.Release(&iter)); // take the address of the reference to a pointer (iter)
103 return; // return as we only ever remove one object. Iterators to container are now invalidated as well so cannot continue
109 * Descends into node's hierarchy and sorts the children of each child according to their depth-index.
110 * @param[in] node The node whose hierarchy to descend
112 void SortSiblingNodesRecursively(Node& node)
114 NodeContainer& container = node.GetChildren();
115 std::sort(container.Begin(), container.End(), [](Node* a, Node* b) { return a->GetDepthIndex() < b->GetDepthIndex(); });
117 // Descend tree and sort as well
118 for(auto&& iter : container)
120 SortSiblingNodesRecursively(*iter);
124 } // unnamed namespace
127 * Structure to contain UpdateManager internal data
129 struct UpdateManager::Impl
131 // SceneInfo keeps the root node of the Scene, its scene graph render task list, and the list of Layer pointers sorted by depth
134 SceneInfo(Layer* root) ///< Constructor
139 ~SceneInfo() = default; ///< Default non-virtual destructor
140 SceneInfo(SceneInfo&& rhs) = default; ///< Move constructor
141 SceneInfo& operator=(SceneInfo&& rhs) = default; ///< Move assignment operator
142 SceneInfo& operator=(const SceneInfo& rhs) = delete; ///< Assignment operator
143 SceneInfo(const SceneInfo& rhs) = delete; ///< Copy constructor
145 Layer* root{nullptr}; ///< Root node (root is a layer). The layer is not stored in the node memory pool.
146 OwnerPointer<RenderTaskList> taskList; ///< Scene graph render task list
147 SortedLayerPointers sortedLayerList; ///< List of Layer pointers sorted by depth (one list of sorted layers per root)
148 OwnerPointer<Scene> scene; ///< Scene graph object of the scene
151 Impl(NotificationManager& notificationManager,
152 CompleteNotificationInterface& animationPlaylist,
153 PropertyNotifier& propertyNotifier,
154 DiscardQueue& discardQueue,
155 RenderController& renderController,
156 RenderManager& renderManager,
157 RenderQueue& renderQueue,
158 SceneGraphBuffers& sceneGraphBuffers,
159 RenderTaskProcessor& renderTaskProcessor)
160 : renderMessageDispatcher(renderManager, renderQueue, sceneGraphBuffers),
161 notificationManager(notificationManager),
163 animationPlaylist(animationPlaylist),
164 propertyNotifier(propertyNotifier),
165 shaderSaver(nullptr),
166 discardQueue(discardQueue),
167 renderController(renderController),
168 sceneController(nullptr),
169 renderManager(renderManager),
170 renderQueue(renderQueue),
171 renderTaskProcessor(renderTaskProcessor),
172 backgroundColor(Dali::DEFAULT_BACKGROUND_COLOR),
176 panGestureProcessor(nullptr),
177 messageQueue(renderController, sceneGraphBuffers),
178 frameCallbackProcessor(nullptr),
179 keepRenderingSeconds(0.0f),
180 nodeDirtyFlags(NodePropertyFlags::TRANSFORM), // set to TransformFlag to ensure full update the first time through Update()
182 renderingBehavior(DevelStage::Rendering::IF_REQUIRED),
183 animationFinishedDuringUpdate(false),
184 previousUpdateScene(false),
185 renderTaskWaiting(false),
186 renderersAdded(false),
187 renderingRequired(false)
189 sceneController = new SceneControllerImpl(renderMessageDispatcher, renderQueue, discardQueue);
191 // create first 'dummy' node
192 nodes.PushBack(nullptr);
197 // Disconnect render tasks from nodes, before destroying the nodes
198 for(auto&& scene : scenes)
200 if(scene && scene->taskList)
202 RenderTaskList::RenderTaskContainer& tasks = scene->taskList->GetTasks();
203 for(auto&& task : tasks)
205 task->SetSourceNode(nullptr);
210 // UpdateManager owns the Nodes. Although Nodes are pool allocated they contain heap allocated parts
211 // like custom properties, which get released here
212 Vector<Node*>::Iterator iter = nodes.Begin() + 1;
213 Vector<Node*>::Iterator endIter = nodes.End();
214 for(; iter != endIter; ++iter)
216 (*iter)->OnDestroy();
220 for(auto&& scene : scenes)
222 if(scene && scene->root)
224 scene->root->OnDestroy();
225 Node::Delete(scene->root);
230 delete sceneController;
234 * Lazy init for FrameCallbackProcessor.
235 * @param[in] updateManager A reference to the update-manager
237 FrameCallbackProcessor& GetFrameCallbackProcessor(UpdateManager& updateManager)
239 if(!frameCallbackProcessor)
241 frameCallbackProcessor = new FrameCallbackProcessor(updateManager, transformManager);
243 return *frameCallbackProcessor;
246 SceneGraphBuffers sceneGraphBuffers; ///< Used to keep track of which buffers are being written or read
247 RenderMessageDispatcher renderMessageDispatcher; ///< Used for passing messages to the render-thread
248 NotificationManager& notificationManager; ///< Queues notification messages for the event-thread.
249 TransformManager transformManager; ///< Used to update the transformation matrices of the nodes
250 CompleteNotificationInterface& animationPlaylist; ///< Holds handles to all the animations
251 PropertyNotifier& propertyNotifier; ///< Provides notification to applications when properties are modified.
252 ShaderSaver* shaderSaver; ///< Saves shader binaries.
253 DiscardQueue& discardQueue; ///< Nodes are added here when disconnected from the scene-graph.
254 RenderController& renderController; ///< render controller
255 SceneControllerImpl* sceneController; ///< scene controller
256 RenderManager& renderManager; ///< This is responsible for rendering the results of each "update"
257 RenderQueue& renderQueue; ///< Used to queue messages for the next render
258 RenderTaskProcessor& renderTaskProcessor; ///< Handles RenderTasks and RenderInstrucitons
260 Vector4 backgroundColor; ///< The glClear color used at the beginning of each frame.
262 using SceneInfoPtr = std::unique_ptr<SceneInfo>;
263 std::vector<SceneInfoPtr> scenes; ///< A container of SceneInfo.
265 Vector<Node*> nodes; ///< A container of all instantiated nodes
267 OwnerContainer<Camera*> cameras; ///< A container of cameras
268 OwnerContainer<PropertyOwner*> customObjects; ///< A container of owned objects (with custom properties)
270 OwnerContainer<PropertyResetterBase*> propertyResetters; ///< A container of property resetters
271 OwnerContainer<Animation*> animations; ///< A container of owned animations
272 PropertyNotificationContainer propertyNotifications; ///< A container of owner property notifications.
273 OwnerContainer<Renderer*> renderers; ///< A container of owned renderers
274 OwnerContainer<TextureSet*> textureSets; ///< A container of owned texture sets
275 OwnerContainer<Shader*> shaders; ///< A container of owned shaders
276 OwnerPointer<PanGesture> panGestureProcessor; ///< Owned pan gesture processor; it lives for the lifecycle of UpdateManager
278 MessageQueue messageQueue; ///< The messages queued from the event-thread
279 std::vector<Internal::ShaderDataPtr> renderCompiledShaders; ///< Shaders compiled on Render thread are inserted here for update thread to pass on to event thread.
280 std::vector<Internal::ShaderDataPtr> updateCompiledShaders; ///< Shaders to be sent from Update to Event
281 Mutex compiledShaderMutex; ///< lock to ensure no corruption on the renderCompiledShaders
283 OwnerPointer<FrameCallbackProcessor> frameCallbackProcessor; ///< Owned FrameCallbackProcessor, only created if required.
285 float keepRenderingSeconds; ///< Set via Dali::Stage::KeepRendering
286 NodePropertyFlags nodeDirtyFlags; ///< cumulative node dirty flags from previous frame
287 uint32_t frameCounter; ///< Frame counter used in debugging to choose which frame to debug and which to ignore.
289 DevelStage::Rendering renderingBehavior; ///< Set via DevelStage::SetRenderingBehavior
291 bool animationFinishedDuringUpdate; ///< Flag whether any animations finished during the Update()
292 bool previousUpdateScene; ///< True if the scene was updated in the previous frame (otherwise it was optimized out)
293 bool renderTaskWaiting; ///< A REFRESH_ONCE render task is waiting to be rendered
294 bool renderersAdded; ///< Flag to keep track when renderers have been added to avoid unnecessary processing
295 bool renderingRequired; ///< True if required to render the current frame
298 Impl(const Impl&); ///< Undefined
299 Impl& operator=(const Impl&); ///< Undefined
302 UpdateManager::UpdateManager(NotificationManager& notificationManager,
303 CompleteNotificationInterface& animationFinishedNotifier,
304 PropertyNotifier& propertyNotifier,
305 DiscardQueue& discardQueue,
306 RenderController& controller,
307 RenderManager& renderManager,
308 RenderQueue& renderQueue,
309 RenderTaskProcessor& renderTaskProcessor)
312 mImpl = new Impl(notificationManager,
313 animationFinishedNotifier,
320 renderTaskProcessor);
323 UpdateManager::~UpdateManager()
328 void UpdateManager::InstallRoot(OwnerPointer<Layer>& layer)
330 DALI_ASSERT_DEBUG(layer->IsLayer());
331 DALI_ASSERT_DEBUG(layer->GetParent() == NULL);
333 Layer* rootLayer = layer.Release();
335 DALI_ASSERT_DEBUG(std::find_if(mImpl->scenes.begin(), mImpl->scenes.end(), [rootLayer](Impl::SceneInfoPtr& scene) {
336 return scene && scene->root == rootLayer;
337 }) == mImpl->scenes.end() &&
338 "Root Node already installed");
340 rootLayer->CreateTransform(&mImpl->transformManager);
341 rootLayer->SetRoot(true);
343 mImpl->scenes.emplace_back(new Impl::SceneInfo(rootLayer));
346 void UpdateManager::UninstallRoot(Layer* layer)
348 DALI_ASSERT_DEBUG(layer->IsLayer());
349 DALI_ASSERT_DEBUG(layer->GetParent() == NULL);
351 for(auto iter = mImpl->scenes.begin(); iter != mImpl->scenes.end(); ++iter)
353 if((*iter) && (*iter)->root == layer)
355 mImpl->scenes.erase(iter);
360 mImpl->discardQueue.Add(mSceneGraphBuffers.GetUpdateBufferIndex(), layer);
362 // Notify the layer about impending destruction
366 void UpdateManager::AddNode(OwnerPointer<Node>& node)
368 DALI_ASSERT_ALWAYS(nullptr == node->GetParent()); // Should not have a parent yet
370 Node* rawNode = node.Release();
371 DALI_LOG_INFO(gLogFilter, Debug::General, "[%x] AddNode\n", rawNode);
373 mImpl->nodes.PushBack(rawNode);
374 rawNode->CreateTransform(&mImpl->transformManager);
377 void UpdateManager::ConnectNode(Node* parent, Node* node)
379 DALI_ASSERT_ALWAYS(nullptr != parent);
380 DALI_ASSERT_ALWAYS(nullptr != node);
381 DALI_ASSERT_ALWAYS(nullptr == node->GetParent()); // Should not have a parent yet
383 DALI_LOG_INFO(gLogFilter, Debug::General, "[%x] ConnectNode\n", node);
385 parent->ConnectChild(node);
387 // Inform the frame-callback-processor, if set, about the node-hierarchy changing
388 if(mImpl->frameCallbackProcessor)
390 mImpl->frameCallbackProcessor->NodeHierarchyChanged();
394 void UpdateManager::DisconnectNode(Node* node)
396 DALI_LOG_INFO(gLogFilter, Debug::General, "[%x] DisconnectNode\n", node);
398 Node* parent = node->GetParent();
399 DALI_ASSERT_ALWAYS(nullptr != parent);
400 parent->SetDirtyFlag(NodePropertyFlags::CHILD_DELETED); // make parent dirty so that render items dont get reused
402 parent->DisconnectChild(mSceneGraphBuffers.GetUpdateBufferIndex(), *node);
404 // Inform the frame-callback-processor, if set, about the node-hierarchy changing
405 if(mImpl->frameCallbackProcessor)
407 mImpl->frameCallbackProcessor->NodeHierarchyChanged();
411 void UpdateManager::DestroyNode(Node* node)
413 DALI_ASSERT_ALWAYS(nullptr != node);
414 DALI_ASSERT_ALWAYS(nullptr == node->GetParent()); // Should have been disconnected
416 DALI_LOG_INFO(gLogFilter, Debug::General, "[%x] DestroyNode\n", node);
418 Vector<Node*>::Iterator iter = mImpl->nodes.Begin() + 1;
419 Vector<Node*>::Iterator endIter = mImpl->nodes.End();
420 for(; iter != endIter; ++iter)
424 mImpl->nodes.Erase(iter);
429 mImpl->discardQueue.Add(mSceneGraphBuffers.GetUpdateBufferIndex(), node);
431 // Notify the Node about impending destruction
435 void UpdateManager::AddCamera(OwnerPointer<Camera>& camera)
437 mImpl->cameras.PushBack(camera.Release()); // takes ownership
440 void UpdateManager::RemoveCamera(Camera* camera)
442 // Find the camera and destroy it
443 EraseUsingDiscardQueue(mImpl->cameras, camera, mImpl->discardQueue, mSceneGraphBuffers.GetUpdateBufferIndex());
446 void UpdateManager::AddObject(OwnerPointer<PropertyOwner>& object)
448 mImpl->customObjects.PushBack(object.Release());
451 void UpdateManager::RemoveObject(PropertyOwner* object)
453 mImpl->customObjects.EraseObject(object);
456 void UpdateManager::AddRenderTaskList(OwnerPointer<RenderTaskList>& taskList)
458 RenderTaskList* taskListPointer = taskList.Release();
459 taskListPointer->SetRenderMessageDispatcher(&mImpl->renderMessageDispatcher);
461 mImpl->scenes.back()->taskList = taskListPointer;
464 void UpdateManager::RemoveRenderTaskList(RenderTaskList* taskList)
466 for(auto&& scene : mImpl->scenes)
468 if(scene && scene->taskList == taskList)
470 scene->taskList.Reset();
476 void UpdateManager::AddScene(OwnerPointer<Scene>& scene)
478 mImpl->scenes.back()->scene = scene.Release();
480 // Initialize the context from render manager
481 typedef MessageValue1<RenderManager, SceneGraph::Scene*> DerivedType;
483 // Reserve some memory inside the render queue
484 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
486 // Construct message in the render queue memory; note that delete should not be called on the return value
487 SceneGraph::Scene& sceneObject = *mImpl->scenes.back()->scene;
488 new(slot) DerivedType(&mImpl->renderManager, &RenderManager::InitializeScene, &sceneObject);
491 void UpdateManager::RemoveScene(Scene* scene)
493 // Initialize the context from render manager
494 using DerivedType = MessageValue1<RenderManager, SceneGraph::Scene*>;
496 // Reserve some memory inside the render queue
497 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
499 // Construct message in the render queue memory; note that delete should not be called on the return value
500 new(slot) DerivedType(&mImpl->renderManager, &RenderManager::UninitializeScene, scene);
502 for(auto&& sceneInfo : mImpl->scenes)
504 if(sceneInfo && sceneInfo->scene && sceneInfo->scene.Get() == scene)
506 mImpl->discardQueue.Add(mSceneGraphBuffers.GetUpdateBufferIndex(), sceneInfo->scene.Release()); // take the address of the reference to a pointer
512 void UpdateManager::AddAnimation(OwnerPointer<SceneGraph::Animation>& animation)
514 mImpl->animations.PushBack(animation.Release());
517 void UpdateManager::StopAnimation(Animation* animation)
519 DALI_ASSERT_DEBUG(animation && "NULL animation called to stop");
521 bool animationFinished = animation->Stop(mSceneGraphBuffers.GetUpdateBufferIndex());
523 mImpl->animationFinishedDuringUpdate = mImpl->animationFinishedDuringUpdate || animationFinished;
526 void UpdateManager::RemoveAnimation(Animation* animation)
528 DALI_ASSERT_DEBUG(animation && "NULL animation called to remove");
530 animation->OnDestroy(mSceneGraphBuffers.GetUpdateBufferIndex());
532 DALI_ASSERT_DEBUG(animation->GetState() == Animation::Destroyed);
535 bool UpdateManager::IsAnimationRunning() const
537 // Find any animation that isn't stopped or paused
538 for(auto&& iter : mImpl->animations)
540 const Animation::State state = iter->GetState();
542 if(state != Animation::Stopped &&
543 state != Animation::Paused)
545 return true; // stop iteration as soon as first one is found
552 void UpdateManager::AddPropertyResetter(OwnerPointer<PropertyResetterBase>& propertyResetter)
554 propertyResetter->Initialize();
555 mImpl->propertyResetters.PushBack(propertyResetter.Release());
558 void UpdateManager::AddPropertyNotification(OwnerPointer<PropertyNotification>& propertyNotification)
560 mImpl->propertyNotifications.PushBack(propertyNotification.Release());
563 void UpdateManager::RemovePropertyNotification(PropertyNotification* propertyNotification)
565 mImpl->propertyNotifications.EraseObject(propertyNotification);
568 void UpdateManager::PropertyNotificationSetNotify(PropertyNotification* propertyNotification, PropertyNotification::NotifyMode notifyMode)
570 DALI_ASSERT_DEBUG(propertyNotification && "propertyNotification scene graph object missing");
571 propertyNotification->SetNotifyMode(notifyMode);
574 void UpdateManager::AddShader(OwnerPointer<Shader>& shader)
576 mImpl->shaders.PushBack(shader.Release());
579 void UpdateManager::RemoveShader(Shader* shader)
581 // Find the shader and destroy it
582 EraseUsingDiscardQueue(mImpl->shaders, shader, mImpl->discardQueue, mSceneGraphBuffers.GetUpdateBufferIndex());
585 void UpdateManager::SaveBinary(Internal::ShaderDataPtr shaderData)
587 DALI_ASSERT_DEBUG(shaderData && "No NULL shader data pointers please.");
588 DALI_ASSERT_DEBUG(shaderData->GetBufferSize() > 0 && "Shader binary empty so nothing to save.");
590 // lock as update might be sending previously compiled shaders to event thread
591 Mutex::ScopedLock lock(mImpl->compiledShaderMutex);
592 mImpl->renderCompiledShaders.push_back(shaderData);
596 void UpdateManager::SetShaderSaver(ShaderSaver& upstream)
598 mImpl->shaderSaver = &upstream;
601 void UpdateManager::AddRenderer(OwnerPointer<Renderer>& renderer)
603 DALI_LOG_INFO(gLogFilter, Debug::General, "[%x] AddRenderer\n", renderer.Get());
605 renderer->ConnectToSceneGraph(*mImpl->sceneController, mSceneGraphBuffers.GetUpdateBufferIndex());
606 mImpl->renderers.PushBack(renderer.Release());
609 void UpdateManager::RemoveRenderer(Renderer* renderer)
611 DALI_LOG_INFO(gLogFilter, Debug::General, "[%x] RemoveRenderer\n", renderer);
613 // Find the renderer and destroy it
614 EraseUsingDiscardQueue(mImpl->renderers, renderer, mImpl->discardQueue, mSceneGraphBuffers.GetUpdateBufferIndex());
615 // Need to remove the render object as well
616 renderer->DisconnectFromSceneGraph(*mImpl->sceneController, mSceneGraphBuffers.GetUpdateBufferIndex());
619 void UpdateManager::AttachRenderer(Node* node, Renderer* renderer)
621 node->AddRenderer(renderer);
622 mImpl->renderersAdded = true;
625 void UpdateManager::SetPanGestureProcessor(PanGesture* panGestureProcessor)
627 DALI_ASSERT_DEBUG(NULL != panGestureProcessor);
629 mImpl->panGestureProcessor = panGestureProcessor;
632 void UpdateManager::AddTextureSet(OwnerPointer<TextureSet>& textureSet)
634 mImpl->textureSets.PushBack(textureSet.Release());
637 void UpdateManager::RemoveTextureSet(TextureSet* textureSet)
639 mImpl->textureSets.EraseObject(textureSet);
642 uint32_t* UpdateManager::ReserveMessageSlot(uint32_t size, bool updateScene)
644 return mImpl->messageQueue.ReserveMessageSlot(size, updateScene);
647 void UpdateManager::EventProcessingStarted()
649 mImpl->messageQueue.EventProcessingStarted();
652 bool UpdateManager::FlushQueue()
654 return mImpl->messageQueue.FlushQueue();
657 void UpdateManager::ResetProperties(BufferIndex bufferIndex)
659 // Clear the "animations finished" flag; This should be set if any (previously playing) animation is stopped
660 mImpl->animationFinishedDuringUpdate = false;
662 // Reset all animating / constrained properties
663 std::vector<PropertyResetterBase*> toDelete;
664 for(auto&& element : mImpl->propertyResetters)
666 element->ResetToBaseValue(bufferIndex);
667 if(element->IsFinished())
669 toDelete.push_back(element);
673 // If a resetter is no longer required (the animator or constraint has been removed), delete it.
674 for(auto&& elementPtr : toDelete)
676 mImpl->propertyResetters.EraseObject(elementPtr);
679 // Clear all root nodes dirty flags
680 for(auto& scene : mImpl->scenes)
682 auto root = scene->root;
683 root->ResetDirtyFlags(bufferIndex);
686 // Clear node dirty flags
687 Vector<Node*>::Iterator iter = mImpl->nodes.Begin() + 1;
688 Vector<Node*>::Iterator endIter = mImpl->nodes.End();
689 for(; iter != endIter; ++iter)
691 (*iter)->ResetDirtyFlags(bufferIndex);
695 bool UpdateManager::ProcessGestures(BufferIndex bufferIndex, uint32_t lastVSyncTimeMilliseconds, uint32_t nextVSyncTimeMilliseconds)
697 bool gestureUpdated(false);
699 if(mImpl->panGestureProcessor)
701 // gesture processor only supports default properties
702 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
703 gestureUpdated |= mImpl->panGestureProcessor->UpdateProperties(lastVSyncTimeMilliseconds, nextVSyncTimeMilliseconds);
706 return gestureUpdated;
709 bool UpdateManager::Animate(BufferIndex bufferIndex, float elapsedSeconds)
711 bool animationActive = false;
713 auto&& iter = mImpl->animations.Begin();
714 bool animationLooped = false;
716 while(iter != mImpl->animations.End())
718 Animation* animation = *iter;
719 bool finished = false;
721 bool progressMarkerReached = false;
722 animation->Update(bufferIndex, elapsedSeconds, looped, finished, progressMarkerReached);
724 animationActive = animationActive || animation->IsActive();
726 if(progressMarkerReached)
728 mImpl->notificationManager.QueueMessage(Internal::NotifyProgressReachedMessage(mImpl->animationPlaylist, animation));
731 mImpl->animationFinishedDuringUpdate = mImpl->animationFinishedDuringUpdate || finished;
732 animationLooped = animationLooped || looped;
734 // Remove animations that had been destroyed but were still waiting for an update
735 if(animation->GetState() == Animation::Destroyed)
737 iter = mImpl->animations.Erase(iter);
745 // queue the notification on finished or looped (to update loop count)
746 if(mImpl->animationFinishedDuringUpdate || animationLooped)
748 // The application should be notified by NotificationManager, in another thread
749 mImpl->notificationManager.QueueCompleteNotification(&mImpl->animationPlaylist);
752 return animationActive;
755 void UpdateManager::ConstrainCustomObjects(BufferIndex bufferIndex)
757 //Constrain custom objects (in construction order)
758 for(auto&& object : mImpl->customObjects)
760 ConstrainPropertyOwner(*object, bufferIndex);
764 void UpdateManager::ConstrainRenderTasks(BufferIndex bufferIndex)
766 // Constrain render-tasks
767 for(auto&& scene : mImpl->scenes)
769 if(scene && scene->taskList)
771 RenderTaskList::RenderTaskContainer& tasks = scene->taskList->GetTasks();
772 for(auto&& task : tasks)
774 ConstrainPropertyOwner(*task, bufferIndex);
780 void UpdateManager::ConstrainShaders(BufferIndex bufferIndex)
782 // constrain shaders... (in construction order)
783 for(auto&& shader : mImpl->shaders)
785 ConstrainPropertyOwner(*shader, bufferIndex);
789 void UpdateManager::ProcessPropertyNotifications(BufferIndex bufferIndex)
791 for(auto&& notification : mImpl->propertyNotifications)
793 bool valid = notification->Check(bufferIndex);
796 mImpl->notificationManager.QueueMessage(PropertyChangedMessage(mImpl->propertyNotifier, notification, notification->GetValidity()));
801 void UpdateManager::ForwardCompiledShadersToEventThread()
803 DALI_ASSERT_DEBUG((mImpl->shaderSaver != 0) && "shaderSaver should be wired-up during startup.");
804 if(mImpl->shaderSaver)
806 // lock and swap the queues
808 // render might be attempting to send us more binaries at the same time
809 Mutex::ScopedLock lock(mImpl->compiledShaderMutex);
810 mImpl->renderCompiledShaders.swap(mImpl->updateCompiledShaders);
813 if(mImpl->updateCompiledShaders.size() > 0)
815 ShaderSaver& factory = *mImpl->shaderSaver;
816 for(auto&& shader : mImpl->updateCompiledShaders)
818 mImpl->notificationManager.QueueMessage(ShaderCompiledMessage(factory, shader));
820 // we don't need them in update anymore
821 mImpl->updateCompiledShaders.clear();
826 void UpdateManager::UpdateRenderers(BufferIndex bufferIndex)
828 for(auto&& renderer : mImpl->renderers)
831 ConstrainPropertyOwner(*renderer, bufferIndex);
833 mImpl->renderingRequired = renderer->PrepareRender(bufferIndex) || mImpl->renderingRequired;
837 void UpdateManager::UpdateNodes(BufferIndex bufferIndex)
839 mImpl->nodeDirtyFlags = NodePropertyFlags::NOTHING;
841 for(auto&& scene : mImpl->scenes)
843 if(scene && scene->root)
845 // Prepare resources, update shaders, for each node
846 // And add the renderers to the sorted layers. Start from root, which is also a layer
847 mImpl->nodeDirtyFlags |= UpdateNodeTree(*scene->root,
854 uint32_t UpdateManager::Update(float elapsedSeconds,
855 uint32_t lastVSyncTimeMilliseconds,
856 uint32_t nextVSyncTimeMilliseconds,
857 bool renderToFboEnabled,
858 bool isRenderingToFbo)
860 const BufferIndex bufferIndex = mSceneGraphBuffers.GetUpdateBufferIndex();
862 //Clear nodes/resources which were previously discarded
863 mImpl->discardQueue.Clear(bufferIndex);
865 bool isAnimationRunning = IsAnimationRunning();
867 //Process Touches & Gestures
868 const bool gestureUpdated = ProcessGestures(bufferIndex, lastVSyncTimeMilliseconds, nextVSyncTimeMilliseconds);
870 bool updateScene = // The scene-graph requires an update if..
871 (mImpl->nodeDirtyFlags & RenderableUpdateFlags) || // ..nodes were dirty in previous frame OR
872 isAnimationRunning || // ..at least one animation is running OR
873 mImpl->messageQueue.IsSceneUpdateRequired() || // ..a message that modifies the scene graph node tree is queued OR
874 mImpl->frameCallbackProcessor || // ..a frame callback processor is existed OR
875 gestureUpdated; // ..a gesture property was updated
877 bool keepRendererRendering = false;
878 mImpl->renderingRequired = false;
880 // Although the scene-graph may not require an update, we still need to synchronize double-buffered
881 // values if the scene was updated in the previous frame.
882 if(updateScene || mImpl->previousUpdateScene)
884 //Reset properties from the previous update
885 ResetProperties(bufferIndex);
886 mImpl->transformManager.ResetToBaseValue();
889 // Process the queued scene messages. Note, MessageQueue::FlushQueue may be called
890 // between calling IsSceneUpdateRequired() above and here, so updateScene should
892 updateScene |= mImpl->messageQueue.ProcessMessages(bufferIndex);
894 //Forward compiled shader programs to event thread for saving
895 ForwardCompiledShadersToEventThread();
897 // Although the scene-graph may not require an update, we still need to synchronize double-buffered
898 // renderer lists if the scene was updated in the previous frame.
899 // We should not start skipping update steps or reusing lists until there has been two frames where nothing changes
900 if(updateScene || mImpl->previousUpdateScene)
903 bool animationActive = Animate(bufferIndex, elapsedSeconds);
905 //Constraint custom objects
906 ConstrainCustomObjects(bufferIndex);
908 //Clear the lists of renderers from the previous update
909 for(auto&& scene : mImpl->scenes)
913 for(auto&& layer : scene->sortedLayerList)
917 layer->ClearRenderables();
923 // Call the frame-callback-processor if set
924 if(mImpl->frameCallbackProcessor)
926 mImpl->frameCallbackProcessor->Update(bufferIndex, elapsedSeconds);
929 //Update node hierarchy, apply constraints and perform sorting / culling.
930 //This will populate each Layer with a list of renderers which are ready.
931 UpdateNodes(bufferIndex);
933 //Apply constraints to RenderTasks, shaders
934 ConstrainRenderTasks(bufferIndex);
935 ConstrainShaders(bufferIndex);
937 //Update renderers and apply constraints
938 UpdateRenderers(bufferIndex);
940 //Update the transformations of all the nodes
941 if(mImpl->transformManager.Update())
943 mImpl->nodeDirtyFlags |= NodePropertyFlags::TRANSFORM;
946 //Process Property Notifications
947 ProcessPropertyNotifications(bufferIndex);
950 for(auto&& cameraIterator : mImpl->cameras)
952 cameraIterator->Update(bufferIndex);
955 //Process the RenderTasks if renderers exist. This creates the instructions for rendering the next frame.
956 //reset the update buffer index and make sure there is enough room in the instruction container
957 if(mImpl->renderersAdded)
959 // Calculate how many render tasks we have in total
960 std::size_t numberOfRenderTasks = 0;
961 for(auto&& scene : mImpl->scenes)
963 if(scene && scene->taskList)
965 numberOfRenderTasks += scene->taskList->GetTasks().Count();
969 std::size_t numberOfRenderInstructions = 0;
970 for(auto&& scene : mImpl->scenes)
972 if(scene && scene->root && scene->taskList && scene->scene)
974 scene->scene->GetRenderInstructions().ResetAndReserve(bufferIndex,
975 static_cast<uint32_t>(scene->taskList->GetTasks().Count()));
977 // If there are animations running, only add render instruction if at least one animation is currently active (i.e. not delayed)
978 // or the nodes are dirty
979 if(!isAnimationRunning || animationActive || mImpl->renderingRequired || (mImpl->nodeDirtyFlags & RenderableUpdateFlags))
981 keepRendererRendering |= mImpl->renderTaskProcessor.Process(bufferIndex,
984 scene->sortedLayerList,
985 scene->scene->GetRenderInstructions(),
989 scene->scene->SetSkipRendering(false);
993 scene->scene->SetSkipRendering(true);
996 numberOfRenderInstructions += scene->scene->GetRenderInstructions().Count(bufferIndex);
1000 DALI_LOG_INFO(gLogFilter, Debug::General, "Update: numberOfRenderTasks(%d), Render Instructions(%d)\n", numberOfRenderTasks, numberOfRenderInstructions);
1004 for(auto&& scene : mImpl->scenes)
1006 if(scene && scene->root && scene->taskList)
1008 RenderTaskList::RenderTaskContainer& tasks = scene->taskList->GetTasks();
1010 // check the countdown and notify
1011 bool doRenderOnceNotify = false;
1012 mImpl->renderTaskWaiting = false;
1013 for(auto&& renderTask : tasks)
1015 renderTask->UpdateState();
1017 if(renderTask->IsWaitingToRender() &&
1018 renderTask->ReadyToRender(bufferIndex) /*avoid updating forever when source actor is off-stage*/)
1020 mImpl->renderTaskWaiting = true; // keep update/render threads alive
1023 if(renderTask->HasRendered())
1025 doRenderOnceNotify = true;
1029 if(doRenderOnceNotify)
1031 DALI_LOG_INFO(gRenderTaskLogFilter, Debug::General, "Notify a render task has finished\n");
1032 mImpl->notificationManager.QueueCompleteNotification(scene->taskList->GetCompleteNotificationInterface());
1037 // Macro is undefined in release build.
1038 SNAPSHOT_NODE_LOGGING;
1040 // A ResetProperties() may be required in the next frame
1041 mImpl->previousUpdateScene = updateScene;
1043 // Check whether further updates are required
1044 uint32_t keepUpdating = KeepUpdatingCheck(elapsedSeconds);
1046 if(keepRendererRendering)
1048 keepUpdating |= KeepUpdating::STAGE_KEEP_RENDERING;
1050 // Set dirty flags for next frame to continue rendering
1051 mImpl->nodeDirtyFlags |= RenderableUpdateFlags;
1054 // tell the update manager that we're done so the queue can be given to event thread
1055 mImpl->notificationManager.UpdateCompleted();
1057 // The update has finished; swap the double-buffering indices
1058 mSceneGraphBuffers.Swap();
1060 return keepUpdating;
1063 uint32_t UpdateManager::KeepUpdatingCheck(float elapsedSeconds) const
1065 // Update the duration set via Stage::KeepRendering()
1066 if(mImpl->keepRenderingSeconds > 0.0f)
1068 mImpl->keepRenderingSeconds -= elapsedSeconds;
1071 uint32_t keepUpdatingRequest = KeepUpdating::NOT_REQUESTED;
1073 // If the rendering behavior is set to continuously render, then continue to render.
1074 // If Stage::KeepRendering() has been called, then continue until the duration has elapsed.
1075 // Keep updating until no messages are received and no animations are running.
1076 // If an animation has just finished, update at least once more for Discard end-actions.
1077 // No need to check for renderQueue as there is always a render after update and if that
1078 // render needs another update it will tell the adaptor to call update again
1080 if((mImpl->renderingBehavior == DevelStage::Rendering::CONTINUOUSLY) ||
1081 (mImpl->keepRenderingSeconds > 0.0f))
1083 keepUpdatingRequest |= KeepUpdating::STAGE_KEEP_RENDERING;
1086 if(IsAnimationRunning() ||
1087 mImpl->animationFinishedDuringUpdate)
1089 keepUpdatingRequest |= KeepUpdating::ANIMATIONS_RUNNING;
1092 if(mImpl->renderTaskWaiting)
1094 keepUpdatingRequest |= KeepUpdating::RENDER_TASK_SYNC;
1097 return keepUpdatingRequest;
1100 void UpdateManager::SurfaceReplaced(Scene* scene)
1102 using DerivedType = MessageValue1<RenderManager, Scene*>;
1104 // Reserve some memory inside the render queue
1105 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
1107 // Construct message in the render queue memory; note that delete should not be called on the return value
1108 new(slot) DerivedType(&mImpl->renderManager, &RenderManager::SurfaceReplaced, scene);
1111 void UpdateManager::KeepRendering(float durationSeconds)
1113 mImpl->keepRenderingSeconds = std::max(mImpl->keepRenderingSeconds, durationSeconds);
1116 void UpdateManager::SetRenderingBehavior(DevelStage::Rendering renderingBehavior)
1118 mImpl->renderingBehavior = renderingBehavior;
1121 void UpdateManager::RequestRendering()
1123 mImpl->renderingRequired = true;
1126 void UpdateManager::SetLayerDepths(const SortedLayerPointers& layers, const Layer* rootLayer)
1128 for(auto&& scene : mImpl->scenes)
1130 if(scene && scene->root == rootLayer)
1132 scene->sortedLayerList = layers;
1138 void UpdateManager::SetDepthIndices(OwnerPointer<NodeDepths>& nodeDepths)
1140 // note,this vector is already in depth order. It could be used as-is to
1141 // remove sorting in update algorithm. However, it lacks layer boundary markers.
1142 for(auto&& iter : nodeDepths->nodeDepths)
1144 iter.node->SetDepthIndex(iter.sortedDepth);
1147 for(auto&& scene : mImpl->scenes)
1151 // Go through node hierarchy and rearrange siblings according to depth-index
1152 SortSiblingNodesRecursively(*scene->root);
1157 void UpdateManager::AddFrameCallback(OwnerPointer<FrameCallback>& frameCallback, const Node* rootNode)
1159 mImpl->GetFrameCallbackProcessor(*this).AddFrameCallback(frameCallback, rootNode);
1162 void UpdateManager::RemoveFrameCallback(FrameCallbackInterface* frameCallback)
1164 mImpl->GetFrameCallbackProcessor(*this).RemoveFrameCallback(frameCallback);
1167 void UpdateManager::AddSampler(OwnerPointer<Render::Sampler>& sampler)
1169 // Message has ownership of Sampler while in transit from update to render
1170 using DerivedType = MessageValue1<RenderManager, OwnerPointer<Render::Sampler> >;
1172 // Reserve some memory inside the render queue
1173 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
1175 // Construct message in the render queue memory; note that delete should not be called on the return value
1176 new(slot) DerivedType(&mImpl->renderManager, &RenderManager::AddSampler, sampler);
1179 void UpdateManager::RemoveSampler(Render::Sampler* sampler)
1181 using DerivedType = MessageValue1<RenderManager, Render::Sampler*>;
1183 // Reserve some memory inside the render queue
1184 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
1186 // Construct message in the render queue memory; note that delete should not be called on the return value
1187 new(slot) DerivedType(&mImpl->renderManager, &RenderManager::RemoveSampler, sampler);
1190 void UpdateManager::SetFilterMode(Render::Sampler* sampler, uint32_t minFilterMode, uint32_t magFilterMode)
1192 using DerivedType = MessageValue3<RenderManager, Render::Sampler*, uint32_t, uint32_t>;
1194 // Reserve some memory inside the render queue
1195 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
1197 // Construct message in the render queue memory; note that delete should not be called on the return value
1198 new(slot) DerivedType(&mImpl->renderManager, &RenderManager::SetFilterMode, sampler, minFilterMode, magFilterMode);
1201 void UpdateManager::SetWrapMode(Render::Sampler* sampler, uint32_t rWrapMode, uint32_t sWrapMode, uint32_t tWrapMode)
1203 using DerivedType = MessageValue4<RenderManager, Render::Sampler*, uint32_t, uint32_t, uint32_t>;
1205 // Reserve some memory inside the render queue
1206 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
1208 // Construct message in the render queue memory; note that delete should not be called on the return value
1209 new(slot) DerivedType(&mImpl->renderManager, &RenderManager::SetWrapMode, sampler, rWrapMode, sWrapMode, tWrapMode);
1212 void UpdateManager::AddVertexBuffer(OwnerPointer<Render::VertexBuffer>& vertexBuffer)
1214 // Message has ownership of format while in transit from update -> render
1215 using DerivedType = MessageValue1<RenderManager, OwnerPointer<Render::VertexBuffer> >;
1217 // Reserve some memory inside the render queue
1218 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
1220 // Construct message in the render queue memory; note that delete should not be called on the return value
1221 new(slot) DerivedType(&mImpl->renderManager, &RenderManager::AddVertexBuffer, vertexBuffer);
1224 void UpdateManager::RemoveVertexBuffer(Render::VertexBuffer* vertexBuffer)
1226 using DerivedType = MessageValue1<RenderManager, Render::VertexBuffer*>;
1228 // Reserve some memory inside the render queue
1229 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
1231 // Construct message in the render queue memory; note that delete should not be called on the return value
1232 new(slot) DerivedType(&mImpl->renderManager, &RenderManager::RemoveVertexBuffer, vertexBuffer);
1235 void UpdateManager::SetVertexBufferFormat(Render::VertexBuffer* vertexBuffer, OwnerPointer<Render::VertexBuffer::Format>& format)
1237 // Message has ownership of format while in transit from update -> render
1238 using DerivedType = MessageValue2<RenderManager, Render::VertexBuffer*, OwnerPointer<Render::VertexBuffer::Format> >;
1240 // Reserve some memory inside the render queue
1241 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
1243 // Construct message in the render queue memory; note that delete should not be called on the return value
1244 new(slot) DerivedType(&mImpl->renderManager, &RenderManager::SetVertexBufferFormat, vertexBuffer, format);
1247 void UpdateManager::SetVertexBufferData(Render::VertexBuffer* vertexBuffer, OwnerPointer<Vector<uint8_t> >& data, uint32_t size)
1249 // Message has ownership of format while in transit from update -> render
1250 using DerivedType = MessageValue3<RenderManager, Render::VertexBuffer*, OwnerPointer<Dali::Vector<uint8_t> >, uint32_t>;
1252 // Reserve some memory inside the render queue
1253 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
1255 // Construct message in the render queue memory; note that delete should not be called on the return value
1256 new(slot) DerivedType(&mImpl->renderManager, &RenderManager::SetVertexBufferData, vertexBuffer, data, size);
1259 void UpdateManager::AddGeometry(OwnerPointer<Render::Geometry>& geometry)
1261 // Message has ownership of format while in transit from update -> render
1262 using DerivedType = MessageValue1<RenderManager, OwnerPointer<Render::Geometry> >;
1264 // Reserve some memory inside the render queue
1265 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
1267 // Construct message in the render queue memory; note that delete should not be called on the return value
1268 new(slot) DerivedType(&mImpl->renderManager, &RenderManager::AddGeometry, geometry);
1271 void UpdateManager::RemoveGeometry(Render::Geometry* geometry)
1273 using DerivedType = MessageValue1<RenderManager, Render::Geometry*>;
1275 // Reserve some memory inside the render queue
1276 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
1278 // Construct message in the render queue memory; note that delete should not be called on the return value
1279 new(slot) DerivedType(&mImpl->renderManager, &RenderManager::RemoveGeometry, geometry);
1282 void UpdateManager::SetGeometryType(Render::Geometry* geometry, uint32_t geometryType)
1284 using DerivedType = MessageValue2<RenderManager, Render::Geometry*, uint32_t>;
1286 // Reserve some memory inside the render queue
1287 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
1289 // Construct message in the render queue memory; note that delete should not be called on the return value
1290 new(slot) DerivedType(&mImpl->renderManager, &RenderManager::SetGeometryType, geometry, geometryType);
1293 void UpdateManager::SetIndexBuffer(Render::Geometry* geometry, Dali::Vector<uint16_t>& indices)
1295 using DerivedType = IndexBufferMessage<RenderManager>;
1297 // Reserve some memory inside the render queue
1298 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
1300 // Construct message in the render queue memory; note that delete should not be called on the return value
1301 new(slot) DerivedType(&mImpl->renderManager, geometry, indices);
1304 void UpdateManager::RemoveVertexBuffer(Render::Geometry* geometry, Render::VertexBuffer* vertexBuffer)
1306 using DerivedType = MessageValue2<RenderManager, Render::Geometry*, Render::VertexBuffer*>;
1308 // Reserve some memory inside the render queue
1309 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
1311 // Construct message in the render queue memory; note that delete should not be called on the return value
1312 new(slot) DerivedType(&mImpl->renderManager, &RenderManager::RemoveVertexBuffer, geometry, vertexBuffer);
1315 void UpdateManager::AttachVertexBuffer(Render::Geometry* geometry, Render::VertexBuffer* vertexBuffer)
1317 using DerivedType = MessageValue2<RenderManager, Render::Geometry*, Render::VertexBuffer*>;
1319 // Reserve some memory inside the render queue
1320 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
1322 // Construct message in the render queue memory; note that delete should not be called on the return value
1323 new(slot) DerivedType(&mImpl->renderManager, &RenderManager::AttachVertexBuffer, geometry, vertexBuffer);
1326 void UpdateManager::AddTexture(OwnerPointer<Render::Texture>& texture)
1328 // Message has ownership of Texture while in transit from update -> render
1329 using DerivedType = MessageValue1<RenderManager, OwnerPointer<Render::Texture> >;
1331 // Reserve some memory inside the render queue
1332 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
1334 // Construct message in the render queue memory; note that delete should not be called on the return value
1335 new(slot) DerivedType(&mImpl->renderManager, &RenderManager::AddTexture, texture);
1338 void UpdateManager::RemoveTexture(Render::Texture* texture)
1340 using DerivedType = MessageValue1<RenderManager, Render::Texture*>;
1342 // Reserve some memory inside the render queue
1343 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
1345 // Construct message in the render queue memory; note that delete should not be called on the return value
1346 new(slot) DerivedType(&mImpl->renderManager, &RenderManager::RemoveTexture, texture);
1349 void UpdateManager::UploadTexture(Render::Texture* texture, PixelDataPtr pixelData, const Texture::UploadParams& params)
1351 using DerivedType = MessageValue3<RenderManager, Render::Texture*, PixelDataPtr, Texture::UploadParams>;
1353 // Reserve some memory inside the message queue
1354 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
1356 // Construct message in the message queue memory; note that delete should not be called on the return value
1357 new(slot) DerivedType(&mImpl->renderManager, &RenderManager::UploadTexture, texture, pixelData, params);
1360 void UpdateManager::GenerateMipmaps(Render::Texture* texture)
1362 using DerivedType = MessageValue1<RenderManager, Render::Texture*>;
1364 // Reserve some memory inside the render queue
1365 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
1367 // Construct message in the render queue memory; note that delete should not be called on the return value
1368 new(slot) DerivedType(&mImpl->renderManager, &RenderManager::GenerateMipmaps, texture);
1371 void UpdateManager::AddFrameBuffer(OwnerPointer<Render::FrameBuffer>& frameBuffer)
1373 using DerivedType = MessageValue1<RenderManager, OwnerPointer<Render::FrameBuffer> >;
1375 // Reserve some memory inside the render queue
1376 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
1378 // Construct message in the render queue memory; note that delete should not be called on the return value
1379 new(slot) DerivedType(&mImpl->renderManager, &RenderManager::AddFrameBuffer, frameBuffer);
1382 void UpdateManager::RemoveFrameBuffer(Render::FrameBuffer* frameBuffer)
1384 using DerivedType = MessageValue1<RenderManager, Render::FrameBuffer*>;
1386 // Reserve some memory inside the render queue
1387 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
1389 // Construct message in the render queue memory; note that delete should not be called on the return value
1390 new(slot) DerivedType(&mImpl->renderManager, &RenderManager::RemoveFrameBuffer, frameBuffer);
1393 void UpdateManager::AttachColorTextureToFrameBuffer(Render::FrameBuffer* frameBuffer, Render::Texture* texture, uint32_t mipmapLevel, uint32_t layer)
1395 using DerivedType = MessageValue4<RenderManager, Render::FrameBuffer*, Render::Texture*, uint32_t, uint32_t>;
1397 // Reserve some memory inside the render queue
1398 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
1400 // Construct message in the render queue memory; note that delete should not be called on the return value
1401 new(slot) DerivedType(&mImpl->renderManager, &RenderManager::AttachColorTextureToFrameBuffer, frameBuffer, texture, mipmapLevel, layer);
1404 void UpdateManager::AttachDepthTextureToFrameBuffer(Render::FrameBuffer* frameBuffer, Render::Texture* texture, uint32_t mipmapLevel)
1406 using DerivedType = MessageValue3<RenderManager, Render::FrameBuffer*, Render::Texture*, uint32_t>;
1408 // Reserve some memory inside the render queue
1409 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
1411 // Construct message in the render queue memory; note that delete should not be called on the return value
1412 new(slot) DerivedType(&mImpl->renderManager, &RenderManager::AttachDepthTextureToFrameBuffer, frameBuffer, texture, mipmapLevel);
1415 void UpdateManager::AttachDepthStencilTextureToFrameBuffer(Render::FrameBuffer* frameBuffer, Render::Texture* texture, uint32_t mipmapLevel)
1417 using DerivedType = MessageValue3<RenderManager, Render::FrameBuffer*, Render::Texture*, uint32_t>;
1419 // Reserve some memory inside the render queue
1420 uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
1422 // Construct message in the render queue memory; note that delete should not be called on the return value
1423 new(slot) DerivedType(&mImpl->renderManager, &RenderManager::AttachDepthStencilTextureToFrameBuffer, frameBuffer, texture, mipmapLevel);
1426 } // namespace SceneGraph
1428 } // namespace Internal