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 CreateLoadingActor(TestApplication& application, std::string filename)
174 Image image = ResourceImage::New(filename);
175 DALI_TEST_CHECK( image );
176 application.SendNotification();
177 application.Render(16);
178 DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
179 Actor actor = CreateRenderableActor(image);
180 actor.SetSize( 80, 80 );
181 application.SendNotification();
182 application.Render(16);
186 Image CreateLoadingImage(TestApplication& application, std::string filename)
188 Image image = ResourceImage::New(filename);
189 DALI_TEST_CHECK( image );
190 application.SendNotification();
191 application.Render(16);
192 DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
197 void CompleteImageLoad(TestApplication& application, Integration::ResourceId resourceId, Integration::ResourceTypeId requestType)
199 std::vector<GLuint> ids;
201 application.GetGlAbstraction().SetNextTextureIds( ids );
203 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
204 Integration::ResourcePointer resource(bitmap);
205 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80);
207 application.GetPlatform().SetResourceLoaded(resourceId, requestType, resource);
210 void FailImageLoad(TestApplication& application, Integration::ResourceId resourceId )
212 application.GetPlatform().SetResourceLoadFailed(resourceId, Integration::FailureUnknown);
215 RenderTask CreateRenderTask(TestApplication& application,
216 CameraActor offscreenCamera,
217 Actor rootActor, // Reset default render task to point at this actor
218 Actor secondRootActor, // Source actor
219 unsigned int refreshRate,
222 // Change main render task to use a different root
223 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
224 taskList.GetTask(0u).SetSourceActor( rootActor );
226 FrameBufferImage frameBufferImage;
229 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
230 frameBufferImage= FrameBufferImage::New( *(testNativeImagePtr.Get()) );
234 frameBufferImage = FrameBufferImage::New( 10, 10 );
237 // Don't draw output framebuffer // '
239 RenderTask newTask = taskList.CreateTask();
240 newTask.SetCameraActor( offscreenCamera );
241 newTask.SetSourceActor( secondRootActor );
242 newTask.SetInputEnabled( false );
243 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
244 newTask.SetClearEnabled( true );
245 newTask.SetExclusive( true );
246 newTask.SetRefreshRate( refreshRate );
247 newTask.SetTargetFrameBuffer( frameBufferImage );
248 newTask.SetProperty( RenderTask::Property::REQUIRES_SYNC, glSync );
252 bool UpdateRender(TestApplication& application, TraceCallStack& callStack, bool testDrawn, bool& finishedSig, bool testFinished, bool testKeepUpdating, int lineNumber )
257 tet_printf("TestApplication::UpdateRender().\n");
259 application.Render(16);
260 application.SendNotification();
262 bool sigPassed = false;
265 sigPassed = finishedSig;
269 sigPassed = ! finishedSig;
272 bool drawResult = callStack.FindMethod("DrawElements") || callStack.FindMethod("DrawArrays");
274 bool drawPassed = false;
277 drawPassed = drawResult;
281 drawPassed = !drawResult;
284 bool keepUpdating = (application.GetUpdateStatus() != 0);
285 bool keepUpdatingPassed = false;
286 if( testKeepUpdating )
288 keepUpdatingPassed = keepUpdating;
292 keepUpdatingPassed = !keepUpdating;
295 bool result = (sigPassed && drawPassed && keepUpdatingPassed);
297 tet_printf("UpdateRender: Expected: Draw:%s Signal:%s KeepUpdating: %s Actual: Draw:%s Signal:%s KeepUpdating: %s %s, line %d\n",
298 BOOLSTR(testDrawn), BOOLSTR(testFinished), BOOLSTR(testKeepUpdating),
299 BOOLSTR(drawResult), BOOLSTR(finishedSig), BOOLSTR(keepUpdating),
300 result ? "Passed":"Failed",
306 // The functor to be used in the hit-test algorithm to check whether the actor is hittable.
307 bool IsActorHittableFunction(Actor actor, Dali::HitTestAlgorithm::TraverseType type)
309 bool hittable = false;
313 case Dali::HitTestAlgorithm::CHECK_ACTOR:
315 // Check whether the actor is visible and not fully transparent.
316 if( actor.IsVisible()
317 && actor.GetCurrentWorldColor().a > 0.01f) // not FULLY_TRANSPARENT
324 case Dali::HitTestAlgorithm::DESCEND_ACTOR_TREE:
326 if( actor.IsVisible() ) // Actor is visible, if not visible then none of its children are visible.
341 } // unnamed namespace
344 /****************************************************************************************************/
345 /****************************************************************************************************/
346 /******************************** TEST CASES BELOW **********************************************/
347 /****************************************************************************************************/
348 /****************************************************************************************************/
350 int UtcDaliRenderTaskDownCast01(void)
352 TestApplication application;
354 tet_infoline("Testing RenderTask::DownCast()");
356 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
358 BaseHandle base = taskList.GetTask( 0u );
359 DALI_TEST_CHECK( base );
361 RenderTask task = RenderTask::DownCast( base );
362 DALI_TEST_CHECK( task );
364 // Try calling a method
365 DALI_TEST_CHECK( task.GetSourceActor() );
369 int UtcDaliRenderTaskDownCast02(void)
371 TestApplication application;
373 tet_infoline("Testing RenderTask::DownCast()");
375 Actor actor = Actor::New();
377 RenderTask task = RenderTask::DownCast( actor );
378 DALI_TEST_CHECK( ! task );
383 int UtcDaliRenderTaskSetSourceActorN(void)
385 TestApplication application;
386 tet_infoline("Testing RenderTask::SetSourceActor() Negative - try with empty actor handle");
387 Stage stage = Stage::GetCurrent();
391 RenderTaskList taskList = stage.GetRenderTaskList();
392 RenderTask renderTask = taskList.CreateTask();
393 renderTask.SetSourceActor(srcActor);
395 application.SendNotification();
396 application.Render();
398 DALI_TEST_CHECK( ! renderTask.GetSourceActor() );
403 int UtcDaliRenderTaskSetSourceActorP01(void)
405 TestApplication application;
407 tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that setting a non-renderable actor stops existing source actor being rendered ");
409 Stage stage = Stage::GetCurrent();
411 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
413 RenderTaskList taskList = stage.GetRenderTaskList();
415 RenderTask task = taskList.GetTask( 0u );
417 Actor actor = task.GetSourceActor();
418 DALI_TEST_CHECK( actor );
420 std::vector<GLuint> ids;
422 application.GetGlAbstraction().SetNextTextureIds( ids );
424 BufferImage img = BufferImage::New( 1,1 );
425 Actor newActor = CreateRenderableActor( img );
426 newActor.SetSize(1,1);
427 stage.Add( newActor );
429 Actor nonRenderableActor = Actor::New();
430 stage.Add( nonRenderableActor );
432 // Stop the newActor from being rendered by changing the source actor
433 DALI_TEST_CHECK( nonRenderableActor );
434 task.SetSourceActor( nonRenderableActor );
435 DALI_TEST_CHECK( task.GetSourceActor() != actor );
436 DALI_TEST_CHECK( task.GetSourceActor() == nonRenderableActor );
438 // Update & Render nothing!
439 application.GetGlAbstraction().ClearBoundTextures();
440 application.SendNotification();
441 application.Render();
443 // Check that nothing was rendered
444 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
450 int UtcDaliRenderTaskSetSourceActorP02(void)
452 TestApplication application;
454 tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that switching source from a non-renderable to a renderable actor causes the texture to be drawn");
456 Stage stage = Stage::GetCurrent();
458 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
460 RenderTaskList taskList = stage.GetRenderTaskList();
462 RenderTask task = taskList.GetTask( 0u );
464 Actor actor = task.GetSourceActor();
465 DALI_TEST_CHECK( actor );
467 std::vector<GLuint> ids;
469 application.GetGlAbstraction().SetNextTextureIds( ids );
471 BufferImage img = BufferImage::New( 1,1 );
472 Actor newActor = CreateRenderableActor( img );
473 newActor.SetSize(1,1);
474 stage.Add( newActor );
476 Actor nonRenderableActor = Actor::New();
477 stage.Add( nonRenderableActor );
479 // Stop the newActor from being rendered by changing the source actor
480 DALI_TEST_CHECK( nonRenderableActor );
481 task.SetSourceActor( nonRenderableActor );
482 DALI_TEST_CHECK( task.GetSourceActor() != actor );
483 DALI_TEST_CHECK( task.GetSourceActor() == nonRenderableActor );
485 // Update & Render nothing!
486 application.GetGlAbstraction().ClearBoundTextures();
487 application.SendNotification();
488 application.Render();
490 // Check that nothing was rendered
491 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
493 // Set newActor as the new source Actor
494 task.SetSourceActor( newActor );
495 DALI_TEST_CHECK( task.GetSourceActor() != actor );
496 DALI_TEST_CHECK( task.GetSourceActor() == newActor );
498 // Update & Render the newActor
499 application.GetGlAbstraction().ClearBoundTextures();
500 application.SendNotification();
501 application.Render();
503 // Check that the newActor was rendered
504 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
505 if ( boundTextures.size() )
507 DALI_TEST_EQUALS( boundTextures[0], 7u, TEST_LOCATION );
512 int UtcDaliRenderTaskSetSourceActorOffStage(void)
514 TestApplication application;
516 tet_infoline("Testing RenderTask::SetSourceActor (on/off stage testing)");
518 Stage stage = Stage::GetCurrent();
520 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
522 RenderTaskList taskList = stage.GetRenderTaskList();
524 RenderTask task = taskList.GetTask( 0u );
526 Actor actor = task.GetSourceActor();
527 DALI_TEST_CHECK( actor );
529 std::vector<GLuint> ids;
530 GLuint expectedTextureId( 3 );
531 ids.push_back( expectedTextureId );
532 application.GetGlAbstraction().SetNextTextureIds( ids );
534 BufferImage img = BufferImage::New( 1,1 );
535 Actor newActor = CreateRenderableActor( img );
536 newActor.SetSize(1,1);
537 task.SetSourceActor( newActor );
538 // Don't add newActor to stage yet //'
540 // Update & Render with the actor initially off-stage
541 application.GetGlAbstraction().ClearBoundTextures();
542 application.SendNotification();
543 application.Render();
545 // Check that nothing was rendered
546 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
549 stage.Add( newActor );
551 // Update & Render with the actor on-stage
552 application.GetGlAbstraction().ClearBoundTextures();
553 application.SendNotification();
554 application.Render();
556 // Check that the newActor was rendered
557 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
558 if ( boundTextures.size() )
560 DALI_TEST_EQUALS( boundTextures[0], expectedTextureId, TEST_LOCATION );
563 // Now remove from stage
564 stage.Remove( newActor );
566 // Update & Render with the actor off-stage
567 application.GetGlAbstraction().ClearBoundTextures();
568 application.SendNotification();
569 application.Render();
573 int UtcDaliRenderTaskSetSourceActorEmpty(void)
575 TestApplication application;
577 tet_infoline("Testing RenderTask::SetSourceActor (empty handle case)");
579 Stage stage = Stage::GetCurrent();
581 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
583 RenderTaskList taskList = stage.GetRenderTaskList();
585 RenderTask task = taskList.GetTask( 0u );
587 Actor actor = task.GetSourceActor();
588 DALI_TEST_CHECK( actor );
590 std::vector<GLuint> ids;
591 GLuint expectedTextureId( 5 );
592 ids.push_back( expectedTextureId );
593 application.GetGlAbstraction().SetNextTextureIds( ids );
595 BufferImage img = BufferImage::New( 1,1 );
596 Actor newActor = CreateRenderableActor( img );
597 newActor.SetSize(1,1);
598 stage.Add( newActor );
600 Actor nonRenderableActor = Actor::New();
601 stage.Add( nonRenderableActor );
603 // Set with empty handle
604 task.SetSourceActor( Actor() );
605 DALI_TEST_CHECK( ! task.GetSourceActor() );
607 // Update & Render nothing!
608 application.GetGlAbstraction().ClearBoundTextures();
609 application.SendNotification();
610 application.Render();
612 // Check that nothing was rendered
613 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
615 // Set with non-empty handle
616 task.SetSourceActor( newActor );
617 DALI_TEST_CHECK( task.GetSourceActor() == newActor );
619 // Update & Render the newActor
620 application.GetGlAbstraction().ClearBoundTextures();
621 application.SendNotification();
622 application.Render();
624 // Check that the newActor was rendered
625 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
626 if ( boundTextures.size() )
628 DALI_TEST_EQUALS( boundTextures[0], expectedTextureId, TEST_LOCATION );
633 int UtcDaliRenderTaskGetSourceActorP01(void)
635 TestApplication application;
637 tet_infoline("Testing RenderTask::GetSourceActor() Check the default render task has a valid source actor");
639 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
641 RenderTask task = taskList.GetTask( 0u );
643 Actor actor = task.GetSourceActor();
644 DALI_TEST_CHECK( actor );
646 // By default the entire scene should be rendered
647 Actor root = Stage::GetCurrent().GetLayer( 0 );
648 DALI_TEST_CHECK( root == actor );
652 int UtcDaliRenderTaskGetSourceActorP02(void)
654 TestApplication application;
656 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.");
658 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
659 RenderTask task = taskList.CreateTask();
660 Actor actor = Actor::New();
661 Stage::GetCurrent().Add(actor);
662 task.SetSourceActor( actor );
664 DALI_TEST_EQUALS( actor, task.GetSourceActor(), TEST_LOCATION );
669 int UtcDaliRenderTaskGetSourceActorN(void)
671 TestApplication application;
673 tet_infoline("Testing RenderTask::GetSourceActor() Try with empty handle");
678 Actor actor = task.GetSourceActor();
680 catch (Dali::DaliException& e)
682 DALI_TEST_PRINT_ASSERT( e );
683 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
689 int UtcDaliRenderTaskSetExclusive(void)
691 TestApplication application;
693 tet_infoline("Testing RenderTask::SetExclusive() Check that exclusion works");
695 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
697 // Manipulate the GenTextures behaviour, to identify different actors
699 std::vector<GLuint> ids;
700 ids.push_back( 8 ); // 8 = actor1
701 ids.push_back( 9 ); // 9 = actor2
702 ids.push_back( 10 ); // 10 = actor3
703 application.GetGlAbstraction().SetNextTextureIds( ids );
705 BufferImage img1 = BufferImage::New( 1,1 );
706 Actor actor1 = CreateRenderableActor( img1 );
708 Stage::GetCurrent().Add( actor1 );
710 // Update & Render actor1
711 application.SendNotification();
712 application.Render();
714 // Check that the actor1 was rendered
715 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
716 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
718 if ( boundTextures.size() )
720 DALI_TEST_EQUALS( boundTextures[0], 8u/*unique to actor1*/, TEST_LOCATION );
723 BufferImage img2 = BufferImage::New( 1,1 );
724 Actor actor2 = CreateRenderableActor( img2 );
727 // Force actor2 to be rendered before actor1
728 Layer layer = Layer::New();
729 Stage::GetCurrent().Add( layer );
731 layer.LowerToBottom();
734 application.GetGlAbstraction().ClearBoundTextures();
735 application.SendNotification();
736 application.Render();
738 // Check that the actors were rendered
739 DALI_TEST_EQUALS( boundTextures.size(), 2u, TEST_LOCATION );
741 if ( boundTextures.size() )
743 DALI_TEST_EQUALS( boundTextures[0], 9u/*unique to actor2*/, TEST_LOCATION );
744 DALI_TEST_EQUALS( boundTextures[1], 8u/*unique to actor1*/, TEST_LOCATION );
747 BufferImage img3 = BufferImage::New( 1,1 );
748 Actor actor3 = CreateRenderableActor( img3 );
751 // Force actor3 to be rendered before actor2
752 layer = Layer::New();
753 Stage::GetCurrent().Add( layer );
755 layer.LowerToBottom();
757 // Update & Render all actors
758 application.GetGlAbstraction().ClearBoundTextures();
759 application.SendNotification();
760 application.Render();
762 // Check that the actors were rendered
763 DALI_TEST_EQUALS( boundTextures.size(), 3u, TEST_LOCATION );
765 if ( boundTextures.size() )
767 DALI_TEST_EQUALS( boundTextures[0], 10u/*unique to actor3*/, TEST_LOCATION );
768 DALI_TEST_EQUALS( boundTextures[1], 9u/*unique to actor2*/, TEST_LOCATION );
769 DALI_TEST_EQUALS( boundTextures[2], 8u/*unique to actor1*/, TEST_LOCATION );
772 // Both actors are now connected to the root node
773 // Setup 2 render-tasks - the first will render from the root-node, and the second from actor2
775 // Not exclusive is the default
776 RenderTask task1 = taskList.GetTask( 0u );
777 DALI_TEST_CHECK( false == task1.IsExclusive() );
779 RenderTask task2 = taskList.CreateTask();
780 DALI_TEST_CHECK( false == task2.IsExclusive() );
781 task2.SetSourceActor( actor2 );
783 // Task1 should render all actors, and task 2 should render only actor2
785 application.GetGlAbstraction().ClearBoundTextures();
786 application.SendNotification();
787 application.Render();
789 DALI_TEST_EQUALS( boundTextures.size(), 4u, TEST_LOCATION );
791 if ( boundTextures.size() == 4 )
793 // Test that task 1 renders actor3, then actor2 & then actor1
794 DALI_TEST_CHECK( boundTextures[0] == 10u );
795 DALI_TEST_CHECK( boundTextures[1] == 9u );
796 DALI_TEST_CHECK( boundTextures[2] == 8u );
798 // Test that task 2 renders actor2
799 DALI_TEST_EQUALS( boundTextures[3], 9u, TEST_LOCATION );
802 // Make actor2 exclusive to task2
804 task2.SetExclusive( true );
805 DALI_TEST_CHECK( true == task2.IsExclusive() );
807 // Task1 should render only actor1, and task 2 should render only actor2
809 application.GetGlAbstraction().ClearBoundTextures();
810 application.SendNotification();
811 application.Render();
813 DALI_TEST_EQUALS( boundTextures.size(), 3u, TEST_LOCATION );
814 if ( boundTextures.size() == 3 )
816 // Test that task 1 renders actor3 & actor1
817 DALI_TEST_CHECK( boundTextures[0] == 10u );
818 DALI_TEST_CHECK( boundTextures[1] == 8u );
820 // Test that task 2 renders actor2
821 DALI_TEST_CHECK( boundTextures[2] == 9u );
826 int UtcDaliRenderTaskSetExclusive02(void)
828 TestApplication application;
830 tet_infoline("Testing RenderTask::SetExclusive() Check that changing from exclusive to not-exclusive works");
832 std::vector<GLuint> ids;
833 ids.push_back( 8 ); // 8 = actor1
834 application.GetGlAbstraction().SetNextTextureIds( ids );
836 BufferImage img1 = BufferImage::New( 1,1 );
837 Actor actor1 = CreateRenderableActor( img1 );
839 Stage::GetCurrent().Add( actor1 );
841 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
842 RenderTask task = taskList.CreateTask();
844 task.SetSourceActor( actor1 );
845 task.SetExclusive(true); // Actor should only render once
847 TestGlAbstraction& gl = application.GetGlAbstraction();
848 TraceCallStack& drawTrace = gl.GetDrawTrace();
849 drawTrace.Enable(true);
851 // Update & Render actor1
852 application.SendNotification();
853 application.Render();
855 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION );
857 // Set task to non-exclusive - actor1 should render twice:
859 task.SetExclusive(false);
860 application.SendNotification();
861 application.Render();
863 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 2, TEST_LOCATION );
868 int UtcDaliRenderTaskSetExclusiveN(void)
870 TestApplication application;
872 tet_infoline("Testing RenderTask::SetExclusive() on empty handle");
877 task.SetExclusive(true);
879 catch (Dali::DaliException& e)
881 DALI_TEST_PRINT_ASSERT( e );
882 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
887 int UtcDaliRenderTaskIsExclusive01(void)
889 TestApplication application;
891 tet_infoline("Testing RenderTask::IsExclusive() Check default values are non-exclusive");
893 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
895 // Not exclusive is the default
896 RenderTask task = taskList.GetTask( 0u );
897 DALI_TEST_CHECK( false == task.IsExclusive() );
899 RenderTask newTask = taskList.CreateTask();
900 DALI_TEST_CHECK( false == newTask.IsExclusive() );
905 int UtcDaliRenderTaskIsExclusive02(void)
907 TestApplication application;
909 tet_infoline("Testing RenderTask::IsExclusive() Check the getter returns set values");
911 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
913 // Not exclusive is the default
914 RenderTask newTask = taskList.CreateTask();
915 DALI_TEST_EQUALS( newTask.IsExclusive(), false, TEST_LOCATION );
917 newTask.SetExclusive(true);
918 DALI_TEST_EQUALS( newTask.IsExclusive(), true, TEST_LOCATION );
922 int UtcDaliRenderTaskIsExclusiveN(void)
924 TestApplication application;
926 tet_infoline("Testing RenderTask::IsExclusive() on empty handle");
931 bool x = task.IsExclusive();
934 catch (Dali::DaliException& e)
936 DALI_TEST_PRINT_ASSERT( e );
937 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
942 int UtcDaliRenderTaskSetInputEnabled(void)
944 TestApplication application;
946 tet_infoline("Testing RenderTask::SetInputEnabled()");
948 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
950 // Input is enabled by default
951 RenderTask task = taskList.GetTask( 0u );
952 DALI_TEST_CHECK( true == task.GetInputEnabled() );
954 task.SetInputEnabled( false );
955 DALI_TEST_CHECK( false == task.GetInputEnabled() );
957 task.SetInputEnabled( true );
958 DALI_TEST_CHECK( true == task.GetInputEnabled() );
962 int UtcDaliRenderTaskGetInputEnabled(void)
964 TestApplication application;
966 tet_infoline("Testing RenderTask::GetInputEnabled()");
968 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
970 // Input is enabled by default
971 RenderTask task = taskList.GetTask( 0u );
972 DALI_TEST_EQUALS( true, task.GetInputEnabled(), TEST_LOCATION );
974 RenderTask newTask = taskList.CreateTask();
975 DALI_TEST_EQUALS( true, newTask.GetInputEnabled(), TEST_LOCATION );
977 newTask.SetInputEnabled(false);
978 DALI_TEST_EQUALS( false, newTask.GetInputEnabled(), TEST_LOCATION );
983 int UtcDaliRenderTaskSetCameraActorP(void)
985 TestApplication application;
987 tet_infoline("Testing RenderTask::SetCameraActor()");
989 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
991 RenderTask task = taskList.GetTask( 0u );
993 Actor defaultCameraActor = task.GetCameraActor();
994 DALI_TEST_CHECK( defaultCameraActor );
996 CameraActor newCameraActor = CameraActor::New();
997 DALI_TEST_CHECK( newCameraActor );
999 task.SetCameraActor( newCameraActor );
1000 DALI_TEST_CHECK( task.GetCameraActor() != defaultCameraActor );
1001 DALI_TEST_EQUALS( task.GetCameraActor(), newCameraActor, TEST_LOCATION );
1006 int UtcDaliRenderTaskSetCameraActorN(void)
1008 TestApplication application;
1010 tet_infoline("Testing RenderTask::SetCameraActor() with empty actor handle");
1012 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1014 RenderTask task = taskList.GetTask( 0u );
1016 Actor actor = task.GetCameraActor();
1017 DALI_TEST_CHECK( actor );
1019 CameraActor cameraActor;
1021 task.SetCameraActor( cameraActor );
1022 DALI_TEST_EQUALS( (bool)task.GetCameraActor(), false, TEST_LOCATION );
1023 DALI_TEST_EQUALS( task.GetCameraActor(), cameraActor, TEST_LOCATION );
1028 int UtcDaliRenderTaskGetCameraActorP(void)
1030 TestApplication application;
1032 tet_infoline("Testing RenderTask::GetCameraActor()");
1034 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1036 RenderTask task = taskList.GetTask( 0u );
1038 CameraActor actor = task.GetCameraActor();
1039 DALI_TEST_CHECK( actor );
1040 DALI_TEST_EQUALS( actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION );
1041 DALI_TEST_GREATER( actor.GetFieldOfView(), 0.0f, TEST_LOCATION );
1045 int UtcDaliRenderTaskGetCameraActorN(void)
1047 TestApplication application;
1049 tet_infoline("Testing RenderTask::GetCameraActor() with empty handle");
1054 Actor actor = task.GetCameraActor();
1056 catch (Dali::DaliException& e)
1058 DALI_TEST_PRINT_ASSERT( e );
1059 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1065 int UtcDaliRenderTaskSetTargetFrameBufferP(void)
1067 TestApplication application;
1069 tet_infoline("Testing RenderTask::SetTargetFrameBuffer()");
1071 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1073 RenderTask task = taskList.GetTask( 0u );
1075 FrameBufferImage newImage = FrameBufferImage::New();
1076 task.SetTargetFrameBuffer( newImage );
1077 DALI_TEST_CHECK( task.GetTargetFrameBuffer() == newImage );
1081 int UtcDaliRenderTaskSetTargetFrameBufferN(void)
1083 TestApplication application;
1085 tet_infoline("Testing RenderTask::SetTargetFrameBuffer()");
1087 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1089 RenderTask task = taskList.GetTask( 0u );
1090 FrameBufferImage newImage; // Empty handle
1091 task.SetTargetFrameBuffer( newImage );
1092 DALI_TEST_EQUALS( (bool)task.GetTargetFrameBuffer(), false, TEST_LOCATION );
1096 int UtcDaliRenderTaskGetTargetFrameBufferP(void)
1098 TestApplication application;
1100 tet_infoline("Testing RenderTask::GetTargetFrameBuffer()");
1102 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1104 RenderTask newTask = taskList.CreateTask();
1105 FrameBufferImage fb = FrameBufferImage::New(128, 128, Pixel::RGBA8888);
1106 newTask.SetTargetFrameBuffer( fb );
1107 DALI_TEST_EQUALS( newTask.GetTargetFrameBuffer(), fb, TEST_LOCATION );
1111 int UtcDaliRenderTaskGetTargetFrameBufferN(void)
1113 TestApplication application;
1115 tet_infoline("Testing RenderTask::GetTargetFrameBuffer()");
1117 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1119 RenderTask task = taskList.GetTask( 0u );
1121 // By default render-tasks do not render off-screen
1122 FrameBufferImage image = task.GetTargetFrameBuffer();
1123 DALI_TEST_CHECK( !image );
1128 int UtcDaliRenderTaskSetFrameBufferP(void)
1130 TestApplication application;
1132 tet_infoline("Testing RenderTask::SetFrameBuffer()");
1134 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1136 RenderTask task = taskList.GetTask( 0u );
1138 FrameBuffer newFrameBuffer = FrameBuffer::New( 128u, 128u, FrameBuffer::Attachment::NONE );
1139 task.SetFrameBuffer( newFrameBuffer );
1140 DALI_TEST_CHECK( task.GetFrameBuffer() == newFrameBuffer );
1144 int UtcDaliRenderTaskSetFrameBufferN(void)
1146 TestApplication application;
1148 tet_infoline("Testing RenderTask::SetFrameBuffer()");
1150 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1152 RenderTask task = taskList.GetTask( 0u );
1153 FrameBuffer newFrameBuffer; // Empty handle
1154 task.SetFrameBuffer( newFrameBuffer );
1155 DALI_TEST_EQUALS( (bool)task.GetFrameBuffer(), false, TEST_LOCATION );
1159 int UtcDaliRenderTaskGetFrameBufferP(void)
1161 TestApplication application;
1163 tet_infoline("Testing RenderTask::GetFrameBuffer()");
1165 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1167 RenderTask task = taskList.GetTask( 0u );
1169 FrameBuffer newFrameBuffer = FrameBuffer::New( 1u, 1u, FrameBuffer::Attachment::NONE );
1170 task.SetFrameBuffer( newFrameBuffer );
1171 DALI_TEST_CHECK( task.GetFrameBuffer() == newFrameBuffer );
1175 int UtcDaliRenderTaskGetFrameBufferN(void)
1177 TestApplication application;
1179 tet_infoline("Testing RenderTask::GetFrameBuffer()");
1181 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1183 RenderTask task = taskList.GetTask( 0u );
1185 // By default render-tasks do not render off-screen
1186 FrameBuffer frameBuffer = task.GetFrameBuffer();
1187 DALI_TEST_CHECK( !frameBuffer );
1192 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionP(void)
1194 TestApplication application;
1196 tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1198 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1200 RenderTask task = taskList.GetTask( 0u );
1202 task.SetScreenToFrameBufferFunction( TestScreenToFrameBufferFunction );
1204 Vector2 coordinates( 5, 10 );
1205 Vector2 convertedCoordinates( 6, 12 ); // + Vector(1, 2)
1207 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1208 DALI_TEST_CHECK( func( coordinates ) );
1209 DALI_TEST_CHECK( coordinates == convertedCoordinates );
1211 task.SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
1212 func = task.GetScreenToFrameBufferFunction();
1213 DALI_TEST_CHECK( func( coordinates ) );
1215 task.SetScreenToFrameBufferFunction( RenderTask::DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION );
1216 func = task.GetScreenToFrameBufferFunction();
1217 DALI_TEST_CHECK( ! func( coordinates ) );
1221 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionN(void)
1223 TestApplication application;
1225 tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1227 RenderTask task; // Empty handle
1230 task.SetScreenToFrameBufferFunction( TestScreenToFrameBufferFunction );
1232 catch (Dali::DaliException& e)
1234 DALI_TEST_PRINT_ASSERT( e );
1235 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1240 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionP(void)
1242 TestApplication application;
1244 tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction()");
1246 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1248 RenderTask task = taskList.GetTask( 0u );
1250 Vector2 originalCoordinates( 5, 10 );
1251 Vector2 coordinates( 5, 10 );
1253 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1254 DALI_TEST_CHECK( !func( coordinates ) ); // conversion should fail by default
1255 DALI_TEST_CHECK( coordinates == originalCoordinates ); // coordinates should not be modified
1259 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionN(void)
1261 TestApplication application;
1263 tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction() on empty handle");
1268 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1271 catch (Dali::DaliException& e)
1273 DALI_TEST_PRINT_ASSERT( e );
1274 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1280 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorP(void)
1282 TestApplication application;
1283 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor ");
1285 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1286 RenderTask renderTask = taskList.CreateTask();
1287 Actor mappingActor = Actor::New();
1288 renderTask.SetScreenToFrameBufferMappingActor(mappingActor);
1290 DALI_TEST_EQUALS( mappingActor, renderTask.GetScreenToFrameBufferMappingActor(), TEST_LOCATION );
1295 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorN(void)
1297 TestApplication application;
1298 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1304 task.SetScreenToFrameBufferMappingActor(mappingActor);
1306 catch (Dali::DaliException& e)
1308 DALI_TEST_PRINT_ASSERT( e );
1309 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1314 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActor02N(void)
1316 TestApplication application;
1317 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1319 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1320 RenderTask renderTask = taskList.CreateTask();
1322 renderTask.SetScreenToFrameBufferMappingActor(actor);
1324 DALI_TEST_EQUALS( (bool)renderTask.GetScreenToFrameBufferMappingActor(), false, TEST_LOCATION);
1328 int UtcDaliRenderTaskGetViewportP01(void)
1330 TestApplication application;
1332 tet_infoline("Testing RenderTask::GetViewport() on default task");
1334 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1335 RenderTask task = taskList.GetTask( 0u );
1336 Viewport viewport = task.GetViewport();
1338 // By default the viewport should match the stage width/height
1339 Vector2 stageSize = Stage::GetCurrent().GetSize();
1340 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1341 DALI_TEST_CHECK( viewport == expectedViewport );
1345 int UtcDaliRenderTaskGetViewportP02(void)
1347 TestApplication application;
1349 tet_infoline("Testing RenderTask::GetViewport() on new task");
1351 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1352 RenderTask task = taskList.CreateTask();
1353 Viewport viewport = task.GetViewport();
1355 // By default the viewport should match the stage width/height
1356 Vector2 stageSize = Stage::GetCurrent().GetSize();
1357 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1358 DALI_TEST_CHECK( viewport == expectedViewport );
1362 int UtcDaliRenderTaskGetViewportN(void)
1364 TestApplication application;
1366 tet_infoline("Testing RenderTask::GetViewport() on empty handle");
1371 Viewport viewport = task.GetViewport();
1374 catch (Dali::DaliException& e)
1376 DALI_TEST_PRINT_ASSERT( e );
1377 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1383 int UtcDaliRenderTaskSetViewportP(void)
1385 TestApplication application;
1387 tet_infoline("Testing RenderTask::SetViewport()");
1389 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1391 RenderTask task = taskList.GetTask( 0u );
1392 Vector2 stageSize = Stage::GetCurrent().GetSize();
1393 Viewport newViewport( 0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f );
1394 task.SetViewport( newViewport );
1396 // Update (viewport is a property)
1397 application.SendNotification();
1398 application.Render();
1400 DALI_TEST_CHECK( task.GetViewport() == newViewport );
1404 int UtcDaliRenderTaskSetViewportN(void)
1406 TestApplication application;
1408 tet_infoline("Testing RenderTask::SetViewport()");
1410 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1415 Vector2 stageSize = Stage::GetCurrent().GetSize();
1416 Viewport newViewport( 0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f );
1417 task.SetViewport( newViewport );
1419 catch (Dali::DaliException& e)
1421 DALI_TEST_PRINT_ASSERT( e );
1422 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1429 int UtcDaliRenderTaskSetViewportPosition(void)
1431 TestApplication application;
1433 tet_infoline("Testing RenderTask::SetViewportPosition()");
1435 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1437 RenderTask task = taskList.GetTask( 0u );
1439 Viewport viewport = task.GetViewport();
1441 // By default the viewport should match the stage width/height
1443 Vector2 stageSize = Stage::GetCurrent().GetSize();
1444 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1445 DALI_TEST_CHECK( viewport == expectedViewport );
1448 Vector2 newPosition(25.0f, 50.0f);
1449 task.SetViewportPosition( newPosition );
1451 // Update (viewport is a property)
1452 application.SendNotification();
1453 application.Render();
1455 DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1457 // Set by Property test
1458 Vector2 newPosition2(32.0f, 32.0f);
1459 task.SetProperty( RenderTask::Property::VIEWPORT_POSITION, newPosition2 );
1462 application.SendNotification();
1463 application.Render();
1465 DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition2, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1467 Vector2 newPosition3(64.0f, 0.0f);
1468 Animation animation = Animation::New(1.0f);
1469 animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_POSITION ), newPosition3, AlphaFunction::LINEAR );
1472 // Perform 1000ms worth of updates at which point animation should have completed.
1473 Wait(application, 1000);
1474 DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1478 int UtcDaliRenderTaskSetViewportSize(void)
1480 TestApplication application;
1482 tet_infoline("Testing RenderTask::SetViewportSize()");
1484 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1486 RenderTask task = taskList.GetTask( 0u );
1488 Viewport viewport = task.GetViewport();
1490 // By default the viewport should match the stage width/height
1492 Vector2 stageSize = Stage::GetCurrent().GetSize();
1493 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1494 DALI_TEST_CHECK( viewport == expectedViewport );
1496 Vector2 newSize(128.0f, 64.0f);
1497 task.SetViewportSize( newSize );
1499 // Update (viewport is a property)
1500 application.SendNotification();
1501 application.Render();
1503 DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1505 // Set by Property test
1506 Vector2 newSize2(50.0f, 50.0f);
1507 task.SetProperty( RenderTask::Property::VIEWPORT_SIZE, newSize2 );
1510 application.SendNotification();
1511 application.Render();
1513 DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize2, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1515 Vector2 newSize3(10.0f, 10.0f);
1516 Animation animation = Animation::New(1.0f);
1517 animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_SIZE ), newSize3, AlphaFunction::LINEAR );
1520 // Perform 1000ms worth of updates at which point animation should have completed.
1521 Wait(application, 1000);
1522 DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1527 int UtcDaliRenderTaskSetClearColorP(void)
1529 TestApplication application;
1531 tet_infoline("Testing RenderTask::SetClearColor()");
1533 Vector4 testColor( 1.0f, 2.0f, 3.0f, 4.0f );
1534 Vector4 testColor2( 5.0f, 6.0f, 7.0f, 8.0f );
1536 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1538 RenderTask task = taskList.GetTask( 0u );
1539 DALI_TEST_CHECK( task.GetClearColor() != testColor );
1541 task.SetClearColor( testColor );
1546 DALI_TEST_EQUALS( task.GetClearColor(), testColor, TEST_LOCATION );
1548 task.SetProperty( RenderTask::Property::CLEAR_COLOR, testColor2 );
1553 DALI_TEST_EQUALS( task.GetClearColor(), testColor2, TEST_LOCATION );
1557 int UtcDaliRenderTaskSetClearColorN(void)
1559 TestApplication application;
1561 tet_infoline("Testing RenderTask::SetClearColor() on empty handle");
1566 task.SetClearColor( Vector4::ZERO );
1568 catch (Dali::DaliException& e)
1570 DALI_TEST_PRINT_ASSERT( e );
1571 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1576 int UtcDaliRenderTaskGetClearColorP(void)
1578 TestApplication application;
1580 tet_infoline("Testing RenderTask::GetClearColor()");
1582 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1583 RenderTask task = taskList.GetTask( 0u );
1584 DALI_TEST_EQUALS( task.GetClearColor(), RenderTask::DEFAULT_CLEAR_COLOR, TEST_LOCATION );
1588 int UtcDaliRenderTaskGetClearColorN(void)
1590 TestApplication application;
1592 tet_infoline("Testing RenderTask::GetClearColor()");
1597 Vector4 color = task.GetClearColor();
1600 catch (Dali::DaliException& e)
1602 DALI_TEST_PRINT_ASSERT( e );
1603 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1608 int UtcDaliRenderTaskSetClearEnabledP(void)
1610 TestApplication application;
1612 tet_infoline("Testing RenderTask::SetClearEnabled()");
1614 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1616 RenderTask task = taskList.GetTask( 0u );
1617 DALI_TEST_CHECK( !task.GetClearEnabled() ); // defaults to false
1619 task.SetClearEnabled( true );
1620 DALI_TEST_EQUALS( task.GetClearEnabled(), true, TEST_LOCATION );
1622 task.SetClearEnabled( false );
1623 DALI_TEST_EQUALS( task.GetClearEnabled(), false, TEST_LOCATION );
1627 int UtcDaliRenderTaskSetClearEnabledN(void)
1629 TestApplication application;
1631 tet_infoline("Testing RenderTask::SetClearEnabled() with empty handle");
1636 task.SetClearEnabled(true);
1638 catch (Dali::DaliException& e)
1640 DALI_TEST_PRINT_ASSERT( e );
1641 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1646 int UtcDaliRenderTaskGetClearEnabledP(void)
1648 TestApplication application;
1650 tet_infoline("Testing RenderTask::GetClearEnabled()");
1652 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1654 RenderTask task = taskList.GetTask( 0u );
1655 DALI_TEST_CHECK( !task.GetClearEnabled() ); // defaults to false
1660 int UtcDaliRenderTaskGetClearEnabledN(void)
1662 TestApplication application;
1664 tet_infoline("Testing RenderTask::GetClearEnabled() with empty handle");
1669 bool x = task.GetClearEnabled();
1672 catch (Dali::DaliException& e)
1674 DALI_TEST_PRINT_ASSERT( e );
1675 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1680 int UtcDaliRenderTaskSetCullModeP(void)
1682 TestApplication application;
1684 tet_infoline("Testing RenderTask::SetCullMode()");
1686 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1687 RenderTask task = taskList.GetTask( 0u );
1688 DALI_TEST_EQUALS( task.GetCullMode(), true, TEST_LOCATION );
1690 task.SetCullMode( false );
1692 DALI_TEST_EQUALS( task.GetCullMode(), false, TEST_LOCATION );
1697 int UtcDaliRenderTaskSetCullModeN(void)
1699 TestApplication application;
1701 tet_infoline("Testing RenderTask::SetCullMode() on empty handle");
1706 task.SetCullMode( false );
1708 catch (Dali::DaliException& e)
1710 DALI_TEST_PRINT_ASSERT( e );
1711 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1716 int UtcDaliRenderTaskGetCullModeP(void)
1718 TestApplication application;
1720 tet_infoline("Testing RenderTask::GetCullMode()");
1722 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1723 RenderTask task = taskList.GetTask( 0u );
1724 DALI_TEST_EQUALS( task.GetCullMode(), true, TEST_LOCATION );
1728 int UtcDaliRenderTaskGetCullModeN(void)
1730 TestApplication application;
1732 tet_infoline("Testing RenderTask::GetCullMode() with empty handle");
1737 bool x = task.GetCullMode();
1740 catch (Dali::DaliException& e)
1742 DALI_TEST_PRINT_ASSERT( e );
1743 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1749 int UtcDaliRenderTaskSetRefreshRate(void)
1751 TestApplication application;
1753 tet_infoline("Testing RenderTask::SetRefreshRate()");
1755 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1757 // By default tasks will be processed every frame
1758 RenderTask task = taskList.GetTask( 0u );
1759 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1761 task.SetRefreshRate( 2u ); // every-other frame
1762 DALI_TEST_CHECK( 2u == task.GetRefreshRate() );
1764 task.SetRefreshRate( RenderTask::REFRESH_ALWAYS );
1765 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1769 int UtcDaliRenderTaskGetRefreshRate(void)
1771 TestApplication application;
1773 tet_infoline("Testing RenderTask::GetRefreshRate()");
1775 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1777 // By default tasks will be processed every frame
1778 RenderTask task = taskList.GetTask( 0u );
1779 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1781 RenderTask newTask = taskList.CreateTask();
1782 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == newTask.GetRefreshRate() );
1786 int UtcDaliRenderTaskSignalFinished(void)
1788 TestApplication application;
1790 tet_infoline("Testing RenderTask::SignalFinished()");
1792 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1793 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
1795 CameraActor offscreenCameraActor = CameraActor::New();
1797 Stage::GetCurrent().Add( offscreenCameraActor );
1799 BufferImage image = BufferImage::New( 10, 10 );
1801 Actor rootActor = CreateRenderableActor( image );
1802 rootActor.SetSize( 10, 10 );
1803 Stage::GetCurrent().Add( rootActor );
1805 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1806 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
1807 FrameBufferImage frameBufferImage = FrameBufferImage::New( *testNativeImagePtr.Get() );
1809 RenderTask newTask = taskList.CreateTask();
1810 newTask.SetCameraActor( offscreenCameraActor );
1811 newTask.SetSourceActor( rootActor );
1812 newTask.SetInputEnabled( false );
1813 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
1814 newTask.SetClearEnabled( true );
1815 newTask.SetExclusive( true );
1816 newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
1817 newTask.SetTargetFrameBuffer( frameBufferImage );
1818 newTask.SetProperty( RenderTask::Property::REQUIRES_SYNC, true );
1820 bool finished = false;
1821 RenderTaskFinished renderTaskFinished( finished );
1822 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1824 // Flush the queue and render.
1825 application.SendNotification();
1827 // 1 render to process render task, then wait for sync before finished msg is sent
1828 // from update to the event thread.
1830 application.Render();
1831 application.SendNotification();
1832 DALI_TEST_CHECK( !finished );
1834 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
1835 DALI_TEST_CHECK( lastSyncObj != NULL );
1837 application.Render();
1838 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
1839 application.SendNotification();
1840 DALI_TEST_CHECK( !finished );
1842 application.Render();
1843 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
1844 application.SendNotification();
1845 DALI_TEST_CHECK( ! finished );
1847 sync.SetObjectSynced( lastSyncObj, true );
1849 application.Render();
1850 application.SendNotification();
1851 DALI_TEST_CHECK( !finished );
1853 application.Render();
1854 application.SendNotification();
1855 DALI_TEST_CHECK( finished );
1857 DALI_TEST_EQUALS( application.GetUpdateStatus(), 0, TEST_LOCATION );
1862 int UtcDaliRenderTaskContinuous01(void)
1864 TestApplication application;
1866 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not staged)\nPOST:continuous renders, no Finished signal");
1868 // SETUP AN OFFSCREEN RENDER TASK
1869 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1870 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1871 drawTrace.Enable(true);
1873 Actor rootActor = Actor::New();
1874 Stage::GetCurrent().Add( rootActor );
1876 CameraActor offscreenCameraActor = CameraActor::New();
1877 Stage::GetCurrent().Add( offscreenCameraActor );
1879 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
1880 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1881 Integration::ResourceId imageRequestId = imageRequest->GetId();
1882 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1884 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1885 bool finished = false;
1886 RenderTaskFinished renderTaskFinished( finished );
1887 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1888 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1889 application.SendNotification();
1891 // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating
1892 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false, __LINE__ ) );
1893 application.GetPlatform().ClearReadyResources();
1895 // ADD SOURCE ACTOR TO STAGE - expect continuous renders to start, no finished signal
1896 Stage::GetCurrent().Add(secondRootActor);
1897 application.SendNotification();
1899 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1900 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
1905 int UtcDaliRenderTaskContinuous02(void)
1907 TestApplication application;
1909 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not visible)\nPOST:continuous renders, no Finished signal");
1911 // SETUP AN OFFSCREEN RENDER TASK
1912 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1913 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1914 drawTrace.Enable(true);
1916 Actor rootActor = Actor::New();
1917 Stage::GetCurrent().Add( rootActor );
1919 CameraActor offscreenCameraActor = CameraActor::New();
1920 Stage::GetCurrent().Add( offscreenCameraActor );
1922 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
1923 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1924 Integration::ResourceId imageRequestId = imageRequest->GetId();
1925 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1926 Stage::GetCurrent().Add(secondRootActor);
1927 secondRootActor.SetVisible(false);
1929 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1930 bool finished = false;
1931 RenderTaskFinished renderTaskFinished( finished );
1932 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1933 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1934 application.SendNotification();
1936 // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating
1937 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false, __LINE__ ) );
1938 application.GetPlatform().ClearReadyResources();
1940 // MAKE SOURCE ACTOR VISIBLE - expect continuous renders to start, no finished signal
1941 secondRootActor.SetVisible(true);
1942 application.SendNotification();
1944 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1945 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
1949 int UtcDaliRenderTaskContinuous03(void)
1951 TestApplication application;
1953 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (camera actor not staged)\nPOST:continuous renders, no Finished signal");
1955 // SETUP AN OFFSCREEN RENDER TASK
1956 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1957 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1958 drawTrace.Enable(true);
1960 Actor rootActor = Actor::New();
1961 Stage::GetCurrent().Add( rootActor );
1963 CameraActor offscreenCameraActor = CameraActor::New();
1964 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
1965 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1966 Integration::ResourceId imageRequestId = imageRequest->GetId();
1967 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1968 Stage::GetCurrent().Add(secondRootActor);
1970 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1971 bool finished = false;
1972 RenderTaskFinished renderTaskFinished( finished );
1973 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1974 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1975 application.SendNotification();
1977 // START PROCESS/RENDER Input, Expected Input, Expected
1978 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false, __LINE__ ) );
1979 application.GetPlatform().ClearReadyResources();
1981 // ADD CAMERA ACTOR TO STAGE - expect continuous renders to start, no finished signal
1982 Stage::GetCurrent().Add( offscreenCameraActor );
1983 application.SendNotification();
1985 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1986 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
1991 int UtcDaliRenderTaskContinuous04(void)
1993 TestApplication application;
1995 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: Resource not ready\nPOST:continuous renders, no Finished signal");
1997 // SETUP AN OFFSCREEN RENDER TASK
1998 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1999 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2000 drawTrace.Enable(true);
2002 Actor rootActor = Actor::New();
2003 Stage::GetCurrent().Add( rootActor );
2005 CameraActor offscreenCameraActor = CameraActor::New();
2006 Stage::GetCurrent().Add( offscreenCameraActor );
2007 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
2008 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2009 Integration::ResourceId imageRequestId = imageRequest->GetId();
2010 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2011 Stage::GetCurrent().Add(secondRootActor);
2013 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2014 bool finished = false;
2015 RenderTaskFinished renderTaskFinished( finished );
2016 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2017 application.SendNotification();
2019 // START PROCESS/RENDER Input, Expected Input, Expected
2020 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2021 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2023 // FINISH RESOURCE LOADING - expect 'continuous' renders to start, no finished signal
2024 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2025 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2029 int UtcDaliRenderTaskContinous05(void)
2031 TestApplication application;
2033 tet_infoline("Testing RenderTask Render Continuous using Mesh which accesses texture through sampler with loading image\n"
2034 "PRE: Resource not ready\nPOST:continuous renders, no Finished signal");
2036 // SETUP AN OFFSCREEN RENDER TASK
2037 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2038 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2039 drawTrace.Enable(true);
2041 Actor rootActor = Actor::New();
2042 Stage::GetCurrent().Add( rootActor );
2044 CameraActor offscreenCameraActor = CameraActor::New();
2045 Stage::GetCurrent().Add( offscreenCameraActor );
2047 Shader shader = CreateShader();
2050 Image image = CreateLoadingImage(application, "aFile.jpg");
2051 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2052 Integration::ResourceId imageRequestId = imageRequest->GetId();
2053 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2054 TextureSet textureSet = CreateTextureSet( image );
2056 Geometry geometry = CreateQuadGeometry();
2057 Renderer renderer = Renderer::New(geometry, shader);
2058 renderer.SetTextures( textureSet );
2059 Actor secondRootActor = Actor::New();
2060 secondRootActor.AddRenderer(renderer);
2061 secondRootActor.SetSize(100, 100);
2062 Stage::GetCurrent().Add(secondRootActor);
2064 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2065 bool finished = false;
2066 RenderTaskFinished renderTaskFinished( finished );
2067 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2068 application.SendNotification();
2070 // START PROCESS/RENDER Input, Expected Input, Expected
2071 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2072 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2074 // FINISH RESOURCE LOADING - expect 'continuous' renders to start, no finished signal
2075 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2076 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2082 int UtcDaliRenderTaskOnce01(void)
2084 TestApplication application;
2086 tet_infoline("Testing RenderTask Render Once GlSync, using loading image\nPRE: Resources not ready, Source not visible\nPOST: Finished signal sent once only");
2088 // SETUP AN OFFSCREEN RENDER TASK
2089 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2090 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2091 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2092 drawTrace.Enable(true);
2094 Actor rootActor = Actor::New();
2095 Stage::GetCurrent().Add( rootActor );
2097 CameraActor offscreenCameraActor = CameraActor::New();
2098 Stage::GetCurrent().Add( offscreenCameraActor );
2099 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
2100 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2101 Integration::ResourceId imageRequestId = imageRequest->GetId();
2102 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2104 Stage::GetCurrent().Add(secondRootActor);
2106 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
2107 bool finished = false;
2108 RenderTaskFinished renderTaskFinished( finished );
2109 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2110 application.SendNotification();
2112 // START PROCESS/RENDER Input, Expected Input, Expected
2113 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2114 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2116 // MAKE SOURCE VISIBLE
2117 secondRootActor.SetVisible(true);
2118 application.SendNotification();
2119 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2120 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2122 // FINISH RESOURCE LOADING - expect no rendering yet
2123 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2124 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2125 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2126 DALI_TEST_CHECK( lastSyncObj != NULL );
2128 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2129 application.GetPlatform().ClearReadyResources();
2130 sync.SetObjectSynced( lastSyncObj, true );
2131 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2132 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2136 int UtcDaliRenderTaskOnce02(void)
2138 TestApplication application;
2140 tet_infoline("Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loading image.\n"
2141 "PRE: Resources not ready\nPOST: Finished signal sent once only");
2143 // SETUP AN OFFSCREEN RENDER TASK
2144 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2145 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2146 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2147 drawTrace.Enable(true);
2149 Actor rootActor = Actor::New();
2150 Stage::GetCurrent().Add( rootActor );
2152 CameraActor offscreenCameraActor = CameraActor::New();
2153 Stage::GetCurrent().Add( offscreenCameraActor );
2155 Shader shader = CreateShader();
2156 Image image = CreateLoadingImage(application, "aFile.jpg");
2157 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2158 Integration::ResourceId imageRequestId = imageRequest->GetId();
2159 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2160 TextureSet textureSet = CreateTextureSet( image );
2162 Geometry geometry = CreateQuadGeometry();
2163 Renderer renderer = Renderer::New(geometry, shader);
2164 renderer.SetTextures( textureSet );
2165 Actor secondRootActor = Actor::New();
2166 secondRootActor.AddRenderer(renderer);
2167 secondRootActor.SetSize(100, 100);
2168 Stage::GetCurrent().Add(secondRootActor);
2170 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
2171 bool finished = false;
2172 RenderTaskFinished renderTaskFinished( finished );
2173 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2174 application.SendNotification();
2176 // START PROCESS/RENDER Input, Expected Input, Expected
2177 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2178 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2180 // FINISH RESOURCE LOADING - expect no rendering yet
2181 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2182 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2183 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2184 DALI_TEST_CHECK( lastSyncObj != NULL );
2186 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2187 application.GetPlatform().ClearReadyResources();
2188 sync.SetObjectSynced( lastSyncObj, true );
2189 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2190 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2195 int UtcDaliRenderTaskOnce03(void)
2197 TestApplication application;
2199 tet_infoline("Testing RenderTask Render Once GlSync, using loading image. Switch from render always after ready to render once\n"
2200 "PRE: Render task ready, Image not loaded\n"
2201 "POST: Finished signal sent only once");
2203 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2204 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2205 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2206 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2207 drawTrace.Enable(true);
2209 Actor rootActor = Actor::New();
2210 Stage::GetCurrent().Add( rootActor );
2212 CameraActor offscreenCameraActor = CameraActor::New();
2213 Stage::GetCurrent().Add( offscreenCameraActor );
2214 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
2215 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2216 Integration::ResourceId imageRequestId = imageRequest->GetId();
2217 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2218 Stage::GetCurrent().Add(secondRootActor);
2220 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2221 bool finished = false;
2222 RenderTaskFinished renderTaskFinished( finished );
2223 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2224 application.SendNotification();
2226 // START PROCESS/RENDER Input, Expected Input, Expected
2227 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2228 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2230 // FINISH RESOURCE LOADING
2231 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2232 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2233 application.GetPlatform().ClearReadyResources();
2234 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2236 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2237 application.SendNotification(); // Input, Expected Input, Expected
2238 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2239 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2240 DALI_TEST_CHECK( lastSyncObj != NULL );
2242 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2243 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2244 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2245 sync.SetObjectSynced( lastSyncObj, true );
2246 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2247 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2253 int UtcDaliRenderTaskOnce04(void)
2255 TestApplication application;
2256 tet_infoline("Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loading image.\n"
2257 "Switch from render always after ready to render once\n"
2258 "PRE: Render task ready, Image not loaded\n"
2259 "POST: Finished signal sent only once");
2261 // SETUP AN OFFSCREEN RENDER TASK
2262 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2263 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2264 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2265 drawTrace.Enable(true);
2267 Actor rootActor = Actor::New();
2268 Stage::GetCurrent().Add( rootActor );
2270 CameraActor offscreenCameraActor = CameraActor::New();
2271 Stage::GetCurrent().Add( offscreenCameraActor );
2273 Shader shader = CreateShader();
2274 Image image = CreateLoadingImage(application, "aFile.jpg");
2275 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2276 Integration::ResourceId imageRequestId = imageRequest->GetId();
2277 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2278 TextureSet textureSet = CreateTextureSet( image );
2280 Geometry geometry = CreateQuadGeometry();
2281 Renderer renderer = Renderer::New(geometry, shader);
2282 renderer.SetTextures( textureSet );
2283 Actor secondRootActor = Actor::New();
2284 secondRootActor.AddRenderer(renderer);
2285 secondRootActor.SetSize(100, 100);
2286 Stage::GetCurrent().Add(secondRootActor);
2288 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2289 bool finished = false;
2290 RenderTaskFinished renderTaskFinished( finished );
2291 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2292 application.SendNotification();
2294 // START PROCESS/RENDER Input, Expected Input, Expected
2295 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2296 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2298 // FINISH RESOURCE LOADING
2299 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2300 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2301 application.GetPlatform().ClearReadyResources();
2302 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2304 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2305 application.SendNotification(); // Input, Expected Input, Expected
2306 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2307 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2308 DALI_TEST_CHECK( lastSyncObj != NULL );
2310 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2311 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2312 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2313 sync.SetObjectSynced( lastSyncObj, true );
2314 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2315 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2320 int UtcDaliRenderTaskOnce05(void)
2322 TestApplication application;
2324 tet_infoline("Testing RenderTask Render Once GlSync\n"
2325 "Switch from Render always after ready to render once with resources unready\n"
2326 "PRE: Everything ready to render\n"
2327 "POST: Finished signal sent once");
2329 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2330 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2331 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2332 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2333 drawTrace.Enable(true);
2335 Actor rootActor = Actor::New();
2336 Stage::GetCurrent().Add( rootActor );
2338 CameraActor offscreenCameraActor = CameraActor::New();
2339 Stage::GetCurrent().Add( offscreenCameraActor );
2340 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
2341 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2342 Integration::ResourceId imageRequestId = imageRequest->GetId();
2343 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2344 Stage::GetCurrent().Add(secondRootActor);
2346 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2347 bool finished = false;
2348 RenderTaskFinished renderTaskFinished( finished );
2349 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2350 application.SendNotification();
2352 // START PROCESS/RENDER Input, Expected Input, Expected
2353 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2354 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2356 // CHANGE TO RENDER ONCE
2357 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2358 application.SendNotification(); // Input, Expected Input, Expected
2359 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2360 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2362 // FINISH RESOURCE LOADING
2363 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2364 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2365 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2366 DALI_TEST_CHECK( lastSyncObj != NULL );
2367 application.GetPlatform().ClearReadyResources();
2369 sync.SetObjectSynced( lastSyncObj, true );
2371 // Expect: No draw - we've just drawn our render task once, above. No finished signal -
2372 // we won't read the gl sync until the next frame. Continue rendering - we're waiting for
2374 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2376 // Expect: 1 final draw - this Update doesn't update the scene, hence render instructions
2377 // from last frame but 1 are still present.
2378 // Finished signal should be true - we've just done the sync.
2379 // Should now stop rendering and updating - nothing left to do.
2380 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, true, false, __LINE__ ) );
2385 int UtcDaliRenderTaskOnce07(void)
2387 TestApplication application;
2389 tet_infoline("Testing RenderTask Render Once GLSync\n"
2390 "Render once, Second call to SetRefreshRate(ONCE) triggers only one more finished signal\n"
2391 "PRE: Everything ready\n"
2392 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
2394 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2395 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2396 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2397 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2398 drawTrace.Enable(true);
2400 Actor rootActor = Actor::New();
2401 Stage::GetCurrent().Add( rootActor );
2403 CameraActor offscreenCameraActor = CameraActor::New();
2404 Stage::GetCurrent().Add( offscreenCameraActor );
2405 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
2406 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2407 Integration::ResourceId imageRequestId = imageRequest->GetId();
2408 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2409 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2410 application.Render();
2411 application.GetPlatform().ClearReadyResources();
2413 Stage::GetCurrent().Add(secondRootActor);
2415 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2416 bool finished = false;
2417 RenderTaskFinished renderTaskFinished( finished );
2418 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2419 application.SendNotification();
2421 // START PROCESS/RENDER Input, Expected Input, Expected
2422 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2424 // CHANGE TO RENDER ONCE,
2425 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2426 application.SendNotification();
2427 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2428 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2429 DALI_TEST_CHECK( lastSyncObj != NULL );
2431 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2432 sync.SetObjectSynced( lastSyncObj, true );
2433 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2434 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2436 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2437 application.SendNotification();
2438 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2439 lastSyncObj = sync.GetLastSyncObject();
2440 DALI_TEST_CHECK( lastSyncObj != NULL );
2442 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2443 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2444 sync.SetObjectSynced( lastSyncObj, true );
2445 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2446 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2450 int UtcDaliRenderTaskOnce08(void)
2452 TestApplication application;
2454 tet_infoline("Testing RenderTask Render Once GLSync\n"
2455 "Render once, Call to SetRefreshRate(ONCE) in Finished signal callback triggers "
2456 "another render & another finished signal\n"
2457 "PRE: Everything ready\n"
2458 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
2461 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2462 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2463 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2464 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2465 sync.GetTrace().Enable(true);
2466 drawTrace.Enable(true);
2468 Actor rootActor = Actor::New();
2469 Stage::GetCurrent().Add( rootActor );
2471 CameraActor offscreenCameraActor = CameraActor::New();
2472 Stage::GetCurrent().Add( offscreenCameraActor );
2473 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
2474 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2475 Integration::ResourceId imageRequestId = imageRequest->GetId();
2476 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2477 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2478 application.Render();
2479 application.GetPlatform().ClearReadyResources();
2481 Stage::GetCurrent().Add(secondRootActor);
2483 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, /*GL-SYNC*/ true);
2484 bool finished = false;
2486 ConnectionTracker connectionTracker;
2487 RenderTaskFinishedRenderAgain renderTaskFinishedRenderAgain( finished );
2488 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinishedRenderAgain );
2490 application.SendNotification();
2492 // START PROCESS/RENDER Input, Expected Input, Expected
2493 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2494 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2495 DALI_TEST_CHECK( lastSyncObj == NULL );
2496 DALI_TEST_EQUALS( sync.GetTrace().CountMethod( "CreateSyncObject" ), 0, TEST_LOCATION );
2499 // CHANGE TO RENDER ONCE,
2500 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2501 application.SendNotification();
2502 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2503 lastSyncObj = sync.GetLastSyncObject();
2504 DALI_TEST_CHECK( lastSyncObj != NULL );
2505 DALI_TEST_EQUALS( sync.GetNumberOfSyncObjects(), 1, TEST_LOCATION );
2506 DALI_TEST_EQUALS( sync.GetTrace().CountMethod( "CreateSyncObject" ), 1, TEST_LOCATION );
2508 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2511 DALI_TEST_EQUALS( sync.GetNumberOfSyncObjects(), 1, TEST_LOCATION );
2512 DALI_TEST_EQUALS( sync.GetTrace().CountMethod( "CreateSyncObject" ), 1, TEST_LOCATION );
2514 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2516 DALI_TEST_EQUALS( sync.GetNumberOfSyncObjects(), 1, TEST_LOCATION );
2517 DALI_TEST_EQUALS( sync.GetTrace().CountMethod( "CreateSyncObject" ), 1, TEST_LOCATION );
2519 sync.SetObjectSynced( lastSyncObj, true );
2520 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2521 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2522 application.SendNotification();
2524 // Expect SetRefreshRate to have been called again
2525 // Prevent next finished signal calling refresh once again
2526 RenderTaskFinished renderTaskFinished( finished );
2527 connectionTracker.DisconnectAll();
2528 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinished );
2529 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2530 lastSyncObj = sync.GetLastSyncObject();
2531 DALI_TEST_CHECK( lastSyncObj != NULL );
2533 sync.SetObjectSynced( lastSyncObj, true );
2534 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2535 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2540 int UtcDaliRenderTaskOnce09(void)
2542 TestApplication application;
2544 tet_infoline("Testing RenderTask Render Once GlSync\n"
2545 "SetRefreshRate(ONCE) again before first finished signal has been sent.\n"
2546 "PRE: resources ready\n"
2547 "POST: Only 1 finished signal sent.");
2549 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2550 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2551 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2552 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2553 drawTrace.Enable(true);
2555 Actor rootActor = Actor::New();
2556 Stage::GetCurrent().Add( rootActor );
2558 CameraActor offscreenCameraActor = CameraActor::New();
2559 Stage::GetCurrent().Add( offscreenCameraActor );
2560 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
2561 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2562 Integration::ResourceId imageRequestId = imageRequest->GetId();
2563 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2564 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2565 application.Render();
2566 application.GetPlatform().ClearReadyResources();
2568 Stage::GetCurrent().Add(secondRootActor);
2570 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2571 bool finished = false;
2572 RenderTaskFinished renderTaskFinished( finished );
2573 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2574 application.SendNotification();
2576 // START PROCESS/RENDER Input, Expected Input, Expected
2577 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2579 // CHANGE TO RENDER ONCE,
2580 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2581 application.SendNotification();
2582 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2583 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2584 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2586 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2587 application.SendNotification();
2588 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2589 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2590 DALI_TEST_CHECK( lastSyncObj != NULL );
2592 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2593 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2594 sync.SetObjectSynced( lastSyncObj, true );
2595 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2596 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2601 int UtcDaliRenderTaskOnce10(void)
2603 TestApplication application;
2605 tet_infoline("Testing RenderTask Render Once GlSync\n"
2606 "SetRefreshRate(ONCE), resource load failed completes render task.\n"
2607 "PRE: resources not ready\n"
2608 "POST: Only 1 finished signal sent.");
2610 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2611 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2612 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2613 drawTrace.Enable(true);
2615 Actor rootActor = Actor::New();
2616 Stage::GetCurrent().Add( rootActor );
2618 CameraActor offscreenCameraActor = CameraActor::New();
2619 Stage::GetCurrent().Add( offscreenCameraActor );
2620 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
2621 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2622 Integration::ResourceId imageRequestId = imageRequest->GetId();
2623 Stage::GetCurrent().Add(secondRootActor);
2625 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2626 bool finished = false;
2627 RenderTaskFinished renderTaskFinished( finished );
2628 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2629 application.SendNotification();
2631 // START PROCESS/RENDER Input, Expected Input, Expected
2632 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2633 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2635 // CHANGE TO RENDER ONCE,
2636 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2637 application.SendNotification();
2638 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2639 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2640 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2642 tet_printf(" FailImageLoad\n");
2644 FailImageLoad(application, imageRequestId); // Need to run Update again for this to complete
2646 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); // nothing to draw
2647 application.SendNotification();
2649 // load is now failed so there's nothing more to render in the render task
2650 // Expect finished signal, as all resources are complete
2651 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2656 int UtcDaliRenderTaskOnceNoSync01(void)
2658 TestApplication application;
2660 tet_infoline("Testing RenderTask Render Once, using loading image\nPRE: Resources not ready, Source not visible\nPOST: Finished signal sent once only");
2662 // SETUP AN OFFSCREEN RENDER TASK
2663 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2664 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2665 drawTrace.Enable(true);
2667 Actor rootActor = Actor::New();
2668 Stage::GetCurrent().Add( rootActor );
2670 CameraActor offscreenCameraActor = CameraActor::New();
2671 Stage::GetCurrent().Add( offscreenCameraActor );
2672 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
2673 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2674 Integration::ResourceId imageRequestId = imageRequest->GetId();
2675 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2677 Stage::GetCurrent().Add(secondRootActor);
2679 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2680 bool finished = false;
2681 RenderTaskFinished renderTaskFinished( finished );
2682 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2683 application.SendNotification();
2685 // START PROCESS/RENDER Input, Expected Input, Expected
2686 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2687 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2689 // FINISH RESOURCE LOADING - expect immediate rendering yet
2690 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2691 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2692 application.GetPlatform().ClearReadyResources();
2693 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2697 int UtcDaliRenderTaskOnceNoSync02(void)
2699 TestApplication application;
2701 tet_infoline("Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loading image.\n"
2702 "PRE: Resources not ready\nPOST: Finished signal sent once only");
2703 // SETUP AN OFFSCREEN RENDER TASK
2704 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2705 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2706 drawTrace.Enable(true);
2708 Actor rootActor = Actor::New();
2709 Stage::GetCurrent().Add( rootActor );
2711 CameraActor offscreenCameraActor = CameraActor::New();
2712 Stage::GetCurrent().Add( offscreenCameraActor );
2714 Shader shader = CreateShader();
2715 Image image = CreateLoadingImage(application, "aFile.jpg");
2716 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2717 Integration::ResourceId imageRequestId = imageRequest->GetId();
2718 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2719 TextureSet textureSet = CreateTextureSet( image );
2721 Geometry geometry = CreateQuadGeometry();
2722 Renderer renderer = Renderer::New(geometry, shader);
2723 renderer.SetTextures( textureSet );
2724 Actor secondRootActor = Actor::New();
2725 secondRootActor.AddRenderer(renderer);
2726 secondRootActor.SetSize(100, 100);
2727 Stage::GetCurrent().Add(secondRootActor);
2729 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2730 bool finished = false;
2731 RenderTaskFinished renderTaskFinished( finished );
2732 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2733 application.SendNotification();
2735 // START PROCESS/RENDER Input, Expected Input, Expected
2736 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2737 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2739 // FINISH RESOURCE LOADING - expect immediate rendering yet
2740 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2741 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2742 application.GetPlatform().ClearReadyResources();
2743 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2748 int UtcDaliRenderTaskOnceNoSync03(void)
2750 TestApplication application;
2752 tet_infoline("Testing RenderTask Render Once, using loading image. Switch from render always after ready to render once\n"
2753 "PRE: Render task ready, Image not loaded\n"
2754 "POST: Finished signal sent only once");
2756 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2757 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2758 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2759 drawTrace.Enable(true);
2761 Actor rootActor = Actor::New();
2762 Stage::GetCurrent().Add( rootActor );
2764 CameraActor offscreenCameraActor = CameraActor::New();
2765 Stage::GetCurrent().Add( offscreenCameraActor );
2766 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
2767 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2768 Integration::ResourceId imageRequestId = imageRequest->GetId();
2769 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2770 Stage::GetCurrent().Add(secondRootActor);
2772 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2773 bool finished = false;
2774 RenderTaskFinished renderTaskFinished( finished );
2775 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2776 application.SendNotification();
2778 // START PROCESS/RENDER Input, Expected Input, Expected
2779 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2780 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2782 // FINISH RESOURCE LOADING
2783 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2784 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2785 application.GetPlatform().ClearReadyResources();
2787 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2788 application.SendNotification(); // Input, Expected Input, Expected
2789 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2790 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2794 int UtcDaliRenderTaskOnceNoSync04(void)
2796 TestApplication application;
2798 tet_infoline("Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loading image.\n"
2799 "Switch from render always after ready to render once\n"
2800 "PRE: Render task ready, Image not loaded\n"
2801 "POST: Finished signal sent only once");
2803 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2804 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2805 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2806 drawTrace.Enable(true);
2808 Actor rootActor = Actor::New();
2809 Stage::GetCurrent().Add( rootActor );
2811 CameraActor offscreenCameraActor = CameraActor::New();
2812 Stage::GetCurrent().Add( offscreenCameraActor );
2814 Shader shader = CreateShader();
2815 Image image = CreateLoadingImage(application, "aFile.jpg");
2816 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2817 Integration::ResourceId imageRequestId = imageRequest->GetId();
2818 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2819 TextureSet textureSet = CreateTextureSet( image );
2821 Geometry geometry = CreateQuadGeometry();
2822 Renderer renderer = Renderer::New(geometry, shader);
2823 renderer.SetTextures( textureSet );
2824 Actor secondRootActor = Actor::New();
2825 secondRootActor.AddRenderer(renderer);
2826 secondRootActor.SetSize(100, 100);
2827 Stage::GetCurrent().Add(secondRootActor);
2830 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2831 bool finished = false;
2832 RenderTaskFinished renderTaskFinished( finished );
2833 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2834 application.SendNotification();
2836 // START PROCESS/RENDER Input, Expected Input, Expected
2837 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2838 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2840 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2841 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2842 DALI_TEST_CHECK( lastSyncObj == NULL );
2844 // FINISH RESOURCE LOADING
2845 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2846 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2847 application.GetPlatform().ClearReadyResources();
2849 lastSyncObj = sync.GetLastSyncObject();
2850 DALI_TEST_CHECK( lastSyncObj == NULL );
2852 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2853 application.SendNotification(); // Input, Expected Input, Expected
2854 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2855 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2857 lastSyncObj = sync.GetLastSyncObject();
2858 DALI_TEST_CHECK( lastSyncObj == NULL );
2863 int UtcDaliRenderTaskOnceNoSync05(void)
2865 TestApplication application;
2867 tet_infoline("Testing RenderTask Render Once\n"
2868 "Switch from Render always after ready to render once with resources unready\n"
2869 "PRE: Everything ready to render\n"
2870 "POST: Finished signal sent once");
2872 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2873 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2874 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2875 drawTrace.Enable(true);
2877 Actor rootActor = Actor::New();
2878 Stage::GetCurrent().Add( rootActor );
2880 CameraActor offscreenCameraActor = CameraActor::New();
2881 Stage::GetCurrent().Add( offscreenCameraActor );
2882 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
2883 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2884 Integration::ResourceId imageRequestId = imageRequest->GetId();
2885 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2886 Stage::GetCurrent().Add(secondRootActor);
2888 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2889 bool finished = false;
2890 RenderTaskFinished renderTaskFinished( finished );
2891 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2892 application.SendNotification();
2894 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2895 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2896 DALI_TEST_CHECK( lastSyncObj == NULL );
2898 // START PROCESS/RENDER Input, Expected Input, Expected
2899 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2900 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2902 // CHANGE TO RENDER ONCE
2903 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2904 application.SendNotification(); // Input, Expected Input, Expected
2905 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2906 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2908 // FINISH RESOURCE LOADING
2909 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2910 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2911 application.GetPlatform().ClearReadyResources();
2912 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2916 int UtcDaliRenderTaskOnceNoSync07(void)
2918 TestApplication application;
2920 tet_infoline("Testing RenderTask Render Once\n"
2921 "Render once, Second call to SetRefreshRate(ONCE) triggers only one more finished signal\n"
2922 "PRE: Everything ready\n"
2923 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
2925 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2926 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2927 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2928 drawTrace.Enable(true);
2930 Actor rootActor = Actor::New();
2931 Stage::GetCurrent().Add( rootActor );
2933 CameraActor offscreenCameraActor = CameraActor::New();
2934 Stage::GetCurrent().Add( offscreenCameraActor );
2935 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
2936 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2937 Integration::ResourceId imageRequestId = imageRequest->GetId();
2938 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2939 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2940 application.Render();
2941 application.GetPlatform().ClearReadyResources();
2943 Stage::GetCurrent().Add(secondRootActor);
2945 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2946 bool finished = false;
2947 RenderTaskFinished renderTaskFinished( finished );
2948 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2949 application.SendNotification();
2951 // START PROCESS/RENDER Input, Expected Input, Expected
2952 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2954 // CHANGE TO RENDER ONCE,
2955 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2956 application.SendNotification();
2957 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2958 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2960 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2961 application.SendNotification();
2962 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2963 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2967 int UtcDaliRenderTaskOnceNoSync08(void)
2969 TestApplication application;
2971 tet_infoline("Testing RenderTask Render Once\n"
2972 "Render once, Call to SetRefreshRate(ONCE) in Finished signal callback triggers\n"
2973 "another render & another finished signal\n"
2974 "PRE: Everything ready\n"
2975 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
2978 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2979 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2980 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2981 drawTrace.Enable(true);
2983 Actor rootActor = Actor::New();
2984 Stage::GetCurrent().Add( rootActor );
2986 CameraActor offscreenCameraActor = CameraActor::New();
2987 Stage::GetCurrent().Add( offscreenCameraActor );
2988 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
2989 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2990 Integration::ResourceId imageRequestId = imageRequest->GetId();
2991 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2992 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2993 application.Render();
2994 application.GetPlatform().ClearReadyResources();
2996 Stage::GetCurrent().Add(secondRootActor);
2998 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2999 bool finished = false;
3001 ConnectionTracker connectionTracker;
3002 RenderTaskFinishedRenderAgain renderTaskFinishedRenderAgain( finished );
3003 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinishedRenderAgain );
3005 application.SendNotification();
3007 // START PROCESS/RENDER Input, Expected Input, Expected
3008 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
3010 // CHANGE TO RENDER ONCE,
3011 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3012 application.SendNotification();
3013 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3014 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3016 // Expect SetRefreshRate to have been called again
3017 // Prevent next finished signal calling refresh once again
3018 RenderTaskFinished renderTaskFinished( finished );
3019 connectionTracker.DisconnectAll();
3020 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinished );
3022 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3023 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3028 int UtcDaliRenderTaskOnceNoSync09(void)
3030 TestApplication application;
3032 tet_infoline("Testing RenderTask Render Once\n"
3033 "SetRefreshRate(ONCE) again before first finished signal has been sent.\n"
3034 "PRE: resources ready\n"
3035 "POST: Only 1 finished signal sent.");
3037 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3038 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3039 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3040 drawTrace.Enable(true);
3042 Actor rootActor = Actor::New();
3043 Stage::GetCurrent().Add( rootActor );
3045 CameraActor offscreenCameraActor = CameraActor::New();
3046 Stage::GetCurrent().Add( offscreenCameraActor );
3047 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
3048 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3049 Integration::ResourceId imageRequestId = imageRequest->GetId();
3050 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
3051 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
3052 application.Render();
3053 application.GetPlatform().ClearReadyResources();
3055 Stage::GetCurrent().Add(secondRootActor);
3057 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3058 bool finished = false;
3059 RenderTaskFinished renderTaskFinished( finished );
3060 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3061 application.SendNotification();
3063 // START PROCESS/RENDER Input, Expected Input, Expected
3064 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
3066 // CHANGE TO RENDER ONCE,
3067 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3068 application.SendNotification();
3069 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3070 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3072 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3073 application.SendNotification();
3074 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3075 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3079 int UtcDaliRenderTaskOnceNoSync10(void)
3081 TestApplication application;
3083 tet_infoline("Testing RenderTask Render Once\n"
3084 "SetRefreshRate(ONCE), resource load failed, completes render task.\n"
3085 "PRE: resources not ready\n"
3086 "POST: Only 1 finished signal sent.");
3088 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3089 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3090 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3091 drawTrace.Enable(true);
3093 Actor rootActor = Actor::New();
3094 Stage::GetCurrent().Add( rootActor );
3096 CameraActor offscreenCameraActor = CameraActor::New();
3097 Stage::GetCurrent().Add( offscreenCameraActor );
3098 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
3099 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3100 Integration::ResourceId imageRequestId = imageRequest->GetId();
3101 Stage::GetCurrent().Add(secondRootActor);
3103 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3104 bool finished = false;
3105 RenderTaskFinished renderTaskFinished( finished );
3106 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3107 application.SendNotification();
3109 // START PROCESS/RENDER Input, Expected Input, Expected
3110 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3111 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3113 // CHANGE TO RENDER ONCE,
3114 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3115 application.SendNotification();
3116 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3117 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3118 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3120 FailImageLoad(application, imageRequestId); // Need to run Update again for this to complete
3121 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); // nothing to draw
3122 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3129 int UtcDaliRenderTaskOnceChain01(void)
3131 TestApplication application;
3133 tet_infoline("Testing RenderTask Render Once Chained render tasks\n"
3134 "SetRefreshRate(ONCE), resource load completes, both render tasks render.\n"
3135 "PRE: resources not ready\n"
3136 "POST: 2 finished signals sent.");
3138 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3139 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3140 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3141 drawTrace.Enable(true);
3143 Actor defaultRootActor = Actor::New(); // Root for default RT
3144 Stage::GetCurrent().Add( defaultRootActor );
3146 CameraActor offscreenCameraActor = CameraActor::New();
3147 Stage::GetCurrent().Add( offscreenCameraActor );
3148 Actor firstRootActor = CreateLoadingActor(application, "aFile.jpg");
3149 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3150 Integration::ResourceId imageRequestId = imageRequest->GetId();
3151 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
3152 Stage::GetCurrent().Add(firstRootActor);
3154 // first render task
3155 RenderTask firstTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, firstRootActor, RenderTask::REFRESH_ONCE, false);
3156 bool firstFinished = false;
3157 RenderTaskFinished renderTask1Finished( firstFinished );
3158 firstTask.FinishedSignal().Connect( &application, renderTask1Finished );
3160 // Second render task
3161 FrameBufferImage fbo = firstTask.GetTargetFrameBuffer();
3162 Actor secondRootActor = CreateRenderableActor( fbo );
3163 Stage::GetCurrent().Add(secondRootActor);
3164 RenderTask secondTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
3165 bool secondFinished = false;
3166 RenderTaskFinished renderTask2Finished( secondFinished );
3167 secondTask.FinishedSignal().Connect( &application, renderTask2Finished );
3169 application.SendNotification();
3171 // START PROCESS/RENDER Input, Expected Input, Expected
3172 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__ ) );
3173 DALI_TEST_CHECK( firstFinished == false );
3174 DALI_TEST_CHECK( secondFinished == false );
3175 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__ ) );
3176 DALI_TEST_CHECK( firstFinished == false );
3177 DALI_TEST_CHECK( secondFinished == false );
3179 CompleteImageLoad(application, imageRequestId, imageType);
3180 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__ ) );
3181 DALI_TEST_CHECK( firstFinished == false );
3182 DALI_TEST_CHECK( secondFinished == false );
3184 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, true, true, __LINE__ ) );
3185 DALI_TEST_CHECK( firstFinished == true );
3186 DALI_TEST_CHECK( secondFinished == false );
3188 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, secondFinished, true, false, __LINE__ ) );
3189 DALI_TEST_CHECK( secondFinished == true );
3194 int UtcDaliRenderTaskProperties(void)
3196 TestApplication application;
3198 RenderTask task = Stage::GetCurrent().GetRenderTaskList().CreateTask();
3200 Property::IndexContainer indices;
3201 task.GetPropertyIndices( indices );
3202 DALI_TEST_CHECK( indices.Size() );
3203 DALI_TEST_EQUALS( indices.Size(), task.GetPropertyCount(), TEST_LOCATION );
3207 int UtcDaliRenderTaskSetScreenToFrameBufferMappingActor(void)
3209 TestApplication application;
3210 tet_infoline("Testing RenderTask::SetScreenToFrameBufferMappingActor ");
3212 Stage stage = Stage::GetCurrent();
3213 Size stageSize = stage.GetSize();
3214 Actor mappingActor = Actor::New();
3215 Vector2 scale( 0.6f, 0.75f);
3216 Vector2 offset( stageSize.x*0.1f, stageSize.y*0.15f);
3217 mappingActor.SetSize( stageSize * scale );
3218 mappingActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
3219 mappingActor.SetPosition( offset.x, offset.y );
3220 stage.Add( mappingActor );
3222 Actor offscreenActor = Actor::New();
3223 offscreenActor.SetSize( stageSize );
3224 offscreenActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
3225 stage.Add( offscreenActor );
3227 RenderTaskList taskList = stage.GetRenderTaskList();
3228 RenderTask renderTask = taskList.CreateTask();
3229 FrameBufferImage frameBufferImage = FrameBufferImage::New(stageSize.width*scale.x, stageSize.height*scale.y, Pixel::A8);
3230 renderTask.SetSourceActor( offscreenActor );
3231 renderTask.SetExclusive( true );
3232 renderTask.SetInputEnabled( true );
3233 renderTask.SetTargetFrameBuffer( frameBufferImage );
3234 renderTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
3235 renderTask.SetScreenToFrameBufferMappingActor( mappingActor );
3236 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3238 // Render and notify
3239 application.SendNotification();
3240 application.Render();
3241 application.Render();
3242 application.SendNotification();
3244 Vector2 screenCoordinates( stageSize.x * 0.05f, stageSize.y * 0.05f );
3245 Dali::HitTestAlgorithm::Results results;
3246 DALI_TEST_CHECK( !results.actor );
3247 DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
3248 // miss expected, results not changed
3249 DALI_TEST_CHECK( false == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3250 DALI_TEST_CHECK( !results.actor );
3251 DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
3253 screenCoordinates.x = stageSize.x * 0.265f;
3254 screenCoordinates.y = stageSize.y * 0.33f;
3255 results.actor = Actor();
3256 results.actorCoordinates = Vector2::ZERO;
3257 // hit expected, results changed
3258 DALI_TEST_CHECK( true == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3259 DALI_TEST_CHECK( results.actor == offscreenActor );
3260 DALI_TEST_EQUALS( (screenCoordinates-offset)/scale , results.actorCoordinates, 0.1f, TEST_LOCATION );
3262 screenCoordinates.x = stageSize.x * 0.435f;
3263 screenCoordinates.y = stageSize.y * 0.52f;
3264 // hit expected, results changed
3265 DALI_TEST_CHECK( true == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3266 DALI_TEST_CHECK( results.actor == offscreenActor );
3267 const Vector2 expectedCoordinates = (screenCoordinates-offset)/scale;
3268 DALI_TEST_EQUALS( expectedCoordinates , results.actorCoordinates, 0.1f, TEST_LOCATION );
3270 screenCoordinates.x = stageSize.x * 0.65f;
3271 screenCoordinates.y = stageSize.y * 0.95f;
3272 // miss expected, results not changed
3273 DALI_TEST_CHECK( false == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3274 DALI_TEST_CHECK( results.actor == offscreenActor );
3275 DALI_TEST_EQUALS( expectedCoordinates , results.actorCoordinates, 0.1f, TEST_LOCATION );
3279 int UtcDaliRenderTaskFinishInvisibleSourceActor(void)
3281 TestApplication application;
3283 tet_infoline("Testing RenderTask::FinishInvisibleSourceActor()");
3285 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3286 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
3288 CameraActor offscreenCameraActor = CameraActor::New();
3290 Stage::GetCurrent().Add( offscreenCameraActor );
3292 BufferImage image = BufferImage::New( 10, 10 );
3293 Actor rootActor = CreateRenderableActor( image );
3294 rootActor.SetSize( 10, 10 );
3295 rootActor.SetVisible(false);
3296 Stage::GetCurrent().Add( rootActor );
3298 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3299 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
3300 FrameBufferImage frameBufferImage = FrameBufferImage::New( *testNativeImagePtr.Get() );
3302 // Flush all outstanding messages
3303 application.SendNotification();
3304 application.Render();
3306 RenderTask newTask = taskList.CreateTask();
3307 newTask.SetCameraActor( offscreenCameraActor );
3308 newTask.SetSourceActor( rootActor );
3309 newTask.SetInputEnabled( false );
3310 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
3311 newTask.SetClearEnabled( true );
3312 newTask.SetExclusive( true );
3313 newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
3314 newTask.SetTargetFrameBuffer( frameBufferImage );
3315 newTask.SetProperty( RenderTask::Property::REQUIRES_SYNC, true );
3317 // Framebuffer doesn't actually get created until Connected, i.e. by previous line
3319 bool finished = false;
3320 RenderTaskFinished renderTaskFinished( finished );
3321 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3323 // Flush the queue and render.
3324 application.SendNotification();
3326 // 1 render to process render task, then wait for sync before finished msg is sent
3327 // from update to the event thread.
3329 application.Render();
3330 application.SendNotification();
3331 DALI_TEST_CHECK( !finished );
3333 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
3334 DALI_TEST_CHECK( lastSyncObj != NULL );
3336 application.Render();
3337 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
3338 application.SendNotification();
3339 DALI_TEST_CHECK( !finished );
3341 application.Render();
3342 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
3343 application.SendNotification();
3344 DALI_TEST_CHECK( ! finished );
3346 sync.SetObjectSynced( lastSyncObj, true );
3348 application.Render();
3349 application.SendNotification();
3350 DALI_TEST_CHECK( !finished );
3352 application.Render();
3353 application.SendNotification();
3354 DALI_TEST_CHECK( finished );
3357 application.Render(); // Double check no more finished signal
3358 application.SendNotification();
3359 DALI_TEST_CHECK( ! finished );
3364 int UtcDaliRenderTaskFinishMissingImage(void)
3366 TestApplication application;
3368 // Previously we had bugs where not having a resource ID would cause render-tasks to wait forever
3369 tet_infoline("Testing RenderTask::SignalFinished() when an Actor has no Image set");
3371 Stage stage = Stage::GetCurrent();
3373 BufferImage image = BufferImage::New( 10, 10 );
3374 Actor rootActor = CreateRenderableActor( image );
3375 rootActor.SetSize( 10, 10 );
3376 stage.Add( rootActor );
3378 Actor actorWithMissingImage = CreateRenderableActor( Image() );
3379 actorWithMissingImage.SetSize( 10, 10 );
3380 stage.Add( actorWithMissingImage );
3382 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3383 RenderTask newTask = taskList.CreateTask();
3384 newTask.SetInputEnabled( false );
3385 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
3386 newTask.SetClearEnabled( true );
3387 newTask.SetExclusive( true );
3388 newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
3390 bool finished = false;
3391 RenderTaskFinished renderTaskFinished( finished );
3392 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3394 // 1 render to process render task, then 1 before finished msg is sent from update to the event thread.
3395 application.SendNotification();
3396 application.Render();
3397 application.Render();
3399 application.SendNotification();
3400 DALI_TEST_CHECK( finished );
3405 int UtcDaliRenderTaskWorldToViewport(void)
3407 TestApplication application( static_cast<size_t>(400), static_cast<size_t>(400) ); // square surface
3409 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3411 Actor actor = Actor::New();
3412 actor.SetSize(100.0f, 100.0f);
3413 actor.SetPosition( Vector3(0.0, 0.0, 0.0) );
3415 actor.SetParentOrigin( Vector3(0.5, 0.5, 0.5) );
3416 actor.SetAnchorPoint( Vector3(0.5, 0.5, 0.5) );
3418 Stage::GetCurrent().Add(actor);
3420 application.SendNotification();
3421 application.Render();
3422 application.SendNotification();
3424 RenderTask task = taskList.GetTask( 0u );
3426 CameraActor camera = task.GetCameraActor();
3428 Vector2 screenSize = task.GetCurrentViewportSize();
3430 float screenX = 0.0;
3431 float screenY = 0.0;
3433 bool ok = task.WorldToViewport(actor.GetCurrentWorldPosition(), screenX, screenY);
3434 DALI_TEST_CHECK(ok == true);
3436 DALI_TEST_EQUALS(screenX, screenSize.x/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
3437 DALI_TEST_EQUALS(screenY, screenSize.y/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
3439 Actor actor2 = Actor::New();
3440 float actor2Size = 100.f;
3441 actor2.SetSize( actor2Size, actor2Size );
3442 actor2.SetPosition( Vector3(0.0, 0.0, 0.0) );
3443 actor2.SetParentOrigin( Vector3(0.5, 0.5, 0.0) );
3444 actor2.SetAnchorPoint( Vector3(0.5, 0.5, 0.0) );
3445 Stage::GetCurrent().Add( actor2 );
3447 actor.SetParentOrigin( Vector3(0,0,0) );
3449 application.SendNotification();
3450 application.Render();
3451 application.SendNotification();
3453 ok = task.WorldToViewport(actor.GetCurrentWorldPosition(), screenX, screenY);
3454 DALI_TEST_CHECK(ok == true);
3456 DALI_TEST_EQUALS(screenX, screenSize.x/2 - actor2Size/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
3457 DALI_TEST_EQUALS(screenY, screenSize.y/2 - actor2Size/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
3463 int UtcDaliRenderTaskViewportToLocal(void)
3465 TestApplication application;
3466 Actor actor = Actor::New();
3467 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
3468 actor.SetSize(100.0f, 100.0f);
3469 actor.SetPosition(10.0f, 10.0f);
3470 Stage::GetCurrent().Add(actor);
3472 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3473 RenderTask task = taskList.GetTask( 0u );
3475 // flush the queue and render once
3476 application.SendNotification();
3477 application.Render();
3478 application.SendNotification();
3479 application.Render();
3487 float screenX = 50.0f;
3488 float screenY = 50.0f;
3490 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, screenX, screenY) );
3492 DALI_TEST_CHECK( task.ViewportToLocal(actor, screenX, screenY, rtLocalX, rtLocalY ) );
3494 DALI_TEST_EQUALS(localX, rtLocalX, 0.01f, TEST_LOCATION);
3495 DALI_TEST_EQUALS(localY, rtLocalY, 0.01f, TEST_LOCATION);