X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali%2Futc-Dali-RenderTask.cpp;h=e5ea26b035cc15d3cf097b7f38ee4403d02e080c;hb=79881246746f65474b24ea4fe14151ccef8df3f4;hp=7e9ad26bf95cbd06010fa85984cd342ebee6214d;hpb=23f274e6d33f22e18a48f29fcc101954333772d7;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/automated-tests/src/dali/utc-Dali-RenderTask.cpp b/automated-tests/src/dali/utc-Dali-RenderTask.cpp index 7e9ad26..e5ea26b 100644 --- a/automated-tests/src/dali/utc-Dali-RenderTask.cpp +++ b/automated-tests/src/dali/utc-Dali-RenderTask.cpp @@ -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. @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -287,41 +286,6 @@ bool UpdateRender(TestApplication& application, TraceCallStack& callStack, bool return result; } -// The functor to be used in the hit-test algorithm to check whether the actor is hittable. -bool IsActorHittableFunction(Actor actor, Dali::HitTestAlgorithm::TraverseType type) -{ - bool hittable = false; - - switch (type) - { - case Dali::HitTestAlgorithm::CHECK_ACTOR: - { - // Check whether the actor is visible and not fully transparent. - if( actor.IsVisible() - && actor.GetCurrentWorldColor().a > 0.01f) // not FULLY_TRANSPARENT - { - - hittable = true; - } - break; - } - case Dali::HitTestAlgorithm::DESCEND_ACTOR_TREE: - { - if( actor.IsVisible() ) // Actor is visible, if not visible then none of its children are visible. - { - hittable = true; - } - break; - } - default: - { - break; - } - } - - return hittable; -} - } // unnamed namespace @@ -588,6 +552,41 @@ int UtcDaliRenderTaskSetSourceActorEmpty(void) END_TEST; } +int UtcDaliRenderTaskSetSourceActorDestroyed(void) +{ + TestApplication application; + + tet_infoline( "Testing RenderTask::SetSourceActor - Set a source actor and destroy the source actor" ); + + Stage stage = Stage::GetCurrent(); + RenderTaskList taskList = stage.GetRenderTaskList(); + RenderTask task = taskList.GetTask( 0u ); + + Actor actor = task.GetSourceActor(); + DALI_TEST_CHECK( actor ); + + BufferImage img = BufferImage::New( 1,1 ); + Actor newActor = CreateRenderableActor( img ); + newActor.SetSize(1,1); + stage.Add( newActor ); + + task.SetSourceActor( newActor ); + + DALI_TEST_CHECK( task.GetSourceActor() != actor ); + DALI_TEST_CHECK( task.GetSourceActor() == newActor ); + + application.SendNotification(); + application.Render(); + + // Destroy the source actor + stage.Remove( newActor ); + newActor.Reset(); + + DALI_TEST_CHECK( !task.GetSourceActor() ); // The source actor should be an empty handle. + + END_TEST; +} + int UtcDaliRenderTaskGetSourceActorP01(void) { TestApplication application; @@ -671,11 +670,16 @@ int UtcDaliRenderTaskSetExclusive(void) // Check that the actor1 was rendered const std::vector& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 ); - DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION ); + DALI_TEST_GREATER( boundTextures.size(), static_cast::size_type>( 0 ), TEST_LOCATION ); if ( boundTextures.size() ) { - DALI_TEST_EQUALS( boundTextures[0], 8u/*unique to actor1*/, TEST_LOCATION ); + int c = 0; + DALI_TEST_EQUALS( boundTextures[c++], 8u/*unique to actor1*/, TEST_LOCATION ); + if( boundTextures.size() > 1 ) + { + DALI_TEST_EQUALS( boundTextures[c++], 8u/*unique to actor1*/, TEST_LOCATION ); + } } BufferImage img2 = BufferImage::New( 1,1 ); @@ -694,12 +698,17 @@ int UtcDaliRenderTaskSetExclusive(void) application.Render(); // Check that the actors were rendered - DALI_TEST_EQUALS( boundTextures.size(), 2u, TEST_LOCATION ); + DALI_TEST_GREATER( boundTextures.size(), static_cast::size_type>( 1 ), TEST_LOCATION ); if ( boundTextures.size() ) { - DALI_TEST_EQUALS( boundTextures[0], 9u/*unique to actor2*/, TEST_LOCATION ); - DALI_TEST_EQUALS( boundTextures[1], 8u/*unique to actor1*/, TEST_LOCATION ); + int c = 0; + DALI_TEST_EQUALS( boundTextures[c++], 9u/*unique to actor2*/, TEST_LOCATION ); + if( boundTextures.size() > 2 ) + { + DALI_TEST_EQUALS( boundTextures[c++], 9u/*unique to actor1*/, TEST_LOCATION ); + } + DALI_TEST_EQUALS( boundTextures[c++], 8u/*unique to actor1*/, TEST_LOCATION ); } BufferImage img3 = BufferImage::New( 1,1 ); @@ -718,13 +727,18 @@ int UtcDaliRenderTaskSetExclusive(void) application.Render(); // Check that the actors were rendered - DALI_TEST_EQUALS( boundTextures.size(), 3u, TEST_LOCATION ); + DALI_TEST_GREATER( boundTextures.size(), static_cast::size_type>( 2 ), TEST_LOCATION ); if ( boundTextures.size() ) { - DALI_TEST_EQUALS( boundTextures[0], 10u/*unique to actor3*/, TEST_LOCATION ); - DALI_TEST_EQUALS( boundTextures[1], 9u/*unique to actor2*/, TEST_LOCATION ); - DALI_TEST_EQUALS( boundTextures[2], 8u/*unique to actor1*/, TEST_LOCATION ); + int c = 0; + DALI_TEST_EQUALS( boundTextures[c++], 10u/*unique to actor3*/, TEST_LOCATION ); + if( boundTextures.size() > 3 ) + { + DALI_TEST_EQUALS( boundTextures[c++], 10u/*unique to actor2*/, TEST_LOCATION ); + } + DALI_TEST_EQUALS( boundTextures[c++], 9u/*unique to actor2*/, TEST_LOCATION ); + DALI_TEST_EQUALS( boundTextures[c++], 8u/*unique to actor1*/, TEST_LOCATION ); } // Both actors are now connected to the root node @@ -778,6 +792,12 @@ int UtcDaliRenderTaskSetExclusive(void) // Test that task 2 renders actor2 DALI_TEST_CHECK( boundTextures[2] == 9u ); } + + // Create a renderable actor and replace the source actor in task2 + auto actor4 = CreateRenderableActor(); + task2.SetSourceActor( actor3 ); + DALI_TEST_EQUALS( actor3, task2.GetSourceActor(), TEST_LOCATION ); + END_TEST; } @@ -982,6 +1002,29 @@ int UtcDaliRenderTaskSetCameraActorN(void) END_TEST; } +int UtcDaliRenderTaskSetCameraActorDestroyed(void) +{ + TestApplication application; + + tet_infoline( "Testing RenderTask::SetCameraActor - Set a camera actor and destroy the camera actor" ); + + Stage stage = Stage::GetCurrent(); + RenderTaskList taskList = stage.GetRenderTaskList(); + RenderTask task = taskList.GetTask( 0u ); + + CameraActor newCameraActor = CameraActor::New(); + task.SetCameraActor( newCameraActor ); + + DALI_TEST_EQUALS( task.GetCameraActor(), newCameraActor, TEST_LOCATION ); + + // Destroy the camera actor + newCameraActor.Reset(); + + CameraActor camera = task.GetCameraActor(); + DALI_TEST_CHECK( !camera ); // The camera actor should be an empty handle. + + END_TEST; +} int UtcDaliRenderTaskGetCameraActorP(void) { @@ -1416,7 +1459,7 @@ int UtcDaliRenderTaskSetViewportPosition(void) Vector2 newPosition2(32.0f, 32.0f); task.SetProperty( RenderTask::Property::VIEWPORT_POSITION, newPosition2 ); DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition2, TEST_LOCATION ); - DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector2 >( task, RenderTask::Property::VIEWPORT_POSITION ), newPosition, TEST_LOCATION ); // still the old position + DALI_TEST_EQUALS( task.GetCurrentProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition, TEST_LOCATION ); // still the old position // Update application.SendNotification(); @@ -1424,7 +1467,7 @@ int UtcDaliRenderTaskSetViewportPosition(void) DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition2, Math::MACHINE_EPSILON_1, TEST_LOCATION ); DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition2, TEST_LOCATION ); - DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector2 >( task, RenderTask::Property::VIEWPORT_POSITION ), newPosition2, TEST_LOCATION ); + DALI_TEST_EQUALS( task.GetCurrentProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition2, TEST_LOCATION ); Vector2 newPosition3(64.0f, 0.0f); Animation animation = Animation::New(1.0f); @@ -1432,13 +1475,30 @@ int UtcDaliRenderTaskSetViewportPosition(void) animation.Play(); DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION ); - DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector2 >( task, RenderTask::Property::VIEWPORT_POSITION ), newPosition2, TEST_LOCATION ); + DALI_TEST_EQUALS( task.GetCurrentProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition2, TEST_LOCATION ); // Perform 1000ms worth of updates at which point animation should have completed. Wait(application, 1000); DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION ); - DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector2 >( task, RenderTask::Property::VIEWPORT_POSITION ), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION ); + DALI_TEST_EQUALS( task.GetCurrentProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION ); DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION ); + + // Create another animation which animates by a certain value + const Vector2 newPosition4( 75.0f, 45.0f ); + const Vector2 relativePosition( newPosition4 - newPosition3 ); + animation = Animation::New( 1.0f ); + animation.AnimateBy( Property( task, RenderTask::Property::VIEWPORT_POSITION ), relativePosition ); + animation.Play(); + + DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition4, Math::MACHINE_EPSILON_1, TEST_LOCATION ); + DALI_TEST_EQUALS( task.GetCurrentProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition3, TEST_LOCATION ); + + // Perform 1000ms worth of updates at which point animation should have completed. + Wait(application, 1000); + DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition4, Math::MACHINE_EPSILON_1, TEST_LOCATION ); + DALI_TEST_EQUALS( task.GetCurrentProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition4, Math::MACHINE_EPSILON_1, TEST_LOCATION ); + DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition4, Math::MACHINE_EPSILON_1, TEST_LOCATION ); + END_TEST; } @@ -1473,7 +1533,7 @@ int UtcDaliRenderTaskSetViewportSize(void) Vector2 newSize2(50.0f, 50.0f); task.SetProperty( RenderTask::Property::VIEWPORT_SIZE, newSize2 ); DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE ), newSize2, TEST_LOCATION ); - DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector2 >( task, RenderTask::Property::VIEWPORT_SIZE ), newSize, TEST_LOCATION ); // still the old position + DALI_TEST_EQUALS( task.GetCurrentProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE ), newSize, TEST_LOCATION ); // still the old position // Update application.SendNotification(); @@ -1481,7 +1541,7 @@ int UtcDaliRenderTaskSetViewportSize(void) DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize2, Math::MACHINE_EPSILON_1, TEST_LOCATION ); DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE ), newSize2, TEST_LOCATION ); - DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector2 >( task, RenderTask::Property::VIEWPORT_SIZE ), newSize2, TEST_LOCATION ); + DALI_TEST_EQUALS( task.GetCurrentProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE ), newSize2, TEST_LOCATION ); Vector2 newSize3(10.0f, 10.0f); Animation animation = Animation::New(1.0f); @@ -1489,14 +1549,30 @@ int UtcDaliRenderTaskSetViewportSize(void) animation.Play(); DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE ), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION ); - DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector2 >( task, RenderTask::Property::VIEWPORT_SIZE ), newSize2, TEST_LOCATION ); + DALI_TEST_EQUALS( task.GetCurrentProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE ), newSize2, TEST_LOCATION ); // Perform 1000ms worth of updates at which point animation should have completed. Wait(application, 1000); DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION ); - DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector2 >( task, RenderTask::Property::VIEWPORT_SIZE ), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION ); + DALI_TEST_EQUALS( task.GetCurrentProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE ), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION ); DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE ), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION ); + // Create another animation which animates by a certain value + const Vector2 newSize4( 75.0f, 45.0f ); + const Vector2 relativeSize( newSize4 - newSize3 ); + animation = Animation::New( 1.0f ); + animation.AnimateBy( Property( task, RenderTask::Property::VIEWPORT_SIZE ), relativeSize ); + animation.Play(); + + DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE ), newSize4, Math::MACHINE_EPSILON_1, TEST_LOCATION ); + DALI_TEST_EQUALS( task.GetCurrentProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE ), newSize3, TEST_LOCATION ); + + // Perform 1000ms worth of updates at which point animation should have completed. + Wait(application, 1000); + DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize4, Math::MACHINE_EPSILON_1, TEST_LOCATION ); + DALI_TEST_EQUALS( task.GetCurrentProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE ), newSize4, Math::MACHINE_EPSILON_1, TEST_LOCATION ); + DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE ), newSize4, Math::MACHINE_EPSILON_1, TEST_LOCATION ); + END_TEST; } @@ -1523,14 +1599,14 @@ int UtcDaliRenderTaskSetClearColorP(void) task.SetProperty( RenderTask::Property::CLEAR_COLOR, testColor2 ); DALI_TEST_EQUALS( task.GetProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR ), testColor2, TEST_LOCATION ); - DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector4 >( task, RenderTask::Property::CLEAR_COLOR ), testColor, TEST_LOCATION ); // still the old color + DALI_TEST_EQUALS( task.GetCurrentProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR ), testColor, TEST_LOCATION ); // still the old color // Wait a frame. Wait(application); DALI_TEST_EQUALS( task.GetClearColor(), testColor2, TEST_LOCATION ); DALI_TEST_EQUALS( task.GetProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR ), testColor2, TEST_LOCATION ); - DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector4 >( task, RenderTask::Property::CLEAR_COLOR ), testColor2, TEST_LOCATION ); + DALI_TEST_EQUALS( task.GetCurrentProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR ), testColor2, TEST_LOCATION ); Vector4 newColor3(10.0f, 10.0f, 20.0f, 30.0f); Animation animation = Animation::New(1.0f); @@ -1538,13 +1614,28 @@ int UtcDaliRenderTaskSetClearColorP(void) animation.Play(); DALI_TEST_EQUALS( task.GetProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR ), newColor3, Math::MACHINE_EPSILON_1, TEST_LOCATION ); - DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector4 >( task, RenderTask::Property::CLEAR_COLOR ), testColor2, TEST_LOCATION ); + DALI_TEST_EQUALS( task.GetCurrentProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR ), testColor2, TEST_LOCATION ); // Perform 1000ms worth of updates at which point animation should have completed. Wait(application, 1000); - DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector4 >( task, RenderTask::Property::CLEAR_COLOR ), newColor3, Math::MACHINE_EPSILON_1, TEST_LOCATION ); + DALI_TEST_EQUALS( task.GetCurrentProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR ), newColor3, Math::MACHINE_EPSILON_1, TEST_LOCATION ); DALI_TEST_EQUALS( task.GetProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR ), newColor3, Math::MACHINE_EPSILON_1, TEST_LOCATION ); + // Create another animation which animates by a certain value + const Vector4 newColor4( 0.45f, 0.35f, 0.25f, 0.1f ); + const Vector4 relativeColor( newColor4 - newColor3 ); + animation = Animation::New( 1.0f ); + animation.AnimateBy( Property( task, RenderTask::Property::CLEAR_COLOR ), relativeColor ); + animation.Play(); + + DALI_TEST_EQUALS( task.GetProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR ), newColor4, Math::MACHINE_EPSILON_10, TEST_LOCATION ); + DALI_TEST_EQUALS( task.GetCurrentProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR ), newColor3, Math::MACHINE_EPSILON_10, TEST_LOCATION ); + + // Perform 1000ms worth of updates at which point animation should have completed. + Wait(application, 1000); + DALI_TEST_EQUALS( task.GetCurrentProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR ), newColor4, Math::MACHINE_EPSILON_10, TEST_LOCATION ); + DALI_TEST_EQUALS( task.GetProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR ), newColor4, Math::MACHINE_EPSILON_10, TEST_LOCATION ); + END_TEST; } @@ -1608,13 +1699,13 @@ int UtcDaliRenderTaskSetClearEnabledP(void) RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); RenderTask task = taskList.GetTask( 0u ); - DALI_TEST_CHECK( !task.GetClearEnabled() ); // defaults to false - - task.SetClearEnabled( true ); - DALI_TEST_EQUALS( task.GetClearEnabled(), true, TEST_LOCATION ); + DALI_TEST_CHECK( task.GetClearEnabled() ); // defaults to true task.SetClearEnabled( false ); DALI_TEST_EQUALS( task.GetClearEnabled(), false, TEST_LOCATION ); + + task.SetClearEnabled( true ); + DALI_TEST_EQUALS( task.GetClearEnabled(), true, TEST_LOCATION ); END_TEST; } @@ -1646,7 +1737,7 @@ int UtcDaliRenderTaskGetClearEnabledP(void) RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); RenderTask task = taskList.GetTask( 0u ); - DALI_TEST_CHECK( !task.GetClearEnabled() ); // defaults to false + DALI_TEST_CHECK( task.GetClearEnabled() ); // defaults to true END_TEST; } @@ -1867,7 +1958,7 @@ int UtcDaliRenderTaskContinuous01(void) Actor rootActor = Actor::New(); Stage::GetCurrent().Add( rootActor ); - CameraActor offscreenCameraActor = CameraActor::New(); + CameraActor offscreenCameraActor = CameraActor::New( Size( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT ) ); Stage::GetCurrent().Add( offscreenCameraActor ); Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg"); @@ -1905,7 +1996,7 @@ int UtcDaliRenderTaskContinuous02(void) Actor rootActor = Actor::New(); Stage::GetCurrent().Add( rootActor ); - CameraActor offscreenCameraActor = CameraActor::New(); + CameraActor offscreenCameraActor = CameraActor::New( Size( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT ) ); Stage::GetCurrent().Add( offscreenCameraActor ); Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg"); @@ -1945,7 +2036,7 @@ int UtcDaliRenderTaskContinuous03(void) Actor rootActor = Actor::New(); Stage::GetCurrent().Add( rootActor ); - CameraActor offscreenCameraActor = CameraActor::New(); + CameraActor offscreenCameraActor = CameraActor::New( Size( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT ) ); Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg"); Stage::GetCurrent().Add(secondRootActor); @@ -1983,7 +2074,7 @@ int UtcDaliRenderTaskContinuous04(void) Actor rootActor = Actor::New(); Stage::GetCurrent().Add( rootActor ); - CameraActor offscreenCameraActor = CameraActor::New(); + CameraActor offscreenCameraActor = CameraActor::New( Size( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT ) ); Stage::GetCurrent().Add( offscreenCameraActor ); Actor secondRootActor = CreateRenderableActorFailed(application, "aFile.jpg"); Stage::GetCurrent().Add(secondRootActor); @@ -2014,7 +2105,7 @@ int UtcDaliRenderTaskOnce01(void) Actor rootActor = Actor::New(); Stage::GetCurrent().Add( rootActor ); - CameraActor offscreenCameraActor = CameraActor::New(); + CameraActor offscreenCameraActor = CameraActor::New( Size( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT ) ); Stage::GetCurrent().Add( offscreenCameraActor ); Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg"); @@ -2052,7 +2143,7 @@ int UtcDaliRenderTaskOnce02(void) Actor rootActor = Actor::New(); Stage::GetCurrent().Add( rootActor ); - CameraActor offscreenCameraActor = CameraActor::New(); + CameraActor offscreenCameraActor = CameraActor::New( Size( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT ) ); Stage::GetCurrent().Add( offscreenCameraActor ); Shader shader = CreateShader(); @@ -2100,7 +2191,7 @@ int UtcDaliRenderTaskOnce03(void) Actor rootActor = Actor::New(); Stage::GetCurrent().Add( rootActor ); - CameraActor offscreenCameraActor = CameraActor::New(); + CameraActor offscreenCameraActor = CameraActor::New( Size( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT ) ); Stage::GetCurrent().Add( offscreenCameraActor ); Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg"); Stage::GetCurrent().Add(secondRootActor); @@ -2145,7 +2236,7 @@ int UtcDaliRenderTaskOnce04(void) Actor rootActor = Actor::New(); Stage::GetCurrent().Add( rootActor ); - CameraActor offscreenCameraActor = CameraActor::New(); + CameraActor offscreenCameraActor = CameraActor::New( Size( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT ) ); Stage::GetCurrent().Add( offscreenCameraActor ); Shader shader = CreateShader(); @@ -2197,7 +2288,7 @@ int UtcDaliRenderTaskOnceNoSync01(void) Actor rootActor = Actor::New(); Stage::GetCurrent().Add( rootActor ); - CameraActor offscreenCameraActor = CameraActor::New(); + CameraActor offscreenCameraActor = CameraActor::New( Size( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT ) ); Stage::GetCurrent().Add( offscreenCameraActor ); Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg"); Stage::GetCurrent().Add(secondRootActor); @@ -2227,7 +2318,7 @@ int UtcDaliRenderTaskOnceNoSync02(void) Actor rootActor = Actor::New(); Stage::GetCurrent().Add( rootActor ); - CameraActor offscreenCameraActor = CameraActor::New(); + CameraActor offscreenCameraActor = CameraActor::New( Size( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT ) ); Stage::GetCurrent().Add( offscreenCameraActor ); Shader shader = CreateShader(); @@ -2271,7 +2362,7 @@ int UtcDaliRenderTaskOnceNoSync03(void) Actor rootActor = Actor::New(); Stage::GetCurrent().Add( rootActor ); - CameraActor offscreenCameraActor = CameraActor::New(); + CameraActor offscreenCameraActor = CameraActor::New( Size( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT ) ); Stage::GetCurrent().Add( offscreenCameraActor ); Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg"); Stage::GetCurrent().Add(secondRootActor); @@ -2308,7 +2399,7 @@ int UtcDaliRenderTaskOnceNoSync04(void) Actor rootActor = Actor::New(); Stage::GetCurrent().Add( rootActor ); - CameraActor offscreenCameraActor = CameraActor::New(); + CameraActor offscreenCameraActor = CameraActor::New( Size( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT ) ); Stage::GetCurrent().Add( offscreenCameraActor ); Shader shader = CreateShader(); @@ -2363,7 +2454,7 @@ int UtcDaliRenderTaskOnceNoSync05(void) Actor rootActor = Actor::New(); Stage::GetCurrent().Add( rootActor ); - CameraActor offscreenCameraActor = CameraActor::New(); + CameraActor offscreenCameraActor = CameraActor::New( Size( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT ) ); Stage::GetCurrent().Add( offscreenCameraActor ); Actor secondRootActor = CreateRenderableActorFailed(application, "aFile.jpg"); Stage::GetCurrent().Add(secondRootActor); @@ -2403,7 +2494,7 @@ int UtcDaliRenderTaskOnceChain01(void) Actor defaultRootActor = Actor::New(); // Root for default RT Stage::GetCurrent().Add( defaultRootActor ); - CameraActor offscreenCameraActor = CameraActor::New(); + CameraActor offscreenCameraActor = CameraActor::New( Size( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT ) ); Stage::GetCurrent().Add( offscreenCameraActor ); Actor firstRootActor = CreateRenderableActorSuccess(application, "aFile.jpg"); Stage::GetCurrent().Add(firstRootActor); @@ -2451,78 +2542,6 @@ int UtcDaliRenderTaskProperties(void) END_TEST; } -int UtcDaliRenderTaskSetScreenToFrameBufferMappingActor(void) -{ - TestApplication application; - tet_infoline("Testing RenderTask::SetScreenToFrameBufferMappingActor "); - - Stage stage = Stage::GetCurrent(); - Size stageSize = stage.GetSize(); - Actor mappingActor = Actor::New(); - Vector2 scale( 0.6f, 0.75f); - Vector2 offset( stageSize.x*0.1f, stageSize.y*0.15f); - mappingActor.SetSize( stageSize * scale ); - mappingActor.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - mappingActor.SetPosition( offset.x, offset.y ); - stage.Add( mappingActor ); - - Actor offscreenActor = Actor::New(); - offscreenActor.SetSize( stageSize ); - offscreenActor.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - stage.Add( offscreenActor ); - - RenderTaskList taskList = stage.GetRenderTaskList(); - RenderTask renderTask = taskList.CreateTask(); - FrameBufferImage frameBufferImage = FrameBufferImage::New(stageSize.width*scale.x, stageSize.height*scale.y, Pixel::A8); - renderTask.SetSourceActor( offscreenActor ); - renderTask.SetExclusive( true ); - renderTask.SetInputEnabled( true ); - renderTask.SetTargetFrameBuffer( frameBufferImage ); - renderTask.SetRefreshRate( RenderTask::REFRESH_ONCE ); - renderTask.SetScreenToFrameBufferMappingActor( mappingActor ); - application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); - - // Render and notify - application.SendNotification(); - application.Render(); - application.Render(); - application.SendNotification(); - - Vector2 screenCoordinates( stageSize.x * 0.05f, stageSize.y * 0.05f ); - Dali::HitTestAlgorithm::Results results; - DALI_TEST_CHECK( !results.actor ); - DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION ); - // miss expected, results not changed - DALI_TEST_CHECK( false == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) ); - DALI_TEST_CHECK( !results.actor ); - DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION ); - - screenCoordinates.x = stageSize.x * 0.265f; - screenCoordinates.y = stageSize.y * 0.33f; - results.actor = Actor(); - results.actorCoordinates = Vector2::ZERO; - // hit expected, results changed - DALI_TEST_CHECK( true == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) ); - DALI_TEST_CHECK( results.actor == offscreenActor ); - DALI_TEST_EQUALS( (screenCoordinates-offset)/scale , results.actorCoordinates, 0.1f, TEST_LOCATION ); - - screenCoordinates.x = stageSize.x * 0.435f; - screenCoordinates.y = stageSize.y * 0.52f; - // hit expected, results changed - DALI_TEST_CHECK( true == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) ); - DALI_TEST_CHECK( results.actor == offscreenActor ); - const Vector2 expectedCoordinates = (screenCoordinates-offset)/scale; - DALI_TEST_EQUALS( expectedCoordinates , results.actorCoordinates, 0.1f, TEST_LOCATION ); - - screenCoordinates.x = stageSize.x * 0.65f; - screenCoordinates.y = stageSize.y * 0.95f; - // miss expected, results not changed - DALI_TEST_CHECK( false == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) ); - DALI_TEST_CHECK( results.actor == offscreenActor ); - DALI_TEST_EQUALS( expectedCoordinates , results.actorCoordinates, 0.1f, TEST_LOCATION ); - END_TEST; -} - int UtcDaliRenderTaskFinishInvisibleSourceActor(void) { TestApplication application; @@ -2651,7 +2670,7 @@ int UtcDaliRenderTaskFinishMissingImage(void) int UtcDaliRenderTaskWorldToViewport(void) { - TestApplication application( static_cast(400), static_cast(400) ); // square surface + TestApplication application( 400u, 400u ); // square surface RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); @@ -2745,6 +2764,52 @@ int UtcDaliRenderTaskViewportToLocal(void) } +int UtcDaliRenderTaskOffscreenViewportToLocal(void) +{ + TestApplication application; + Actor actor = Actor::New(); + actor.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + actor.SetSize( 100.0f, 100.0f ); + actor.SetPosition( 10.0f, 10.0f ); + Stage::GetCurrent().Add( actor ); + + RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); + RenderTask task = taskList.CreateTask(); + + FrameBufferImage newFrameBuffer = FrameBufferImage::New( 10, 10 ); + task.SetTargetFrameBuffer( newFrameBuffer ); + task.SetSourceActor( actor ); + task.SetScreenToFrameBufferMappingActor( actor ); + + CameraActor offscreenCameraActor = CameraActor::New( Size( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT ) ); + Stage::GetCurrent().Add( offscreenCameraActor ); + task.SetCameraActor( offscreenCameraActor ); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + application.SendNotification(); + application.Render(); + + float localX; + float localY; + + float rtLocalX; + float rtLocalY; + + float screenX = 50.0f; + float screenY = 50.0f; + + DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, screenX, screenY) ); + + DALI_TEST_CHECK( task.ViewportToLocal(actor, screenX, screenY, rtLocalX, rtLocalY ) ); + + DALI_TEST_EQUALS(localX, rtLocalX, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(localY, rtLocalY, 0.01f, TEST_LOCATION); + + END_TEST; +} + int UtcDaliRenderTaskRequiresSync(void) { TestApplication application; @@ -2754,12 +2819,54 @@ int UtcDaliRenderTaskRequiresSync(void) newTask.SetProperty( RenderTask::Property::REQUIRES_SYNC, false ); DALI_TEST_EQUALS( newTask.GetProperty< bool >( RenderTask::Property::REQUIRES_SYNC ), false, TEST_LOCATION ); - DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< bool >( newTask, RenderTask::Property::REQUIRES_SYNC ), false, TEST_LOCATION ); + DALI_TEST_EQUALS( newTask.GetCurrentProperty< bool >( RenderTask::Property::REQUIRES_SYNC ), false, TEST_LOCATION ); newTask.SetProperty( RenderTask::Property::REQUIRES_SYNC, true ); DALI_TEST_EQUALS( newTask.GetProperty< bool >( RenderTask::Property::REQUIRES_SYNC ), true, TEST_LOCATION ); - DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< bool >( newTask, RenderTask::Property::REQUIRES_SYNC ), true, TEST_LOCATION ); + DALI_TEST_EQUALS( newTask.GetCurrentProperty< bool >( RenderTask::Property::REQUIRES_SYNC ), true, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliRenderTaskSetClearEnabled(void) +{ + TestApplication application; + + tet_infoline("UtcDaliRenderTaskSetClearEnabled"); + + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + TestGlAbstraction& gl = application.GetGlAbstraction(); + + Actor renderableActor = CreateRenderableActorSuccess( application, "aFile.jpg" ); + Stage::GetCurrent().Add( renderableActor ); + + Actor rootActor = Actor::New(); + Stage::GetCurrent().Add( rootActor ); + + CameraActor offscreenCameraActor = CameraActor::New( Size( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT ) ); + Stage::GetCurrent().Add( offscreenCameraActor ); + + Actor sourceActor = CreateRenderableActorSuccess( application, "aFile.jpg" ); + Stage::GetCurrent().Add( sourceActor ); + + RenderTask newTask = CreateRenderTask( application, offscreenCameraActor, rootActor, sourceActor, RenderTask::REFRESH_ALWAYS, false ); + + DALI_TEST_EQUALS( gl.GetClearCountCalled(), 0, TEST_LOCATION ); + + application.SendNotification(); + application.Render(); + + // glClear should be called twice - default task and the new task. + DALI_TEST_EQUALS( gl.GetClearCountCalled(), 2, TEST_LOCATION ); + + newTask.SetClearEnabled( false ); + + application.SendNotification(); + application.Render(); + + // The count should increase by 1 - default task only. + DALI_TEST_EQUALS( gl.GetClearCountCalled(), 3, TEST_LOCATION ); END_TEST; }