2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include <dali/public-api/dali-core.h>
21 #include <dali/devel-api/events/hit-test-algorithm.h>
22 #include <dali-test-suite-utils.h>
23 #include <dali/integration-api/debug.h>
24 #include <test-native-image.h>
26 #include <mesh-builder.h>
28 #define BOOLSTR(x) ((x)?"T":"F")
30 //& set: DaliRenderTask
34 void utc_dali_render_task_startup(void)
36 test_return_value = TET_UNDEF;
39 void utc_dali_render_task_cleanup(void)
41 test_return_value = TET_PASS;
47 * Constructor, Destructor, DownCast, New, copy constructor, assignment operator
49 * SetSourceActor 2+ve, 1-ve
50 * GetSourceActor 1+ve, 1-ve
51 * SetExclusive 2+ve, 0-ve
52 * IsExclusive 2+ve, 0-ve
53 * SetInputEnabled 1+ve, 0-ve
54 * GetInputEnabled 1+ve, 0-ve
55 * SetCameraActor 1+ve, 1-ve
56 * GetCameraActor 1+ve, 1-ve
57 * SetTargetFrameBuffer 1+ve, 1-ve
58 * GetTargetFrameBuffer 1+ve, 1-ve
59 * SetScreenToFrameBufferFunction 1+ve, 1-ve
60 * GetScreenToFrameBufferFunction 1+ve, 1-ve
61 * SetScreenToFrameBufferMappingActor 1+ve, 1-ve
62 * GetScreenToFrameBufferMappingActor 1+ve, 1-ve
63 * SetViewportPosition 1+ve
64 * GetCurrentViewportPosition 1+ve
65 * SetViewportSize 1+ve
66 * GetCurrentViewportSize 1+ve
67 * SetViewport 2+ve, 1-ve
68 * GetViewport 2+ve, 1-ve
69 * SetClearColor 1+ve, 1-ve
70 * GetClearColor 1+ve, 1-ve
71 * SetClearEnabled 1+ve, 1-ve
72 * GetClearEnabled 1+ve, 1-ve
80 namespace // unnamed namespace
83 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
86 * Simulate time passed by.
88 * @note this will always process at least 1 frame (1/60 sec)
90 * @param application Test application instance
91 * @param duration Time to pass in milliseconds.
92 * @return The actual time passed in milliseconds
94 int Wait(TestApplication& application, int duration = 0)
98 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
100 application.SendNotification();
101 application.Render(RENDER_FRAME_INTERVAL);
102 time += RENDER_FRAME_INTERVAL;
108 struct RenderTaskFinished
110 RenderTaskFinished( bool& finished )
111 : finished( finished )
115 void operator()( RenderTask& renderTask )
123 struct RenderTaskFinishedRemoveSource
125 RenderTaskFinishedRemoveSource( bool& finished )
126 : finished( finished ),
131 void operator()( RenderTask& renderTask )
133 DALI_TEST_CHECK(finishedOnce == false);
136 Actor srcActor = renderTask.GetSourceActor();
137 UnparentAndReset(srcActor);
144 struct RenderTaskFinishedRenderAgain
146 RenderTaskFinishedRenderAgain( bool& finished )
147 : finished( finished ),
152 void operator()( RenderTask& renderTask )
154 DALI_TEST_CHECK(finishedOnce == false);
157 renderTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
165 bool TestScreenToFrameBufferFunction( Vector2& coordinates )
167 coordinates = coordinates + Vector2( 1, 2 );
172 Actor CreateRenderableActorSuccess(TestApplication& application, std::string filename)
174 PrepareResourceImage( application, 80u, 80u, Pixel::RGBA8888 );
175 Image image = ResourceImage::New(filename);
176 Actor actor = CreateRenderableActor(image);
177 actor.SetSize( 80, 80 );
181 Actor CreateRenderableActorFailed(TestApplication& application, std::string filename)
183 Image image = ResourceImage::New(filename);
184 DALI_TEST_CHECK( image );
185 Actor actor = CreateRenderableActor(image);
186 actor.SetSize( 80, 80 );
190 Image CreateResourceImage(TestApplication& application, std::string filename)
192 PrepareResourceImage( application, 80u, 80u, Pixel::RGBA8888 );
193 Image image = ResourceImage::New(filename);
194 DALI_TEST_CHECK( image );
198 RenderTask CreateRenderTask(TestApplication& application,
199 CameraActor offscreenCamera,
200 Actor rootActor, // Reset default render task to point at this actor
201 Actor secondRootActor, // Source actor
202 unsigned int refreshRate,
205 // Change main render task to use a different root
206 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
207 taskList.GetTask(0u).SetSourceActor( rootActor );
209 FrameBufferImage frameBufferImage;
212 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
213 frameBufferImage= FrameBufferImage::New( *(testNativeImagePtr.Get()) );
217 frameBufferImage = FrameBufferImage::New( 10, 10 );
220 // Don't draw output framebuffer // '
222 RenderTask newTask = taskList.CreateTask();
223 newTask.SetCameraActor( offscreenCamera );
224 newTask.SetSourceActor( secondRootActor );
225 newTask.SetInputEnabled( false );
226 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
227 newTask.SetClearEnabled( true );
228 newTask.SetExclusive( true );
229 newTask.SetRefreshRate( refreshRate );
230 newTask.SetTargetFrameBuffer( frameBufferImage );
231 newTask.SetProperty( RenderTask::Property::REQUIRES_SYNC, glSync );
235 bool UpdateRender(TestApplication& application, TraceCallStack& callStack, bool testDrawn, bool& finishedSig, bool testFinished, bool testKeepUpdating, int lineNumber )
240 tet_printf("TestApplication::UpdateRender().\n");
242 application.Render(16);
243 application.SendNotification();
245 bool sigPassed = false;
248 sigPassed = finishedSig;
252 sigPassed = ! finishedSig;
255 bool drawResult = callStack.FindMethod("DrawElements") || callStack.FindMethod("DrawArrays");
257 bool drawPassed = false;
260 drawPassed = drawResult;
264 drawPassed = !drawResult;
267 bool keepUpdating = (application.GetUpdateStatus() != 0);
268 bool keepUpdatingPassed = false;
269 if( testKeepUpdating )
271 keepUpdatingPassed = keepUpdating;
275 keepUpdatingPassed = !keepUpdating;
278 bool result = (sigPassed && drawPassed && keepUpdatingPassed);
280 tet_printf("UpdateRender: Expected: Draw:%s Signal:%s KeepUpdating: %s Actual: Draw:%s Signal:%s KeepUpdating: %s %s, line %d\n",
281 BOOLSTR(testDrawn), BOOLSTR(testFinished), BOOLSTR(testKeepUpdating),
282 BOOLSTR(drawResult), BOOLSTR(finishedSig), BOOLSTR(keepUpdating),
283 result ? "Passed":"Failed",
289 // The functor to be used in the hit-test algorithm to check whether the actor is hittable.
290 bool IsActorHittableFunction(Actor actor, Dali::HitTestAlgorithm::TraverseType type)
292 bool hittable = false;
296 case Dali::HitTestAlgorithm::CHECK_ACTOR:
298 // Check whether the actor is visible and not fully transparent.
299 if( actor.IsVisible()
300 && actor.GetCurrentWorldColor().a > 0.01f) // not FULLY_TRANSPARENT
307 case Dali::HitTestAlgorithm::DESCEND_ACTOR_TREE:
309 if( actor.IsVisible() ) // Actor is visible, if not visible then none of its children are visible.
324 } // unnamed namespace
327 /****************************************************************************************************/
328 /****************************************************************************************************/
329 /******************************** TEST CASES BELOW **********************************************/
330 /****************************************************************************************************/
331 /****************************************************************************************************/
333 int UtcDaliRenderTaskDownCast01(void)
335 TestApplication application;
337 tet_infoline("Testing RenderTask::DownCast()");
339 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
341 BaseHandle base = taskList.GetTask( 0u );
342 DALI_TEST_CHECK( base );
344 RenderTask task = RenderTask::DownCast( base );
345 DALI_TEST_CHECK( task );
347 // Try calling a method
348 DALI_TEST_CHECK( task.GetSourceActor() );
352 int UtcDaliRenderTaskDownCast02(void)
354 TestApplication application;
356 tet_infoline("Testing RenderTask::DownCast()");
358 Actor actor = Actor::New();
360 RenderTask task = RenderTask::DownCast( actor );
361 DALI_TEST_CHECK( ! task );
366 int UtcDaliRenderTaskSetSourceActorN(void)
368 TestApplication application;
369 tet_infoline("Testing RenderTask::SetSourceActor() Negative - try with empty actor handle");
370 Stage stage = Stage::GetCurrent();
374 RenderTaskList taskList = stage.GetRenderTaskList();
375 RenderTask renderTask = taskList.CreateTask();
376 renderTask.SetSourceActor(srcActor);
378 application.SendNotification();
379 application.Render();
381 DALI_TEST_CHECK( ! renderTask.GetSourceActor() );
386 int UtcDaliRenderTaskSetSourceActorP01(void)
388 TestApplication application;
390 tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that setting a non-renderable actor stops existing source actor being rendered ");
392 Stage stage = Stage::GetCurrent();
393 RenderTaskList taskList = stage.GetRenderTaskList();
394 RenderTask task = taskList.GetTask( 0u );
396 Actor actor = task.GetSourceActor();
397 DALI_TEST_CHECK( actor );
399 BufferImage img = BufferImage::New( 1,1 );
400 Actor newActor = CreateRenderableActor( img );
401 newActor.SetSize(1,1);
402 stage.Add( newActor );
404 Actor nonRenderableActor = Actor::New();
405 stage.Add( nonRenderableActor );
407 // Stop the newActor from being rendered by changing the source actor
408 DALI_TEST_CHECK( nonRenderableActor );
409 task.SetSourceActor( nonRenderableActor );
410 DALI_TEST_CHECK( task.GetSourceActor() != actor );
411 DALI_TEST_CHECK( task.GetSourceActor() == nonRenderableActor );
413 TestGlAbstraction& gl = application.GetGlAbstraction();
414 TraceCallStack& drawTrace = gl.GetDrawTrace();
415 drawTrace.Enable(true);
417 // Update & Render nothing!
418 application.GetGlAbstraction().ClearBoundTextures();
419 application.SendNotification();
420 application.Render();
422 // Check that nothing was rendered
423 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION );
429 int UtcDaliRenderTaskSetSourceActorP02(void)
431 TestApplication application;
433 tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that switching source from a non-renderable to a renderable actor causes the texture to be drawn");
435 Stage stage = Stage::GetCurrent();
437 RenderTaskList taskList = stage.GetRenderTaskList();
439 RenderTask task = taskList.GetTask( 0u );
441 Actor actor = task.GetSourceActor();
442 DALI_TEST_CHECK( actor );
445 BufferImage img = BufferImage::New( 1,1 );
446 Actor newActor = CreateRenderableActor( img );
447 newActor.SetSize(1,1);
448 stage.Add( newActor );
450 Actor nonRenderableActor = Actor::New();
451 stage.Add( nonRenderableActor );
453 TestGlAbstraction& gl = application.GetGlAbstraction();
454 TraceCallStack& drawTrace = gl.GetDrawTrace();
455 drawTrace.Enable(true);
457 // Stop the newActor from being rendered by changing the source actor
458 DALI_TEST_CHECK( nonRenderableActor );
459 task.SetSourceActor( nonRenderableActor );
460 DALI_TEST_CHECK( task.GetSourceActor() != actor );
461 DALI_TEST_CHECK( task.GetSourceActor() == nonRenderableActor );
463 // Update & Render nothing!
464 application.GetGlAbstraction().ClearBoundTextures();
465 application.SendNotification();
466 application.Render();
468 // Check that nothing was rendered
469 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION );
472 // Set newActor as the new source Actor
473 task.SetSourceActor( newActor );
474 DALI_TEST_CHECK( task.GetSourceActor() != actor );
475 DALI_TEST_CHECK( task.GetSourceActor() == newActor );
477 // Update & Render the newActor
478 application.GetGlAbstraction().ClearBoundTextures();
479 application.SendNotification();
480 application.Render();
482 // Check that the newActor was rendered
483 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION );
487 int UtcDaliRenderTaskSetSourceActorOffStage(void)
489 TestApplication application;
491 tet_infoline("Testing RenderTask::SetSourceActor (on/off stage testing)");
493 Stage stage = Stage::GetCurrent();
494 RenderTaskList taskList = stage.GetRenderTaskList();
495 RenderTask task = taskList.GetTask( 0u );
497 Actor actor = task.GetSourceActor();
498 DALI_TEST_CHECK( actor );
500 TestGlAbstraction& gl = application.GetGlAbstraction();
501 TraceCallStack& drawTrace = gl.GetDrawTrace();
502 drawTrace.Enable(true);
504 BufferImage img = BufferImage::New( 1,1 );
505 Actor newActor = CreateRenderableActor( img );
506 newActor.SetSize(1,1);
507 task.SetSourceActor( newActor );
508 // Don't add newActor to stage yet //'
510 // Update & Render with the actor initially off-stage
511 application.SendNotification();
512 application.Render();
514 // Check that nothing was rendered
515 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION );
518 stage.Add( newActor );
520 // Update & Render with the actor on-stage
521 application.GetGlAbstraction().ClearBoundTextures();
522 application.SendNotification();
523 application.Render();
525 // Check that the newActor was rendered
526 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION );
529 // Now remove from stage
530 stage.Remove( newActor );
532 // Update & Render with the actor off-stage
533 application.SendNotification();
534 application.Render();
535 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION );
540 int UtcDaliRenderTaskSetSourceActorEmpty(void)
542 TestApplication application;
544 tet_infoline("Testing RenderTask::SetSourceActor (empty handle case)");
546 Stage stage = Stage::GetCurrent();
547 RenderTaskList taskList = stage.GetRenderTaskList();
548 RenderTask task = taskList.GetTask( 0u );
550 Actor actor = task.GetSourceActor();
551 DALI_TEST_CHECK( actor );
553 BufferImage img = BufferImage::New( 1,1 );
554 Actor newActor = CreateRenderableActor( img );
555 newActor.SetSize(1,1);
556 stage.Add( newActor );
558 Actor nonRenderableActor = Actor::New();
559 stage.Add( nonRenderableActor );
561 // Set with empty handle
562 task.SetSourceActor( Actor() );
563 DALI_TEST_CHECK( ! task.GetSourceActor() );
565 TestGlAbstraction& gl = application.GetGlAbstraction();
566 TraceCallStack& drawTrace = gl.GetDrawTrace();
567 drawTrace.Enable(true);
569 // Update & Render nothing!
570 application.SendNotification();
571 application.Render();
573 // Check that nothing was rendered
574 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION );
576 // Set with non-empty handle
577 task.SetSourceActor( newActor );
578 DALI_TEST_CHECK( task.GetSourceActor() == newActor );
580 // Update & Render the newActor
581 application.GetGlAbstraction().ClearBoundTextures();
582 application.SendNotification();
583 application.Render();
585 // Check that the newActor was rendered
586 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION );
590 int UtcDaliRenderTaskGetSourceActorP01(void)
592 TestApplication application;
594 tet_infoline("Testing RenderTask::GetSourceActor() Check the default render task has a valid source actor");
596 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
598 RenderTask task = taskList.GetTask( 0u );
600 Actor actor = task.GetSourceActor();
601 DALI_TEST_CHECK( actor );
603 // By default the entire scene should be rendered
604 Actor root = Stage::GetCurrent().GetLayer( 0 );
605 DALI_TEST_CHECK( root == actor );
609 int UtcDaliRenderTaskGetSourceActorP02(void)
611 TestApplication application;
613 tet_infoline("Testing RenderTask::GetSourceActor() Create a new render task, Add a new actor to the stage and set it as the source of the new render task. Get its source actor and check that it is equivalent to what was set.");
615 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
616 RenderTask task = taskList.CreateTask();
617 Actor actor = Actor::New();
618 Stage::GetCurrent().Add(actor);
619 task.SetSourceActor( actor );
621 DALI_TEST_EQUALS( actor, task.GetSourceActor(), TEST_LOCATION );
626 int UtcDaliRenderTaskGetSourceActorN(void)
628 TestApplication application;
630 tet_infoline("Testing RenderTask::GetSourceActor() Try with empty handle");
635 Actor actor = task.GetSourceActor();
637 catch (Dali::DaliException& e)
639 DALI_TEST_PRINT_ASSERT( e );
640 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
646 int UtcDaliRenderTaskSetExclusive(void)
648 TestApplication application;
650 tet_infoline("Testing RenderTask::SetExclusive() Check that exclusion works");
652 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
654 // Manipulate the GenTextures behaviour, to identify different actors
656 std::vector<GLuint> ids;
657 ids.push_back( 8 ); // 8 = actor1
658 ids.push_back( 9 ); // 9 = actor2
659 ids.push_back( 10 ); // 10 = actor3
660 application.GetGlAbstraction().SetNextTextureIds( ids );
662 BufferImage img1 = BufferImage::New( 1,1 );
663 Actor actor1 = CreateRenderableActor( img1 );
665 Stage::GetCurrent().Add( actor1 );
667 // Update & Render actor1
668 application.SendNotification();
669 application.Render();
671 // Check that the actor1 was rendered
672 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
673 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
675 if ( boundTextures.size() )
677 DALI_TEST_EQUALS( boundTextures[0], 8u/*unique to actor1*/, TEST_LOCATION );
680 BufferImage img2 = BufferImage::New( 1,1 );
681 Actor actor2 = CreateRenderableActor( img2 );
684 // Force actor2 to be rendered before actor1
685 Layer layer = Layer::New();
686 Stage::GetCurrent().Add( layer );
688 layer.LowerToBottom();
691 application.GetGlAbstraction().ClearBoundTextures();
692 application.SendNotification();
693 application.Render();
695 // Check that the actors were rendered
696 DALI_TEST_EQUALS( boundTextures.size(), 2u, TEST_LOCATION );
698 if ( boundTextures.size() )
700 DALI_TEST_EQUALS( boundTextures[0], 9u/*unique to actor2*/, TEST_LOCATION );
701 DALI_TEST_EQUALS( boundTextures[1], 8u/*unique to actor1*/, TEST_LOCATION );
704 BufferImage img3 = BufferImage::New( 1,1 );
705 Actor actor3 = CreateRenderableActor( img3 );
708 // Force actor3 to be rendered before actor2
709 layer = Layer::New();
710 Stage::GetCurrent().Add( layer );
712 layer.LowerToBottom();
714 // Update & Render all actors
715 application.GetGlAbstraction().ClearBoundTextures();
716 application.SendNotification();
717 application.Render();
719 // Check that the actors were rendered
720 DALI_TEST_EQUALS( boundTextures.size(), 3u, TEST_LOCATION );
722 if ( boundTextures.size() )
724 DALI_TEST_EQUALS( boundTextures[0], 10u/*unique to actor3*/, TEST_LOCATION );
725 DALI_TEST_EQUALS( boundTextures[1], 9u/*unique to actor2*/, TEST_LOCATION );
726 DALI_TEST_EQUALS( boundTextures[2], 8u/*unique to actor1*/, TEST_LOCATION );
729 // Both actors are now connected to the root node
730 // Setup 2 render-tasks - the first will render from the root-node, and the second from actor2
732 // Not exclusive is the default
733 RenderTask task1 = taskList.GetTask( 0u );
734 DALI_TEST_CHECK( false == task1.IsExclusive() );
736 RenderTask task2 = taskList.CreateTask();
737 DALI_TEST_CHECK( false == task2.IsExclusive() );
738 task2.SetSourceActor( actor2 );
740 // Task1 should render all actors, and task 2 should render only actor2
742 application.GetGlAbstraction().ClearBoundTextures();
743 application.SendNotification();
744 application.Render();
746 DALI_TEST_EQUALS( boundTextures.size(), 4u, TEST_LOCATION );
748 if ( boundTextures.size() == 4 )
750 // Test that task 1 renders actor3, then actor2 & then actor1
751 DALI_TEST_CHECK( boundTextures[0] == 10u );
752 DALI_TEST_CHECK( boundTextures[1] == 9u );
753 DALI_TEST_CHECK( boundTextures[2] == 8u );
755 // Test that task 2 renders actor2
756 DALI_TEST_EQUALS( boundTextures[3], 9u, TEST_LOCATION );
759 // Make actor2 exclusive to task2
761 task2.SetExclusive( true );
762 DALI_TEST_CHECK( true == task2.IsExclusive() );
764 // Task1 should render only actor1, and task 2 should render only actor2
766 application.GetGlAbstraction().ClearBoundTextures();
767 application.SendNotification();
768 application.Render();
770 DALI_TEST_EQUALS( boundTextures.size(), 3u, TEST_LOCATION );
771 if ( boundTextures.size() == 3 )
773 // Test that task 1 renders actor3 & actor1
774 DALI_TEST_CHECK( boundTextures[0] == 10u );
775 DALI_TEST_CHECK( boundTextures[1] == 8u );
777 // Test that task 2 renders actor2
778 DALI_TEST_CHECK( boundTextures[2] == 9u );
783 int UtcDaliRenderTaskSetExclusive02(void)
785 TestApplication application;
787 tet_infoline("Testing RenderTask::SetExclusive() Check that changing from exclusive to not-exclusive works");
789 std::vector<GLuint> ids;
790 ids.push_back( 8 ); // 8 = actor1
791 application.GetGlAbstraction().SetNextTextureIds( ids );
793 BufferImage img1 = BufferImage::New( 1,1 );
794 Actor actor1 = CreateRenderableActor( img1 );
796 Stage::GetCurrent().Add( actor1 );
798 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
799 RenderTask task = taskList.CreateTask();
801 task.SetSourceActor( actor1 );
802 task.SetExclusive(true); // Actor should only render once
804 TestGlAbstraction& gl = application.GetGlAbstraction();
805 TraceCallStack& drawTrace = gl.GetDrawTrace();
806 drawTrace.Enable(true);
808 // Update & Render actor1
809 application.SendNotification();
810 application.Render();
812 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION );
814 // Set task to non-exclusive - actor1 should render twice:
816 task.SetExclusive(false);
817 application.SendNotification();
818 application.Render();
820 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 2, TEST_LOCATION );
825 int UtcDaliRenderTaskSetExclusiveN(void)
827 TestApplication application;
829 tet_infoline("Testing RenderTask::SetExclusive() on empty handle");
834 task.SetExclusive(true);
836 catch (Dali::DaliException& e)
838 DALI_TEST_PRINT_ASSERT( e );
839 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
844 int UtcDaliRenderTaskIsExclusive01(void)
846 TestApplication application;
848 tet_infoline("Testing RenderTask::IsExclusive() Check default values are non-exclusive");
850 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
852 // Not exclusive is the default
853 RenderTask task = taskList.GetTask( 0u );
854 DALI_TEST_CHECK( false == task.IsExclusive() );
856 RenderTask newTask = taskList.CreateTask();
857 DALI_TEST_CHECK( false == newTask.IsExclusive() );
862 int UtcDaliRenderTaskIsExclusive02(void)
864 TestApplication application;
866 tet_infoline("Testing RenderTask::IsExclusive() Check the getter returns set values");
868 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
870 // Not exclusive is the default
871 RenderTask newTask = taskList.CreateTask();
872 DALI_TEST_EQUALS( newTask.IsExclusive(), false, TEST_LOCATION );
874 newTask.SetExclusive(true);
875 DALI_TEST_EQUALS( newTask.IsExclusive(), true, TEST_LOCATION );
879 int UtcDaliRenderTaskIsExclusiveN(void)
881 TestApplication application;
883 tet_infoline("Testing RenderTask::IsExclusive() on empty handle");
888 bool x = task.IsExclusive();
891 catch (Dali::DaliException& e)
893 DALI_TEST_PRINT_ASSERT( e );
894 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
899 int UtcDaliRenderTaskSetInputEnabled(void)
901 TestApplication application;
903 tet_infoline("Testing RenderTask::SetInputEnabled()");
905 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
907 // Input is enabled by default
908 RenderTask task = taskList.GetTask( 0u );
909 DALI_TEST_CHECK( true == task.GetInputEnabled() );
911 task.SetInputEnabled( false );
912 DALI_TEST_CHECK( false == task.GetInputEnabled() );
914 task.SetInputEnabled( true );
915 DALI_TEST_CHECK( true == task.GetInputEnabled() );
919 int UtcDaliRenderTaskGetInputEnabled(void)
921 TestApplication application;
923 tet_infoline("Testing RenderTask::GetInputEnabled()");
925 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
927 // Input is enabled by default
928 RenderTask task = taskList.GetTask( 0u );
929 DALI_TEST_EQUALS( true, task.GetInputEnabled(), TEST_LOCATION );
931 RenderTask newTask = taskList.CreateTask();
932 DALI_TEST_EQUALS( true, newTask.GetInputEnabled(), TEST_LOCATION );
934 newTask.SetInputEnabled(false);
935 DALI_TEST_EQUALS( false, newTask.GetInputEnabled(), TEST_LOCATION );
940 int UtcDaliRenderTaskSetCameraActorP(void)
942 TestApplication application;
944 tet_infoline("Testing RenderTask::SetCameraActor()");
946 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
948 RenderTask task = taskList.GetTask( 0u );
950 Actor defaultCameraActor = task.GetCameraActor();
951 DALI_TEST_CHECK( defaultCameraActor );
953 CameraActor newCameraActor = CameraActor::New();
954 DALI_TEST_CHECK( newCameraActor );
956 task.SetCameraActor( newCameraActor );
957 DALI_TEST_CHECK( task.GetCameraActor() != defaultCameraActor );
958 DALI_TEST_EQUALS( task.GetCameraActor(), newCameraActor, TEST_LOCATION );
963 int UtcDaliRenderTaskSetCameraActorN(void)
965 TestApplication application;
967 tet_infoline("Testing RenderTask::SetCameraActor() with empty actor handle");
969 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
971 RenderTask task = taskList.GetTask( 0u );
973 Actor actor = task.GetCameraActor();
974 DALI_TEST_CHECK( actor );
976 CameraActor cameraActor;
978 task.SetCameraActor( cameraActor );
979 DALI_TEST_EQUALS( (bool)task.GetCameraActor(), false, TEST_LOCATION );
980 DALI_TEST_EQUALS( task.GetCameraActor(), cameraActor, TEST_LOCATION );
985 int UtcDaliRenderTaskGetCameraActorP(void)
987 TestApplication application;
989 tet_infoline("Testing RenderTask::GetCameraActor()");
991 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
993 RenderTask task = taskList.GetTask( 0u );
995 CameraActor actor = task.GetCameraActor();
996 DALI_TEST_CHECK( actor );
997 DALI_TEST_EQUALS( actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION );
998 DALI_TEST_GREATER( actor.GetFieldOfView(), 0.0f, TEST_LOCATION );
1002 int UtcDaliRenderTaskGetCameraActorN(void)
1004 TestApplication application;
1006 tet_infoline("Testing RenderTask::GetCameraActor() with empty handle");
1011 Actor actor = task.GetCameraActor();
1013 catch (Dali::DaliException& e)
1015 DALI_TEST_PRINT_ASSERT( e );
1016 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1022 int UtcDaliRenderTaskSetTargetFrameBufferP(void)
1024 TestApplication application;
1026 tet_infoline("Testing RenderTask::SetTargetFrameBuffer()");
1028 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1030 RenderTask task = taskList.GetTask( 0u );
1032 FrameBufferImage newImage = FrameBufferImage::New();
1033 task.SetTargetFrameBuffer( newImage );
1034 DALI_TEST_CHECK( task.GetTargetFrameBuffer() == newImage );
1038 int UtcDaliRenderTaskSetTargetFrameBufferN(void)
1040 TestApplication application;
1042 tet_infoline("Testing RenderTask::SetTargetFrameBuffer()");
1044 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1046 RenderTask task = taskList.GetTask( 0u );
1047 FrameBufferImage newImage; // Empty handle
1048 task.SetTargetFrameBuffer( newImage );
1049 DALI_TEST_EQUALS( (bool)task.GetTargetFrameBuffer(), false, TEST_LOCATION );
1053 int UtcDaliRenderTaskGetTargetFrameBufferP(void)
1055 TestApplication application;
1057 tet_infoline("Testing RenderTask::GetTargetFrameBuffer()");
1059 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1061 RenderTask newTask = taskList.CreateTask();
1062 FrameBufferImage fb = FrameBufferImage::New(128, 128, Pixel::RGBA8888);
1063 newTask.SetTargetFrameBuffer( fb );
1064 DALI_TEST_EQUALS( newTask.GetTargetFrameBuffer(), fb, TEST_LOCATION );
1068 int UtcDaliRenderTaskGetTargetFrameBufferN(void)
1070 TestApplication application;
1072 tet_infoline("Testing RenderTask::GetTargetFrameBuffer()");
1074 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1076 RenderTask task = taskList.GetTask( 0u );
1078 // By default render-tasks do not render off-screen
1079 FrameBufferImage image = task.GetTargetFrameBuffer();
1080 DALI_TEST_CHECK( !image );
1085 int UtcDaliRenderTaskSetFrameBufferP(void)
1087 TestApplication application;
1089 tet_infoline("Testing RenderTask::SetFrameBuffer()");
1091 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1093 RenderTask task = taskList.GetTask( 0u );
1095 FrameBuffer newFrameBuffer = FrameBuffer::New( 128u, 128u, FrameBuffer::Attachment::NONE );
1096 task.SetFrameBuffer( newFrameBuffer );
1097 DALI_TEST_CHECK( task.GetFrameBuffer() == newFrameBuffer );
1101 int UtcDaliRenderTaskSetFrameBufferN(void)
1103 TestApplication application;
1105 tet_infoline("Testing RenderTask::SetFrameBuffer()");
1107 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1109 RenderTask task = taskList.GetTask( 0u );
1110 FrameBuffer newFrameBuffer; // Empty handle
1111 task.SetFrameBuffer( newFrameBuffer );
1112 DALI_TEST_EQUALS( (bool)task.GetFrameBuffer(), false, TEST_LOCATION );
1116 int UtcDaliRenderTaskGetFrameBufferP(void)
1118 TestApplication application;
1120 tet_infoline("Testing RenderTask::GetFrameBuffer()");
1122 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1124 RenderTask task = taskList.GetTask( 0u );
1126 FrameBuffer newFrameBuffer = FrameBuffer::New( 1u, 1u, FrameBuffer::Attachment::NONE );
1127 task.SetFrameBuffer( newFrameBuffer );
1128 DALI_TEST_CHECK( task.GetFrameBuffer() == newFrameBuffer );
1132 int UtcDaliRenderTaskGetFrameBufferN(void)
1134 TestApplication application;
1136 tet_infoline("Testing RenderTask::GetFrameBuffer()");
1138 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1140 RenderTask task = taskList.GetTask( 0u );
1142 // By default render-tasks do not render off-screen
1143 FrameBuffer frameBuffer = task.GetFrameBuffer();
1144 DALI_TEST_CHECK( !frameBuffer );
1149 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionP(void)
1151 TestApplication application;
1153 tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1155 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1157 RenderTask task = taskList.GetTask( 0u );
1159 task.SetScreenToFrameBufferFunction( TestScreenToFrameBufferFunction );
1161 Vector2 coordinates( 5, 10 );
1162 Vector2 convertedCoordinates( 6, 12 ); // + Vector(1, 2)
1164 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1165 DALI_TEST_CHECK( func( coordinates ) );
1166 DALI_TEST_CHECK( coordinates == convertedCoordinates );
1168 task.SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
1169 func = task.GetScreenToFrameBufferFunction();
1170 DALI_TEST_CHECK( func( coordinates ) );
1172 task.SetScreenToFrameBufferFunction( RenderTask::DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION );
1173 func = task.GetScreenToFrameBufferFunction();
1174 DALI_TEST_CHECK( ! func( coordinates ) );
1178 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionN(void)
1180 TestApplication application;
1182 tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1184 RenderTask task; // Empty handle
1187 task.SetScreenToFrameBufferFunction( TestScreenToFrameBufferFunction );
1189 catch (Dali::DaliException& e)
1191 DALI_TEST_PRINT_ASSERT( e );
1192 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1197 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionP(void)
1199 TestApplication application;
1201 tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction()");
1203 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1205 RenderTask task = taskList.GetTask( 0u );
1207 Vector2 originalCoordinates( 5, 10 );
1208 Vector2 coordinates( 5, 10 );
1210 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1211 DALI_TEST_CHECK( !func( coordinates ) ); // conversion should fail by default
1212 DALI_TEST_CHECK( coordinates == originalCoordinates ); // coordinates should not be modified
1216 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionN(void)
1218 TestApplication application;
1220 tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction() on empty handle");
1225 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1228 catch (Dali::DaliException& e)
1230 DALI_TEST_PRINT_ASSERT( e );
1231 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1237 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorP(void)
1239 TestApplication application;
1240 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor ");
1242 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1243 RenderTask renderTask = taskList.CreateTask();
1244 Actor mappingActor = Actor::New();
1245 renderTask.SetScreenToFrameBufferMappingActor(mappingActor);
1247 DALI_TEST_EQUALS( mappingActor, renderTask.GetScreenToFrameBufferMappingActor(), TEST_LOCATION );
1252 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorN(void)
1254 TestApplication application;
1255 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1261 task.SetScreenToFrameBufferMappingActor(mappingActor);
1263 catch (Dali::DaliException& e)
1265 DALI_TEST_PRINT_ASSERT( e );
1266 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1271 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActor02N(void)
1273 TestApplication application;
1274 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1276 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1277 RenderTask renderTask = taskList.CreateTask();
1279 renderTask.SetScreenToFrameBufferMappingActor(actor);
1281 DALI_TEST_EQUALS( (bool)renderTask.GetScreenToFrameBufferMappingActor(), false, TEST_LOCATION);
1285 int UtcDaliRenderTaskGetViewportP01(void)
1287 TestApplication application;
1289 tet_infoline("Testing RenderTask::GetViewport() on default task");
1291 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1292 RenderTask task = taskList.GetTask( 0u );
1293 Viewport viewport = task.GetViewport();
1295 // By default the viewport should match the stage width/height
1296 Vector2 stageSize = Stage::GetCurrent().GetSize();
1297 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1298 DALI_TEST_CHECK( viewport == expectedViewport );
1302 int UtcDaliRenderTaskGetViewportP02(void)
1304 TestApplication application;
1306 tet_infoline("Testing RenderTask::GetViewport() on new task");
1308 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1309 RenderTask task = taskList.CreateTask();
1310 Viewport viewport = task.GetViewport();
1312 // By default the viewport should match the stage width/height
1313 Vector2 stageSize = Stage::GetCurrent().GetSize();
1314 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1315 DALI_TEST_CHECK( viewport == expectedViewport );
1319 int UtcDaliRenderTaskGetViewportN(void)
1321 TestApplication application;
1323 tet_infoline("Testing RenderTask::GetViewport() on empty handle");
1328 Viewport viewport = task.GetViewport();
1331 catch (Dali::DaliException& e)
1333 DALI_TEST_PRINT_ASSERT( e );
1334 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1340 int UtcDaliRenderTaskSetViewportP(void)
1342 TestApplication application;
1344 tet_infoline("Testing RenderTask::SetViewport()");
1346 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1348 RenderTask task = taskList.GetTask( 0u );
1349 Vector2 stageSize = Stage::GetCurrent().GetSize();
1350 Viewport newViewport( 0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f );
1351 task.SetViewport( newViewport );
1353 // Update (viewport is a property)
1354 application.SendNotification();
1355 application.Render();
1357 DALI_TEST_CHECK( task.GetViewport() == newViewport );
1361 int UtcDaliRenderTaskSetViewportN(void)
1363 TestApplication application;
1365 tet_infoline("Testing RenderTask::SetViewport()");
1367 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1372 Vector2 stageSize = Stage::GetCurrent().GetSize();
1373 Viewport newViewport( 0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f );
1374 task.SetViewport( newViewport );
1376 catch (Dali::DaliException& e)
1378 DALI_TEST_PRINT_ASSERT( e );
1379 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1386 int UtcDaliRenderTaskSetViewportPosition(void)
1388 TestApplication application;
1390 tet_infoline("Testing RenderTask::SetViewportPosition()");
1392 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1394 RenderTask task = taskList.GetTask( 0u );
1396 Viewport viewport = task.GetViewport();
1398 // By default the viewport should match the stage width/height
1400 Vector2 stageSize = Stage::GetCurrent().GetSize();
1401 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1402 DALI_TEST_CHECK( viewport == expectedViewport );
1405 Vector2 newPosition(25.0f, 50.0f);
1406 task.SetViewportPosition( newPosition );
1408 // Update (viewport is a property)
1409 application.SendNotification();
1410 application.Render();
1412 DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1414 // Set by Property test
1415 Vector2 newPosition2(32.0f, 32.0f);
1416 task.SetProperty( RenderTask::Property::VIEWPORT_POSITION, newPosition2 );
1419 application.SendNotification();
1420 application.Render();
1422 DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition2, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1424 Vector2 newPosition3(64.0f, 0.0f);
1425 Animation animation = Animation::New(1.0f);
1426 animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_POSITION ), newPosition3, AlphaFunction::LINEAR );
1429 // Perform 1000ms worth of updates at which point animation should have completed.
1430 Wait(application, 1000);
1431 DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1435 int UtcDaliRenderTaskSetViewportSize(void)
1437 TestApplication application;
1439 tet_infoline("Testing RenderTask::SetViewportSize()");
1441 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1443 RenderTask task = taskList.GetTask( 0u );
1445 Viewport viewport = task.GetViewport();
1447 // By default the viewport should match the stage width/height
1449 Vector2 stageSize = Stage::GetCurrent().GetSize();
1450 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1451 DALI_TEST_CHECK( viewport == expectedViewport );
1453 Vector2 newSize(128.0f, 64.0f);
1454 task.SetViewportSize( newSize );
1456 // Update (viewport is a property)
1457 application.SendNotification();
1458 application.Render();
1460 DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1462 // Set by Property test
1463 Vector2 newSize2(50.0f, 50.0f);
1464 task.SetProperty( RenderTask::Property::VIEWPORT_SIZE, newSize2 );
1467 application.SendNotification();
1468 application.Render();
1470 DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize2, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1472 Vector2 newSize3(10.0f, 10.0f);
1473 Animation animation = Animation::New(1.0f);
1474 animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_SIZE ), newSize3, AlphaFunction::LINEAR );
1477 // Perform 1000ms worth of updates at which point animation should have completed.
1478 Wait(application, 1000);
1479 DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1484 int UtcDaliRenderTaskSetClearColorP(void)
1486 TestApplication application;
1488 tet_infoline("Testing RenderTask::SetClearColor()");
1490 Vector4 testColor( 1.0f, 2.0f, 3.0f, 4.0f );
1491 Vector4 testColor2( 5.0f, 6.0f, 7.0f, 8.0f );
1493 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1495 RenderTask task = taskList.GetTask( 0u );
1496 DALI_TEST_CHECK( task.GetClearColor() != testColor );
1498 task.SetClearColor( testColor );
1503 DALI_TEST_EQUALS( task.GetClearColor(), testColor, TEST_LOCATION );
1505 task.SetProperty( RenderTask::Property::CLEAR_COLOR, testColor2 );
1510 DALI_TEST_EQUALS( task.GetClearColor(), testColor2, TEST_LOCATION );
1514 int UtcDaliRenderTaskSetClearColorN(void)
1516 TestApplication application;
1518 tet_infoline("Testing RenderTask::SetClearColor() on empty handle");
1523 task.SetClearColor( Vector4::ZERO );
1525 catch (Dali::DaliException& e)
1527 DALI_TEST_PRINT_ASSERT( e );
1528 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1533 int UtcDaliRenderTaskGetClearColorP(void)
1535 TestApplication application;
1537 tet_infoline("Testing RenderTask::GetClearColor()");
1539 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1540 RenderTask task = taskList.GetTask( 0u );
1541 DALI_TEST_EQUALS( task.GetClearColor(), RenderTask::DEFAULT_CLEAR_COLOR, TEST_LOCATION );
1545 int UtcDaliRenderTaskGetClearColorN(void)
1547 TestApplication application;
1549 tet_infoline("Testing RenderTask::GetClearColor()");
1554 Vector4 color = task.GetClearColor();
1557 catch (Dali::DaliException& e)
1559 DALI_TEST_PRINT_ASSERT( e );
1560 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1565 int UtcDaliRenderTaskSetClearEnabledP(void)
1567 TestApplication application;
1569 tet_infoline("Testing RenderTask::SetClearEnabled()");
1571 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1573 RenderTask task = taskList.GetTask( 0u );
1574 DALI_TEST_CHECK( !task.GetClearEnabled() ); // defaults to false
1576 task.SetClearEnabled( true );
1577 DALI_TEST_EQUALS( task.GetClearEnabled(), true, TEST_LOCATION );
1579 task.SetClearEnabled( false );
1580 DALI_TEST_EQUALS( task.GetClearEnabled(), false, TEST_LOCATION );
1584 int UtcDaliRenderTaskSetClearEnabledN(void)
1586 TestApplication application;
1588 tet_infoline("Testing RenderTask::SetClearEnabled() with empty handle");
1593 task.SetClearEnabled(true);
1595 catch (Dali::DaliException& e)
1597 DALI_TEST_PRINT_ASSERT( e );
1598 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1603 int UtcDaliRenderTaskGetClearEnabledP(void)
1605 TestApplication application;
1607 tet_infoline("Testing RenderTask::GetClearEnabled()");
1609 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1611 RenderTask task = taskList.GetTask( 0u );
1612 DALI_TEST_CHECK( !task.GetClearEnabled() ); // defaults to false
1617 int UtcDaliRenderTaskGetClearEnabledN(void)
1619 TestApplication application;
1621 tet_infoline("Testing RenderTask::GetClearEnabled() with empty handle");
1626 bool x = task.GetClearEnabled();
1629 catch (Dali::DaliException& e)
1631 DALI_TEST_PRINT_ASSERT( e );
1632 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1637 int UtcDaliRenderTaskSetCullModeP(void)
1639 TestApplication application;
1641 tet_infoline("Testing RenderTask::SetCullMode()");
1643 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1644 RenderTask task = taskList.GetTask( 0u );
1645 DALI_TEST_EQUALS( task.GetCullMode(), true, TEST_LOCATION );
1647 task.SetCullMode( false );
1649 DALI_TEST_EQUALS( task.GetCullMode(), false, TEST_LOCATION );
1654 int UtcDaliRenderTaskSetCullModeN(void)
1656 TestApplication application;
1658 tet_infoline("Testing RenderTask::SetCullMode() on empty handle");
1663 task.SetCullMode( false );
1665 catch (Dali::DaliException& e)
1667 DALI_TEST_PRINT_ASSERT( e );
1668 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1673 int UtcDaliRenderTaskGetCullModeP(void)
1675 TestApplication application;
1677 tet_infoline("Testing RenderTask::GetCullMode()");
1679 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1680 RenderTask task = taskList.GetTask( 0u );
1681 DALI_TEST_EQUALS( task.GetCullMode(), true, TEST_LOCATION );
1685 int UtcDaliRenderTaskGetCullModeN(void)
1687 TestApplication application;
1689 tet_infoline("Testing RenderTask::GetCullMode() with empty handle");
1694 bool x = task.GetCullMode();
1697 catch (Dali::DaliException& e)
1699 DALI_TEST_PRINT_ASSERT( e );
1700 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1706 int UtcDaliRenderTaskSetRefreshRate(void)
1708 TestApplication application;
1710 tet_infoline("Testing RenderTask::SetRefreshRate()");
1712 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1714 // By default tasks will be processed every frame
1715 RenderTask task = taskList.GetTask( 0u );
1716 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1718 task.SetRefreshRate( 2u ); // every-other frame
1719 DALI_TEST_CHECK( 2u == task.GetRefreshRate() );
1721 task.SetRefreshRate( RenderTask::REFRESH_ALWAYS );
1722 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1726 int UtcDaliRenderTaskGetRefreshRate(void)
1728 TestApplication application;
1730 tet_infoline("Testing RenderTask::GetRefreshRate()");
1732 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1734 // By default tasks will be processed every frame
1735 RenderTask task = taskList.GetTask( 0u );
1736 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1738 RenderTask newTask = taskList.CreateTask();
1739 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == newTask.GetRefreshRate() );
1743 int UtcDaliRenderTaskSignalFinished(void)
1745 TestApplication application;
1747 tet_infoline("Testing RenderTask::SignalFinished()");
1749 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1750 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
1752 CameraActor offscreenCameraActor = CameraActor::New();
1754 Stage::GetCurrent().Add( offscreenCameraActor );
1756 BufferImage image = BufferImage::New( 10, 10 );
1758 Actor rootActor = CreateRenderableActor( image );
1759 rootActor.SetSize( 10, 10 );
1760 Stage::GetCurrent().Add( rootActor );
1762 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1763 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
1764 FrameBufferImage frameBufferImage = FrameBufferImage::New( *testNativeImagePtr.Get() );
1766 RenderTask newTask = taskList.CreateTask();
1767 newTask.SetCameraActor( offscreenCameraActor );
1768 newTask.SetSourceActor( rootActor );
1769 newTask.SetInputEnabled( false );
1770 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
1771 newTask.SetClearEnabled( true );
1772 newTask.SetExclusive( true );
1773 newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
1774 newTask.SetTargetFrameBuffer( frameBufferImage );
1775 newTask.SetProperty( RenderTask::Property::REQUIRES_SYNC, true );
1777 bool finished = false;
1778 RenderTaskFinished renderTaskFinished( finished );
1779 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1781 // Flush the queue and render.
1782 application.SendNotification();
1784 // 1 render to process render task, then wait for sync before finished msg is sent
1785 // from update to the event thread.
1787 application.Render();
1788 application.SendNotification();
1789 DALI_TEST_CHECK( !finished );
1791 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
1792 DALI_TEST_CHECK( lastSyncObj != NULL );
1794 application.Render();
1795 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
1796 application.SendNotification();
1797 DALI_TEST_CHECK( !finished );
1799 application.Render();
1800 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
1801 application.SendNotification();
1802 DALI_TEST_CHECK( ! finished );
1804 sync.SetObjectSynced( lastSyncObj, true );
1806 application.Render();
1807 application.SendNotification();
1808 DALI_TEST_CHECK( !finished );
1810 application.Render();
1811 application.SendNotification();
1812 DALI_TEST_CHECK( finished );
1814 DALI_TEST_EQUALS( application.GetUpdateStatus(), 0, TEST_LOCATION );
1819 int UtcDaliRenderTaskContinuous01(void)
1821 TestApplication application;
1823 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not staged)\nPOST:continuous renders, no Finished signal");
1825 // SETUP AN OFFSCREEN RENDER TASK
1826 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1827 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1828 drawTrace.Enable(true);
1830 Actor rootActor = Actor::New();
1831 Stage::GetCurrent().Add( rootActor );
1833 CameraActor offscreenCameraActor = CameraActor::New();
1834 Stage::GetCurrent().Add( offscreenCameraActor );
1836 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
1838 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1839 bool finished = false;
1840 RenderTaskFinished renderTaskFinished( finished );
1841 application.SendNotification();
1843 // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating
1844 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false, __LINE__ ) );
1845 application.GetPlatform().ClearReadyResources();
1847 // ADD SOURCE ACTOR TO STAGE - expect continuous renders to start, no finished signal
1848 Stage::GetCurrent().Add(secondRootActor);
1849 application.SendNotification();
1851 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1852 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
1857 int UtcDaliRenderTaskContinuous02(void)
1859 TestApplication application;
1861 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not visible)\nPOST:continuous renders, no Finished signal");
1863 // SETUP AN OFFSCREEN RENDER TASK
1864 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1865 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1866 drawTrace.Enable(true);
1868 Actor rootActor = Actor::New();
1869 Stage::GetCurrent().Add( rootActor );
1871 CameraActor offscreenCameraActor = CameraActor::New();
1872 Stage::GetCurrent().Add( offscreenCameraActor );
1874 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
1875 Stage::GetCurrent().Add(secondRootActor);
1876 secondRootActor.SetVisible(false);
1878 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1879 bool finished = false;
1880 RenderTaskFinished renderTaskFinished( finished );
1881 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1882 application.SendNotification();
1884 // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating
1885 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false, __LINE__ ) );
1886 application.GetPlatform().ClearReadyResources();
1888 // MAKE SOURCE ACTOR VISIBLE - expect continuous renders to start, no finished signal
1889 secondRootActor.SetVisible(true);
1890 application.SendNotification();
1892 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1893 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
1897 int UtcDaliRenderTaskContinuous03(void)
1899 TestApplication application;
1901 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (camera actor not staged)\nPOST:continuous renders, no Finished signal");
1903 // SETUP AN OFFSCREEN RENDER TASK
1904 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1905 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1906 drawTrace.Enable(true);
1908 Actor rootActor = Actor::New();
1909 Stage::GetCurrent().Add( rootActor );
1911 CameraActor offscreenCameraActor = CameraActor::New();
1912 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
1913 Stage::GetCurrent().Add(secondRootActor);
1915 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1916 bool finished = false;
1917 RenderTaskFinished renderTaskFinished( finished );
1918 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1919 application.SendNotification();
1921 // START PROCESS/RENDER Input, Expected Input, Expected
1922 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false, __LINE__ ) );
1923 application.GetPlatform().ClearReadyResources();
1925 // ADD CAMERA ACTOR TO STAGE - expect continuous renders to start, no finished signal
1926 Stage::GetCurrent().Add( offscreenCameraActor );
1927 application.SendNotification();
1929 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1930 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
1935 int UtcDaliRenderTaskContinuous04(void)
1937 TestApplication application;
1939 tet_infoline("Testing RenderTask Render Continuous using loaded image");
1941 // SETUP AN OFFSCREEN RENDER TASK
1942 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1943 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1944 drawTrace.Enable(true);
1946 Actor rootActor = Actor::New();
1947 Stage::GetCurrent().Add( rootActor );
1949 CameraActor offscreenCameraActor = CameraActor::New();
1950 Stage::GetCurrent().Add( offscreenCameraActor );
1951 Actor secondRootActor = CreateRenderableActorFailed(application, "aFile.jpg");
1952 Stage::GetCurrent().Add(secondRootActor);
1954 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1955 bool finished = false;
1956 RenderTaskFinished renderTaskFinished( finished );
1957 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1958 application.SendNotification();
1960 // START PROCESS/RENDER Input, Expected Input, Expected
1961 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
1965 int UtcDaliRenderTaskOnce01(void)
1967 TestApplication application;
1969 tet_infoline("Testing RenderTask Render Once GlSync, using loaded image");
1971 // SETUP AN OFFSCREEN RENDER TASK
1972 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1973 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
1974 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1975 drawTrace.Enable(true);
1977 Actor rootActor = Actor::New();
1978 Stage::GetCurrent().Add( rootActor );
1980 CameraActor offscreenCameraActor = CameraActor::New();
1981 Stage::GetCurrent().Add( offscreenCameraActor );
1982 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
1984 Stage::GetCurrent().Add(secondRootActor);
1986 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
1987 bool finished = false;
1988 RenderTaskFinished renderTaskFinished( finished );
1989 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1990 application.SendNotification();
1992 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
1994 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
1995 DALI_TEST_CHECK( lastSyncObj != NULL );
1996 sync.SetObjectSynced( lastSyncObj, true );
1998 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
1999 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2003 int UtcDaliRenderTaskOnce02(void)
2005 TestApplication application;
2007 tet_infoline("Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loaded image.\n");
2009 // SETUP AN OFFSCREEN RENDER TASK
2010 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2011 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2012 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2013 drawTrace.Enable(true);
2015 Actor rootActor = Actor::New();
2016 Stage::GetCurrent().Add( rootActor );
2018 CameraActor offscreenCameraActor = CameraActor::New();
2019 Stage::GetCurrent().Add( offscreenCameraActor );
2021 Shader shader = CreateShader();
2022 Image image = CreateResourceImage(application, "aFile.jpg");
2023 TextureSet textureSet = CreateTextureSet( image );
2025 Geometry geometry = CreateQuadGeometry();
2026 Renderer renderer = Renderer::New(geometry, shader);
2027 renderer.SetTextures( textureSet );
2028 Actor secondRootActor = Actor::New();
2029 secondRootActor.AddRenderer(renderer);
2030 secondRootActor.SetSize(100, 100);
2031 Stage::GetCurrent().Add(secondRootActor);
2033 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
2034 bool finished = false;
2035 RenderTaskFinished renderTaskFinished( finished );
2036 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2037 application.SendNotification();
2039 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2041 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2042 DALI_TEST_CHECK( lastSyncObj != NULL );
2043 sync.SetObjectSynced( lastSyncObj, true );
2045 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2046 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2051 int UtcDaliRenderTaskOnce03(void)
2053 TestApplication application;
2055 tet_infoline("Testing RenderTask Render Once GlSync, using loaded image. Switch from render always after ready to render once\n");
2057 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2058 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2059 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2060 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2061 drawTrace.Enable(true);
2063 Actor rootActor = Actor::New();
2064 Stage::GetCurrent().Add( rootActor );
2066 CameraActor offscreenCameraActor = CameraActor::New();
2067 Stage::GetCurrent().Add( offscreenCameraActor );
2068 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2069 Stage::GetCurrent().Add(secondRootActor);
2071 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2072 bool finished = false;
2073 RenderTaskFinished renderTaskFinished( finished );
2074 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2075 application.SendNotification();
2077 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2079 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2080 application.SendNotification();
2082 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2084 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2085 DALI_TEST_CHECK( lastSyncObj != NULL );
2086 sync.SetObjectSynced( lastSyncObj, true );
2088 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2089 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2095 int UtcDaliRenderTaskOnce04(void)
2097 TestApplication application;
2098 tet_infoline("Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loaded image.\n"
2099 "Switch from render always after ready to render once\n"
2102 // SETUP AN OFFSCREEN RENDER TASK
2103 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2104 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2105 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2106 drawTrace.Enable(true);
2108 Actor rootActor = Actor::New();
2109 Stage::GetCurrent().Add( rootActor );
2111 CameraActor offscreenCameraActor = CameraActor::New();
2112 Stage::GetCurrent().Add( offscreenCameraActor );
2114 Shader shader = CreateShader();
2115 Image image = CreateResourceImage(application, "aFile.jpg");
2116 TextureSet textureSet = CreateTextureSet( image );
2118 Geometry geometry = CreateQuadGeometry();
2119 Renderer renderer = Renderer::New(geometry, shader);
2120 renderer.SetTextures( textureSet );
2121 Actor secondRootActor = Actor::New();
2122 secondRootActor.AddRenderer(renderer);
2123 secondRootActor.SetSize(100, 100);
2124 Stage::GetCurrent().Add(secondRootActor);
2126 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2127 bool finished = false;
2128 RenderTaskFinished renderTaskFinished( finished );
2129 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2130 application.SendNotification();
2132 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2134 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2135 application.SendNotification();
2137 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2139 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2140 DALI_TEST_CHECK( lastSyncObj != NULL );
2141 sync.SetObjectSynced( lastSyncObj, true );
2143 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2144 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2149 int UtcDaliRenderTaskOnceNoSync01(void)
2151 TestApplication application;
2153 tet_infoline("Testing RenderTask Render Once, \nPRE: Resources ready\nPOST: Finished signal sent once only");
2155 // SETUP AN OFFSCREEN RENDER TASK
2156 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2157 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2158 drawTrace.Enable(true);
2160 Actor rootActor = Actor::New();
2161 Stage::GetCurrent().Add( rootActor );
2163 CameraActor offscreenCameraActor = CameraActor::New();
2164 Stage::GetCurrent().Add( offscreenCameraActor );
2165 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2166 Stage::GetCurrent().Add(secondRootActor);
2168 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2169 bool finished = false;
2170 RenderTaskFinished renderTaskFinished( finished );
2171 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2172 application.SendNotification();
2174 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2175 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2179 int UtcDaliRenderTaskOnceNoSync02(void)
2181 TestApplication application;
2183 tet_infoline("Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loaded image.\n"
2184 "PRE: Resources ready\nPOST: Finished signal sent once only");
2185 // SETUP AN OFFSCREEN RENDER TASK
2186 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2187 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2188 drawTrace.Enable(true);
2190 Actor rootActor = Actor::New();
2191 Stage::GetCurrent().Add( rootActor );
2193 CameraActor offscreenCameraActor = CameraActor::New();
2194 Stage::GetCurrent().Add( offscreenCameraActor );
2196 Shader shader = CreateShader();
2197 Image image = CreateResourceImage(application, "aFile.jpg");
2198 TextureSet textureSet = CreateTextureSet( image );
2200 Geometry geometry = CreateQuadGeometry();
2201 Renderer renderer = Renderer::New(geometry, shader);
2202 renderer.SetTextures( textureSet );
2203 Actor secondRootActor = Actor::New();
2204 secondRootActor.AddRenderer(renderer);
2205 secondRootActor.SetSize(100, 100);
2206 Stage::GetCurrent().Add(secondRootActor);
2208 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2209 bool finished = false;
2210 RenderTaskFinished renderTaskFinished( finished );
2211 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2212 application.SendNotification();
2214 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2215 application.GetPlatform().ClearReadyResources();
2216 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2221 int UtcDaliRenderTaskOnceNoSync03(void)
2223 TestApplication application;
2225 tet_infoline("Testing RenderTask Render Once, using loaded image. Switch from render always after ready to render once\n"
2226 "PRE: Render task ready, Image loaded\n"
2227 "POST: Finished signal sent only once");
2229 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2230 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2231 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2232 drawTrace.Enable(true);
2234 Actor rootActor = Actor::New();
2235 Stage::GetCurrent().Add( rootActor );
2237 CameraActor offscreenCameraActor = CameraActor::New();
2238 Stage::GetCurrent().Add( offscreenCameraActor );
2239 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2240 Stage::GetCurrent().Add(secondRootActor);
2242 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2243 bool finished = false;
2244 RenderTaskFinished renderTaskFinished( finished );
2245 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2246 application.SendNotification();
2248 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2250 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2251 application.SendNotification(); // Input, Expected Input, Expected
2252 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2253 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2257 int UtcDaliRenderTaskOnceNoSync04(void)
2259 TestApplication application;
2261 tet_infoline("Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loading image.\n"
2262 "Switch from render always after ready to render once\n"
2263 "PRE: Render task ready, Image not loaded\n"
2264 "POST: Finished signal sent only once");
2266 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2267 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2268 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2269 drawTrace.Enable(true);
2271 Actor rootActor = Actor::New();
2272 Stage::GetCurrent().Add( rootActor );
2274 CameraActor offscreenCameraActor = CameraActor::New();
2275 Stage::GetCurrent().Add( offscreenCameraActor );
2277 Shader shader = CreateShader();
2278 Image image = CreateResourceImage(application, "aFile.jpg");
2279 TextureSet textureSet = CreateTextureSet( image );
2281 Geometry geometry = CreateQuadGeometry();
2282 Renderer renderer = Renderer::New(geometry, shader);
2283 renderer.SetTextures( textureSet );
2284 Actor secondRootActor = Actor::New();
2285 secondRootActor.AddRenderer(renderer);
2286 secondRootActor.SetSize(100, 100);
2287 Stage::GetCurrent().Add(secondRootActor);
2290 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2291 bool finished = false;
2292 RenderTaskFinished renderTaskFinished( finished );
2293 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2294 application.SendNotification();
2296 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2297 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2298 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2299 DALI_TEST_CHECK( lastSyncObj == NULL );
2301 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2302 application.SendNotification(); // Input, Expected Input, Expected
2303 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2304 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2306 lastSyncObj = sync.GetLastSyncObject();
2307 DALI_TEST_CHECK( lastSyncObj == NULL );
2312 int UtcDaliRenderTaskOnceNoSync05(void)
2314 TestApplication application;
2316 tet_infoline("Testing RenderTask Render Once\n"
2317 "SetRefreshRate(ONCE), resource load failed, completes render task.\n"
2318 "PRE: resources failed to load\n"
2319 "POST: No finished signal sent.");
2321 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2322 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2323 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2324 drawTrace.Enable(true);
2326 Actor rootActor = Actor::New();
2327 Stage::GetCurrent().Add( rootActor );
2329 CameraActor offscreenCameraActor = CameraActor::New();
2330 Stage::GetCurrent().Add( offscreenCameraActor );
2331 Actor secondRootActor = CreateRenderableActorFailed(application, "aFile.jpg");
2332 Stage::GetCurrent().Add(secondRootActor);
2334 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2335 bool finished = false;
2336 RenderTaskFinished renderTaskFinished( finished );
2337 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2338 application.SendNotification();
2340 // START PROCESS/RENDER Input, Expected Input, Expected
2341 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2343 // CHANGE TO RENDER ONCE,
2344 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2345 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2352 int UtcDaliRenderTaskOnceChain01(void)
2354 TestApplication application;
2356 tet_infoline("Testing RenderTask Render Once Chained render tasks\n"
2357 "SetRefreshRate(ONCE), resource load completes, both render tasks render.\n"
2358 "PRE: resources ready\n"
2359 "POST: 2 finished signals sent.");
2361 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2362 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2363 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2364 drawTrace.Enable(true);
2366 Actor defaultRootActor = Actor::New(); // Root for default RT
2367 Stage::GetCurrent().Add( defaultRootActor );
2369 CameraActor offscreenCameraActor = CameraActor::New();
2370 Stage::GetCurrent().Add( offscreenCameraActor );
2371 Actor firstRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2372 Stage::GetCurrent().Add(firstRootActor);
2374 // first render task
2375 RenderTask firstTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, firstRootActor, RenderTask::REFRESH_ONCE, false);
2376 bool firstFinished = false;
2377 RenderTaskFinished renderTask1Finished( firstFinished );
2378 firstTask.FinishedSignal().Connect( &application, renderTask1Finished );
2380 // Second render task
2381 FrameBufferImage fbo = firstTask.GetTargetFrameBuffer();
2382 Actor secondRootActor = CreateRenderableActor( fbo );
2383 Stage::GetCurrent().Add(secondRootActor);
2384 RenderTask secondTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2385 bool secondFinished = false;
2386 RenderTaskFinished renderTask2Finished( secondFinished );
2387 secondTask.FinishedSignal().Connect( &application, renderTask2Finished );
2389 application.SendNotification();
2391 //Both render tasks are executed.
2392 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__ ) );
2393 DALI_TEST_CHECK( firstFinished == false );
2394 DALI_TEST_CHECK( secondFinished == false );
2396 //Nothing else to render and both render task should have finished now
2397 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, firstFinished, true, false, __LINE__ ) );
2398 DALI_TEST_CHECK( firstFinished == true );
2399 DALI_TEST_CHECK( secondFinished == true );
2404 int UtcDaliRenderTaskProperties(void)
2406 TestApplication application;
2408 RenderTask task = Stage::GetCurrent().GetRenderTaskList().CreateTask();
2410 Property::IndexContainer indices;
2411 task.GetPropertyIndices( indices );
2412 DALI_TEST_CHECK( indices.Size() );
2413 DALI_TEST_EQUALS( indices.Size(), task.GetPropertyCount(), TEST_LOCATION );
2417 int UtcDaliRenderTaskSetScreenToFrameBufferMappingActor(void)
2419 TestApplication application;
2420 tet_infoline("Testing RenderTask::SetScreenToFrameBufferMappingActor ");
2422 Stage stage = Stage::GetCurrent();
2423 Size stageSize = stage.GetSize();
2424 Actor mappingActor = Actor::New();
2425 Vector2 scale( 0.6f, 0.75f);
2426 Vector2 offset( stageSize.x*0.1f, stageSize.y*0.15f);
2427 mappingActor.SetSize( stageSize * scale );
2428 mappingActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2429 mappingActor.SetPosition( offset.x, offset.y );
2430 stage.Add( mappingActor );
2432 Actor offscreenActor = Actor::New();
2433 offscreenActor.SetSize( stageSize );
2434 offscreenActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2435 stage.Add( offscreenActor );
2437 RenderTaskList taskList = stage.GetRenderTaskList();
2438 RenderTask renderTask = taskList.CreateTask();
2439 FrameBufferImage frameBufferImage = FrameBufferImage::New(stageSize.width*scale.x, stageSize.height*scale.y, Pixel::A8);
2440 renderTask.SetSourceActor( offscreenActor );
2441 renderTask.SetExclusive( true );
2442 renderTask.SetInputEnabled( true );
2443 renderTask.SetTargetFrameBuffer( frameBufferImage );
2444 renderTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
2445 renderTask.SetScreenToFrameBufferMappingActor( mappingActor );
2446 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2448 // Render and notify
2449 application.SendNotification();
2450 application.Render();
2451 application.Render();
2452 application.SendNotification();
2454 Vector2 screenCoordinates( stageSize.x * 0.05f, stageSize.y * 0.05f );
2455 Dali::HitTestAlgorithm::Results results;
2456 DALI_TEST_CHECK( !results.actor );
2457 DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
2458 // miss expected, results not changed
2459 DALI_TEST_CHECK( false == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
2460 DALI_TEST_CHECK( !results.actor );
2461 DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
2463 screenCoordinates.x = stageSize.x * 0.265f;
2464 screenCoordinates.y = stageSize.y * 0.33f;
2465 results.actor = Actor();
2466 results.actorCoordinates = Vector2::ZERO;
2467 // hit expected, results changed
2468 DALI_TEST_CHECK( true == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
2469 DALI_TEST_CHECK( results.actor == offscreenActor );
2470 DALI_TEST_EQUALS( (screenCoordinates-offset)/scale , results.actorCoordinates, 0.1f, TEST_LOCATION );
2472 screenCoordinates.x = stageSize.x * 0.435f;
2473 screenCoordinates.y = stageSize.y * 0.52f;
2474 // hit expected, results changed
2475 DALI_TEST_CHECK( true == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
2476 DALI_TEST_CHECK( results.actor == offscreenActor );
2477 const Vector2 expectedCoordinates = (screenCoordinates-offset)/scale;
2478 DALI_TEST_EQUALS( expectedCoordinates , results.actorCoordinates, 0.1f, TEST_LOCATION );
2480 screenCoordinates.x = stageSize.x * 0.65f;
2481 screenCoordinates.y = stageSize.y * 0.95f;
2482 // miss expected, results not changed
2483 DALI_TEST_CHECK( false == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
2484 DALI_TEST_CHECK( results.actor == offscreenActor );
2485 DALI_TEST_EQUALS( expectedCoordinates , results.actorCoordinates, 0.1f, TEST_LOCATION );
2489 int UtcDaliRenderTaskFinishInvisibleSourceActor(void)
2491 TestApplication application;
2493 tet_infoline("Testing RenderTask::FinishInvisibleSourceActor()");
2495 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2496 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2498 CameraActor offscreenCameraActor = CameraActor::New();
2500 Stage::GetCurrent().Add( offscreenCameraActor );
2502 BufferImage image = BufferImage::New( 10, 10 );
2503 Actor rootActor = CreateRenderableActor( image );
2504 rootActor.SetSize( 10, 10 );
2505 rootActor.SetVisible(false);
2506 Stage::GetCurrent().Add( rootActor );
2508 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
2509 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
2510 FrameBufferImage frameBufferImage = FrameBufferImage::New( *testNativeImagePtr.Get() );
2512 // Flush all outstanding messages
2513 application.SendNotification();
2514 application.Render();
2516 RenderTask newTask = taskList.CreateTask();
2517 newTask.SetCameraActor( offscreenCameraActor );
2518 newTask.SetSourceActor( rootActor );
2519 newTask.SetInputEnabled( false );
2520 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
2521 newTask.SetClearEnabled( true );
2522 newTask.SetExclusive( true );
2523 newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
2524 newTask.SetTargetFrameBuffer( frameBufferImage );
2525 newTask.SetProperty( RenderTask::Property::REQUIRES_SYNC, true );
2527 // Framebuffer doesn't actually get created until Connected, i.e. by previous line
2529 bool finished = false;
2530 RenderTaskFinished renderTaskFinished( finished );
2531 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2533 // Flush the queue and render.
2534 application.SendNotification();
2536 // 1 render to process render task, then wait for sync before finished msg is sent
2537 // from update to the event thread.
2539 application.Render();
2540 application.SendNotification();
2541 DALI_TEST_CHECK( !finished );
2543 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2544 DALI_TEST_CHECK( lastSyncObj != NULL );
2546 application.Render();
2547 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
2548 application.SendNotification();
2549 DALI_TEST_CHECK( !finished );
2551 application.Render();
2552 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
2553 application.SendNotification();
2554 DALI_TEST_CHECK( ! finished );
2556 sync.SetObjectSynced( lastSyncObj, true );
2558 application.Render();
2559 application.SendNotification();
2560 DALI_TEST_CHECK( !finished );
2562 application.Render();
2563 application.SendNotification();
2564 DALI_TEST_CHECK( finished );
2567 application.Render(); // Double check no more finished signal
2568 application.SendNotification();
2569 DALI_TEST_CHECK( ! finished );
2574 int UtcDaliRenderTaskFinishMissingImage(void)
2576 TestApplication application;
2578 // Previously we had bugs where not having a resource ID would cause render-tasks to wait forever
2579 tet_infoline("Testing RenderTask::SignalFinished() when an Actor has no Image set");
2581 Stage stage = Stage::GetCurrent();
2583 BufferImage image = BufferImage::New( 10, 10 );
2584 Actor rootActor = CreateRenderableActor( image );
2585 rootActor.SetSize( 10, 10 );
2586 stage.Add( rootActor );
2588 Actor actorWithMissingImage = CreateRenderableActor( Image() );
2589 actorWithMissingImage.SetSize( 10, 10 );
2590 stage.Add( actorWithMissingImage );
2592 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
2593 RenderTask newTask = taskList.CreateTask();
2594 newTask.SetInputEnabled( false );
2595 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
2596 newTask.SetClearEnabled( true );
2597 newTask.SetExclusive( true );
2598 newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
2600 bool finished = false;
2601 RenderTaskFinished renderTaskFinished( finished );
2602 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2604 // 1 render to process render task, then 1 before finished msg is sent from update to the event thread.
2605 application.SendNotification();
2606 application.Render();
2607 application.Render();
2609 application.SendNotification();
2610 DALI_TEST_CHECK( finished );
2615 int UtcDaliRenderTaskWorldToViewport(void)
2617 TestApplication application( static_cast<size_t>(400), static_cast<size_t>(400) ); // square surface
2619 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
2621 Actor actor = Actor::New();
2622 actor.SetSize(100.0f, 100.0f);
2623 actor.SetPosition( Vector3(0.0, 0.0, 0.0) );
2625 actor.SetParentOrigin( Vector3(0.5, 0.5, 0.5) );
2626 actor.SetAnchorPoint( Vector3(0.5, 0.5, 0.5) );
2628 Stage::GetCurrent().Add(actor);
2630 application.SendNotification();
2631 application.Render();
2632 application.SendNotification();
2634 RenderTask task = taskList.GetTask( 0u );
2636 CameraActor camera = task.GetCameraActor();
2638 Vector2 screenSize = task.GetCurrentViewportSize();
2640 float screenX = 0.0;
2641 float screenY = 0.0;
2643 bool ok = task.WorldToViewport(actor.GetCurrentWorldPosition(), screenX, screenY);
2644 DALI_TEST_CHECK(ok == true);
2646 DALI_TEST_EQUALS(screenX, screenSize.x/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
2647 DALI_TEST_EQUALS(screenY, screenSize.y/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
2649 Actor actor2 = Actor::New();
2650 float actor2Size = 100.f;
2651 actor2.SetSize( actor2Size, actor2Size );
2652 actor2.SetPosition( Vector3(0.0, 0.0, 0.0) );
2653 actor2.SetParentOrigin( Vector3(0.5, 0.5, 0.0) );
2654 actor2.SetAnchorPoint( Vector3(0.5, 0.5, 0.0) );
2655 Stage::GetCurrent().Add( actor2 );
2657 actor.SetParentOrigin( Vector3(0,0,0) );
2659 application.SendNotification();
2660 application.Render();
2661 application.SendNotification();
2663 ok = task.WorldToViewport(actor.GetCurrentWorldPosition(), screenX, screenY);
2664 DALI_TEST_CHECK(ok == true);
2666 DALI_TEST_EQUALS(screenX, screenSize.x/2 - actor2Size/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
2667 DALI_TEST_EQUALS(screenY, screenSize.y/2 - actor2Size/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
2673 int UtcDaliRenderTaskViewportToLocal(void)
2675 TestApplication application;
2676 Actor actor = Actor::New();
2677 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2678 actor.SetSize(100.0f, 100.0f);
2679 actor.SetPosition(10.0f, 10.0f);
2680 Stage::GetCurrent().Add(actor);
2682 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
2683 RenderTask task = taskList.GetTask( 0u );
2685 // flush the queue and render once
2686 application.SendNotification();
2687 application.Render();
2688 application.SendNotification();
2689 application.Render();
2697 float screenX = 50.0f;
2698 float screenY = 50.0f;
2700 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, screenX, screenY) );
2702 DALI_TEST_CHECK( task.ViewportToLocal(actor, screenX, screenY, rtLocalX, rtLocalY ) );
2704 DALI_TEST_EQUALS(localX, rtLocalX, 0.01f, TEST_LOCATION);
2705 DALI_TEST_EQUALS(localY, rtLocalY, 0.01f, TEST_LOCATION);