Ensure not rendering before a Renderer is added 08/233808/2
authorHeeyong Song <heeyong.song@samsung.com>
Tue, 19 May 2020 08:27:08 +0000 (17:27 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Mon, 1 Jun 2020 09:20:56 +0000 (09:20 +0000)
Change-Id: Ia933e3058e90ca563d035f8d041fc062a96625e3

automated-tests/src/dali/dali-test-suite-utils/test-application.cpp
automated-tests/src/dali/dali-test-suite-utils/test-application.h
automated-tests/src/dali/utc-Dali-Scene.cpp
dali/integration-api/core.cpp
dali/integration-api/core.h
dali/internal/common/core-impl.cpp
dali/internal/common/core-impl.h
dali/internal/render/common/render-manager.cpp
dali/internal/render/common/render-manager.h

index f85f14d..e8c0d12 100644 (file)
@@ -188,9 +188,13 @@ bool TestApplication::Render( uint32_t intervalMilliseconds, const char* locatio
 {
   DoUpdate( intervalMilliseconds, location );
 
+  // Reset the status
+  mRenderStatus.SetNeedsUpdate( false );
+  mRenderStatus.SetNeedsPostRender( false );
+
   mCore->PreRender( mRenderStatus, false /*do not force clear*/, false /*do not skip rendering*/ );
-  mCore->RenderScene( mScene, true /*render the off-screen buffers*/);
-  mCore->RenderScene( mScene, false /*render the surface*/);
+  mCore->RenderScene( mRenderStatus, mScene, true /*render the off-screen buffers*/);
+  mCore->RenderScene( mRenderStatus, mScene, false /*render the surface*/);
   mCore->PostRender( false /*do not skip rendering*/ );
 
   mFrame++;
@@ -214,12 +218,17 @@ bool TestApplication::GetRenderNeedsUpdate()
   return mRenderStatus.NeedsUpdate();
 }
 
+bool TestApplication::GetRenderNeedsPostRender()
+{
+  return mRenderStatus.NeedsPostRender();
+}
+
 bool TestApplication::RenderOnly( )
 {
   // Update Time values
   mCore->PreRender( mRenderStatus, false /*do not force clear*/, false /*do not skip rendering*/ );
-  mCore->RenderScene( mScene, true /*render the off-screen buffers*/);
-  mCore->RenderScene( mScene, false /*render the surface*/);
+  mCore->RenderScene( mRenderStatus, mScene, true /*render the off-screen buffers*/);
+  mCore->RenderScene( mRenderStatus, mScene, false /*render the surface*/);
   mCore->PostRender( false /*do not skip rendering*/ );
 
   mFrame++;
index a922e23..e96f759 100644 (file)
@@ -74,6 +74,7 @@ public:
   bool RenderOnly( );
   void ResetContext();
   bool GetRenderNeedsUpdate();
+  bool GetRenderNeedsPostRender();
   uint32_t Wait( uint32_t durationToWait );
   static void EnableLogging( bool enabled )
   {
index c2335ed..b52e2c2 100644 (file)
@@ -1166,3 +1166,52 @@ int UtcDaliSceneEnsureReplacedSurfaceKeepsClearColor(void)
 
   END_TEST;
 }
+
+int UtcDaliSceneEmptySceneRendering(void)
+{
+  tet_infoline( "Ensure not rendering before a Renderer is added" );
+
+  TestApplication application;
+  TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+
+  // Render without any renderer
+  application.SendNotification();
+  application.Render();
+
+  // Check the clear count and the render status
+  DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), 0, TEST_LOCATION );
+  DALI_TEST_EQUALS( application.GetRenderNeedsPostRender(), false, TEST_LOCATION );
+
+  // Add a Renderer
+  Geometry geometry = CreateQuadGeometry();
+  Shader shader = CreateShader();
+  Renderer renderer = Renderer::New( geometry, shader );
+
+  Actor actor = Actor::New();
+  actor.AddRenderer( renderer );
+  actor.SetSize( 400, 400 );
+  Stage::GetCurrent().Add( actor );
+
+  // Render
+  application.SendNotification();
+  application.Render();
+
+  // Check the clear count and the render status
+  DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), 1, TEST_LOCATION );
+  DALI_TEST_EQUALS( application.GetRenderNeedsPostRender(), true, TEST_LOCATION );
+
+  // Remove the Renderer
+  Stage::GetCurrent().Remove( actor );
+  actor.Reset();
+  renderer.Reset();
+
+  // Render
+  application.SendNotification();
+  application.Render();
+
+  // Check the clear count and the render status
+  DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), 2, TEST_LOCATION );  // Should be cleared
+  DALI_TEST_EQUALS( application.GetRenderNeedsPostRender(), true, TEST_LOCATION );
+
+  END_TEST;
+}
index d15cd28..47eb713 100644 (file)
@@ -116,9 +116,9 @@ void Core::PreRender( RenderStatus& status, bool forceClear, bool uploadOnly )
   mImpl->PreRender( status, forceClear, uploadOnly );
 }
 
-void Core::RenderScene( Integration::Scene& scene, bool renderToFbo )
+void Core::RenderScene( RenderStatus& status, Integration::Scene& scene, bool renderToFbo )
 {
-  mImpl->RenderScene( scene, renderToFbo );
+  mImpl->RenderScene( status, scene, renderToFbo );
 }
 
 void Core::PostRender( bool uploadOnly )
index f2a9f7a..f1a7e63 100644 (file)
@@ -354,10 +354,11 @@ public:
    * and the second pass to render the surface.
    * Multi-threading note: this method should be called from a dedicated rendering thread.
    * @pre The GL context must have been created, and made current.
+   * @param[out] status Contains the rendering flags.
    * @param[in] scene The scene to be rendered.
    * @param[in] renderToFbo True to render off-screen frame buffers only if any, and False to render the surface only.
    */
-  void RenderScene( Integration::Scene& scene, bool renderToFbo );
+  void RenderScene( RenderStatus& status, Integration::Scene& scene, bool renderToFbo );
 
 
   /**
index f1c6cd4..5da52a4 100644 (file)
@@ -221,9 +221,9 @@ void Core::PreRender( RenderStatus& status, bool forceClear, bool uploadOnly )
   mRenderManager->PreRender( status, forceClear, uploadOnly );
 }
 
-void Core::RenderScene( Integration::Scene& scene, bool renderToFbo )
+void Core::RenderScene( RenderStatus& status, Integration::Scene& scene, bool renderToFbo )
 {
-  mRenderManager->RenderScene( scene, renderToFbo );
+  mRenderManager->RenderScene( status, scene, renderToFbo );
 }
 
 void Core::PostRender( bool uploadOnly )
index 9272e16..cbe41a4 100644 (file)
@@ -136,7 +136,7 @@ public:
   /**
    * @copydoc Dali::Integration::Core::RenderScene()
    */
-  void RenderScene( Integration::Scene& scene, bool renderToFbo );
+  void RenderScene( Integration::RenderStatus& status, Integration::Scene& scene, bool renderToFbo );
 
   /**
    * @copydoc Dali::Integration::Core::Render()
index 5a0d3c1..77f6088 100644 (file)
@@ -507,12 +507,6 @@ void RenderManager::PreRender( Integration::RenderStatus& status, bool forceClea
   {
     DALI_LOG_INFO( gLogFilter, Debug::General, "Render: Processing\n" );
 
-    if ( !uploadOnly )
-    {
-      // Mark that we will require a post-render step to be performed (includes swap-buffers).
-      status.SetNeedsPostRender( true );
-    }
-
     // Switch to the shared context
     if ( mImpl->currentContext != &mImpl->context )
     {
@@ -570,7 +564,7 @@ void RenderManager::PreRender( Integration::RenderStatus& status, bool forceClea
 }
 
 
-void RenderManager::RenderScene( Integration::Scene& scene, bool renderToFbo )
+void RenderManager::RenderScene( Integration::RenderStatus& status, Integration::Scene& scene, bool renderToFbo )
 {
   Internal::Scene& sceneInternal = GetImplementation( scene );
   SceneGraph::Scene* sceneObject = sceneInternal.GetSceneObject();
@@ -586,6 +580,9 @@ void RenderManager::RenderScene( Integration::Scene& scene, bool renderToFbo )
       continue; // skip
     }
 
+    // Mark that we will require a post-render step to be performed (includes swap-buffers).
+    status.SetNeedsPostRender( true );
+
     Rect<int32_t> viewportRect;
     Vector4   clearColor;
 
index 396495e..5ed4296 100644 (file)
@@ -367,10 +367,11 @@ public:
    * and the second pass to render the surface.
    * Multi-threading note: this method should be called from a dedicated rendering thread.
    * @pre The GL context must have been created, and made current.
+   * @param[out] status contains the rendering flags.
    * @param[in] scene The scene to be rendered.
    * @param[in] renderToFbo True to render off-screen frame buffers only if any, and False to render the surface only.
    */
-  void RenderScene( Integration::Scene& scene, bool renderToFbo );
+  void RenderScene( Integration::RenderStatus& status, Integration::Scene& scene, bool renderToFbo );
 
   // This method should be called from Core::PostRender()