2 * Copyright (c) 2014 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.
21 #include <dali/public-api/dali-core.h>
22 #include <dali-test-suite-utils.h>
23 #include <dali/integration-api/debug.h>
24 #include <test-native-image.h>
26 #define BOOLSTR(x) ((x)?"T":"F")
31 void utc_dali_render_task_startup(void)
33 test_return_value = TET_UNDEF;
36 void utc_dali_render_task_cleanup(void)
38 test_return_value = TET_PASS;
44 * Constructor, Destructor, DownCast, New, copy constructor, assignment operator
46 * SetSourceActor 2+ve, 1-ve
47 * GetSourceActor 1+ve, 1-ve
48 * SetExclusive 2+ve, 0-ve
49 * IsExclusive 2+ve, 0-ve
50 * SetInputEnabled 1+ve, 0-ve
51 * GetInputEnabled 1+ve, 0-ve
52 * SetCameraActor 1+ve, 1-ve
53 * GetCameraActor 1+ve, 1-ve
54 * SetTargetFrameBuffer 1+ve, 1-ve
55 * GetTargetFrameBuffer 1+ve, 1-ve
56 * SetScreenToFrameBufferFunction 1+ve, 1-ve
57 * GetScreenToFrameBufferFunction 1+ve, 1-ve
58 * SetScreenToFrameBufferMappingActor 1+ve, 1-ve
59 * GetScreenToFrameBufferMappingActor 1+ve, 1-ve
60 * SetViewportPosition 1+ve
61 * GetCurrentViewportPosition 1+ve
62 * SetViewportSize 1+ve
63 * GetCurrentViewportSize 1+ve
64 * SetViewport 2+ve, 1-ve
65 * GetViewport 2+ve, 1-ve
66 * SetClearColor 1+ve, 1-ve
67 * GetClearColor 1+ve, 1-ve
68 * SetClearEnabled 1+ve, 1-ve
69 * GetClearEnabled 1+ve, 1-ve
77 namespace // unnamed namespace
80 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
83 * Simulate time passed by.
85 * @note this will always process at least 1 frame (1/60 sec)
87 * @param application Test application instance
88 * @param duration Time to pass in milliseconds.
89 * @return The actual time passed in milliseconds
91 int Wait(TestApplication& application, int duration = 0)
95 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
97 application.SendNotification();
98 application.Render(RENDER_FRAME_INTERVAL);
99 time += RENDER_FRAME_INTERVAL;
105 struct RenderTaskFinished
107 RenderTaskFinished( bool& finished )
108 : finished( finished )
112 void operator()( RenderTask& renderTask )
120 struct RenderTaskFinishedRemoveSource
122 RenderTaskFinishedRemoveSource( bool& finished )
123 : finished( finished ),
128 void operator()( RenderTask& renderTask )
130 DALI_TEST_CHECK(finishedOnce == false);
133 Actor srcActor = renderTask.GetSourceActor();
134 UnparentAndReset(srcActor);
141 struct RenderTaskFinishedRenderAgain
143 RenderTaskFinishedRenderAgain( bool& finished )
144 : finished( finished ),
149 void operator()( RenderTask& renderTask )
151 DALI_TEST_CHECK(finishedOnce == false);
154 renderTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
162 bool TestScreenToFrameBufferFunction( Vector2& coordinates )
164 coordinates = coordinates + Vector2( 1, 2 );
169 ImageActor CreateLoadingImage(TestApplication& application, std::string filename, ResourceImage::LoadPolicy loadPolicy, Image::ReleasePolicy releasePolicy)
171 Image image = ResourceImage::New(filename, loadPolicy, releasePolicy);
172 DALI_TEST_CHECK( image );
173 application.SendNotification();
174 application.Render(16);
175 DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
176 ImageActor actor = ImageActor::New(image);
177 actor.SetSize( 80, 80 );
178 application.SendNotification();
179 application.Render(16);
183 void CompleteImageLoad(TestApplication& application, Integration::ResourceId resourceId, Integration::ResourceTypeId requestType)
185 std::vector<GLuint> ids;
187 application.GetGlAbstraction().SetNextTextureIds( ids );
189 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
190 Integration::ResourcePointer resource(bitmap);
191 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80);
193 application.GetPlatform().SetResourceLoaded(resourceId, requestType, resource);
196 void FailImageLoad(TestApplication& application, Integration::ResourceId resourceId )
198 application.GetPlatform().SetResourceLoadFailed(resourceId, Integration::FailureUnknown);
201 void ReloadImage(TestApplication& application, ResourceImage image)
203 application.GetPlatform().ClearReadyResources();
204 application.GetPlatform().DiscardRequest();
205 application.GetPlatform().ResetTrace();
206 application.GetPlatform().SetClosestImageSize(Vector2(80.0f, 80.0f)); // Ensure reload is called.
210 RenderTask CreateRenderTask(TestApplication& application,
211 CameraActor offscreenCamera,
212 Actor rootActor, // Reset default render task to point at this actor
213 Actor secondRootActor, // Source actor
214 unsigned int refreshRate,
217 // Change main render task to use a different root
218 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
219 taskList.GetTask(0u).SetSourceActor( rootActor );
221 FrameBufferImage frameBufferImage;
224 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
225 frameBufferImage= FrameBufferImage::New( *(testNativeImagePtr.Get()) );
229 frameBufferImage = FrameBufferImage::New( 10, 10 );
232 // Don't draw output framebuffer // '
234 RenderTask newTask = taskList.CreateTask();
235 newTask.SetCameraActor( offscreenCamera );
236 newTask.SetSourceActor( secondRootActor );
237 newTask.SetInputEnabled( false );
238 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
239 newTask.SetClearEnabled( true );
240 newTask.SetExclusive( true );
241 newTask.SetRefreshRate( refreshRate );
242 newTask.SetTargetFrameBuffer( frameBufferImage );
246 bool UpdateRender(TestApplication& application, TraceCallStack& callStack, bool testDrawn, bool& finishedSig, bool testFinished, bool testKeepUpdating )
250 application.Render(16);
251 application.SendNotification();
253 bool sigPassed = false;
256 sigPassed = finishedSig;
260 sigPassed = ! finishedSig;
263 bool drawResult = callStack.FindMethod("DrawElements") || callStack.FindMethod("DrawArrays");
265 bool drawPassed = false;
268 drawPassed = drawResult;
272 drawPassed = !drawResult;
275 bool keepUpdating = (application.GetUpdateStatus() != 0);
276 bool keepUpdatingPassed = false;
277 if( testKeepUpdating )
279 keepUpdatingPassed = keepUpdating;
283 keepUpdatingPassed = !keepUpdating;
286 bool result = (sigPassed && drawPassed && keepUpdatingPassed);
288 tet_printf("UpdateRender: Expected: Draw:%s Signal:%s Keep Updating: %s Actual: Draw:%s Signal:%s KeepUpdating: %s %s\n",
289 BOOLSTR(testDrawn), BOOLSTR(testFinished), BOOLSTR(testKeepUpdating),
290 BOOLSTR(drawResult), BOOLSTR(finishedSig), BOOLSTR(keepUpdating),
291 result ? "Passed":"Failed");
296 // The functor to be used in the hit-test algorithm to check whether the actor is hittable.
297 bool IsActorHittableFunction(Actor actor, Dali::HitTestAlgorithm::TraverseType type)
299 bool hittable = false;
303 case Dali::HitTestAlgorithm::CHECK_ACTOR:
305 // Check whether the actor is visible and not fully transparent.
306 if( actor.IsVisible()
307 && actor.GetCurrentWorldColor().a > 0.01f) // not FULLY_TRANSPARENT
314 case Dali::HitTestAlgorithm::DESCEND_ACTOR_TREE:
316 if( actor.IsVisible() ) // Actor is visible, if not visible then none of its children are visible.
331 } // unnamed namespace
334 /****************************************************************************************************/
335 /****************************************************************************************************/
336 /******************************** TEST CASES BELOW **********************************************/
337 /****************************************************************************************************/
338 /****************************************************************************************************/
340 int UtcDaliRenderTaskDownCast01(void)
342 TestApplication application;
344 tet_infoline("Testing RenderTask::DownCast()");
346 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
348 BaseHandle base = taskList.GetTask( 0u );
349 DALI_TEST_CHECK( base );
351 RenderTask task = RenderTask::DownCast( base );
352 DALI_TEST_CHECK( task );
354 // Try calling a method
355 DALI_TEST_CHECK( task.GetSourceActor() );
359 int UtcDaliRenderTaskDownCast02(void)
361 TestApplication application;
363 tet_infoline("Testing RenderTask::DownCast()");
365 Actor actor = Actor::New();
367 RenderTask task = RenderTask::DownCast( actor );
368 DALI_TEST_CHECK( ! task );
373 int UtcDaliRenderTaskSetSourceActorN(void)
375 TestApplication application;
376 tet_infoline("Testing RenderTask::SetSourceActor() Negative - try with empty actor handle");
377 Stage stage = Stage::GetCurrent();
381 RenderTaskList taskList = stage.GetRenderTaskList();
382 RenderTask renderTask = taskList.CreateTask();
383 renderTask.SetSourceActor(srcActor);
385 application.SendNotification();
386 application.Render();
388 DALI_TEST_CHECK( ! renderTask.GetSourceActor() );
393 int UtcDaliRenderTaskSetSourceActorP01(void)
395 TestApplication application;
397 tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that setting a non-renderable actor stops existing source actor being rendered ");
399 Stage stage = Stage::GetCurrent();
401 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
403 RenderTaskList taskList = stage.GetRenderTaskList();
405 RenderTask task = taskList.GetTask( 0u );
407 Actor actor = task.GetSourceActor();
408 DALI_TEST_CHECK( actor );
410 std::vector<GLuint> ids;
412 application.GetGlAbstraction().SetNextTextureIds( ids );
414 BufferImage img = BufferImage::New( 1,1 );
415 ImageActor newActor = ImageActor::New( img );
416 newActor.SetSize(1,1);
417 stage.Add( newActor );
419 Actor nonRenderableActor = Actor::New();
420 stage.Add( nonRenderableActor );
422 // Stop the newActor from being rendered by changing the source actor
423 DALI_TEST_CHECK( nonRenderableActor );
424 task.SetSourceActor( nonRenderableActor );
425 DALI_TEST_CHECK( task.GetSourceActor() != actor );
426 DALI_TEST_CHECK( task.GetSourceActor() == nonRenderableActor );
428 // Update & Render nothing!
429 application.GetGlAbstraction().ClearBoundTextures();
430 application.SendNotification();
431 application.Render();
433 // Check that nothing was rendered
434 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
440 int UtcDaliRenderTaskSetSourceActorP02(void)
442 TestApplication application;
444 tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that switching source from a non-renderable to a renderable actor causes the texture to be drawn");
446 Stage stage = Stage::GetCurrent();
448 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
450 RenderTaskList taskList = stage.GetRenderTaskList();
452 RenderTask task = taskList.GetTask( 0u );
454 Actor actor = task.GetSourceActor();
455 DALI_TEST_CHECK( actor );
457 std::vector<GLuint> ids;
459 application.GetGlAbstraction().SetNextTextureIds( ids );
461 BufferImage img = BufferImage::New( 1,1 );
462 ImageActor newActor = ImageActor::New( img );
463 newActor.SetSize(1,1);
464 stage.Add( newActor );
466 Actor nonRenderableActor = Actor::New();
467 stage.Add( nonRenderableActor );
469 // Stop the newActor from being rendered by changing the source actor
470 DALI_TEST_CHECK( nonRenderableActor );
471 task.SetSourceActor( nonRenderableActor );
472 DALI_TEST_CHECK( task.GetSourceActor() != actor );
473 DALI_TEST_CHECK( task.GetSourceActor() == nonRenderableActor );
475 // Update & Render nothing!
476 application.GetGlAbstraction().ClearBoundTextures();
477 application.SendNotification();
478 application.Render();
480 // Check that nothing was rendered
481 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
483 // Set newActor as the new source Actor
484 task.SetSourceActor( newActor );
485 DALI_TEST_CHECK( task.GetSourceActor() != actor );
486 DALI_TEST_CHECK( task.GetSourceActor() == newActor );
488 // Update & Render the newActor
489 application.GetGlAbstraction().ClearBoundTextures();
490 application.SendNotification();
491 application.Render();
493 // Check that the newActor was rendered
494 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
495 if ( boundTextures.size() )
497 DALI_TEST_EQUALS( boundTextures[0], 7u, TEST_LOCATION );
502 int UtcDaliRenderTaskSetSourceActorOffStage(void)
504 TestApplication application;
506 tet_infoline("Testing RenderTask::SetSourceActor (on/off stage testing)");
508 Stage stage = Stage::GetCurrent();
510 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
512 RenderTaskList taskList = stage.GetRenderTaskList();
514 RenderTask task = taskList.GetTask( 0u );
516 Actor actor = task.GetSourceActor();
517 DALI_TEST_CHECK( actor );
519 std::vector<GLuint> ids;
520 GLuint expectedTextureId( 3 );
521 ids.push_back( expectedTextureId );
522 application.GetGlAbstraction().SetNextTextureIds( ids );
524 BufferImage img = BufferImage::New( 1,1 );
525 ImageActor newActor = ImageActor::New( img );
526 newActor.SetSize(1,1);
527 task.SetSourceActor( newActor );
528 // Don't add newActor to stage yet //'
530 // Update & Render with the actor initially off-stage
531 application.GetGlAbstraction().ClearBoundTextures();
532 application.SendNotification();
533 application.Render();
535 // Check that nothing was rendered
536 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
539 stage.Add( newActor );
541 // Update & Render with the actor on-stage
542 application.GetGlAbstraction().ClearBoundTextures();
543 application.SendNotification();
544 application.Render();
546 // Check that the newActor was rendered
547 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
548 if ( boundTextures.size() )
550 DALI_TEST_EQUALS( boundTextures[0], expectedTextureId, TEST_LOCATION );
553 // Now remove from stage
554 stage.Remove( newActor );
556 // Update & Render with the actor off-stage
557 application.GetGlAbstraction().ClearBoundTextures();
558 application.SendNotification();
559 application.Render();
563 int UtcDaliRenderTaskSetSourceActorEmpty(void)
565 TestApplication application;
567 tet_infoline("Testing RenderTask::SetSourceActor (empty handle case)");
569 Stage stage = Stage::GetCurrent();
571 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
573 RenderTaskList taskList = stage.GetRenderTaskList();
575 RenderTask task = taskList.GetTask( 0u );
577 Actor actor = task.GetSourceActor();
578 DALI_TEST_CHECK( actor );
580 std::vector<GLuint> ids;
581 GLuint expectedTextureId( 5 );
582 ids.push_back( expectedTextureId );
583 application.GetGlAbstraction().SetNextTextureIds( ids );
585 BufferImage img = BufferImage::New( 1,1 );
586 ImageActor newActor = ImageActor::New( img );
587 newActor.SetSize(1,1);
588 stage.Add( newActor );
590 Actor nonRenderableActor = Actor::New();
591 stage.Add( nonRenderableActor );
593 // Set with empty handle
594 task.SetSourceActor( Actor() );
595 DALI_TEST_CHECK( ! task.GetSourceActor() );
597 // Update & Render nothing!
598 application.GetGlAbstraction().ClearBoundTextures();
599 application.SendNotification();
600 application.Render();
602 // Check that nothing was rendered
603 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
605 // Set with non-empty handle
606 task.SetSourceActor( newActor );
607 DALI_TEST_CHECK( task.GetSourceActor() == newActor );
609 // Update & Render the newActor
610 application.GetGlAbstraction().ClearBoundTextures();
611 application.SendNotification();
612 application.Render();
614 // Check that the newActor was rendered
615 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
616 if ( boundTextures.size() )
618 DALI_TEST_EQUALS( boundTextures[0], expectedTextureId, TEST_LOCATION );
623 int UtcDaliRenderTaskGetSourceActorP01(void)
625 TestApplication application;
627 tet_infoline("Testing RenderTask::GetSourceActor() Check the default render task has a valid source actor");
629 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
631 RenderTask task = taskList.GetTask( 0u );
633 Actor actor = task.GetSourceActor();
634 DALI_TEST_CHECK( actor );
636 // By default the entire scene should be rendered
637 Actor root = Stage::GetCurrent().GetLayer( 0 );
638 DALI_TEST_CHECK( root == actor );
642 int UtcDaliRenderTaskGetSourceActorP02(void)
644 TestApplication application;
646 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.");
648 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
649 RenderTask task = taskList.CreateTask();
650 Actor actor = Actor::New();
651 Stage::GetCurrent().Add(actor);
652 task.SetSourceActor( actor );
654 DALI_TEST_EQUALS( actor, task.GetSourceActor(), TEST_LOCATION );
659 int UtcDaliRenderTaskGetSourceActorN(void)
661 TestApplication application;
663 tet_infoline("Testing RenderTask::GetSourceActor() Try with empty handle");
668 Actor actor = task.GetSourceActor();
670 catch (Dali::DaliException(e))
672 DALI_TEST_PRINT_ASSERT( e );
673 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
679 int UtcDaliRenderTaskSetExclusive(void)
681 TestApplication application;
683 tet_infoline("Testing RenderTask::SetExclusive() Check that exclusion works");
685 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
687 // Manipulate the GenTextures behaviour, to identify different ImageActors
689 std::vector<GLuint> ids;
690 ids.push_back( 8 ); // 8 = actor1
691 ids.push_back( 9 ); // 9 = actor2
692 ids.push_back( 10 ); // 10 = actor3
693 application.GetGlAbstraction().SetNextTextureIds( ids );
695 BufferImage img1 = BufferImage::New( 1,1 );
696 ImageActor actor1 = ImageActor::New( img1 );
698 Stage::GetCurrent().Add( actor1 );
700 // Update & Render actor1
701 application.SendNotification();
702 application.Render();
704 // Check that the actor1 was rendered
705 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
706 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
708 if ( boundTextures.size() )
710 DALI_TEST_EQUALS( boundTextures[0], 8u/*unique to actor1*/, TEST_LOCATION );
713 BufferImage img2 = BufferImage::New( 1,1 );
714 ImageActor actor2 = ImageActor::New( img2 );
717 // Force actor2 to be rendered before actor1
718 Layer layer = Layer::New();
719 Stage::GetCurrent().Add( layer );
721 layer.LowerToBottom();
724 application.GetGlAbstraction().ClearBoundTextures();
725 application.SendNotification();
726 application.Render();
728 // Check that the actors were rendered
729 DALI_TEST_EQUALS( boundTextures.size(), 2u, TEST_LOCATION );
731 if ( boundTextures.size() )
733 DALI_TEST_EQUALS( boundTextures[0], 9u/*unique to actor2*/, TEST_LOCATION );
734 DALI_TEST_EQUALS( boundTextures[1], 8u/*unique to actor1*/, TEST_LOCATION );
737 BufferImage img3 = BufferImage::New( 1,1 );
738 ImageActor actor3 = ImageActor::New( img3 );
741 // Force actor3 to be rendered before actor2
742 layer = Layer::New();
743 Stage::GetCurrent().Add( layer );
745 layer.LowerToBottom();
747 // Update & Render all actors
748 application.GetGlAbstraction().ClearBoundTextures();
749 application.SendNotification();
750 application.Render();
752 // Check that the actors were rendered
753 DALI_TEST_EQUALS( boundTextures.size(), 3u, TEST_LOCATION );
755 if ( boundTextures.size() )
757 DALI_TEST_EQUALS( boundTextures[0], 10u/*unique to actor3*/, TEST_LOCATION );
758 DALI_TEST_EQUALS( boundTextures[1], 9u/*unique to actor2*/, TEST_LOCATION );
759 DALI_TEST_EQUALS( boundTextures[2], 8u/*unique to actor1*/, TEST_LOCATION );
762 // Both actors are now connected to the root node
763 // Setup 2 render-tasks - the first will render from the root-node, and the second from actor2
765 // Not exclusive is the default
766 RenderTask task1 = taskList.GetTask( 0u );
767 DALI_TEST_CHECK( false == task1.IsExclusive() );
769 RenderTask task2 = taskList.CreateTask();
770 DALI_TEST_CHECK( false == task2.IsExclusive() );
771 task2.SetSourceActor( actor2 );
773 // Task1 should render all actors, and task 2 should render only actor2
775 application.GetGlAbstraction().ClearBoundTextures();
776 application.SendNotification();
777 application.Render();
779 DALI_TEST_EQUALS( boundTextures.size(), 4u, TEST_LOCATION );
781 if ( boundTextures.size() == 4 )
783 // Test that task 1 renders actor3, then actor2 & then actor1
784 DALI_TEST_CHECK( boundTextures[0] == 10u );
785 DALI_TEST_CHECK( boundTextures[1] == 9u );
786 DALI_TEST_CHECK( boundTextures[2] == 8u );
788 // Test that task 2 renders actor2
789 DALI_TEST_EQUALS( boundTextures[3], 9u, TEST_LOCATION );
792 // Make actor2 exclusive to task2
794 task2.SetExclusive( true );
795 DALI_TEST_CHECK( true == task2.IsExclusive() );
797 // Task1 should render only actor1, and task 2 should render only actor2
799 application.GetGlAbstraction().ClearBoundTextures();
800 application.SendNotification();
801 application.Render();
803 DALI_TEST_EQUALS( boundTextures.size(), 3u, TEST_LOCATION );
804 if ( boundTextures.size() == 3 )
806 // Test that task 1 renders actor3 & actor1
807 DALI_TEST_CHECK( boundTextures[0] == 10u );
808 DALI_TEST_CHECK( boundTextures[1] == 8u );
810 // Test that task 2 renders actor2
811 DALI_TEST_CHECK( boundTextures[2] == 9u );
816 int UtcDaliRenderTaskSetExclusive02(void)
818 TestApplication application;
820 tet_infoline("Testing RenderTask::SetExclusive() Check that changing from exclusive to not-exclusive works");
822 std::vector<GLuint> ids;
823 ids.push_back( 8 ); // 8 = actor1
824 application.GetGlAbstraction().SetNextTextureIds( ids );
826 BufferImage img1 = BufferImage::New( 1,1 );
827 ImageActor actor1 = ImageActor::New( img1 );
829 Stage::GetCurrent().Add( actor1 );
831 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
832 RenderTask task = taskList.CreateTask();
834 task.SetSourceActor( actor1 );
835 task.SetExclusive(true); // Actor should only render once
837 TestGlAbstraction& gl = application.GetGlAbstraction();
838 TraceCallStack& drawTrace = gl.GetDrawTrace();
839 drawTrace.Enable(true);
841 // Update & Render actor1
842 application.SendNotification();
843 application.Render();
845 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawArrays"), 1, TEST_LOCATION );
847 // Set task to non-exclusive - actor1 should render twice:
849 task.SetExclusive(false);
850 application.SendNotification();
851 application.Render();
853 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawArrays"), 2, TEST_LOCATION );
858 int UtcDaliRenderTaskSetExclusiveN(void)
860 TestApplication application;
862 tet_infoline("Testing RenderTask::SetExclusive() on empty handle");
867 task.SetExclusive(true);
869 catch (Dali::DaliException(e))
871 DALI_TEST_PRINT_ASSERT( e );
872 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
877 int UtcDaliRenderTaskIsExclusive01(void)
879 TestApplication application;
881 tet_infoline("Testing RenderTask::IsExclusive() Check default values are non-exclusive");
883 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
885 // Not exclusive is the default
886 RenderTask task = taskList.GetTask( 0u );
887 DALI_TEST_CHECK( false == task.IsExclusive() );
889 RenderTask newTask = taskList.CreateTask();
890 DALI_TEST_CHECK( false == newTask.IsExclusive() );
895 int UtcDaliRenderTaskIsExclusive02(void)
897 TestApplication application;
899 tet_infoline("Testing RenderTask::IsExclusive() Check the getter returns set values");
901 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
903 // Not exclusive is the default
904 RenderTask newTask = taskList.CreateTask();
905 DALI_TEST_EQUALS( newTask.IsExclusive(), false, TEST_LOCATION );
907 newTask.SetExclusive(true);
908 DALI_TEST_EQUALS( newTask.IsExclusive(), true, TEST_LOCATION );
912 int UtcDaliRenderTaskIsExclusiveN(void)
914 TestApplication application;
916 tet_infoline("Testing RenderTask::IsExclusive() on empty handle");
921 bool x = task.IsExclusive();
924 catch (Dali::DaliException(e))
926 DALI_TEST_PRINT_ASSERT( e );
927 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
932 int UtcDaliRenderTaskSetInputEnabled(void)
934 TestApplication application;
936 tet_infoline("Testing RenderTask::SetInputEnabled()");
938 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
940 // Input is enabled by default
941 RenderTask task = taskList.GetTask( 0u );
942 DALI_TEST_CHECK( true == task.GetInputEnabled() );
944 task.SetInputEnabled( false );
945 DALI_TEST_CHECK( false == task.GetInputEnabled() );
947 task.SetInputEnabled( true );
948 DALI_TEST_CHECK( true == task.GetInputEnabled() );
952 int UtcDaliRenderTaskGetInputEnabled(void)
954 TestApplication application;
956 tet_infoline("Testing RenderTask::GetInputEnabled()");
958 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
960 // Input is enabled by default
961 RenderTask task = taskList.GetTask( 0u );
962 DALI_TEST_EQUALS( true, task.GetInputEnabled(), TEST_LOCATION );
964 RenderTask newTask = taskList.CreateTask();
965 DALI_TEST_EQUALS( true, newTask.GetInputEnabled(), TEST_LOCATION );
967 newTask.SetInputEnabled(false);
968 DALI_TEST_EQUALS( false, newTask.GetInputEnabled(), TEST_LOCATION );
973 int UtcDaliRenderTaskSetCameraActorP(void)
975 TestApplication application;
977 tet_infoline("Testing RenderTask::SetCameraActor()");
979 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
981 RenderTask task = taskList.GetTask( 0u );
983 Actor defaultCameraActor = task.GetCameraActor();
984 DALI_TEST_CHECK( defaultCameraActor );
986 CameraActor newCameraActor = CameraActor::New();
987 DALI_TEST_CHECK( newCameraActor );
989 task.SetCameraActor( newCameraActor );
990 DALI_TEST_CHECK( task.GetCameraActor() != defaultCameraActor );
991 DALI_TEST_EQUALS( task.GetCameraActor(), newCameraActor, TEST_LOCATION );
996 int UtcDaliRenderTaskSetCameraActorN(void)
998 TestApplication application;
1000 tet_infoline("Testing RenderTask::SetCameraActor() with empty actor handle");
1002 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1004 RenderTask task = taskList.GetTask( 0u );
1006 Actor actor = task.GetCameraActor();
1007 DALI_TEST_CHECK( actor );
1009 CameraActor cameraActor;
1011 task.SetCameraActor( cameraActor );
1012 DALI_TEST_EQUALS( (bool)task.GetCameraActor(), false, TEST_LOCATION );
1013 DALI_TEST_EQUALS( task.GetCameraActor(), cameraActor, TEST_LOCATION );
1018 int UtcDaliRenderTaskGetCameraActorP(void)
1020 TestApplication application;
1022 tet_infoline("Testing RenderTask::GetCameraActor()");
1024 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1026 RenderTask task = taskList.GetTask( 0u );
1028 CameraActor actor = task.GetCameraActor();
1029 DALI_TEST_CHECK( actor );
1030 DALI_TEST_EQUALS( actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION );
1031 DALI_TEST_GREATER( actor.GetFieldOfView(), 0.0f, TEST_LOCATION );
1035 int UtcDaliRenderTaskGetCameraActorN(void)
1037 TestApplication application;
1039 tet_infoline("Testing RenderTask::GetCameraActor() with empty handle");
1044 Actor actor = task.GetCameraActor();
1046 catch (Dali::DaliException(e))
1048 DALI_TEST_PRINT_ASSERT( e );
1049 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1055 int UtcDaliRenderTaskSetTargetFrameBufferP(void)
1057 TestApplication application;
1059 tet_infoline("Testing RenderTask::SetTargetFrameBuffer()");
1061 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1063 RenderTask task = taskList.GetTask( 0u );
1065 FrameBufferImage newImage = FrameBufferImage::New();
1066 task.SetTargetFrameBuffer( newImage );
1067 DALI_TEST_CHECK( task.GetTargetFrameBuffer() == newImage );
1071 int UtcDaliRenderTaskSetTargetFrameBufferN(void)
1073 TestApplication application;
1075 tet_infoline("Testing RenderTask::SetTargetFrameBuffer()");
1077 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1079 RenderTask task = taskList.GetTask( 0u );
1080 FrameBufferImage newImage; // Empty handle
1081 task.SetTargetFrameBuffer( newImage );
1082 DALI_TEST_EQUALS( (bool)task.GetTargetFrameBuffer(), false, TEST_LOCATION );
1086 int UtcDaliRenderTaskGetTargetFrameBufferP(void)
1088 TestApplication application;
1090 tet_infoline("Testing RenderTask::GetTargetFrameBuffer()");
1092 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1094 RenderTask newTask = taskList.CreateTask();
1095 FrameBufferImage fb = FrameBufferImage::New(128, 128, Pixel::RGBA8888);
1096 newTask.SetTargetFrameBuffer( fb );
1097 DALI_TEST_EQUALS( newTask.GetTargetFrameBuffer(), fb, TEST_LOCATION );
1101 int UtcDaliRenderTaskGetTargetFrameBufferN(void)
1103 TestApplication application;
1105 tet_infoline("Testing RenderTask::GetTargetFrameBuffer()");
1107 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1109 RenderTask task = taskList.GetTask( 0u );
1111 // By default render-tasks do not render off-screen
1112 FrameBufferImage image = task.GetTargetFrameBuffer();
1113 DALI_TEST_CHECK( !image );
1118 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionP(void)
1120 TestApplication application;
1122 tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1124 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1126 RenderTask task = taskList.GetTask( 0u );
1128 task.SetScreenToFrameBufferFunction( TestScreenToFrameBufferFunction );
1130 Vector2 coordinates( 5, 10 );
1131 Vector2 convertedCoordinates( 6, 12 ); // + Vector(1, 2)
1133 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1134 DALI_TEST_CHECK( func( coordinates ) );
1135 DALI_TEST_CHECK( coordinates == convertedCoordinates );
1137 task.SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
1138 func = task.GetScreenToFrameBufferFunction();
1139 DALI_TEST_CHECK( func( coordinates ) );
1141 task.SetScreenToFrameBufferFunction( RenderTask::DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION );
1142 func = task.GetScreenToFrameBufferFunction();
1143 DALI_TEST_CHECK( ! func( coordinates ) );
1147 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionN(void)
1149 TestApplication application;
1151 tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1153 RenderTask task; // Empty handle
1156 task.SetScreenToFrameBufferFunction( TestScreenToFrameBufferFunction );
1158 catch (Dali::DaliException(e))
1160 DALI_TEST_PRINT_ASSERT( e );
1161 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1166 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionP(void)
1168 TestApplication application;
1170 tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction()");
1172 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1174 RenderTask task = taskList.GetTask( 0u );
1176 Vector2 originalCoordinates( 5, 10 );
1177 Vector2 coordinates( 5, 10 );
1179 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1180 DALI_TEST_CHECK( !func( coordinates ) ); // conversion should fail by default
1181 DALI_TEST_CHECK( coordinates == originalCoordinates ); // coordinates should not be modified
1185 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionN(void)
1187 TestApplication application;
1189 tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction() on empty handle");
1194 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1197 catch (Dali::DaliException(e))
1199 DALI_TEST_PRINT_ASSERT( e );
1200 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1206 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorP(void)
1208 TestApplication application;
1209 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor ");
1211 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1212 RenderTask renderTask = taskList.CreateTask();
1213 Actor mappingActor = Actor::New();
1214 renderTask.SetScreenToFrameBufferMappingActor(mappingActor);
1216 DALI_TEST_EQUALS( mappingActor, renderTask.GetScreenToFrameBufferMappingActor(), TEST_LOCATION );
1221 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorN(void)
1223 TestApplication application;
1224 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1230 task.SetScreenToFrameBufferMappingActor(mappingActor);
1232 catch (Dali::DaliException(e))
1234 DALI_TEST_PRINT_ASSERT( e );
1235 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1240 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActor02N(void)
1242 TestApplication application;
1243 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1245 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1246 RenderTask renderTask = taskList.CreateTask();
1248 renderTask.SetScreenToFrameBufferMappingActor(actor);
1250 DALI_TEST_EQUALS( (bool)renderTask.GetScreenToFrameBufferMappingActor(), false, TEST_LOCATION);
1254 int UtcDaliRenderTaskGetViewportP01(void)
1256 TestApplication application;
1258 tet_infoline("Testing RenderTask::GetViewport() on default task");
1260 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1261 RenderTask task = taskList.GetTask( 0u );
1262 Viewport viewport = task.GetViewport();
1264 // By default the viewport should match the stage width/height
1265 Vector2 stageSize = Stage::GetCurrent().GetSize();
1266 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1267 DALI_TEST_CHECK( viewport == expectedViewport );
1271 int UtcDaliRenderTaskGetViewportP02(void)
1273 TestApplication application;
1275 tet_infoline("Testing RenderTask::GetViewport() on new task");
1277 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1278 RenderTask task = taskList.CreateTask();
1279 Viewport viewport = task.GetViewport();
1281 // By default the viewport should match the stage width/height
1282 Vector2 stageSize = Stage::GetCurrent().GetSize();
1283 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1284 DALI_TEST_CHECK( viewport == expectedViewport );
1288 int UtcDaliRenderTaskGetViewportN(void)
1290 TestApplication application;
1292 tet_infoline("Testing RenderTask::GetViewport() on empty handle");
1297 Viewport viewport = task.GetViewport();
1298 viewport = viewport;
1300 catch (Dali::DaliException(e))
1302 DALI_TEST_PRINT_ASSERT( e );
1303 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1309 int UtcDaliRenderTaskSetViewportP(void)
1311 TestApplication application;
1313 tet_infoline("Testing RenderTask::SetViewport()");
1315 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1317 RenderTask task = taskList.GetTask( 0u );
1318 Vector2 stageSize = Stage::GetCurrent().GetSize();
1319 Viewport newViewport( 0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f );
1320 task.SetViewport( newViewport );
1322 // Update (viewport is a property)
1323 application.SendNotification();
1324 application.Render();
1326 DALI_TEST_CHECK( task.GetViewport() == newViewport );
1330 int UtcDaliRenderTaskSetViewportN(void)
1332 TestApplication application;
1334 tet_infoline("Testing RenderTask::SetViewport()");
1336 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1341 Vector2 stageSize = Stage::GetCurrent().GetSize();
1342 Viewport newViewport( 0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f );
1343 task.SetViewport( newViewport );
1345 catch (Dali::DaliException(e))
1347 DALI_TEST_PRINT_ASSERT( e );
1348 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1355 int UtcDaliRenderTaskSetViewportPosition(void)
1357 TestApplication application;
1359 tet_infoline("Testing RenderTask::SetViewportPosition()");
1361 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1363 RenderTask task = taskList.GetTask( 0u );
1365 Viewport viewport = task.GetViewport();
1367 // By default the viewport should match the stage width/height
1369 Vector2 stageSize = Stage::GetCurrent().GetSize();
1370 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1371 DALI_TEST_CHECK( viewport == expectedViewport );
1374 Vector2 newPosition(25.0f, 50.0f);
1375 task.SetViewportPosition( newPosition );
1377 // Update (viewport is a property)
1378 application.SendNotification();
1379 application.Render();
1381 DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1383 // Set by Property test
1384 Vector2 newPosition2(32.0f, 32.0f);
1385 task.SetProperty( RenderTask::Property::VIEWPORT_POSITION, newPosition2 );
1388 application.SendNotification();
1389 application.Render();
1391 DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition2, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1393 Vector2 newPosition3(64.0f, 0.0f);
1394 Animation animation = Animation::New(1.0f);
1395 animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_POSITION ), newPosition3, AlphaFunctions::Linear );
1398 // Perform 1000ms worth of updates at which point animation should have completed.
1399 Wait(application, 1000);
1400 DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1404 int UtcDaliRenderTaskSetViewportSize(void)
1406 TestApplication application;
1408 tet_infoline("Testing RenderTask::SetViewportSize()");
1410 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1412 RenderTask task = taskList.GetTask( 0u );
1414 Viewport viewport = task.GetViewport();
1416 // By default the viewport should match the stage width/height
1418 Vector2 stageSize = Stage::GetCurrent().GetSize();
1419 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1420 DALI_TEST_CHECK( viewport == expectedViewport );
1422 Vector2 newSize(128.0f, 64.0f);
1423 task.SetViewportSize( newSize );
1425 // Update (viewport is a property)
1426 application.SendNotification();
1427 application.Render();
1429 DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1431 // Set by Property test
1432 Vector2 newSize2(50.0f, 50.0f);
1433 task.SetProperty( RenderTask::Property::VIEWPORT_SIZE, newSize2 );
1436 application.SendNotification();
1437 application.Render();
1439 DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize2, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1441 Vector2 newSize3(10.0f, 10.0f);
1442 Animation animation = Animation::New(1.0f);
1443 animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_SIZE ), newSize3, AlphaFunctions::Linear );
1446 // Perform 1000ms worth of updates at which point animation should have completed.
1447 Wait(application, 1000);
1448 DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1453 int UtcDaliRenderTaskSetClearColorP(void)
1455 TestApplication application;
1457 tet_infoline("Testing RenderTask::SetClearColor()");
1459 Vector4 testColor( 1.0f, 2.0f, 3.0f, 4.0f );
1460 Vector4 testColor2( 5.0f, 6.0f, 7.0f, 8.0f );
1462 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1464 RenderTask task = taskList.GetTask( 0u );
1465 DALI_TEST_CHECK( task.GetClearColor() != testColor );
1467 task.SetClearColor( testColor );
1472 DALI_TEST_EQUALS( task.GetClearColor(), testColor, TEST_LOCATION );
1474 task.SetProperty( RenderTask::Property::CLEAR_COLOR, testColor2 );
1479 DALI_TEST_EQUALS( task.GetClearColor(), testColor2, TEST_LOCATION );
1483 int UtcDaliRenderTaskSetClearColorN(void)
1485 TestApplication application;
1487 tet_infoline("Testing RenderTask::SetClearColor() on empty handle");
1492 task.SetClearColor( Vector4::ZERO );
1494 catch (Dali::DaliException(e))
1496 DALI_TEST_PRINT_ASSERT( e );
1497 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1502 int UtcDaliRenderTaskGetClearColorP(void)
1504 TestApplication application;
1506 tet_infoline("Testing RenderTask::GetClearColor()");
1508 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1509 RenderTask task = taskList.GetTask( 0u );
1510 DALI_TEST_EQUALS( task.GetClearColor(), RenderTask::DEFAULT_CLEAR_COLOR, TEST_LOCATION );
1514 int UtcDaliRenderTaskGetClearColorN(void)
1516 TestApplication application;
1518 tet_infoline("Testing RenderTask::GetClearColor()");
1523 Vector4 color = task.GetClearColor();
1526 catch (Dali::DaliException(e))
1528 DALI_TEST_PRINT_ASSERT( e );
1529 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1534 int UtcDaliRenderTaskSetClearEnabledP(void)
1536 TestApplication application;
1538 tet_infoline("Testing RenderTask::SetClearEnabled()");
1540 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1542 RenderTask task = taskList.GetTask( 0u );
1543 DALI_TEST_CHECK( !task.GetClearEnabled() ); // defaults to false
1545 task.SetClearEnabled( true );
1546 DALI_TEST_EQUALS( task.GetClearEnabled(), true, TEST_LOCATION );
1548 task.SetClearEnabled( false );
1549 DALI_TEST_EQUALS( task.GetClearEnabled(), false, TEST_LOCATION );
1553 int UtcDaliRenderTaskSetClearEnabledN(void)
1555 TestApplication application;
1557 tet_infoline("Testing RenderTask::SetClearEnabled() with empty handle");
1562 task.SetClearEnabled(true);
1564 catch (Dali::DaliException(e))
1566 DALI_TEST_PRINT_ASSERT( e );
1567 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1572 int UtcDaliRenderTaskGetClearEnabledP(void)
1574 TestApplication application;
1576 tet_infoline("Testing RenderTask::GetClearEnabled()");
1578 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1580 RenderTask task = taskList.GetTask( 0u );
1581 DALI_TEST_CHECK( !task.GetClearEnabled() ); // defaults to false
1586 int UtcDaliRenderTaskGetClearEnabledN(void)
1588 TestApplication application;
1590 tet_infoline("Testing RenderTask::GetClearEnabled() with empty handle");
1595 bool x = task.GetClearEnabled();
1598 catch (Dali::DaliException(e))
1600 DALI_TEST_PRINT_ASSERT( e );
1601 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1606 int UtcDaliRenderTaskSetCullModeP(void)
1608 TestApplication application;
1610 tet_infoline("Testing RenderTask::SetCullMode()");
1612 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1613 RenderTask task = taskList.GetTask( 0u );
1614 DALI_TEST_EQUALS( task.GetCullMode(), true, TEST_LOCATION );
1616 task.SetCullMode( false );
1618 DALI_TEST_EQUALS( task.GetCullMode(), false, TEST_LOCATION );
1623 int UtcDaliRenderTaskSetCullModeN(void)
1625 TestApplication application;
1627 tet_infoline("Testing RenderTask::SetCullMode() on empty handle");
1632 task.SetCullMode( false );
1634 catch (Dali::DaliException(e))
1636 DALI_TEST_PRINT_ASSERT( e );
1637 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1642 int UtcDaliRenderTaskGetCullModeP(void)
1644 TestApplication application;
1646 tet_infoline("Testing RenderTask::GetCullMode()");
1648 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1649 RenderTask task = taskList.GetTask( 0u );
1650 DALI_TEST_EQUALS( task.GetCullMode(), true, TEST_LOCATION );
1654 int UtcDaliRenderTaskGetCullModeN(void)
1656 TestApplication application;
1658 tet_infoline("Testing RenderTask::GetCullMode() with empty handle");
1663 bool x = task.GetCullMode();
1666 catch (Dali::DaliException(e))
1668 DALI_TEST_PRINT_ASSERT( e );
1669 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1675 int UtcDaliRenderTaskSetRefreshRate(void)
1677 TestApplication application;
1679 tet_infoline("Testing RenderTask::SetRefreshRate()");
1681 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1683 // By default tasks will be processed every frame
1684 RenderTask task = taskList.GetTask( 0u );
1685 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1687 task.SetRefreshRate( 2u ); // every-other frame
1688 DALI_TEST_CHECK( 2u == task.GetRefreshRate() );
1690 task.SetRefreshRate( RenderTask::REFRESH_ALWAYS );
1691 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1695 int UtcDaliRenderTaskGetRefreshRate(void)
1697 TestApplication application;
1699 tet_infoline("Testing RenderTask::GetRefreshRate()");
1701 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1703 // By default tasks will be processed every frame
1704 RenderTask task = taskList.GetTask( 0u );
1705 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1707 RenderTask newTask = taskList.CreateTask();
1708 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == newTask.GetRefreshRate() );
1712 int UtcDaliRenderTaskSignalFinished(void)
1714 TestApplication application;
1716 tet_infoline("Testing RenderTask::SignalFinished()");
1718 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1719 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
1721 CameraActor offscreenCameraActor = CameraActor::New();
1723 Stage::GetCurrent().Add( offscreenCameraActor );
1725 BufferImage image = BufferImage::New( 10, 10 );
1726 ImageActor rootActor = ImageActor::New( image );
1727 rootActor.SetSize( 10, 10 );
1728 Stage::GetCurrent().Add( rootActor );
1730 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1731 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
1732 FrameBufferImage frameBufferImage = FrameBufferImage::New( *testNativeImagePtr.Get() );
1734 // Flush all outstanding messages
1735 application.SendNotification();
1736 application.Render();
1738 RenderTask newTask = taskList.CreateTask();
1739 newTask.SetCameraActor( offscreenCameraActor );
1740 newTask.SetSourceActor( rootActor );
1741 newTask.SetInputEnabled( false );
1742 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
1743 newTask.SetClearEnabled( true );
1744 newTask.SetExclusive( true );
1745 newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
1746 newTask.SetTargetFrameBuffer( frameBufferImage );
1748 // Framebuffer doesn't actually get created until Connected, i.e. by previous line
1750 bool finished = false;
1751 RenderTaskFinished renderTaskFinished( finished );
1752 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1754 // Flush the queue and render.
1755 application.SendNotification();
1757 // 1 render to process render task, then wait for sync before finished msg is sent
1758 // from update to the event thread.
1760 application.Render();
1761 application.SendNotification();
1762 DALI_TEST_CHECK( !finished );
1764 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
1765 DALI_TEST_CHECK( lastSyncObj != NULL );
1767 application.Render();
1768 DALI_TEST_EQUALS( (application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
1769 application.SendNotification();
1770 DALI_TEST_CHECK( !finished );
1772 application.Render();
1773 DALI_TEST_EQUALS( (application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
1774 application.SendNotification();
1775 DALI_TEST_CHECK( ! finished );
1777 sync.SetObjectSynced( lastSyncObj, true );
1779 application.Render();
1780 application.SendNotification();
1781 DALI_TEST_CHECK( !finished );
1783 application.Render();
1784 application.SendNotification();
1785 DALI_TEST_CHECK( finished );
1788 application.Render(); // Double check no more finished signal
1789 application.SendNotification();
1790 DALI_TEST_CHECK( ! finished );
1795 int UtcDaliRenderTaskContinuous01(void)
1797 TestApplication application;
1799 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not staged)\nPOST:continuous renders, no Finished signal");
1801 // SETUP AN OFFSCREEN RENDER TASK
1802 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1803 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1804 drawTrace.Enable(true);
1806 Actor rootActor = Actor::New();
1807 Stage::GetCurrent().Add( rootActor );
1809 CameraActor offscreenCameraActor = CameraActor::New();
1810 Stage::GetCurrent().Add( offscreenCameraActor );
1812 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1813 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1814 Integration::ResourceId imageRequestId = imageRequest->GetId();
1815 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1817 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1818 bool finished = false;
1819 RenderTaskFinished renderTaskFinished( finished );
1820 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1821 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1822 application.SendNotification();
1824 // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating
1825 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false ) );
1826 application.GetPlatform().ClearReadyResources();
1828 // ADD SOURCE ACTOR TO STAGE - expect continuous renders to start, no finished signal
1829 Stage::GetCurrent().Add(secondRootActor);
1830 application.SendNotification();
1832 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1833 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
1838 int UtcDaliRenderTaskContinuous02(void)
1840 TestApplication application;
1842 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not visible)\nPOST:continuous renders, no Finished signal");
1844 // SETUP AN OFFSCREEN RENDER TASK
1845 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1846 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1847 drawTrace.Enable(true);
1849 Actor rootActor = Actor::New();
1850 Stage::GetCurrent().Add( rootActor );
1852 CameraActor offscreenCameraActor = CameraActor::New();
1853 Stage::GetCurrent().Add( offscreenCameraActor );
1855 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1856 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1857 Integration::ResourceId imageRequestId = imageRequest->GetId();
1858 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1859 Stage::GetCurrent().Add(secondRootActor);
1860 secondRootActor.SetVisible(false);
1862 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1863 bool finished = false;
1864 RenderTaskFinished renderTaskFinished( finished );
1865 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1866 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1867 application.SendNotification();
1869 // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating
1870 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false ) );
1871 application.GetPlatform().ClearReadyResources();
1873 // MAKE SOURCE ACTOR VISIBLE - expect continuous renders to start, no finished signal
1874 secondRootActor.SetVisible(true);
1875 application.SendNotification();
1877 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1878 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
1882 int UtcDaliRenderTaskContinuous03(void)
1884 TestApplication application;
1886 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (camera actor not staged)\nPOST:continuous renders, no Finished signal");
1888 // SETUP AN OFFSCREEN RENDER TASK
1889 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1890 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1891 drawTrace.Enable(true);
1893 Actor rootActor = Actor::New();
1894 Stage::GetCurrent().Add( rootActor );
1896 CameraActor offscreenCameraActor = CameraActor::New();
1897 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1898 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1899 Integration::ResourceId imageRequestId = imageRequest->GetId();
1900 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1901 Stage::GetCurrent().Add(secondRootActor);
1903 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1904 bool finished = false;
1905 RenderTaskFinished renderTaskFinished( finished );
1906 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1907 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1908 application.SendNotification();
1910 // START PROCESS/RENDER Input, Expected Input, Expected
1911 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false ) );
1912 application.GetPlatform().ClearReadyResources();
1914 // ADD CAMERA ACTOR TO STAGE - expect continuous renders to start, no finished signal
1915 Stage::GetCurrent().Add( offscreenCameraActor );
1916 application.SendNotification();
1918 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1919 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
1924 int UtcDaliRenderTaskContinuous04(void)
1926 TestApplication application;
1928 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: Resource not ready\nPOST:continuous renders, no Finished signal");
1930 // SETUP AN OFFSCREEN RENDER TASK
1931 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1932 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1933 drawTrace.Enable(true);
1935 Actor rootActor = Actor::New();
1936 Stage::GetCurrent().Add( rootActor );
1938 CameraActor offscreenCameraActor = CameraActor::New();
1939 Stage::GetCurrent().Add( offscreenCameraActor );
1940 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1941 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1942 Integration::ResourceId imageRequestId = imageRequest->GetId();
1943 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1944 Stage::GetCurrent().Add(secondRootActor);
1946 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1947 bool finished = false;
1948 RenderTaskFinished renderTaskFinished( finished );
1949 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1950 application.SendNotification();
1952 // START PROCESS/RENDER Input, Expected Input, Expected
1953 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
1954 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
1956 // FINISH RESOURCE LOADING - expect 'continuous' renders to start, no finished signal
1957 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1958 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
1963 int UtcDaliRenderTaskOnce01(void)
1965 TestApplication application;
1967 tet_infoline("Testing RenderTask Render Once GlSync, using loading image\nPRE: Resources not ready, Source not visible\nPOST: Finished signal sent once only");
1969 // SETUP AN OFFSCREEN RENDER TASK
1970 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1971 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
1972 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1973 drawTrace.Enable(true);
1975 Actor rootActor = Actor::New();
1976 Stage::GetCurrent().Add( rootActor );
1978 CameraActor offscreenCameraActor = CameraActor::New();
1979 Stage::GetCurrent().Add( offscreenCameraActor );
1980 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1981 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1982 Integration::ResourceId imageRequestId = imageRequest->GetId();
1983 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1985 Stage::GetCurrent().Add(secondRootActor);
1987 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
1988 bool finished = false;
1989 RenderTaskFinished renderTaskFinished( finished );
1990 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1991 application.SendNotification();
1993 // START PROCESS/RENDER Input, Expected Input, Expected
1994 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
1995 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
1997 // MAKE SOURCE VISIBLE
1998 secondRootActor.SetVisible(true);
1999 application.SendNotification();
2000 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2001 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2003 // FINISH RESOURCE LOADING - expect no rendering yet
2004 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2005 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2006 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2007 DALI_TEST_CHECK( lastSyncObj != NULL );
2009 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2010 application.GetPlatform().ClearReadyResources();
2011 sync.SetObjectSynced( lastSyncObj, true );
2012 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2013 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2017 int UtcDaliRenderTaskOnce02(void)
2019 TestApplication application;
2021 tet_infoline("Testing RenderTask Render Once GlSync, using loading image. Switch from render always after ready to render once\n"
2022 "PRE: Render task ready, Image not loaded\n"
2023 "POST: Finished signal sent only once");
2025 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2026 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2027 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2028 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2029 drawTrace.Enable(true);
2031 Actor rootActor = Actor::New();
2032 Stage::GetCurrent().Add( rootActor );
2034 CameraActor offscreenCameraActor = CameraActor::New();
2035 Stage::GetCurrent().Add( offscreenCameraActor );
2036 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2037 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2038 Integration::ResourceId imageRequestId = imageRequest->GetId();
2039 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2040 Stage::GetCurrent().Add(secondRootActor);
2042 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2043 bool finished = false;
2044 RenderTaskFinished renderTaskFinished( finished );
2045 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2046 application.SendNotification();
2048 // START PROCESS/RENDER Input, Expected Input, Expected
2049 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2050 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2052 // FINISH RESOURCE LOADING
2053 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2054 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
2055 application.GetPlatform().ClearReadyResources();
2056 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
2058 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2059 application.SendNotification(); // Input, Expected Input, Expected
2060 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2061 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2062 DALI_TEST_CHECK( lastSyncObj != NULL );
2064 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2065 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2066 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2067 sync.SetObjectSynced( lastSyncObj, true );
2068 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2069 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2075 int UtcDaliRenderTaskOnce03(void)
2077 TestApplication application;
2079 tet_infoline("Testing RenderTask Render Once GlSync\n"
2080 "Switch from Render always after ready to render once with resources unready\n"
2081 "PRE: Everything ready to render\n"
2082 "POST: Finished signal sent once");
2084 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2085 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2086 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2087 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2088 drawTrace.Enable(true);
2090 Actor rootActor = Actor::New();
2091 Stage::GetCurrent().Add( rootActor );
2093 CameraActor offscreenCameraActor = CameraActor::New();
2094 Stage::GetCurrent().Add( offscreenCameraActor );
2095 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2096 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2097 Integration::ResourceId imageRequestId = imageRequest->GetId();
2098 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2099 Stage::GetCurrent().Add(secondRootActor);
2101 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2102 bool finished = false;
2103 RenderTaskFinished renderTaskFinished( finished );
2104 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2105 application.SendNotification();
2107 // START PROCESS/RENDER Input, Expected Input, Expected
2108 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2109 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2111 // CHANGE TO RENDER ONCE
2112 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2113 application.SendNotification(); // Input, Expected Input, Expected
2114 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2115 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2117 // FINISH RESOURCE LOADING
2118 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2119 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2120 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2121 DALI_TEST_CHECK( lastSyncObj != NULL );
2122 application.GetPlatform().ClearReadyResources();
2124 sync.SetObjectSynced( lastSyncObj, true );
2126 // Expect: No draw - we've just drawn our render task once, above. No finished signal -
2127 // we won't read the gl sync until the next frame. Continue rendering - we're waiting for
2129 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2131 // Expect: 1 final draw - this Update doesn't update the scene, hence render instructions
2132 // from last frame but 1 are still present.
2133 // Finished signal should be true - we've just done the sync.
2134 // Should now stop rendering and updating - nothing left to do.
2135 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, true, false ) );
2141 //int UtcDaliRenderTaskOnce04(void)
2143 TestApplication application;
2145 tet_infoline("Testing RenderTask Render Once GlSync\n"
2146 "During RenderOnce, make ready resources unready before sending first finished signal\n"
2147 "PRE: Everything ready.\n"
2148 "POST: Finished signal sent only once");
2150 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2151 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2152 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2153 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2154 drawTrace.Enable(true);
2156 Actor rootActor = Actor::New();
2157 Stage::GetCurrent().Add( rootActor );
2159 CameraActor offscreenCameraActor = CameraActor::New();
2160 Stage::GetCurrent().Add( offscreenCameraActor );
2161 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2162 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2163 Integration::ResourceId imageRequestId = imageRequest->GetId();
2164 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2165 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2166 application.Render();
2168 Stage::GetCurrent().Add(secondRootActor);
2169 application.GetPlatform().ClearReadyResources();
2171 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, 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, true, finished, false, true ) );
2179 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2181 // CHANGE TO RENDER ONCE, RESOURCES BECOME NOT READY
2182 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2185 ReloadImage(application, secondRootActor.GetImage());
2186 application.SendNotification(); // Input, Expected Input, Expected
2188 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2189 DALI_TEST_EQUALS( secondRootActor.GetImage().GetLoadingState(), Dali::ResourceLoading, TEST_LOCATION);
2190 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2192 // FINISH RESOURCE LOADING
2193 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2194 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2195 application.GetPlatform().ClearReadyResources();
2196 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2197 DALI_TEST_CHECK( lastSyncObj != NULL );
2199 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2200 sync.SetObjectSynced( lastSyncObj, true );
2201 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2202 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, true ) );
2204 // Finished rendering - expect no more renders, no more signals:
2205 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2206 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2207 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2208 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2209 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2210 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2215 int UtcDaliRenderTaskOnce05(void)
2217 TestApplication application;
2219 tet_infoline("Testing RenderTask Render Once GLSync\n"
2220 "Render once, Second call to SetRefreshRate(ONCE) triggers only one more finished signal\n"
2221 "PRE: Everything ready\n"
2222 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
2224 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2225 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2226 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2227 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2228 drawTrace.Enable(true);
2230 Actor rootActor = Actor::New();
2231 Stage::GetCurrent().Add( rootActor );
2233 CameraActor offscreenCameraActor = CameraActor::New();
2234 Stage::GetCurrent().Add( offscreenCameraActor );
2235 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2236 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2237 Integration::ResourceId imageRequestId = imageRequest->GetId();
2238 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2239 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2240 application.Render();
2241 application.GetPlatform().ClearReadyResources();
2243 Stage::GetCurrent().Add(secondRootActor);
2245 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2246 bool finished = false;
2247 RenderTaskFinished renderTaskFinished( finished );
2248 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2249 application.SendNotification();
2251 // START PROCESS/RENDER Input, Expected Input, Expected
2252 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
2254 // CHANGE TO RENDER ONCE,
2255 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2256 application.SendNotification();
2257 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2258 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2259 DALI_TEST_CHECK( lastSyncObj != NULL );
2261 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2262 sync.SetObjectSynced( lastSyncObj, true );
2263 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2264 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2266 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2267 application.SendNotification();
2268 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2269 lastSyncObj = sync.GetLastSyncObject();
2270 DALI_TEST_CHECK( lastSyncObj != NULL );
2272 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2273 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2274 sync.SetObjectSynced( lastSyncObj, true );
2275 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2276 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2280 int UtcDaliRenderTaskOnce06(void)
2282 TestApplication application;
2284 tet_infoline("Testing RenderTask Render Once GLSync\n"
2285 "Render once, Call to SetRefreshRate(ONCE) in Finished signal callback triggers "
2286 "another render & another finished signal\n"
2287 "PRE: Everything ready\n"
2288 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
2291 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2292 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2293 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2294 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2295 drawTrace.Enable(true);
2297 Actor rootActor = Actor::New();
2298 Stage::GetCurrent().Add( rootActor );
2300 CameraActor offscreenCameraActor = CameraActor::New();
2301 Stage::GetCurrent().Add( offscreenCameraActor );
2302 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2303 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2304 Integration::ResourceId imageRequestId = imageRequest->GetId();
2305 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2306 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2307 application.Render();
2308 application.GetPlatform().ClearReadyResources();
2310 Stage::GetCurrent().Add(secondRootActor);
2312 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2313 bool finished = false;
2315 ConnectionTracker connectionTracker;
2316 RenderTaskFinishedRenderAgain renderTaskFinishedRenderAgain( finished );
2317 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinishedRenderAgain );
2319 application.SendNotification();
2321 // START PROCESS/RENDER Input, Expected Input, Expected
2322 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
2323 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2324 DALI_TEST_CHECK( lastSyncObj == NULL );
2326 // CHANGE TO RENDER ONCE,
2327 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2328 application.SendNotification();
2329 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2330 lastSyncObj = sync.GetLastSyncObject();
2331 DALI_TEST_CHECK( lastSyncObj != NULL );
2333 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2334 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2336 sync.SetObjectSynced( lastSyncObj, true );
2337 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2338 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2339 application.SendNotification();
2341 // Expect SetRefreshRate to have been called again
2342 // Prevent next finished signal calling refresh once again
2343 RenderTaskFinished renderTaskFinished( finished );
2344 connectionTracker.DisconnectAll();
2345 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinished );
2346 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2347 lastSyncObj = sync.GetLastSyncObject();
2348 DALI_TEST_CHECK( lastSyncObj != NULL );
2350 sync.SetObjectSynced( lastSyncObj, true );
2351 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2352 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2357 int UtcDaliRenderTaskOnce07(void)
2359 TestApplication application;
2361 tet_infoline("Testing RenderTask Render Once GlSync\n"
2362 "SetRefreshRate(ONCE) again before first finished signal has been sent.\n"
2363 "PRE: resources ready\n"
2364 "POST: Only 1 finished signal sent.");
2366 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2367 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2368 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2369 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2370 drawTrace.Enable(true);
2372 Actor rootActor = Actor::New();
2373 Stage::GetCurrent().Add( rootActor );
2375 CameraActor offscreenCameraActor = CameraActor::New();
2376 Stage::GetCurrent().Add( offscreenCameraActor );
2377 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2378 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2379 Integration::ResourceId imageRequestId = imageRequest->GetId();
2380 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2381 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2382 application.Render();
2383 application.GetPlatform().ClearReadyResources();
2385 Stage::GetCurrent().Add(secondRootActor);
2387 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2388 bool finished = false;
2389 RenderTaskFinished renderTaskFinished( finished );
2390 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2391 application.SendNotification();
2393 // START PROCESS/RENDER Input, Expected Input, Expected
2394 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
2396 // CHANGE TO RENDER ONCE,
2397 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2398 application.SendNotification();
2399 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2400 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2401 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2403 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2404 application.SendNotification();
2405 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2406 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2407 DALI_TEST_CHECK( lastSyncObj != NULL );
2409 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2410 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2411 sync.SetObjectSynced( lastSyncObj, true );
2412 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2413 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2420 int UtcDaliRenderTaskOnce08(void)
2422 TestApplication application;
2424 tet_infoline("Testing RenderTask Render Once GlSync\n"
2425 "SetRefreshRate(ONCE), resource load failed completes render task.\n"
2426 "PRE: resources not ready\n"
2427 "POST: Only 1 finished signal sent.");
2429 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2430 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2431 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2432 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2433 drawTrace.Enable(true);
2435 Actor rootActor = Actor::New();
2436 Stage::GetCurrent().Add( rootActor );
2438 CameraActor offscreenCameraActor = CameraActor::New();
2439 Stage::GetCurrent().Add( offscreenCameraActor );
2440 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2441 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2442 Integration::ResourceId imageRequestId = imageRequest->GetId();
2443 Stage::GetCurrent().Add(secondRootActor);
2445 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2446 bool finished = false;
2447 RenderTaskFinished renderTaskFinished( finished );
2448 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2449 application.SendNotification();
2451 // START PROCESS/RENDER Input, Expected Input, Expected
2452 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2453 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2455 // CHANGE TO RENDER ONCE,
2456 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2457 application.SendNotification();
2458 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2459 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2460 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2462 tet_printf(" FailImageLoad\n");
2464 FailImageLoad(application, imageRequestId); // Need to run Update again for this to complete
2466 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) ); // nothing to draw
2467 application.SendNotification();
2469 // Drawing empty framebuffer, so will still get a GL sync
2470 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2471 DALI_TEST_CHECK( lastSyncObj != NULL );
2473 sync.SetObjectSynced( lastSyncObj, true );
2475 // Expect finished signal, as all resources are complete
2476 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2477 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2484 int UtcDaliRenderTaskOnceNoSync01(void)
2486 TestApplication application;
2488 tet_infoline("Testing RenderTask Render Once, using loading image\nPRE: Resources not ready, Source not visible\nPOST: Finished signal sent once only");
2490 // SETUP AN OFFSCREEN RENDER TASK
2491 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2492 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2493 drawTrace.Enable(true);
2495 Actor rootActor = Actor::New();
2496 Stage::GetCurrent().Add( rootActor );
2498 CameraActor offscreenCameraActor = CameraActor::New();
2499 Stage::GetCurrent().Add( offscreenCameraActor );
2500 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2501 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2502 Integration::ResourceId imageRequestId = imageRequest->GetId();
2503 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2505 Stage::GetCurrent().Add(secondRootActor);
2507 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2508 bool finished = false;
2509 RenderTaskFinished renderTaskFinished( finished );
2510 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2511 application.SendNotification();
2513 // START PROCESS/RENDER Input, Expected Input, Expected
2514 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2515 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2517 // FINISH RESOURCE LOADING - expect immediate rendering yet
2518 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2519 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2520 application.GetPlatform().ClearReadyResources();
2521 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2525 int UtcDaliRenderTaskOnceNoSync02(void)
2527 TestApplication application;
2529 tet_infoline("Testing RenderTask Render Once, using loading image. Switch from render always after ready to render once\n"
2530 "PRE: Render task ready, Image not loaded\n"
2531 "POST: Finished signal sent only once");
2533 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2534 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2535 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2536 drawTrace.Enable(true);
2538 Actor rootActor = Actor::New();
2539 Stage::GetCurrent().Add( rootActor );
2541 CameraActor offscreenCameraActor = CameraActor::New();
2542 Stage::GetCurrent().Add( offscreenCameraActor );
2543 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2544 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2545 Integration::ResourceId imageRequestId = imageRequest->GetId();
2546 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2547 Stage::GetCurrent().Add(secondRootActor);
2549 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2550 bool finished = false;
2551 RenderTaskFinished renderTaskFinished( finished );
2552 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2553 application.SendNotification();
2555 // START PROCESS/RENDER Input, Expected Input, Expected
2556 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2557 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2559 // FINISH RESOURCE LOADING
2560 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2561 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
2562 application.GetPlatform().ClearReadyResources();
2564 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2565 application.SendNotification(); // Input, Expected Input, Expected
2566 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2567 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2572 int UtcDaliRenderTaskOnceNoSync03(void)
2574 TestApplication application;
2576 tet_infoline("Testing RenderTask Render Once\n"
2577 "Switch from Render always after ready to render once with resources unready\n"
2578 "PRE: Everything ready to render\n"
2579 "POST: Finished signal sent once");
2581 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2582 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2583 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2584 drawTrace.Enable(true);
2586 Actor rootActor = Actor::New();
2587 Stage::GetCurrent().Add( rootActor );
2589 CameraActor offscreenCameraActor = CameraActor::New();
2590 Stage::GetCurrent().Add( offscreenCameraActor );
2591 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2592 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2593 Integration::ResourceId imageRequestId = imageRequest->GetId();
2594 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2595 Stage::GetCurrent().Add(secondRootActor);
2597 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2598 bool finished = false;
2599 RenderTaskFinished renderTaskFinished( finished );
2600 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2601 application.SendNotification();
2603 // START PROCESS/RENDER Input, Expected Input, Expected
2604 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2605 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2607 // CHANGE TO RENDER ONCE
2608 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2609 application.SendNotification(); // Input, Expected Input, Expected
2610 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2611 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2613 // FINISH RESOURCE LOADING
2614 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2615 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2616 application.GetPlatform().ClearReadyResources();
2617 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2622 //int UtcDaliRenderTaskOnceNoSync04(void)
2624 TestApplication application;
2626 tet_infoline("Testing RenderTask Render Once\n"
2627 "During RenderOnce, make ready resources unready before sending first finished signal\n"
2628 "PRE: Everything ready.\n"
2629 "POST: Finished signal sent only once");
2631 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2632 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2633 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2634 drawTrace.Enable(true);
2636 Actor rootActor = Actor::New();
2637 Stage::GetCurrent().Add( rootActor );
2639 CameraActor offscreenCameraActor = CameraActor::New();
2640 Stage::GetCurrent().Add( offscreenCameraActor );
2641 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2642 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2643 Integration::ResourceId imageRequestId = imageRequest->GetId();
2644 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2645 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2646 application.Render();
2647 application.GetPlatform().ClearReadyResources();
2649 Stage::GetCurrent().Add(secondRootActor);
2651 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2652 bool finished = false;
2653 RenderTaskFinished renderTaskFinished( finished );
2654 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2655 application.SendNotification();
2657 // START PROCESS/RENDER Input, Expected Input, Expected
2658 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2659 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
2661 // CHANGE TO RENDER ONCE, RESOURCES BECOME NOT READY
2662 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2665 ReloadImage(application, secondRootActor.GetImage());
2666 application.SendNotification(); // Input, Expected Input, Expected
2668 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2669 DALI_TEST_EQUALS( secondRootActor.GetImage().GetLoadingState(), Dali::ResourceLoading, TEST_LOCATION);
2670 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2672 // FINISH RESOURCE LOADING
2673 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2674 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, true, true ) );
2675 application.GetPlatform().ClearReadyResources();
2676 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2677 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2678 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2679 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2684 int UtcDaliRenderTaskOnceNoSync05(void)
2686 TestApplication application;
2688 tet_infoline("Testing RenderTask Render Once\n"
2689 "Render once, Second call to SetRefreshRate(ONCE) triggers only one more finished signal\n"
2690 "PRE: Everything ready\n"
2691 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
2693 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2694 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2695 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2696 drawTrace.Enable(true);
2698 Actor rootActor = Actor::New();
2699 Stage::GetCurrent().Add( rootActor );
2701 CameraActor offscreenCameraActor = CameraActor::New();
2702 Stage::GetCurrent().Add( offscreenCameraActor );
2703 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2704 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2705 Integration::ResourceId imageRequestId = imageRequest->GetId();
2706 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2707 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2708 application.Render();
2709 application.GetPlatform().ClearReadyResources();
2711 Stage::GetCurrent().Add(secondRootActor);
2713 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2714 bool finished = false;
2715 RenderTaskFinished renderTaskFinished( finished );
2716 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2717 application.SendNotification();
2719 // START PROCESS/RENDER Input, Expected Input, Expected
2720 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
2722 // CHANGE TO RENDER ONCE,
2723 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2724 application.SendNotification();
2725 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2726 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2728 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2729 application.SendNotification();
2730 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2731 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2735 int UtcDaliRenderTaskOnceNoSync06(void)
2737 TestApplication application;
2739 tet_infoline("Testing RenderTask Render Once\n"
2740 "Render once, Call to SetRefreshRate(ONCE) in Finished signal callback triggers\n"
2741 "another render & another finished signal\n"
2742 "PRE: Everything ready\n"
2743 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
2746 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2747 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2748 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2749 drawTrace.Enable(true);
2751 Actor rootActor = Actor::New();
2752 Stage::GetCurrent().Add( rootActor );
2754 CameraActor offscreenCameraActor = CameraActor::New();
2755 Stage::GetCurrent().Add( offscreenCameraActor );
2756 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2757 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2758 Integration::ResourceId imageRequestId = imageRequest->GetId();
2759 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2760 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2761 application.Render();
2762 application.GetPlatform().ClearReadyResources();
2764 Stage::GetCurrent().Add(secondRootActor);
2766 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2767 bool finished = false;
2769 ConnectionTracker connectionTracker;
2770 RenderTaskFinishedRenderAgain renderTaskFinishedRenderAgain( finished );
2771 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinishedRenderAgain );
2773 application.SendNotification();
2775 // START PROCESS/RENDER Input, Expected Input, Expected
2776 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
2778 // CHANGE TO RENDER ONCE,
2779 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2780 application.SendNotification();
2781 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2782 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2784 // Expect SetRefreshRate to have been called again
2785 // Prevent next finished signal calling refresh once again
2786 RenderTaskFinished renderTaskFinished( finished );
2787 connectionTracker.DisconnectAll();
2788 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinished );
2790 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2791 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2796 int UtcDaliRenderTaskOnceNoSync07(void)
2798 TestApplication application;
2800 tet_infoline("Testing RenderTask Render Once\n"
2801 "SetRefreshRate(ONCE) again before first finished signal has been sent.\n"
2802 "PRE: resources ready\n"
2803 "POST: Only 1 finished signal sent.");
2805 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2806 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2807 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2808 drawTrace.Enable(true);
2810 Actor rootActor = Actor::New();
2811 Stage::GetCurrent().Add( rootActor );
2813 CameraActor offscreenCameraActor = CameraActor::New();
2814 Stage::GetCurrent().Add( offscreenCameraActor );
2815 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2816 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2817 Integration::ResourceId imageRequestId = imageRequest->GetId();
2818 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2819 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2820 application.Render();
2821 application.GetPlatform().ClearReadyResources();
2823 Stage::GetCurrent().Add(secondRootActor);
2825 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2826 bool finished = false;
2827 RenderTaskFinished renderTaskFinished( finished );
2828 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2829 application.SendNotification();
2831 // START PROCESS/RENDER Input, Expected Input, Expected
2832 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
2834 // CHANGE TO RENDER ONCE,
2835 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2836 application.SendNotification();
2837 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2838 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2840 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2841 application.SendNotification();
2842 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2843 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2847 int UtcDaliRenderTaskOnceNoSync08(void)
2849 TestApplication application;
2851 tet_infoline("Testing RenderTask Render Once\n"
2852 "SetRefreshRate(ONCE), resource load failed, completes render task.\n"
2853 "PRE: resources not ready\n"
2854 "POST: Only 1 finished signal sent.");
2856 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2857 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2858 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2859 drawTrace.Enable(true);
2861 Actor rootActor = Actor::New();
2862 Stage::GetCurrent().Add( rootActor );
2864 CameraActor offscreenCameraActor = CameraActor::New();
2865 Stage::GetCurrent().Add( offscreenCameraActor );
2866 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2867 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2868 Integration::ResourceId imageRequestId = imageRequest->GetId();
2869 Stage::GetCurrent().Add(secondRootActor);
2871 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2872 bool finished = false;
2873 RenderTaskFinished renderTaskFinished( finished );
2874 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2875 application.SendNotification();
2877 // START PROCESS/RENDER Input, Expected Input, Expected
2878 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2879 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2881 // CHANGE TO RENDER ONCE,
2882 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2883 application.SendNotification();
2884 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2885 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2886 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2888 FailImageLoad(application, imageRequestId); // Need to run Update again for this to complete
2889 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) ); // nothing to draw
2890 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2897 int UtcDaliRenderTaskOnceChain01(void)
2899 TestApplication application;
2901 tet_infoline("Testing RenderTask Render Once Chained render tasks\n"
2902 "SetRefreshRate(ONCE), resource load completes, both render tasks render.\n"
2903 "PRE: resources not ready\n"
2904 "POST: 2 finished signals sent.");
2906 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2907 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2908 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2909 drawTrace.Enable(true);
2911 Actor defaultRootActor = Actor::New(); // Root for default RT
2912 Stage::GetCurrent().Add( defaultRootActor );
2914 CameraActor offscreenCameraActor = CameraActor::New();
2915 Stage::GetCurrent().Add( offscreenCameraActor );
2916 ImageActor firstRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2917 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2918 Integration::ResourceId imageRequestId = imageRequest->GetId();
2919 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2920 Stage::GetCurrent().Add(firstRootActor);
2922 // first render task
2923 RenderTask firstTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, firstRootActor, RenderTask::REFRESH_ONCE, false);
2924 bool firstFinished = false;
2925 RenderTaskFinished renderTask1Finished( firstFinished );
2926 firstTask.FinishedSignal().Connect( &application, renderTask1Finished );
2928 // Second render task
2929 FrameBufferImage fbo = firstTask.GetTargetFrameBuffer();
2930 ImageActor secondRootActor = ImageActor::New( fbo );
2931 Stage::GetCurrent().Add(secondRootActor);
2932 RenderTask secondTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2933 bool secondFinished = false;
2934 RenderTaskFinished renderTask2Finished( secondFinished );
2935 secondTask.FinishedSignal().Connect( &application, renderTask2Finished );
2937 application.SendNotification();
2939 // START PROCESS/RENDER Input, Expected Input, Expected
2940 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true ) );
2941 DALI_TEST_CHECK( secondFinished == false );
2942 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true ) );
2943 DALI_TEST_CHECK( secondFinished == false );
2945 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2946 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true ) );
2947 DALI_TEST_CHECK( secondFinished == false );
2948 application.GetPlatform().ClearReadyResources();
2950 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, firstFinished, true, false ) );
2951 DALI_TEST_CHECK( secondFinished == true );
2956 int UtcDaliRenderTaskProperties(void)
2958 TestApplication application;
2960 RenderTask task = Stage::GetCurrent().GetRenderTaskList().CreateTask();
2962 Property::IndexContainer indices;
2963 task.GetPropertyIndices( indices );
2964 DALI_TEST_CHECK( ! indices.empty() );
2965 DALI_TEST_EQUALS( indices.size(), task.GetPropertyCount(), TEST_LOCATION );
2969 int UtcDaliRenderTaskSetScreenToFrameBufferMappingActor(void)
2971 TestApplication application;
2972 tet_infoline("Testing RenderTask::SetScreenToFrameBufferMappingActor ");
2974 Stage stage = Stage::GetCurrent();
2975 Size stageSize = stage.GetSize();
2976 Actor mappingActor = Actor::New();
2977 Vector2 scale( 0.6f, 0.75f);
2978 Vector2 offset( stageSize.x*0.1f, stageSize.y*0.15f);
2979 mappingActor.SetSize( stageSize * scale );
2980 mappingActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2981 mappingActor.SetPosition( offset.x, offset.y );
2982 stage.Add( mappingActor );
2984 Actor offscreenActor = Actor::New();
2985 offscreenActor.SetSize( stageSize );
2986 offscreenActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2987 stage.Add( offscreenActor );
2989 RenderTaskList taskList = stage.GetRenderTaskList();
2990 RenderTask renderTask = taskList.CreateTask();
2991 FrameBufferImage frameBufferImage = FrameBufferImage::New(stageSize.width*scale.x, stageSize.height*scale.y, Pixel::A8, Image::NEVER);
2992 renderTask.SetSourceActor( offscreenActor );
2993 renderTask.SetExclusive( true );
2994 renderTask.SetInputEnabled( true );
2995 renderTask.SetTargetFrameBuffer( frameBufferImage );
2996 renderTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
2997 renderTask.SetScreenToFrameBufferMappingActor( mappingActor );
2998 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3000 // Render and notify
3001 application.SendNotification();
3002 application.Render();
3003 application.Render();
3004 application.SendNotification();
3006 Vector2 screenCoordinates( stageSize.x * 0.05f, stageSize.y * 0.05f );
3007 Dali::HitTestAlgorithm::Results results;
3008 DALI_TEST_CHECK( !results.actor );
3009 DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
3010 // miss expected, results not changed
3011 DALI_TEST_CHECK( false == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3012 DALI_TEST_CHECK( !results.actor );
3013 DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
3015 screenCoordinates.x = stageSize.x * 0.265f;
3016 screenCoordinates.y = stageSize.y * 0.33f;
3017 results.actor = Actor();
3018 results.actorCoordinates = Vector2::ZERO;
3019 // hit expected, results changed
3020 DALI_TEST_CHECK( true == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3021 DALI_TEST_CHECK( results.actor == offscreenActor );
3022 DALI_TEST_EQUALS( (screenCoordinates-offset)/scale , results.actorCoordinates, 0.1f, TEST_LOCATION );
3024 screenCoordinates.x = stageSize.x * 0.435f;
3025 screenCoordinates.y = stageSize.y * 0.52f;
3026 // hit expected, results changed
3027 DALI_TEST_CHECK( true == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3028 DALI_TEST_CHECK( results.actor == offscreenActor );
3029 const Vector2 expectedCoordinates = (screenCoordinates-offset)/scale;
3030 DALI_TEST_EQUALS( expectedCoordinates , results.actorCoordinates, 0.1f, TEST_LOCATION );
3032 screenCoordinates.x = stageSize.x * 0.65f;
3033 screenCoordinates.y = stageSize.y * 0.95f;
3034 // miss expected, results not changed
3035 DALI_TEST_CHECK( false == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3036 DALI_TEST_CHECK( results.actor == offscreenActor );
3037 DALI_TEST_EQUALS( expectedCoordinates , results.actorCoordinates, 0.1f, TEST_LOCATION );
3041 int UtcDaliRenderTaskFinishInvisibleSourceActor(void)
3043 TestApplication application;
3045 tet_infoline("Testing RenderTask::SignalFinished()");
3047 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3048 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
3050 CameraActor offscreenCameraActor = CameraActor::New();
3052 Stage::GetCurrent().Add( offscreenCameraActor );
3054 BufferImage image = BufferImage::New( 10, 10 );
3055 ImageActor rootActor = ImageActor::New( image );
3056 rootActor.SetSize( 10, 10 );
3057 rootActor.SetVisible(false);
3058 Stage::GetCurrent().Add( rootActor );
3060 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3061 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
3062 FrameBufferImage frameBufferImage = FrameBufferImage::New( *testNativeImagePtr.Get() );
3064 // Flush all outstanding messages
3065 application.SendNotification();
3066 application.Render();
3068 RenderTask newTask = taskList.CreateTask();
3069 newTask.SetCameraActor( offscreenCameraActor );
3070 newTask.SetSourceActor( rootActor );
3071 newTask.SetInputEnabled( false );
3072 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
3073 newTask.SetClearEnabled( true );
3074 newTask.SetExclusive( true );
3075 newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
3076 newTask.SetTargetFrameBuffer( frameBufferImage );
3078 // Framebuffer doesn't actually get created until Connected, i.e. by previous line
3080 bool finished = false;
3081 RenderTaskFinished renderTaskFinished( finished );
3082 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3084 // Flush the queue and render.
3085 application.SendNotification();
3087 // 1 render to process render task, then wait for sync before finished msg is sent
3088 // from update to the event thread.
3090 application.Render();
3091 application.SendNotification();
3092 DALI_TEST_CHECK( !finished );
3094 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
3095 DALI_TEST_CHECK( lastSyncObj != NULL );
3097 application.Render();
3098 DALI_TEST_EQUALS( (application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
3099 application.SendNotification();
3100 DALI_TEST_CHECK( !finished );
3102 application.Render();
3103 DALI_TEST_EQUALS( (application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
3104 application.SendNotification();
3105 DALI_TEST_CHECK( ! finished );
3107 sync.SetObjectSynced( lastSyncObj, true );
3109 application.Render();
3110 application.SendNotification();
3111 DALI_TEST_CHECK( !finished );
3113 application.Render();
3114 application.SendNotification();
3115 DALI_TEST_CHECK( finished );
3118 application.Render(); // Double check no more finished signal
3119 application.SendNotification();
3120 DALI_TEST_CHECK( ! finished );