From f8ab99fc0f893e1c1046a1d81b974fa7a249b5b9 Mon Sep 17 00:00:00 2001 From: Victor Cebollada Date: Wed, 25 Oct 2017 16:03:40 +0100 Subject: [PATCH] [4.0] RenderTaskProcessor code cleaning. * Removes a cut & pasted code. Change-Id: I927fe965209ee3209604385094e0ed6c8e9d8657 Signed-off-by: Victor Cebollada (cherry picked from commit 8008ad178766370cf938c962c7562109e59be2b9) --- .../update/manager/render-task-processor.cpp | 177 +++++++++------------ 1 file changed, 79 insertions(+), 98 deletions(-) diff --git a/dali/internal/update/manager/render-task-processor.cpp b/dali/internal/update/manager/render-task-processor.cpp index 6c8a5ef..c5b7e31 100644 --- a/dali/internal/update/manager/render-task-processor.cpp +++ b/dali/internal/update/manager/render-task-processor.cpp @@ -40,7 +40,6 @@ namespace Dali namespace Internal { - namespace SceneGraph { @@ -190,50 +189,39 @@ void AddRenderablesForTask( BufferIndex updateBufferIndex, } } -} // Anonymous namespace. - - -RenderTaskProcessor::RenderTaskProcessor() -{ -} - -RenderTaskProcessor::~RenderTaskProcessor() -{ -} -void RenderTaskProcessor::Process( BufferIndex updateBufferIndex, - RenderTaskList& renderTasks, - Layer& rootNode, - SortedLayerPointers& sortedLayers, - RenderInstructionContainer& instructions ) +/** + * Process the list of render-tasks; the output is a series of render instructions. + * @note When ProcessRenderTasks is called, the layers should already the transparent/opaque renderers which are ready to render. + * If there is only one default render-task, then no further processing is required. + * @param[in] updateBufferIndex The current update buffer index. + * @param[in] taskContainer The container of render-tasks. + * @param[in] rootNode The root node of the scene-graph. + * @param[in] sortedLayers The layers containing lists of opaque / transparent renderables. + * @param[out] instructions The instructions for rendering the next frame. + * @param[in] renderInstructionProcessor An instance of the RenderInstructionProcessor used to sort and handle the renderers for each layer. + * @param[in] processOffscreen Whether the offscreen render tasks are the ones processed. Otherwise it processes the onscreen tasks. + */ +void ProcessTasks( BufferIndex updateBufferIndex, + RenderTaskList::RenderTaskContainer& taskContainer, + Layer& rootNode, + SortedLayerPointers& sortedLayers, + RenderInstructionContainer& instructions, + RenderInstructionProcessor& renderInstructionProcessor, + bool processOffscreen ) { - RenderTaskList::RenderTaskContainer& taskContainer = renderTasks.GetTasks(); - - if( taskContainer.IsEmpty() ) - { - // Early-exit if there are no tasks to process - return; - } - - // For each render-task: - // 1) Prepare the render-task - // 2) Clear the layer-stored lists of renderers (TODO check if the layer is not changed and don't clear in this case) - // 3) Traverse the scene-graph, filling the lists for the current render-task - // 4) Prepare render-instructions - - DALI_LOG_INFO( gRenderTaskLogFilter, Debug::General, "RenderTaskProcessor::Process() Offscreens first\n" ); - - // First process off screen render tasks - we may need the results of these for the on screen renders uint32_t clippingId = 0u; bool hasClippingNodes = false; - RenderTaskList::RenderTaskContainer::ConstIterator endIter = taskContainer.End(); - for( RenderTaskList::RenderTaskContainer::Iterator iter = taskContainer.Begin(); endIter != iter; ++iter ) + for( RenderTaskList::RenderTaskContainer::Iterator iter = taskContainer.Begin(), endIter = taskContainer.End(); endIter != iter; ++iter ) { RenderTask& renderTask = **iter; - // Off screen only. - if( ( renderTask.GetFrameBuffer() == 0 ) || ( !renderTask.ReadyToRender( updateBufferIndex ) ) ) + const bool hasFrameBuffer = renderTask.GetFrameBuffer() != 0; + + if( ( !processOffscreen && hasFrameBuffer ) || + ( processOffscreen && !hasFrameBuffer ) || + !renderTask.ReadyToRender( updateBufferIndex ) ) { // Skip to next task. continue; @@ -243,7 +231,7 @@ void RenderTaskProcessor::Process( BufferIndex updateBufferIndex, DALI_ASSERT_DEBUG( NULL != sourceNode ); // Otherwise Prepare() should return false // Check that the source node is not exclusive to another task. - if( ! CheckExclusivity( *sourceNode, renderTask ) ) + if( !CheckExclusivity( *sourceNode, renderTask ) ) { continue; } @@ -257,8 +245,7 @@ void RenderTaskProcessor::Process( BufferIndex updateBufferIndex, if( renderTask.IsRenderRequired() ) { - size_t layerCount( sortedLayers.size() ); - for( size_t i(0); iClearRenderables(); } @@ -273,76 +260,70 @@ void RenderTaskProcessor::Process( BufferIndex updateBufferIndex, 0u, hasClippingNodes ); - mRenderInstructionProcessor.Prepare( updateBufferIndex, - sortedLayers, - renderTask, - renderTask.GetCullMode(), - hasClippingNodes, - instructions ); + renderInstructionProcessor.Prepare( updateBufferIndex, + sortedLayers, + renderTask, + renderTask.GetCullMode(), + hasClippingNodes, + instructions ); } } +} - DALI_LOG_INFO( gRenderTaskLogFilter, Debug::General, "RenderTaskProcessor::Process() Onscreen\n" ); +} // Anonymous namespace. - // Now that the off screen renders are done we can process on screen render tasks. - // Reset the clipping Id for the OnScreen render tasks. - clippingId = 0u; - hasClippingNodes = false; - for ( RenderTaskList::RenderTaskContainer::Iterator iter = taskContainer.Begin(); endIter != iter; ++iter ) - { - RenderTask& renderTask = **iter; +RenderTaskProcessor::RenderTaskProcessor() +{ +} - // On screen only. - if( ( renderTask.GetFrameBuffer() != 0 ) || ( !renderTask.ReadyToRender( updateBufferIndex ) ) ) - { - // Skip to next task. - continue; - } +RenderTaskProcessor::~RenderTaskProcessor() +{ +} - Node* sourceNode = renderTask.GetSourceNode(); - DALI_ASSERT_DEBUG( NULL != sourceNode ); // Otherwise Prepare() should return false. +void RenderTaskProcessor::Process( BufferIndex updateBufferIndex, + RenderTaskList& renderTasks, + Layer& rootNode, + SortedLayerPointers& sortedLayers, + RenderInstructionContainer& instructions ) +{ + RenderTaskList::RenderTaskContainer& taskContainer = renderTasks.GetTasks(); - // Check that the source node is not exclusive to another task. - if( ! CheckExclusivity( *sourceNode, renderTask ) ) - { - continue; - } + if( taskContainer.IsEmpty() ) + { + // Early-exit if there are no tasks to process + return; + } - Layer* layer = FindLayer( *sourceNode ); - if( !layer ) - { - // Skip to next task as no layer. - continue; - } + // For each render-task: + // 1) Prepare the render-task + // 2) Clear the layer-stored lists of renderers (TODO check if the layer is not changed and don't clear in this case) + // 3) Traverse the scene-graph, filling the lists for the current render-task + // 4) Prepare render-instructions - if( renderTask.IsRenderRequired() ) - { - size_t layerCount( sortedLayers.size() ); - for( size_t i(0); i < layerCount; ++i ) - { - sortedLayers[i]->ClearRenderables(); - } + DALI_LOG_INFO( gRenderTaskLogFilter, Debug::General, "RenderTaskProcessor::Process() Offscreens first\n" ); - AddRenderablesForTask( updateBufferIndex, - *sourceNode, - *layer, - renderTask, - sourceNode->GetDrawMode(), - clippingId, - 0u, - 0u, - hasClippingNodes ); + // First process off screen render tasks - we may need the results of these for the on screen renders - mRenderInstructionProcessor.Prepare( updateBufferIndex, - sortedLayers, - renderTask, - renderTask.GetCullMode(), - hasClippingNodes, - instructions ); - } - } -} + ProcessTasks( updateBufferIndex, + taskContainer, + rootNode, + sortedLayers, + instructions, + mRenderInstructionProcessor, + true ); + DALI_LOG_INFO( gRenderTaskLogFilter, Debug::General, "RenderTaskProcessor::Process() Onscreen\n" ); + + // Now that the off screen renders are done we can process on screen render tasks. + // Reset the clipping Id for the OnScreen render tasks. + ProcessTasks( updateBufferIndex, + taskContainer, + rootNode, + sortedLayers, + instructions, + mRenderInstructionProcessor, + false ); +} } // SceneGraph -- 2.7.4