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();
1372 viewport = viewport;
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 );
1858 DALI_TEST_EQUALS( application.GetUpdateStatus(), 0, TEST_LOCATION );
1863 int UtcDaliRenderTaskContinuous01(void)
1865 TestApplication application;
1867 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not staged)\nPOST:continuous renders, no Finished signal");
1869 // SETUP AN OFFSCREEN RENDER TASK
1870 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1871 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1872 drawTrace.Enable(true);
1874 Actor rootActor = Actor::New();
1875 Stage::GetCurrent().Add( rootActor );
1877 CameraActor offscreenCameraActor = CameraActor::New();
1878 Stage::GetCurrent().Add( offscreenCameraActor );
1880 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
1881 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1882 Integration::ResourceId imageRequestId = imageRequest->GetId();
1883 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1885 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1886 bool finished = false;
1887 RenderTaskFinished renderTaskFinished( finished );
1888 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1889 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1890 application.SendNotification();
1892 // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating
1893 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false, __LINE__ ) );
1894 application.GetPlatform().ClearReadyResources();
1896 // ADD SOURCE ACTOR TO STAGE - expect continuous renders to start, no finished signal
1897 Stage::GetCurrent().Add(secondRootActor);
1898 application.SendNotification();
1900 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1901 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
1906 int UtcDaliRenderTaskContinuous02(void)
1908 TestApplication application;
1910 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not visible)\nPOST:continuous renders, no Finished signal");
1912 // SETUP AN OFFSCREEN RENDER TASK
1913 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1914 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1915 drawTrace.Enable(true);
1917 Actor rootActor = Actor::New();
1918 Stage::GetCurrent().Add( rootActor );
1920 CameraActor offscreenCameraActor = CameraActor::New();
1921 Stage::GetCurrent().Add( offscreenCameraActor );
1923 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
1924 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1925 Integration::ResourceId imageRequestId = imageRequest->GetId();
1926 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1927 Stage::GetCurrent().Add(secondRootActor);
1928 secondRootActor.SetVisible(false);
1930 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1931 bool finished = false;
1932 RenderTaskFinished renderTaskFinished( finished );
1933 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1934 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1935 application.SendNotification();
1937 // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating
1938 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false, __LINE__ ) );
1939 application.GetPlatform().ClearReadyResources();
1941 // MAKE SOURCE ACTOR VISIBLE - expect continuous renders to start, no finished signal
1942 secondRootActor.SetVisible(true);
1943 application.SendNotification();
1945 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1946 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
1950 int UtcDaliRenderTaskContinuous03(void)
1952 TestApplication application;
1954 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (camera actor not staged)\nPOST:continuous renders, no Finished signal");
1956 // SETUP AN OFFSCREEN RENDER TASK
1957 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1958 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1959 drawTrace.Enable(true);
1961 Actor rootActor = Actor::New();
1962 Stage::GetCurrent().Add( rootActor );
1964 CameraActor offscreenCameraActor = CameraActor::New();
1965 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
1966 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1967 Integration::ResourceId imageRequestId = imageRequest->GetId();
1968 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1969 Stage::GetCurrent().Add(secondRootActor);
1971 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1972 bool finished = false;
1973 RenderTaskFinished renderTaskFinished( finished );
1974 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1975 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1976 application.SendNotification();
1978 // START PROCESS/RENDER Input, Expected Input, Expected
1979 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false, __LINE__ ) );
1980 application.GetPlatform().ClearReadyResources();
1982 // ADD CAMERA ACTOR TO STAGE - expect continuous renders to start, no finished signal
1983 Stage::GetCurrent().Add( offscreenCameraActor );
1984 application.SendNotification();
1986 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1987 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
1992 int UtcDaliRenderTaskContinuous04(void)
1994 TestApplication application;
1996 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: Resource not ready\nPOST:continuous renders, no Finished signal");
1998 // SETUP AN OFFSCREEN RENDER TASK
1999 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2000 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2001 drawTrace.Enable(true);
2003 Actor rootActor = Actor::New();
2004 Stage::GetCurrent().Add( rootActor );
2006 CameraActor offscreenCameraActor = CameraActor::New();
2007 Stage::GetCurrent().Add( offscreenCameraActor );
2008 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
2009 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2010 Integration::ResourceId imageRequestId = imageRequest->GetId();
2011 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2012 Stage::GetCurrent().Add(secondRootActor);
2014 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2015 bool finished = false;
2016 RenderTaskFinished renderTaskFinished( finished );
2017 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2018 application.SendNotification();
2020 // START PROCESS/RENDER Input, Expected Input, Expected
2021 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2022 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2024 // FINISH RESOURCE LOADING - expect 'continuous' renders to start, no finished signal
2025 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2026 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2030 int UtcDaliRenderTaskContinous05(void)
2032 TestApplication application;
2034 tet_infoline("Testing RenderTask Render Continuous using Mesh which accesses texture through sampler with loading image\n"
2035 "PRE: Resource not ready\nPOST:continuous renders, no Finished signal");
2037 // SETUP AN OFFSCREEN RENDER TASK
2038 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2039 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2040 drawTrace.Enable(true);
2042 Actor rootActor = Actor::New();
2043 Stage::GetCurrent().Add( rootActor );
2045 CameraActor offscreenCameraActor = CameraActor::New();
2046 Stage::GetCurrent().Add( offscreenCameraActor );
2048 Shader shader = CreateShader();
2051 Image image = CreateLoadingImage(application, "aFile.jpg");
2052 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2053 Integration::ResourceId imageRequestId = imageRequest->GetId();
2054 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2055 TextureSet textureSet = CreateTextureSet( image );
2057 Geometry geometry = CreateQuadGeometry();
2058 Renderer renderer = Renderer::New(geometry, shader);
2059 renderer.SetTextures( textureSet );
2060 Actor secondRootActor = Actor::New();
2061 secondRootActor.AddRenderer(renderer);
2062 secondRootActor.SetSize(100, 100);
2063 Stage::GetCurrent().Add(secondRootActor);
2065 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2066 bool finished = false;
2067 RenderTaskFinished renderTaskFinished( finished );
2068 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2069 application.SendNotification();
2071 // START PROCESS/RENDER Input, Expected Input, Expected
2072 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2073 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2075 // FINISH RESOURCE LOADING - expect 'continuous' renders to start, no finished signal
2076 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2077 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2083 int UtcDaliRenderTaskOnce01(void)
2085 TestApplication application;
2087 tet_infoline("Testing RenderTask Render Once GlSync, using loading image\nPRE: Resources not ready, Source not visible\nPOST: Finished signal sent once only");
2089 // SETUP AN OFFSCREEN RENDER TASK
2090 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2091 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2092 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2093 drawTrace.Enable(true);
2095 Actor rootActor = Actor::New();
2096 Stage::GetCurrent().Add( rootActor );
2098 CameraActor offscreenCameraActor = CameraActor::New();
2099 Stage::GetCurrent().Add( offscreenCameraActor );
2100 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
2101 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2102 Integration::ResourceId imageRequestId = imageRequest->GetId();
2103 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2105 Stage::GetCurrent().Add(secondRootActor);
2107 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
2108 bool finished = false;
2109 RenderTaskFinished renderTaskFinished( finished );
2110 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2111 application.SendNotification();
2113 // START PROCESS/RENDER Input, Expected Input, Expected
2114 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2115 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2117 // MAKE SOURCE VISIBLE
2118 secondRootActor.SetVisible(true);
2119 application.SendNotification();
2120 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2121 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2123 // FINISH RESOURCE LOADING - expect no rendering yet
2124 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2125 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2126 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2127 DALI_TEST_CHECK( lastSyncObj != NULL );
2129 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2130 application.GetPlatform().ClearReadyResources();
2131 sync.SetObjectSynced( lastSyncObj, true );
2132 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2133 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2137 int UtcDaliRenderTaskOnce02(void)
2139 TestApplication application;
2141 tet_infoline("Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loading image.\n"
2142 "PRE: Resources not ready\nPOST: Finished signal sent once only");
2144 // SETUP AN OFFSCREEN RENDER TASK
2145 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2146 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2147 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2148 drawTrace.Enable(true);
2150 Actor rootActor = Actor::New();
2151 Stage::GetCurrent().Add( rootActor );
2153 CameraActor offscreenCameraActor = CameraActor::New();
2154 Stage::GetCurrent().Add( offscreenCameraActor );
2156 Shader shader = CreateShader();
2157 Image image = CreateLoadingImage(application, "aFile.jpg");
2158 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2159 Integration::ResourceId imageRequestId = imageRequest->GetId();
2160 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2161 TextureSet textureSet = CreateTextureSet( image );
2163 Geometry geometry = CreateQuadGeometry();
2164 Renderer renderer = Renderer::New(geometry, shader);
2165 renderer.SetTextures( textureSet );
2166 Actor secondRootActor = Actor::New();
2167 secondRootActor.AddRenderer(renderer);
2168 secondRootActor.SetSize(100, 100);
2169 Stage::GetCurrent().Add(secondRootActor);
2171 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
2172 bool finished = false;
2173 RenderTaskFinished renderTaskFinished( finished );
2174 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2175 application.SendNotification();
2177 // START PROCESS/RENDER Input, Expected Input, Expected
2178 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2179 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2181 // FINISH RESOURCE LOADING - expect no rendering yet
2182 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2183 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2184 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2185 DALI_TEST_CHECK( lastSyncObj != NULL );
2187 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2188 application.GetPlatform().ClearReadyResources();
2189 sync.SetObjectSynced( lastSyncObj, true );
2190 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2191 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2196 int UtcDaliRenderTaskOnce03(void)
2198 TestApplication application;
2200 tet_infoline("Testing RenderTask Render Once GlSync, using loading image. Switch from render always after ready to render once\n"
2201 "PRE: Render task ready, Image not loaded\n"
2202 "POST: Finished signal sent only once");
2204 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2205 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2206 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2207 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2208 drawTrace.Enable(true);
2210 Actor rootActor = Actor::New();
2211 Stage::GetCurrent().Add( rootActor );
2213 CameraActor offscreenCameraActor = CameraActor::New();
2214 Stage::GetCurrent().Add( offscreenCameraActor );
2215 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
2216 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2217 Integration::ResourceId imageRequestId = imageRequest->GetId();
2218 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2219 Stage::GetCurrent().Add(secondRootActor);
2221 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2222 bool finished = false;
2223 RenderTaskFinished renderTaskFinished( finished );
2224 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2225 application.SendNotification();
2227 // START PROCESS/RENDER Input, Expected Input, Expected
2228 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2229 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2231 // FINISH RESOURCE LOADING
2232 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2233 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2234 application.GetPlatform().ClearReadyResources();
2235 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2237 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2238 application.SendNotification(); // Input, Expected Input, Expected
2239 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2240 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2241 DALI_TEST_CHECK( lastSyncObj != NULL );
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 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2246 sync.SetObjectSynced( lastSyncObj, true );
2247 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2248 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2254 int UtcDaliRenderTaskOnce04(void)
2256 TestApplication application;
2257 tet_infoline("Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loading image.\n"
2258 "Switch from render always after ready to render once\n"
2259 "PRE: Render task ready, Image not loaded\n"
2260 "POST: Finished signal sent only once");
2262 // SETUP AN OFFSCREEN RENDER TASK
2263 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2264 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2265 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2266 drawTrace.Enable(true);
2268 Actor rootActor = Actor::New();
2269 Stage::GetCurrent().Add( rootActor );
2271 CameraActor offscreenCameraActor = CameraActor::New();
2272 Stage::GetCurrent().Add( offscreenCameraActor );
2274 Shader shader = CreateShader();
2275 Image image = CreateLoadingImage(application, "aFile.jpg");
2276 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2277 Integration::ResourceId imageRequestId = imageRequest->GetId();
2278 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2279 TextureSet textureSet = CreateTextureSet( image );
2281 Geometry geometry = CreateQuadGeometry();
2282 Renderer renderer = Renderer::New(geometry, shader);
2283 renderer.SetTextures( textureSet );
2284 Actor secondRootActor = Actor::New();
2285 secondRootActor.AddRenderer(renderer);
2286 secondRootActor.SetSize(100, 100);
2287 Stage::GetCurrent().Add(secondRootActor);
2289 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2290 bool finished = false;
2291 RenderTaskFinished renderTaskFinished( finished );
2292 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2293 application.SendNotification();
2295 // START PROCESS/RENDER Input, Expected Input, Expected
2296 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2297 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2299 // FINISH RESOURCE LOADING
2300 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2301 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2302 application.GetPlatform().ClearReadyResources();
2303 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2305 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2306 application.SendNotification(); // Input, Expected Input, Expected
2307 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2308 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2309 DALI_TEST_CHECK( lastSyncObj != NULL );
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 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2314 sync.SetObjectSynced( lastSyncObj, true );
2315 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2316 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2321 int UtcDaliRenderTaskOnce05(void)
2323 TestApplication application;
2325 tet_infoline("Testing RenderTask Render Once GlSync\n"
2326 "Switch from Render always after ready to render once with resources unready\n"
2327 "PRE: Everything ready to render\n"
2328 "POST: Finished signal sent once");
2330 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2331 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2332 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2333 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2334 drawTrace.Enable(true);
2336 Actor rootActor = Actor::New();
2337 Stage::GetCurrent().Add( rootActor );
2339 CameraActor offscreenCameraActor = CameraActor::New();
2340 Stage::GetCurrent().Add( offscreenCameraActor );
2341 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
2342 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2343 Integration::ResourceId imageRequestId = imageRequest->GetId();
2344 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2345 Stage::GetCurrent().Add(secondRootActor);
2347 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2348 bool finished = false;
2349 RenderTaskFinished renderTaskFinished( finished );
2350 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2351 application.SendNotification();
2353 // START PROCESS/RENDER Input, Expected Input, Expected
2354 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2355 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2357 // CHANGE TO RENDER ONCE
2358 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2359 application.SendNotification(); // Input, Expected Input, Expected
2360 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2361 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2363 // FINISH RESOURCE LOADING
2364 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2365 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2366 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2367 DALI_TEST_CHECK( lastSyncObj != NULL );
2368 application.GetPlatform().ClearReadyResources();
2370 sync.SetObjectSynced( lastSyncObj, true );
2372 // Expect: No draw - we've just drawn our render task once, above. No finished signal -
2373 // we won't read the gl sync until the next frame. Continue rendering - we're waiting for
2375 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2377 // Expect: 1 final draw - this Update doesn't update the scene, hence render instructions
2378 // from last frame but 1 are still present.
2379 // Finished signal should be true - we've just done the sync.
2380 // Should now stop rendering and updating - nothing left to do.
2381 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, true, false, __LINE__ ) );
2386 int UtcDaliRenderTaskOnce07(void)
2388 TestApplication application;
2390 tet_infoline("Testing RenderTask Render Once GLSync\n"
2391 "Render once, Second call to SetRefreshRate(ONCE) triggers only one more finished signal\n"
2392 "PRE: Everything ready\n"
2393 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
2395 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2396 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2397 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2398 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2399 drawTrace.Enable(true);
2401 Actor rootActor = Actor::New();
2402 Stage::GetCurrent().Add( rootActor );
2404 CameraActor offscreenCameraActor = CameraActor::New();
2405 Stage::GetCurrent().Add( offscreenCameraActor );
2406 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
2407 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2408 Integration::ResourceId imageRequestId = imageRequest->GetId();
2409 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2410 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2411 application.Render();
2412 application.GetPlatform().ClearReadyResources();
2414 Stage::GetCurrent().Add(secondRootActor);
2416 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2417 bool finished = false;
2418 RenderTaskFinished renderTaskFinished( finished );
2419 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2420 application.SendNotification();
2422 // START PROCESS/RENDER Input, Expected Input, Expected
2423 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2425 // CHANGE TO RENDER ONCE,
2426 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2427 application.SendNotification();
2428 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2429 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2430 DALI_TEST_CHECK( lastSyncObj != NULL );
2432 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2433 sync.SetObjectSynced( lastSyncObj, true );
2434 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2435 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2437 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2438 application.SendNotification();
2439 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2440 lastSyncObj = sync.GetLastSyncObject();
2441 DALI_TEST_CHECK( lastSyncObj != NULL );
2443 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2444 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2445 sync.SetObjectSynced( lastSyncObj, true );
2446 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2447 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2451 int UtcDaliRenderTaskOnce08(void)
2453 TestApplication application;
2455 tet_infoline("Testing RenderTask Render Once GLSync\n"
2456 "Render once, Call to SetRefreshRate(ONCE) in Finished signal callback triggers "
2457 "another render & another finished signal\n"
2458 "PRE: Everything ready\n"
2459 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
2462 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2463 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2464 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2465 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2466 sync.GetTrace().Enable(true);
2467 drawTrace.Enable(true);
2469 Actor rootActor = Actor::New();
2470 Stage::GetCurrent().Add( rootActor );
2472 CameraActor offscreenCameraActor = CameraActor::New();
2473 Stage::GetCurrent().Add( offscreenCameraActor );
2474 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
2475 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2476 Integration::ResourceId imageRequestId = imageRequest->GetId();
2477 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2478 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2479 application.Render();
2480 application.GetPlatform().ClearReadyResources();
2482 Stage::GetCurrent().Add(secondRootActor);
2484 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, /*GL-SYNC*/ true);
2485 bool finished = false;
2487 ConnectionTracker connectionTracker;
2488 RenderTaskFinishedRenderAgain renderTaskFinishedRenderAgain( finished );
2489 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinishedRenderAgain );
2491 application.SendNotification();
2493 // START PROCESS/RENDER Input, Expected Input, Expected
2494 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2495 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2496 DALI_TEST_CHECK( lastSyncObj == NULL );
2497 DALI_TEST_EQUALS( sync.GetTrace().CountMethod( "CreateSyncObject" ), 0, TEST_LOCATION );
2500 // CHANGE TO RENDER ONCE,
2501 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2502 application.SendNotification();
2503 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2504 lastSyncObj = sync.GetLastSyncObject();
2505 DALI_TEST_CHECK( lastSyncObj != NULL );
2506 DALI_TEST_EQUALS( sync.GetNumberOfSyncObjects(), 1, TEST_LOCATION );
2507 DALI_TEST_EQUALS( sync.GetTrace().CountMethod( "CreateSyncObject" ), 1, TEST_LOCATION );
2509 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2512 DALI_TEST_EQUALS( sync.GetNumberOfSyncObjects(), 1, TEST_LOCATION );
2513 DALI_TEST_EQUALS( sync.GetTrace().CountMethod( "CreateSyncObject" ), 1, TEST_LOCATION );
2515 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2517 DALI_TEST_EQUALS( sync.GetNumberOfSyncObjects(), 1, TEST_LOCATION );
2518 DALI_TEST_EQUALS( sync.GetTrace().CountMethod( "CreateSyncObject" ), 1, TEST_LOCATION );
2520 sync.SetObjectSynced( lastSyncObj, true );
2521 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2522 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2523 application.SendNotification();
2525 // Expect SetRefreshRate to have been called again
2526 // Prevent next finished signal calling refresh once again
2527 RenderTaskFinished renderTaskFinished( finished );
2528 connectionTracker.DisconnectAll();
2529 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinished );
2530 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2531 lastSyncObj = sync.GetLastSyncObject();
2532 DALI_TEST_CHECK( lastSyncObj != NULL );
2534 sync.SetObjectSynced( lastSyncObj, true );
2535 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2536 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2541 int UtcDaliRenderTaskOnce09(void)
2543 TestApplication application;
2545 tet_infoline("Testing RenderTask Render Once GlSync\n"
2546 "SetRefreshRate(ONCE) again before first finished signal has been sent.\n"
2547 "PRE: resources ready\n"
2548 "POST: Only 1 finished signal sent.");
2550 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2551 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2552 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2553 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2554 drawTrace.Enable(true);
2556 Actor rootActor = Actor::New();
2557 Stage::GetCurrent().Add( rootActor );
2559 CameraActor offscreenCameraActor = CameraActor::New();
2560 Stage::GetCurrent().Add( offscreenCameraActor );
2561 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
2562 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2563 Integration::ResourceId imageRequestId = imageRequest->GetId();
2564 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2565 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2566 application.Render();
2567 application.GetPlatform().ClearReadyResources();
2569 Stage::GetCurrent().Add(secondRootActor);
2571 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2572 bool finished = false;
2573 RenderTaskFinished renderTaskFinished( finished );
2574 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2575 application.SendNotification();
2577 // START PROCESS/RENDER Input, Expected Input, Expected
2578 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2580 // CHANGE TO RENDER ONCE,
2581 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2582 application.SendNotification();
2583 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2584 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2585 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2587 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2588 application.SendNotification();
2589 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2590 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2591 DALI_TEST_CHECK( lastSyncObj != NULL );
2593 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2594 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2595 sync.SetObjectSynced( lastSyncObj, true );
2596 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2597 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2602 int UtcDaliRenderTaskOnce10(void)
2604 TestApplication application;
2606 tet_infoline("Testing RenderTask Render Once GlSync\n"
2607 "SetRefreshRate(ONCE), resource load failed completes render task.\n"
2608 "PRE: resources not ready\n"
2609 "POST: Only 1 finished signal sent.");
2611 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2612 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2613 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2614 drawTrace.Enable(true);
2616 Actor rootActor = Actor::New();
2617 Stage::GetCurrent().Add( rootActor );
2619 CameraActor offscreenCameraActor = CameraActor::New();
2620 Stage::GetCurrent().Add( offscreenCameraActor );
2621 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
2622 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2623 Integration::ResourceId imageRequestId = imageRequest->GetId();
2624 Stage::GetCurrent().Add(secondRootActor);
2626 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2627 bool finished = false;
2628 RenderTaskFinished renderTaskFinished( finished );
2629 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2630 application.SendNotification();
2632 // START PROCESS/RENDER Input, Expected Input, Expected
2633 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2634 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2636 // CHANGE TO RENDER ONCE,
2637 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2638 application.SendNotification();
2639 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2640 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2641 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2643 tet_printf(" FailImageLoad\n");
2645 FailImageLoad(application, imageRequestId); // Need to run Update again for this to complete
2647 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); // nothing to draw
2648 application.SendNotification();
2650 // load is now failed so there's nothing more to render in the render task
2651 // Expect finished signal, as all resources are complete
2652 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2657 int UtcDaliRenderTaskOnceNoSync01(void)
2659 TestApplication application;
2661 tet_infoline("Testing RenderTask Render Once, using loading image\nPRE: Resources not ready, Source not visible\nPOST: Finished signal sent once only");
2663 // SETUP AN OFFSCREEN RENDER TASK
2664 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2665 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2666 drawTrace.Enable(true);
2668 Actor rootActor = Actor::New();
2669 Stage::GetCurrent().Add( rootActor );
2671 CameraActor offscreenCameraActor = CameraActor::New();
2672 Stage::GetCurrent().Add( offscreenCameraActor );
2673 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
2674 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2675 Integration::ResourceId imageRequestId = imageRequest->GetId();
2676 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2678 Stage::GetCurrent().Add(secondRootActor);
2680 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2681 bool finished = false;
2682 RenderTaskFinished renderTaskFinished( finished );
2683 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2684 application.SendNotification();
2686 // START PROCESS/RENDER Input, Expected Input, Expected
2687 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2688 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2690 // FINISH RESOURCE LOADING - expect immediate rendering yet
2691 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2692 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2693 application.GetPlatform().ClearReadyResources();
2694 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2698 int UtcDaliRenderTaskOnceNoSync02(void)
2700 TestApplication application;
2702 tet_infoline("Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loading image.\n"
2703 "PRE: Resources not ready\nPOST: Finished signal sent once only");
2704 // SETUP AN OFFSCREEN RENDER TASK
2705 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2706 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2707 drawTrace.Enable(true);
2709 Actor rootActor = Actor::New();
2710 Stage::GetCurrent().Add( rootActor );
2712 CameraActor offscreenCameraActor = CameraActor::New();
2713 Stage::GetCurrent().Add( offscreenCameraActor );
2715 Shader shader = CreateShader();
2716 Image image = CreateLoadingImage(application, "aFile.jpg");
2717 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2718 Integration::ResourceId imageRequestId = imageRequest->GetId();
2719 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2720 TextureSet textureSet = CreateTextureSet( image );
2722 Geometry geometry = CreateQuadGeometry();
2723 Renderer renderer = Renderer::New(geometry, shader);
2724 renderer.SetTextures( textureSet );
2725 Actor secondRootActor = Actor::New();
2726 secondRootActor.AddRenderer(renderer);
2727 secondRootActor.SetSize(100, 100);
2728 Stage::GetCurrent().Add(secondRootActor);
2730 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2731 bool finished = false;
2732 RenderTaskFinished renderTaskFinished( finished );
2733 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2734 application.SendNotification();
2736 // START PROCESS/RENDER Input, Expected Input, Expected
2737 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2738 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2740 // FINISH RESOURCE LOADING - expect immediate rendering yet
2741 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2742 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2743 application.GetPlatform().ClearReadyResources();
2744 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2749 int UtcDaliRenderTaskOnceNoSync03(void)
2751 TestApplication application;
2753 tet_infoline("Testing RenderTask Render Once, using loading image. Switch from render always after ready to render once\n"
2754 "PRE: Render task ready, Image not loaded\n"
2755 "POST: Finished signal sent only once");
2757 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2758 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2759 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2760 drawTrace.Enable(true);
2762 Actor rootActor = Actor::New();
2763 Stage::GetCurrent().Add( rootActor );
2765 CameraActor offscreenCameraActor = CameraActor::New();
2766 Stage::GetCurrent().Add( offscreenCameraActor );
2767 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
2768 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2769 Integration::ResourceId imageRequestId = imageRequest->GetId();
2770 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2771 Stage::GetCurrent().Add(secondRootActor);
2773 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2774 bool finished = false;
2775 RenderTaskFinished renderTaskFinished( finished );
2776 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2777 application.SendNotification();
2779 // START PROCESS/RENDER Input, Expected Input, Expected
2780 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2781 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2783 // FINISH RESOURCE LOADING
2784 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2785 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2786 application.GetPlatform().ClearReadyResources();
2788 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2789 application.SendNotification(); // Input, Expected Input, Expected
2790 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2791 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2795 int UtcDaliRenderTaskOnceNoSync04(void)
2797 TestApplication application;
2799 tet_infoline("Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loading image.\n"
2800 "Switch from render always after ready to render once\n"
2801 "PRE: Render task ready, Image not loaded\n"
2802 "POST: Finished signal sent only once");
2804 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2805 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2806 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2807 drawTrace.Enable(true);
2809 Actor rootActor = Actor::New();
2810 Stage::GetCurrent().Add( rootActor );
2812 CameraActor offscreenCameraActor = CameraActor::New();
2813 Stage::GetCurrent().Add( offscreenCameraActor );
2815 Shader shader = CreateShader();
2816 Image image = CreateLoadingImage(application, "aFile.jpg");
2817 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2818 Integration::ResourceId imageRequestId = imageRequest->GetId();
2819 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2820 TextureSet textureSet = CreateTextureSet( image );
2822 Geometry geometry = CreateQuadGeometry();
2823 Renderer renderer = Renderer::New(geometry, shader);
2824 renderer.SetTextures( textureSet );
2825 Actor secondRootActor = Actor::New();
2826 secondRootActor.AddRenderer(renderer);
2827 secondRootActor.SetSize(100, 100);
2828 Stage::GetCurrent().Add(secondRootActor);
2831 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2832 bool finished = false;
2833 RenderTaskFinished renderTaskFinished( finished );
2834 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2835 application.SendNotification();
2837 // START PROCESS/RENDER Input, Expected Input, Expected
2838 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2839 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2841 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2842 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2843 DALI_TEST_CHECK( lastSyncObj == NULL );
2845 // FINISH RESOURCE LOADING
2846 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2847 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2848 application.GetPlatform().ClearReadyResources();
2850 lastSyncObj = sync.GetLastSyncObject();
2851 DALI_TEST_CHECK( lastSyncObj == NULL );
2853 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2854 application.SendNotification(); // Input, Expected Input, Expected
2855 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2856 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2858 lastSyncObj = sync.GetLastSyncObject();
2859 DALI_TEST_CHECK( lastSyncObj == NULL );
2864 int UtcDaliRenderTaskOnceNoSync05(void)
2866 TestApplication application;
2868 tet_infoline("Testing RenderTask Render Once\n"
2869 "Switch from Render always after ready to render once with resources unready\n"
2870 "PRE: Everything ready to render\n"
2871 "POST: Finished signal sent once");
2873 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2874 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2875 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2876 drawTrace.Enable(true);
2878 Actor rootActor = Actor::New();
2879 Stage::GetCurrent().Add( rootActor );
2881 CameraActor offscreenCameraActor = CameraActor::New();
2882 Stage::GetCurrent().Add( offscreenCameraActor );
2883 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
2884 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2885 Integration::ResourceId imageRequestId = imageRequest->GetId();
2886 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2887 Stage::GetCurrent().Add(secondRootActor);
2889 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2890 bool finished = false;
2891 RenderTaskFinished renderTaskFinished( finished );
2892 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2893 application.SendNotification();
2895 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2896 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2897 DALI_TEST_CHECK( lastSyncObj == NULL );
2899 // START PROCESS/RENDER Input, Expected Input, Expected
2900 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2901 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2903 // CHANGE TO RENDER ONCE
2904 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2905 application.SendNotification(); // Input, Expected Input, Expected
2906 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2907 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2909 // FINISH RESOURCE LOADING
2910 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2911 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2912 application.GetPlatform().ClearReadyResources();
2913 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2917 int UtcDaliRenderTaskOnceNoSync07(void)
2919 TestApplication application;
2921 tet_infoline("Testing RenderTask Render Once\n"
2922 "Render once, Second call to SetRefreshRate(ONCE) triggers only one more finished signal\n"
2923 "PRE: Everything ready\n"
2924 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
2926 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2927 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2928 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2929 drawTrace.Enable(true);
2931 Actor rootActor = Actor::New();
2932 Stage::GetCurrent().Add( rootActor );
2934 CameraActor offscreenCameraActor = CameraActor::New();
2935 Stage::GetCurrent().Add( offscreenCameraActor );
2936 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
2937 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2938 Integration::ResourceId imageRequestId = imageRequest->GetId();
2939 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2940 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2941 application.Render();
2942 application.GetPlatform().ClearReadyResources();
2944 Stage::GetCurrent().Add(secondRootActor);
2946 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2947 bool finished = false;
2948 RenderTaskFinished renderTaskFinished( finished );
2949 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2950 application.SendNotification();
2952 // START PROCESS/RENDER Input, Expected Input, Expected
2953 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2955 // CHANGE TO RENDER ONCE,
2956 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2957 application.SendNotification();
2958 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2959 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2961 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2962 application.SendNotification();
2963 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2964 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2968 int UtcDaliRenderTaskOnceNoSync08(void)
2970 TestApplication application;
2972 tet_infoline("Testing RenderTask Render Once\n"
2973 "Render once, Call to SetRefreshRate(ONCE) in Finished signal callback triggers\n"
2974 "another render & another finished signal\n"
2975 "PRE: Everything ready\n"
2976 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
2979 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2980 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2981 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2982 drawTrace.Enable(true);
2984 Actor rootActor = Actor::New();
2985 Stage::GetCurrent().Add( rootActor );
2987 CameraActor offscreenCameraActor = CameraActor::New();
2988 Stage::GetCurrent().Add( offscreenCameraActor );
2989 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
2990 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2991 Integration::ResourceId imageRequestId = imageRequest->GetId();
2992 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2993 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2994 application.Render();
2995 application.GetPlatform().ClearReadyResources();
2997 Stage::GetCurrent().Add(secondRootActor);
2999 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3000 bool finished = false;
3002 ConnectionTracker connectionTracker;
3003 RenderTaskFinishedRenderAgain renderTaskFinishedRenderAgain( finished );
3004 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinishedRenderAgain );
3006 application.SendNotification();
3008 // START PROCESS/RENDER Input, Expected Input, Expected
3009 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
3011 // CHANGE TO RENDER ONCE,
3012 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3013 application.SendNotification();
3014 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3015 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3017 // Expect SetRefreshRate to have been called again
3018 // Prevent next finished signal calling refresh once again
3019 RenderTaskFinished renderTaskFinished( finished );
3020 connectionTracker.DisconnectAll();
3021 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinished );
3023 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3024 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3029 int UtcDaliRenderTaskOnceNoSync09(void)
3031 TestApplication application;
3033 tet_infoline("Testing RenderTask Render Once\n"
3034 "SetRefreshRate(ONCE) again before first finished signal has been sent.\n"
3035 "PRE: resources ready\n"
3036 "POST: Only 1 finished signal sent.");
3038 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3039 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3040 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3041 drawTrace.Enable(true);
3043 Actor rootActor = Actor::New();
3044 Stage::GetCurrent().Add( rootActor );
3046 CameraActor offscreenCameraActor = CameraActor::New();
3047 Stage::GetCurrent().Add( offscreenCameraActor );
3048 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
3049 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3050 Integration::ResourceId imageRequestId = imageRequest->GetId();
3051 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
3052 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
3053 application.Render();
3054 application.GetPlatform().ClearReadyResources();
3056 Stage::GetCurrent().Add(secondRootActor);
3058 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3059 bool finished = false;
3060 RenderTaskFinished renderTaskFinished( finished );
3061 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3062 application.SendNotification();
3064 // START PROCESS/RENDER Input, Expected Input, Expected
3065 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
3067 // CHANGE TO RENDER ONCE,
3068 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3069 application.SendNotification();
3070 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3071 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3073 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3074 application.SendNotification();
3075 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3076 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3080 int UtcDaliRenderTaskOnceNoSync10(void)
3082 TestApplication application;
3084 tet_infoline("Testing RenderTask Render Once\n"
3085 "SetRefreshRate(ONCE), resource load failed, completes render task.\n"
3086 "PRE: resources not ready\n"
3087 "POST: Only 1 finished signal sent.");
3089 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3090 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3091 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3092 drawTrace.Enable(true);
3094 Actor rootActor = Actor::New();
3095 Stage::GetCurrent().Add( rootActor );
3097 CameraActor offscreenCameraActor = CameraActor::New();
3098 Stage::GetCurrent().Add( offscreenCameraActor );
3099 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg");
3100 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3101 Integration::ResourceId imageRequestId = imageRequest->GetId();
3102 Stage::GetCurrent().Add(secondRootActor);
3104 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3105 bool finished = false;
3106 RenderTaskFinished renderTaskFinished( finished );
3107 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3108 application.SendNotification();
3110 // START PROCESS/RENDER Input, Expected Input, Expected
3111 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3112 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3114 // CHANGE TO RENDER ONCE,
3115 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3116 application.SendNotification();
3117 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3118 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3119 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3121 FailImageLoad(application, imageRequestId); // Need to run Update again for this to complete
3122 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); // nothing to draw
3123 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3130 int UtcDaliRenderTaskOnceChain01(void)
3132 TestApplication application;
3134 tet_infoline("Testing RenderTask Render Once Chained render tasks\n"
3135 "SetRefreshRate(ONCE), resource load completes, both render tasks render.\n"
3136 "PRE: resources not ready\n"
3137 "POST: 2 finished signals sent.");
3139 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3140 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3141 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3142 drawTrace.Enable(true);
3144 Actor defaultRootActor = Actor::New(); // Root for default RT
3145 Stage::GetCurrent().Add( defaultRootActor );
3147 CameraActor offscreenCameraActor = CameraActor::New();
3148 Stage::GetCurrent().Add( offscreenCameraActor );
3149 Actor firstRootActor = CreateLoadingActor(application, "aFile.jpg");
3150 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3151 Integration::ResourceId imageRequestId = imageRequest->GetId();
3152 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
3153 Stage::GetCurrent().Add(firstRootActor);
3155 // first render task
3156 RenderTask firstTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, firstRootActor, RenderTask::REFRESH_ONCE, false);
3157 bool firstFinished = false;
3158 RenderTaskFinished renderTask1Finished( firstFinished );
3159 firstTask.FinishedSignal().Connect( &application, renderTask1Finished );
3161 // Second render task
3162 FrameBufferImage fbo = firstTask.GetTargetFrameBuffer();
3163 Actor secondRootActor = CreateRenderableActor( fbo );
3164 Stage::GetCurrent().Add(secondRootActor);
3165 RenderTask secondTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
3166 bool secondFinished = false;
3167 RenderTaskFinished renderTask2Finished( secondFinished );
3168 secondTask.FinishedSignal().Connect( &application, renderTask2Finished );
3170 application.SendNotification();
3172 // START PROCESS/RENDER Input, Expected Input, Expected
3173 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__ ) );
3174 DALI_TEST_CHECK( firstFinished == false );
3175 DALI_TEST_CHECK( secondFinished == false );
3176 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__ ) );
3177 DALI_TEST_CHECK( firstFinished == false );
3178 DALI_TEST_CHECK( secondFinished == false );
3180 CompleteImageLoad(application, imageRequestId, imageType);
3181 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__ ) );
3182 DALI_TEST_CHECK( firstFinished == false );
3183 DALI_TEST_CHECK( secondFinished == false );
3185 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, true, true, __LINE__ ) );
3186 DALI_TEST_CHECK( firstFinished == true );
3187 DALI_TEST_CHECK( secondFinished == false );
3189 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, secondFinished, true, false, __LINE__ ) );
3190 DALI_TEST_CHECK( secondFinished == true );
3195 int UtcDaliRenderTaskProperties(void)
3197 TestApplication application;
3199 RenderTask task = Stage::GetCurrent().GetRenderTaskList().CreateTask();
3201 Property::IndexContainer indices;
3202 task.GetPropertyIndices( indices );
3203 DALI_TEST_CHECK( indices.Size() );
3204 DALI_TEST_EQUALS( indices.Size(), task.GetPropertyCount(), TEST_LOCATION );
3208 int UtcDaliRenderTaskSetScreenToFrameBufferMappingActor(void)
3210 TestApplication application;
3211 tet_infoline("Testing RenderTask::SetScreenToFrameBufferMappingActor ");
3213 Stage stage = Stage::GetCurrent();
3214 Size stageSize = stage.GetSize();
3215 Actor mappingActor = Actor::New();
3216 Vector2 scale( 0.6f, 0.75f);
3217 Vector2 offset( stageSize.x*0.1f, stageSize.y*0.15f);
3218 mappingActor.SetSize( stageSize * scale );
3219 mappingActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
3220 mappingActor.SetPosition( offset.x, offset.y );
3221 stage.Add( mappingActor );
3223 Actor offscreenActor = Actor::New();
3224 offscreenActor.SetSize( stageSize );
3225 offscreenActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
3226 stage.Add( offscreenActor );
3228 RenderTaskList taskList = stage.GetRenderTaskList();
3229 RenderTask renderTask = taskList.CreateTask();
3230 FrameBufferImage frameBufferImage = FrameBufferImage::New(stageSize.width*scale.x, stageSize.height*scale.y, Pixel::A8);
3231 renderTask.SetSourceActor( offscreenActor );
3232 renderTask.SetExclusive( true );
3233 renderTask.SetInputEnabled( true );
3234 renderTask.SetTargetFrameBuffer( frameBufferImage );
3235 renderTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
3236 renderTask.SetScreenToFrameBufferMappingActor( mappingActor );
3237 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3239 // Render and notify
3240 application.SendNotification();
3241 application.Render();
3242 application.Render();
3243 application.SendNotification();
3245 Vector2 screenCoordinates( stageSize.x * 0.05f, stageSize.y * 0.05f );
3246 Dali::HitTestAlgorithm::Results results;
3247 DALI_TEST_CHECK( !results.actor );
3248 DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
3249 // miss expected, results not changed
3250 DALI_TEST_CHECK( false == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3251 DALI_TEST_CHECK( !results.actor );
3252 DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
3254 screenCoordinates.x = stageSize.x * 0.265f;
3255 screenCoordinates.y = stageSize.y * 0.33f;
3256 results.actor = Actor();
3257 results.actorCoordinates = Vector2::ZERO;
3258 // hit expected, results changed
3259 DALI_TEST_CHECK( true == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3260 DALI_TEST_CHECK( results.actor == offscreenActor );
3261 DALI_TEST_EQUALS( (screenCoordinates-offset)/scale , results.actorCoordinates, 0.1f, TEST_LOCATION );
3263 screenCoordinates.x = stageSize.x * 0.435f;
3264 screenCoordinates.y = stageSize.y * 0.52f;
3265 // hit expected, results changed
3266 DALI_TEST_CHECK( true == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3267 DALI_TEST_CHECK( results.actor == offscreenActor );
3268 const Vector2 expectedCoordinates = (screenCoordinates-offset)/scale;
3269 DALI_TEST_EQUALS( expectedCoordinates , results.actorCoordinates, 0.1f, TEST_LOCATION );
3271 screenCoordinates.x = stageSize.x * 0.65f;
3272 screenCoordinates.y = stageSize.y * 0.95f;
3273 // miss expected, results not changed
3274 DALI_TEST_CHECK( false == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3275 DALI_TEST_CHECK( results.actor == offscreenActor );
3276 DALI_TEST_EQUALS( expectedCoordinates , results.actorCoordinates, 0.1f, TEST_LOCATION );
3280 int UtcDaliRenderTaskFinishInvisibleSourceActor(void)
3282 TestApplication application;
3284 tet_infoline("Testing RenderTask::FinishInvisibleSourceActor()");
3286 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3287 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
3289 CameraActor offscreenCameraActor = CameraActor::New();
3291 Stage::GetCurrent().Add( offscreenCameraActor );
3293 BufferImage image = BufferImage::New( 10, 10 );
3294 Actor rootActor = CreateRenderableActor( image );
3295 rootActor.SetSize( 10, 10 );
3296 rootActor.SetVisible(false);
3297 Stage::GetCurrent().Add( rootActor );
3299 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3300 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
3301 FrameBufferImage frameBufferImage = FrameBufferImage::New( *testNativeImagePtr.Get() );
3303 // Flush all outstanding messages
3304 application.SendNotification();
3305 application.Render();
3307 RenderTask newTask = taskList.CreateTask();
3308 newTask.SetCameraActor( offscreenCameraActor );
3309 newTask.SetSourceActor( rootActor );
3310 newTask.SetInputEnabled( false );
3311 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
3312 newTask.SetClearEnabled( true );
3313 newTask.SetExclusive( true );
3314 newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
3315 newTask.SetTargetFrameBuffer( frameBufferImage );
3316 newTask.SetProperty( RenderTask::Property::REQUIRES_SYNC, true );
3318 // Framebuffer doesn't actually get created until Connected, i.e. by previous line
3320 bool finished = false;
3321 RenderTaskFinished renderTaskFinished( finished );
3322 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3324 // Flush the queue and render.
3325 application.SendNotification();
3327 // 1 render to process render task, then wait for sync before finished msg is sent
3328 // from update to the event thread.
3330 application.Render();
3331 application.SendNotification();
3332 DALI_TEST_CHECK( !finished );
3334 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
3335 DALI_TEST_CHECK( lastSyncObj != NULL );
3337 application.Render();
3338 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
3339 application.SendNotification();
3340 DALI_TEST_CHECK( !finished );
3342 application.Render();
3343 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
3344 application.SendNotification();
3345 DALI_TEST_CHECK( ! finished );
3347 sync.SetObjectSynced( lastSyncObj, true );
3349 application.Render();
3350 application.SendNotification();
3351 DALI_TEST_CHECK( !finished );
3353 application.Render();
3354 application.SendNotification();
3355 DALI_TEST_CHECK( finished );
3358 application.Render(); // Double check no more finished signal
3359 application.SendNotification();
3360 DALI_TEST_CHECK( ! finished );
3365 int UtcDaliRenderTaskFinishMissingImage(void)
3367 TestApplication application;
3369 // Previously we had bugs where not having a resource ID would cause render-tasks to wait forever
3370 tet_infoline("Testing RenderTask::SignalFinished() when an Actor has no Image set");
3372 Stage stage = Stage::GetCurrent();
3374 BufferImage image = BufferImage::New( 10, 10 );
3375 Actor rootActor = CreateRenderableActor( image );
3376 rootActor.SetSize( 10, 10 );
3377 stage.Add( rootActor );
3379 Actor actorWithMissingImage = CreateRenderableActor( Image() );
3380 actorWithMissingImage.SetSize( 10, 10 );
3381 stage.Add( actorWithMissingImage );
3383 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3384 RenderTask newTask = taskList.CreateTask();
3385 newTask.SetInputEnabled( false );
3386 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
3387 newTask.SetClearEnabled( true );
3388 newTask.SetExclusive( true );
3389 newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
3391 bool finished = false;
3392 RenderTaskFinished renderTaskFinished( finished );
3393 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3395 // 1 render to process render task, then 1 before finished msg is sent from update to the event thread.
3396 application.SendNotification();
3397 application.Render();
3398 application.Render();
3400 application.SendNotification();
3401 DALI_TEST_CHECK( finished );
3406 int UtcDaliRenderTaskWorldToViewport(void)
3408 TestApplication application( static_cast<size_t>(400), static_cast<size_t>(400) ); // square surface
3410 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3412 Actor actor = Actor::New();
3413 actor.SetSize(100.0f, 100.0f);
3414 actor.SetPosition( Vector3(0.0, 0.0, 0.0) );
3416 actor.SetParentOrigin( Vector3(0.5, 0.5, 0.5) );
3417 actor.SetAnchorPoint( Vector3(0.5, 0.5, 0.5) );
3419 Stage::GetCurrent().Add(actor);
3421 application.SendNotification();
3422 application.Render();
3423 application.SendNotification();
3425 RenderTask task = taskList.GetTask( 0u );
3427 CameraActor camera = task.GetCameraActor();
3429 Vector2 screenSize = task.GetCurrentViewportSize();
3431 float screenX = 0.0;
3432 float screenY = 0.0;
3434 bool ok = task.WorldToViewport(actor.GetCurrentWorldPosition(), screenX, screenY);
3435 DALI_TEST_CHECK(ok == true);
3437 DALI_TEST_EQUALS(screenX, screenSize.x/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
3438 DALI_TEST_EQUALS(screenY, screenSize.y/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
3440 Actor actor2 = Actor::New();
3441 float actor2Size = 100.f;
3442 actor2.SetSize( actor2Size, actor2Size );
3443 actor2.SetPosition( Vector3(0.0, 0.0, 0.0) );
3444 actor2.SetParentOrigin( Vector3(0.5, 0.5, 0.0) );
3445 actor2.SetAnchorPoint( Vector3(0.5, 0.5, 0.0) );
3446 Stage::GetCurrent().Add( actor2 );
3448 actor.SetParentOrigin( Vector3(0,0,0) );
3450 application.SendNotification();
3451 application.Render();
3452 application.SendNotification();
3454 ok = task.WorldToViewport(actor.GetCurrentWorldPosition(), screenX, screenY);
3455 DALI_TEST_CHECK(ok == true);
3457 DALI_TEST_EQUALS(screenX, screenSize.x/2 - actor2Size/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
3458 DALI_TEST_EQUALS(screenY, screenSize.y/2 - actor2Size/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
3464 int UtcDaliRenderTaskViewportToLocal(void)
3466 TestApplication application;
3467 Actor actor = Actor::New();
3468 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
3469 actor.SetSize(100.0f, 100.0f);
3470 actor.SetPosition(10.0f, 10.0f);
3471 Stage::GetCurrent().Add(actor);
3473 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3474 RenderTask task = taskList.GetTask( 0u );
3476 // flush the queue and render once
3477 application.SendNotification();
3478 application.Render();
3479 application.SendNotification();
3480 application.Render();
3488 float screenX = 50.0f;
3489 float screenY = 50.0f;
3491 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, screenX, screenY) );
3493 DALI_TEST_CHECK( task.ViewportToLocal(actor, screenX, screenY, rtLocalX, rtLocalY ) );
3495 DALI_TEST_EQUALS(localX, rtLocalX, 0.01f, TEST_LOCATION);
3496 DALI_TEST_EQUALS(localY, rtLocalY, 0.01f, TEST_LOCATION);