use modern construct 'nullptr' instead of 'NULL' or '0'
[platform/core/uifw/dali-core.git] / dali / internal / update / manager / render-task-processor.cpp
index 938cd7d..73ea5cf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 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.
@@ -68,10 +68,10 @@ bool CheckExclusivity( const Node& node, const RenderTask& task )
 Layer* FindLayer( Node& node )
 {
   Node* currentNode( &node );
-  Layer* layer( NULL );
+  Layer* layer( nullptr );
   while( currentNode )
   {
-    if( ( layer = currentNode->GetLayer() ) != NULL )
+    if( ( layer = currentNode->GetLayer() ) != nullptr )
     {
       return layer;
     }
@@ -79,7 +79,7 @@ Layer* FindLayer( Node& node )
     currentNode = currentNode->GetParent();
   }
 
-  return NULL;
+  return nullptr;
 }
 
 /**
@@ -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).
@@ -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;
 }
 
 /**
@@ -202,8 +212,9 @@ void AddRenderablesForTask( BufferIndex updateBufferIndex,
  * @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,
@@ -217,11 +228,12 @@ 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;
 
-    const bool hasFrameBuffer = NULL != renderTask.GetFrameBuffer();
+    const bool hasFrameBuffer = nullptr != renderTask.GetFrameBuffer();
     const bool isDefaultRenderTask = isFirstRenderTask;
     isFirstRenderTask = false;
 
@@ -261,15 +273,15 @@ void ProcessTasks( BufferIndex updateBufferIndex,
         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,
@@ -290,6 +302,8 @@ void ProcessTasks( BufferIndex updateBufferIndex,
       }
     }
   }
+
+  return keepRendering;
 }
 
 } // Anonymous namespace.
@@ -302,7 +316,7 @@ RenderTaskProcessor::~RenderTaskProcessor()
 {
 }
 
-void RenderTaskProcessor::Process( BufferIndex updateBufferIndex,
+bool RenderTaskProcessor::Process( BufferIndex updateBufferIndex,
                                    RenderTaskList& renderTasks,
                                    Layer& rootNode,
                                    SortedLayerPointers& sortedLayers,
@@ -311,11 +325,12 @@ void RenderTaskProcessor::Process( BufferIndex updateBufferIndex,
                                    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:
@@ -328,30 +343,32 @@ 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,
+                                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,
+                                 instructions,
+                                 mRenderInstructionProcessor,
+                                 renderToFboEnabled,
+                                 isRenderingToFbo,
+                                 false );
+
+  return keepRendering;
 }
 
 } // SceneGraph