/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <dali/internal/update/manager/update-manager.h>
// INTERNAL INCLUDES
-#include <dali/public-api/common/stage.h>
-#include <dali/devel-api/common/owner-container.h>
-#include <dali/devel-api/threading/mutex.h>
-
#include <dali/integration-api/core.h>
-#include <dali/integration-api/render-controller.h>
-#include <dali/internal/common/shader-data.h>
-#include <dali/integration-api/debug.h>
-
-#include <dali/internal/common/core-impl.h>
-#include <dali/internal/common/message.h>
#include <dali/internal/event/common/notification-manager.h>
-#include <dali/internal/event/common/property-notification-impl.h>
#include <dali/internal/event/common/property-notifier.h>
#include <dali/internal/event/effects/shader-factory.h>
#include <dali/internal/event/animation/animation-playlist.h>
-#include <dali/internal/update/animation/scene-graph-animator.h>
-#include <dali/internal/update/animation/scene-graph-animation.h>
#include <dali/internal/update/common/discard-queue.h>
-#include <dali/internal/update/common/scene-graph-buffers.h>
#include <dali/internal/update/controllers/render-message-dispatcher.h>
#include <dali/internal/update/controllers/scene-controller-impl.h>
-#include <dali/internal/update/gestures/scene-graph-pan-gesture.h>
#include <dali/internal/update/manager/frame-callback-processor.h>
#include <dali/internal/update/manager/render-task-processor.h>
-#include <dali/internal/update/manager/sorted-layers.h>
-#include <dali/internal/update/manager/scene-graph-frame-callback.h>
#include <dali/internal/update/manager/update-algorithms.h>
#include <dali/internal/update/manager/update-manager-debug.h>
#include <dali/internal/update/manager/transform-manager.h>
#include <dali/internal/update/nodes/node.h>
-#include <dali/internal/update/nodes/scene-graph-layer.h>
#include <dali/internal/update/queue/update-message-queue.h>
-#include <dali/internal/update/render-tasks/scene-graph-render-task.h>
-#include <dali/internal/update/render-tasks/scene-graph-render-task-list.h>
-#include <dali/internal/update/render-tasks/scene-graph-camera.h>
-#include <dali/internal/render/common/render-instruction-container.h>
#include <dali/internal/render/common/render-manager.h>
#include <dali/internal/render/queue/render-queue.h>
-#include <dali/internal/render/shaders/scene-graph-shader.h>
// Un-comment to enable node tree debug logging
//#define NODE_TREE_LOGGING 1
Layer* root{ nullptr }; ///< Root node (root is a layer). The layer is not stored in the node memory pool.
OwnerPointer< RenderTaskList > taskList; ///< Scene graph render task list
SortedLayerPointers sortedLayerList; ///< List of Layer pointers sorted by depth (one list of sorted layers per root)
+ OwnerPointer< Scene > scene; ///< Scene graph object of the scene
};
Impl( NotificationManager& notificationManager,
RenderManager& renderManager,
RenderQueue& renderQueue,
SceneGraphBuffers& sceneGraphBuffers,
- RenderTaskProcessor& renderTaskProcessor,
- bool partialUpdateAvailable )
+ RenderTaskProcessor& renderTaskProcessor )
: renderMessageDispatcher( renderManager, renderQueue, sceneGraphBuffers ),
notificationManager( notificationManager ),
transformManager(),
sceneController( NULL ),
renderManager( renderManager ),
renderQueue( renderQueue ),
- renderInstructions( renderManager.GetRenderInstructionContainer() ),
renderTaskProcessor( renderTaskProcessor ),
backgroundColor( Dali::Stage::DEFAULT_BACKGROUND_COLOR ),
renderers(),
previousUpdateScene( false ),
renderTaskWaiting( false ),
renderersAdded( false ),
- surfaceRectChanged( false ),
- partialUpdateAvailable( partialUpdateAvailable )
+ surfaceRectChanged( false )
{
sceneController = new SceneControllerImpl( renderMessageDispatcher, renderQueue, discardQueue );
SceneControllerImpl* sceneController; ///< scene controller
RenderManager& renderManager; ///< This is responsible for rendering the results of each "update"
RenderQueue& renderQueue; ///< Used to queue messages for the next render
- RenderInstructionContainer& renderInstructions; ///< Used to prepare the render instructions
RenderTaskProcessor& renderTaskProcessor; ///< Handles RenderTasks and RenderInstrucitons
Vector4 backgroundColor; ///< The glClear color used at the beginning of each frame.
bool renderTaskWaiting; ///< A REFRESH_ONCE render task is waiting to be rendered
bool renderersAdded; ///< Flag to keep track when renderers have been added to avoid unnecessary processing
bool surfaceRectChanged; ///< True if the default surface rect is changed
- bool partialUpdateAvailable; ///< Whether the partial update is available
private:
RenderController& controller,
RenderManager& renderManager,
RenderQueue& renderQueue,
- RenderTaskProcessor& renderTaskProcessor,
- bool partialUpdateAvailable )
+ RenderTaskProcessor& renderTaskProcessor )
: mImpl(NULL)
{
mImpl = new Impl( notificationManager,
renderManager,
renderQueue,
mSceneGraphBuffers,
- renderTaskProcessor,
- partialUpdateAvailable );
+ renderTaskProcessor );
}
{
mImpl->nodes.Insert((iter+1), rawNode );
rawNode->CreateTransform( &mImpl->transformManager );
- rawNode->SetPartialUpdateAvailable( mImpl->partialUpdateAvailable );
return;
}
}
parent->ConnectChild( node );
- parent->SetPropertyDirty( true );
-
// Inform the frame-callback-processor, if set, about the node-hierarchy changing
if( mImpl->frameCallbackProcessor )
{
}
}
+void UpdateManager::AddScene( OwnerPointer< Scene >& scene )
+{
+ mImpl->scenes.back()->scene = scene.Release();
+
+ // Initialize the context from render manager
+ typedef MessageValue1< RenderManager, SceneGraph::Scene* > DerivedType;
+
+ // Reserve some memory inside the render queue
+ uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+
+ // Construct message in the render queue memory; note that delete should not be called on the return value
+ SceneGraph::Scene& sceneObject = *mImpl->scenes.back()->scene;
+ new (slot) DerivedType( &mImpl->renderManager, &RenderManager::InitializeScene, &sceneObject );
+}
+
+void UpdateManager::RemoveScene( Scene* scene )
+{
+ // Initialize the context from render manager
+ typedef MessageValue1< RenderManager, SceneGraph::Scene* > DerivedType;
+
+ // Reserve some memory inside the render queue
+ uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+
+ // Construct message in the render queue memory; note that delete should not be called on the return value
+ new (slot) DerivedType( &mImpl->renderManager, &RenderManager::UninitializeScene, scene );
+
+ for ( auto&& sceneInfo : mImpl->scenes )
+ {
+ if ( sceneInfo && sceneInfo->scene && sceneInfo->scene.Get() == scene )
+ {
+ mImpl->discardQueue.Add( mSceneGraphBuffers.GetUpdateBufferIndex(), sceneInfo->scene.Release() ); // take the address of the reference to a pointer
+ break;
+ }
+ }
+}
+
void UpdateManager::AddAnimation( OwnerPointer< SceneGraph::Animation >& animation )
{
mImpl->animations.PushBack( animation.Release() );
}
}
- mImpl->renderInstructions.ResetAndReserve( bufferIndex,
- static_cast<uint32_t>( numberOfRenderTasks ) );
+ std::size_t numberOfRenderInstructions = 0;
for ( auto&& scene : mImpl->scenes )
{
- if ( scene && scene->root && scene->taskList )
+ if ( scene && scene->root && scene->taskList && scene->scene )
{
+ scene->scene->GetRenderInstructions().ResetAndReserve( bufferIndex,
+ static_cast<uint32_t>( scene->taskList->GetTasks().Count() ) );
+
keepRendererRendering |= mImpl->renderTaskProcessor.Process( bufferIndex,
*scene->taskList,
*scene->root,
scene->sortedLayerList,
- mImpl->renderInstructions,
+ scene->scene->GetRenderInstructions(),
renderToFboEnabled,
isRenderingToFbo );
+
+ numberOfRenderInstructions += scene->scene->GetRenderInstructions().Count( bufferIndex );
}
}
DALI_LOG_INFO( gLogFilter, Debug::General,
"Update: numberOfRenderTasks(%d), Render Instructions(%d)\n",
- numberOfRenderTasks, mImpl->renderInstructions.Count( bufferIndex ) );
+ numberOfRenderTasks, numberOfRenderInstructions );
}
}
if( keepRendererRendering )
{
keepUpdating |= KeepUpdating::STAGE_KEEP_RENDERING;
+
+ // Set dirty flags for next frame to continue rendering
+ mImpl->nodeDirtyFlags |= RenderableUpdateFlags;
}
// tell the update manager that we're done so the queue can be given to event thread
return keepUpdatingRequest;
}
-void UpdateManager::SetBackgroundColor( const Vector4& color )
+void UpdateManager::SetDefaultSurfaceRect( const Rect<int32_t>& rect )
{
- typedef MessageValue1< RenderManager, Vector4 > DerivedType;
+ mImpl->surfaceRectChanged = true;
+
+ typedef MessageValue1< RenderManager, Rect<int32_t> > DerivedType;
// Reserve some memory inside the render queue
uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
// Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &mImpl->renderManager, &RenderManager::SetBackgroundColor, color );
+ new (slot) DerivedType( &mImpl->renderManager, &RenderManager::SetDefaultSurfaceRect, rect );
}
-void UpdateManager::SetDefaultSurfaceRect( const Rect<int32_t>& rect )
+void UpdateManager::SurfaceReplaced( Scene* scene )
{
- mImpl->surfaceRectChanged = true;
-
- typedef MessageValue1< RenderManager, Rect<int32_t> > DerivedType;
+ typedef MessageValue1< RenderManager, Scene* > DerivedType;
// Reserve some memory inside the render queue
uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
// Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &mImpl->renderManager, &RenderManager::SetDefaultSurfaceRect, rect );
+ new (slot) DerivedType( &mImpl->renderManager, &RenderManager::SurfaceReplaced, scene );
}
void UpdateManager::SetDefaultSurfaceOrientation( int orientation )
new (slot) DerivedType( &mImpl->renderManager, &RenderManager::AttachColorTextureToFrameBuffer, frameBuffer, texture, mipmapLevel, layer );
}
+void UpdateManager::AttachDepthTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::Texture* texture, uint32_t mipmapLevel )
+{
+ typedef MessageValue3< RenderManager, Render::FrameBuffer*, Render::Texture*, uint32_t > DerivedType;
+
+ // Reserve some memory inside the render queue
+ uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+
+ // Construct message in the render queue memory; note that delete should not be called on the return value
+ new (slot) DerivedType( &mImpl->renderManager, &RenderManager::AttachDepthTextureToFrameBuffer, frameBuffer, texture, mipmapLevel );
+}
+
+void UpdateManager::AttachDepthStencilTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::Texture* texture, uint32_t mipmapLevel )
+{
+ typedef MessageValue3< RenderManager, Render::FrameBuffer*, Render::Texture*, uint32_t > DerivedType;
+
+ // Reserve some memory inside the render queue
+ uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+
+ // Construct message in the render queue memory; note that delete should not be called on the return value
+ new (slot) DerivedType( &mImpl->renderManager, &RenderManager::AttachDepthStencilTextureToFrameBuffer, frameBuffer, texture, mipmapLevel );
+}
+
} // namespace SceneGraph
} // namespace Internal