From: Heeyong Song Date: Tue, 19 May 2020 08:27:08 +0000 (+0900) Subject: Ensure not rendering before a Renderer is added X-Git-Tag: dali_1.5.15~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=514d5a10c9349236ac74d0e20f7eaf612d86a3ff;p=platform%2Fcore%2Fuifw%2Fdali-core-legacy.git Ensure not rendering before a Renderer is added Change-Id: Ia933e3058e90ca563d035f8d041fc062a96625e3 --- diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-application.cpp b/automated-tests/src/dali/dali-test-suite-utils/test-application.cpp index f85f14d..e8c0d12 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-application.cpp +++ b/automated-tests/src/dali/dali-test-suite-utils/test-application.cpp @@ -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++; diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-application.h b/automated-tests/src/dali/dali-test-suite-utils/test-application.h index a922e23..e96f759 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-application.h +++ b/automated-tests/src/dali/dali-test-suite-utils/test-application.h @@ -74,6 +74,7 @@ public: bool RenderOnly( ); void ResetContext(); bool GetRenderNeedsUpdate(); + bool GetRenderNeedsPostRender(); uint32_t Wait( uint32_t durationToWait ); static void EnableLogging( bool enabled ) { diff --git a/automated-tests/src/dali/utc-Dali-Scene.cpp b/automated-tests/src/dali/utc-Dali-Scene.cpp index c2335ed..b52e2c2 100644 --- a/automated-tests/src/dali/utc-Dali-Scene.cpp +++ b/automated-tests/src/dali/utc-Dali-Scene.cpp @@ -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; +} diff --git a/dali/integration-api/core.cpp b/dali/integration-api/core.cpp index d15cd28..47eb713 100644 --- a/dali/integration-api/core.cpp +++ b/dali/integration-api/core.cpp @@ -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 ) diff --git a/dali/integration-api/core.h b/dali/integration-api/core.h index f2a9f7a..f1a7e63 100644 --- a/dali/integration-api/core.h +++ b/dali/integration-api/core.h @@ -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 ); /** diff --git a/dali/internal/common/core-impl.cpp b/dali/internal/common/core-impl.cpp index f1c6cd4..5da52a4 100644 --- a/dali/internal/common/core-impl.cpp +++ b/dali/internal/common/core-impl.cpp @@ -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 ) diff --git a/dali/internal/common/core-impl.h b/dali/internal/common/core-impl.h index 9272e16..cbe41a4 100644 --- a/dali/internal/common/core-impl.h +++ b/dali/internal/common/core-impl.h @@ -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() diff --git a/dali/internal/render/common/render-manager.cpp b/dali/internal/render/common/render-manager.cpp index 5a0d3c1..77f6088 100644 --- a/dali/internal/render/common/render-manager.cpp +++ b/dali/internal/render/common/render-manager.cpp @@ -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 viewportRect; Vector4 clearColor; diff --git a/dali/internal/render/common/render-manager.h b/dali/internal/render/common/render-manager.h index 396495e..5ed4296 100644 --- a/dali/internal/render/common/render-manager.h +++ b/dali/internal/render/common/render-manager.h @@ -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()