Remove RenderSurface from Core
[platform/core/uifw/dali-core.git] / dali / internal / update / manager / render-task-processor.cpp
index 31422ca..0fdc554 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 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.
@@ -97,8 +97,9 @@ Layer* FindLayer( Node& node )
  * @param[in]  clippingDepth The current stencil clipping depth
  * @param[in]  clippingDepth The current scissor clipping depth
  * @param[out] clippingUsed  Gets set to true if any clipping nodes have been found
+ * @return true if rendering should be kept, false otherwise.
  */
-void AddRenderablesForTask( BufferIndex updateBufferIndex,
+bool AddRenderablesForTask( BufferIndex updateBufferIndex,
                             Node& node,
                             Layer& currentLayer,
                             RenderTask& renderTask,
@@ -108,17 +109,19 @@ void AddRenderablesForTask( BufferIndex updateBufferIndex,
                             uint32_t scissorDepth,
                             bool& clippingUsed )
 {
+  bool keepRendering = false;
+
   // Short-circuit for invisible nodes
   if( !node.IsVisible( updateBufferIndex ) )
   {
-    return;
+    return keepRendering;
   }
 
   // Check whether node is exclusive to a different render-task
   const RenderTask* exclusiveTo = node.GetExclusiveRenderTask();
   if( exclusiveTo && ( exclusiveTo != &renderTask ) )
   {
-    return;
+    return keepRendering;
   }
 
   // Assume all children go to this layer (if this node is a layer).
@@ -137,7 +140,7 @@ void AddRenderablesForTask( BufferIndex updateBufferIndex,
 
   DALI_ASSERT_DEBUG( NULL != layer );
 
-  const unsigned int count = node.GetRendererCount();
+  const uint32_t count = node.GetRendererCount();
 
   // Update the clipping Id and depth for this node (if clipping is enabled).
   const Dali::ClippingMode::Type clippingMode = node.GetClippingMode();
@@ -164,7 +167,7 @@ void AddRenderablesForTask( BufferIndex updateBufferIndex,
   // Set the information in the node.
   node.SetClippingInformation( currentClippingId, clippingDepth, scissorDepth );
 
-  for( unsigned int i = 0; i < count; ++i )
+  for( uint32_t i = 0; i < count; ++i )
   {
     SceneGraph::Renderer* renderer = node.GetRendererAt( i );
 
@@ -177,6 +180,11 @@ void AddRenderablesForTask( BufferIndex updateBufferIndex,
     {
       layer->overlayRenderables.PushBack( Renderable( &node, renderer ) );
     }
+
+    if( renderer->GetRenderingBehavior() == DevelRenderer::Rendering::CONTINUOUSLY )
+    {
+      keepRendering = true;
+    }
   }
 
   // Recurse children.
@@ -185,8 +193,10 @@ void AddRenderablesForTask( BufferIndex updateBufferIndex,
   for( NodeIter iter = children.Begin(); iter != endIter; ++iter )
   {
     Node& child = **iter;
-    AddRenderablesForTask( updateBufferIndex, child, *layer, renderTask, inheritedDrawMode, currentClippingId, clippingDepth, scissorDepth, clippingUsed );
+    keepRendering |= AddRenderablesForTask( updateBufferIndex, child, *layer, renderTask, inheritedDrawMode, currentClippingId, clippingDepth, scissorDepth, clippingUsed );
   }
+
+  return keepRendering;
 }
 
 /**
@@ -197,16 +207,19 @@ void AddRenderablesForTask( BufferIndex updateBufferIndex,
  * @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[in]  context                    The context holding the GL state of rendering for the rendering instructions.
  * @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]  renderToFboEnabled         Whether rendering into the Frame Buffer Object is enabled (used to measure FPS above 60)
  * @param[in]  isRenderingToFbo           Whether this frame is being rendered into the Frame Buffer Object (used to measure FPS above 60)
  * @param[in]  processOffscreen           Whether the offscreen render tasks are the ones processed. Otherwise it processes the onscreen tasks.
+ * @return true if rendering should be kept, false otherwise.
  */
-void ProcessTasks( BufferIndex updateBufferIndex,
+bool ProcessTasks( BufferIndex updateBufferIndex,
                    RenderTaskList::RenderTaskContainer& taskContainer,
                    Layer& rootNode,
                    SortedLayerPointers& sortedLayers,
+                   Context& context,
                    RenderInstructionContainer& instructions,
                    RenderInstructionProcessor& renderInstructionProcessor,
                    bool renderToFboEnabled,
@@ -217,6 +230,7 @@ void ProcessTasks( BufferIndex updateBufferIndex,
   bool hasClippingNodes = false;
 
   bool isFirstRenderTask = true;
+  bool keepRendering = false;
   for( RenderTaskList::RenderTaskContainer::Iterator iter = taskContainer.Begin(), endIter = taskContainer.End(); endIter != iter; ++iter )
   {
     RenderTask& renderTask = **iter;
@@ -252,27 +266,28 @@ void ProcessTasks( BufferIndex updateBufferIndex,
       continue;
     }
 
-    const unsigned int currentNumberOfInstructions = instructions.Count( updateBufferIndex );
+    const uint32_t currentNumberOfInstructions = instructions.Count( updateBufferIndex );
 
     if( renderTask.IsRenderRequired() )
     {
-      for( size_t i = 0u, layerCount = sortedLayers.size(); i < layerCount; ++i )
+      for( auto&& sortedLayer : sortedLayers )
       {
-        sortedLayers[i]->ClearRenderables();
+        sortedLayer->ClearRenderables();
       }
 
-      AddRenderablesForTask( updateBufferIndex,
-                             *sourceNode,
-                             *layer,
-                             renderTask,
-                             sourceNode->GetDrawMode(),
-                             clippingId,
-                             0u,
-                             0u,
-                             hasClippingNodes );
+      keepRendering |= AddRenderablesForTask( updateBufferIndex,
+                                              *sourceNode,
+                                              *layer,
+                                              renderTask,
+                                              sourceNode->GetDrawMode(),
+                                              clippingId,
+                                              0u,
+                                              0u,
+                                              hasClippingNodes );
 
       renderInstructionProcessor.Prepare( updateBufferIndex,
                                           sortedLayers,
+                                          context,
                                           renderTask,
                                           renderTask.GetCullMode(),
                                           hasClippingNodes,
@@ -282,13 +297,16 @@ void ProcessTasks( BufferIndex updateBufferIndex,
     if( !processOffscreen && isDefaultRenderTask && renderToFboEnabled && !isRenderingToFbo && hasFrameBuffer )
     {
       // Traverse the instructions of the default render task and mark them to be rendered into the frame buffer.
-      for( unsigned int index = currentNumberOfInstructions, count = instructions.Count( updateBufferIndex ); index < count; ++index )
+      const uint32_t count = instructions.Count( updateBufferIndex );
+      for( uint32_t index = currentNumberOfInstructions; index < count; ++index )
       {
         RenderInstruction& instruction = instructions.At( updateBufferIndex, index );
         instruction.mIgnoreRenderToFbo = true;
       }
     }
   }
+
+  return keepRendering;
 }
 
 } // Anonymous namespace.
@@ -301,20 +319,22 @@ RenderTaskProcessor::~RenderTaskProcessor()
 {
 }
 
-void RenderTaskProcessor::Process( BufferIndex updateBufferIndex,
+bool RenderTaskProcessor::Process( BufferIndex updateBufferIndex,
                                    RenderTaskList& renderTasks,
                                    Layer& rootNode,
                                    SortedLayerPointers& sortedLayers,
+                                   Context& context,
                                    RenderInstructionContainer& instructions,
                                    bool renderToFboEnabled,
                                    bool isRenderingToFbo )
 {
   RenderTaskList::RenderTaskContainer& taskContainer = renderTasks.GetTasks();
+  bool keepRendering = false;
 
   if( taskContainer.IsEmpty() )
   {
     // Early-exit if there are no tasks to process
-    return;
+    return keepRendering;
   }
 
   // For each render-task:
@@ -327,30 +347,34 @@ void RenderTaskProcessor::Process( BufferIndex updateBufferIndex,
 
   // First process off screen render tasks - we may need the results of these for the on screen renders
 
-  ProcessTasks( updateBufferIndex,
-                taskContainer,
-                rootNode,
-                sortedLayers,
-                instructions,
-                mRenderInstructionProcessor,
-                renderToFboEnabled,
-                isRenderingToFbo,
-                true );
+  keepRendering = ProcessTasks( updateBufferIndex,
+                                taskContainer,
+                                rootNode,
+                                sortedLayers,
+                                context,
+                                instructions,
+                                mRenderInstructionProcessor,
+                                renderToFboEnabled,
+                                isRenderingToFbo,
+                                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,
-                renderToFboEnabled,
-                isRenderingToFbo,
-                false );
+  keepRendering |= ProcessTasks( updateBufferIndex,
+                                 taskContainer,
+                                 rootNode,
+                                 sortedLayers,
+                                 context,
+                                 instructions,
+                                 mRenderInstructionProcessor,
+                                 renderToFboEnabled,
+                                 isRenderingToFbo,
+                                 false );
+
+  return keepRendering;
 }
 
 } // SceneGraph