- // Create a scene with a surface and ensure the size and surface is set correctly on the scene
- Vector2 surfaceSize( 480.0f, 800.0f );
- TestRenderSurface surface( PositionSize( 0.0f, 0.0f, surfaceSize.width, surfaceSize.height ) );
- auto scene = Integration::Scene::New( surface );
- DALI_TEST_EQUALS( scene.GetSize(), surfaceSize, TEST_LOCATION );
- DALI_TEST_CHECK( scene.GetSurface() == &surface );
-
- // Create a new surface and set that on the scene
- Vector2 newSurfaceSize( 1000.0f, 1000.0f );
- TestRenderSurface newSurface( PositionSize( 0.0f, 0.0f, newSurfaceSize.width, newSurfaceSize.height ) );
- scene.SetSurface( newSurface );
- DALI_TEST_EQUALS( scene.GetSize(), newSurfaceSize, TEST_LOCATION );
- DALI_TEST_CHECK( scene.GetSurface() == &newSurface );
-
- // Ensure setting the same surface again doesn't have any side effects
- scene.SetSurface( newSurface );
- DALI_TEST_EQUALS( scene.GetSize(), newSurfaceSize, TEST_LOCATION );
- DALI_TEST_CHECK( scene.GetSurface() == &newSurface );
+ // Create a new scene and set the background color of the main scene
+ auto defaultScene = application.GetScene();
+ defaultScene.SetBackgroundColor( Color::BLUE );
+
+ // Need to create a renderable as we don't start rendering until we have at least one
+ // We don't need to add this to any scene
+ auto actor = CreateRenderableActor();
+
+ auto& glAbstraction = application.GetGlAbstraction();
+ auto clearCountBefore = glAbstraction.GetClearCountCalled();
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION );
+ DALI_TEST_EQUALS( glAbstraction.GetLastClearColor(), Color::BLUE, TEST_LOCATION );
+
+ defaultScene.SurfaceReplaced();
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), clearCountBefore + 2, TEST_LOCATION );
+ DALI_TEST_EQUALS( glAbstraction.GetLastClearColor(), Color::BLUE, TEST_LOCATION );
+
+ // Check when the main render task viewport is set the clear color is clipped using scissors
+ TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
+ TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
+ scissorTrace.Enable( true );
+ enabledDisableTrace.Enable( true );
+
+ defaultScene.GetRenderTaskList().GetTask( 0 ).SetViewport( Viewport( 0.0f, 0.0f, 100.0f, 100.0f ) );
+
+ application.SendNotification();
+ application.Render();
+
+ // Check scissor test was enabled.
+ DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
+
+ // Check the scissor was set, and the coordinates are correct.
+ DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", "0, 700, 100, 100" ) );
+
+ DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), clearCountBefore + 3, TEST_LOCATION );
+ DALI_TEST_EQUALS( glAbstraction.GetLastClearColor(), Color::BLUE, TEST_LOCATION );
+
+ scissorTrace.Enable( false );
+ scissorTrace.Reset();
+
+ enabledDisableTrace.Enable( false );
+ enabledDisableTrace.Reset();
+
+ 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.SetProperty( Actor::Property::SIZE, Vector2( 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 );