2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include <dali/public-api/dali-core.h>
21 #include <dali/devel-api/events/hit-test-algorithm.h>
22 #include <dali-test-suite-utils.h>
23 #include <dali/integration-api/debug.h>
24 #include <test-native-image.h>
26 #include <mesh-builder.h>
28 #define BOOLSTR(x) ((x)?"T":"F")
30 //& set: DaliRenderTask
34 void utc_dali_render_task_startup(void)
36 test_return_value = TET_UNDEF;
39 void utc_dali_render_task_cleanup(void)
41 test_return_value = TET_PASS;
47 * Constructor, Destructor, DownCast, New, copy constructor, assignment operator
49 * SetSourceActor 2+ve, 1-ve
50 * GetSourceActor 1+ve, 1-ve
51 * SetExclusive 2+ve, 0-ve
52 * IsExclusive 2+ve, 0-ve
53 * SetInputEnabled 1+ve, 0-ve
54 * GetInputEnabled 1+ve, 0-ve
55 * SetCameraActor 1+ve, 1-ve
56 * GetCameraActor 1+ve, 1-ve
57 * SetTargetFrameBuffer 1+ve, 1-ve
58 * GetTargetFrameBuffer 1+ve, 1-ve
59 * SetScreenToFrameBufferFunction 1+ve, 1-ve
60 * GetScreenToFrameBufferFunction 1+ve, 1-ve
61 * SetScreenToFrameBufferMappingActor 1+ve, 1-ve
62 * GetScreenToFrameBufferMappingActor 1+ve, 1-ve
63 * SetViewportPosition 1+ve
64 * GetCurrentViewportPosition 1+ve
65 * SetViewportSize 1+ve
66 * GetCurrentViewportSize 1+ve
67 * SetViewport 2+ve, 1-ve
68 * GetViewport 2+ve, 1-ve
69 * SetClearColor 1+ve, 1-ve
70 * GetClearColor 1+ve, 1-ve
71 * SetClearEnabled 1+ve, 1-ve
72 * GetClearEnabled 1+ve, 1-ve
80 namespace // unnamed namespace
83 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
86 * Simulate time passed by.
88 * @note this will always process at least 1 frame (1/60 sec)
90 * @param application Test application instance
91 * @param duration Time to pass in milliseconds.
92 * @return The actual time passed in milliseconds
94 int Wait(TestApplication& application, int duration = 0)
98 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
100 application.SendNotification();
101 application.Render(RENDER_FRAME_INTERVAL);
102 time += RENDER_FRAME_INTERVAL;
108 struct RenderTaskFinished
110 RenderTaskFinished( bool& finished )
111 : finished( finished )
115 void operator()( RenderTask& renderTask )
123 struct RenderTaskFinishedRemoveSource
125 RenderTaskFinishedRemoveSource( bool& finished )
126 : finished( finished ),
131 void operator()( RenderTask& renderTask )
133 DALI_TEST_CHECK(finishedOnce == false);
136 Actor srcActor = renderTask.GetSourceActor();
137 UnparentAndReset(srcActor);
144 struct RenderTaskFinishedRenderAgain
146 RenderTaskFinishedRenderAgain( bool& finished )
147 : finished( finished ),
152 void operator()( RenderTask& renderTask )
154 DALI_TEST_CHECK(finishedOnce == false);
157 renderTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
165 bool TestScreenToFrameBufferFunction( Vector2& coordinates )
167 coordinates = coordinates + Vector2( 1, 2 );
172 Actor CreateLoadingActor(TestApplication& application, std::string filename, ResourceImage::LoadPolicy loadPolicy, Image::ReleasePolicy releasePolicy)
174 Image image = ResourceImage::New(filename, loadPolicy, releasePolicy);
175 DALI_TEST_CHECK( image );
176 application.SendNotification();
177 application.Render(16);
178 DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
179 Actor actor = CreateRenderableActor(image);
180 actor.SetSize( 80, 80 );
181 application.SendNotification();
182 application.Render(16);
186 Image CreateLoadingImage(TestApplication& application, std::string filename, ResourceImage::LoadPolicy loadPolicy, Image::ReleasePolicy releasePolicy)
188 Image image = ResourceImage::New(filename, loadPolicy, releasePolicy);
189 DALI_TEST_CHECK( image );
190 application.SendNotification();
191 application.Render(16);
192 DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
197 void CompleteImageLoad(TestApplication& application, Integration::ResourceId resourceId, Integration::ResourceTypeId requestType)
199 std::vector<GLuint> ids;
201 application.GetGlAbstraction().SetNextTextureIds( ids );
203 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
204 Integration::ResourcePointer resource(bitmap);
205 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80);
207 application.GetPlatform().SetResourceLoaded(resourceId, requestType, resource);
210 void FailImageLoad(TestApplication& application, Integration::ResourceId resourceId )
212 application.GetPlatform().SetResourceLoadFailed(resourceId, Integration::FailureUnknown);
215 void ReloadImage(TestApplication& application, ResourceImage image)
217 application.GetPlatform().ClearReadyResources();
218 application.GetPlatform().DiscardRequest();
219 application.GetPlatform().ResetTrace();
220 application.GetPlatform().SetClosestImageSize(Vector2(80.0f, 80.0f)); // Ensure reload is called.
224 RenderTask CreateRenderTask(TestApplication& application,
225 CameraActor offscreenCamera,
226 Actor rootActor, // Reset default render task to point at this actor
227 Actor secondRootActor, // Source actor
228 unsigned int refreshRate,
231 // Change main render task to use a different root
232 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
233 taskList.GetTask(0u).SetSourceActor( rootActor );
235 FrameBufferImage frameBufferImage;
238 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
239 frameBufferImage= FrameBufferImage::New( *(testNativeImagePtr.Get()) );
243 frameBufferImage = FrameBufferImage::New( 10, 10 );
246 // Don't draw output framebuffer // '
248 RenderTask newTask = taskList.CreateTask();
249 newTask.SetCameraActor( offscreenCamera );
250 newTask.SetSourceActor( secondRootActor );
251 newTask.SetInputEnabled( false );
252 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
253 newTask.SetClearEnabled( true );
254 newTask.SetExclusive( true );
255 newTask.SetRefreshRate( refreshRate );
256 newTask.SetTargetFrameBuffer( frameBufferImage );
257 newTask.SetProperty( RenderTask::Property::REQUIRES_SYNC, glSync );
261 bool UpdateRender(TestApplication& application, TraceCallStack& callStack, bool testDrawn, bool& finishedSig, bool testFinished, bool testKeepUpdating, int lineNumber )
266 tet_printf("TestApplication::UpdateRender().\n");
268 application.Render(16);
269 application.SendNotification();
271 bool sigPassed = false;
274 sigPassed = finishedSig;
278 sigPassed = ! finishedSig;
281 bool drawResult = callStack.FindMethod("DrawElements") || callStack.FindMethod("DrawArrays");
283 bool drawPassed = false;
286 drawPassed = drawResult;
290 drawPassed = !drawResult;
293 bool keepUpdating = (application.GetUpdateStatus() != 0);
294 bool keepUpdatingPassed = false;
295 if( testKeepUpdating )
297 keepUpdatingPassed = keepUpdating;
301 keepUpdatingPassed = !keepUpdating;
304 bool result = (sigPassed && drawPassed && keepUpdatingPassed);
306 tet_printf("UpdateRender: Expected: Draw:%s Signal:%s KeepUpdating: %s Actual: Draw:%s Signal:%s KeepUpdating: %s %s, line %d\n",
307 BOOLSTR(testDrawn), BOOLSTR(testFinished), BOOLSTR(testKeepUpdating),
308 BOOLSTR(drawResult), BOOLSTR(finishedSig), BOOLSTR(keepUpdating),
309 result ? "Passed":"Failed",
315 // The functor to be used in the hit-test algorithm to check whether the actor is hittable.
316 bool IsActorHittableFunction(Actor actor, Dali::HitTestAlgorithm::TraverseType type)
318 bool hittable = false;
322 case Dali::HitTestAlgorithm::CHECK_ACTOR:
324 // Check whether the actor is visible and not fully transparent.
325 if( actor.IsVisible()
326 && actor.GetCurrentWorldColor().a > 0.01f) // not FULLY_TRANSPARENT
333 case Dali::HitTestAlgorithm::DESCEND_ACTOR_TREE:
335 if( actor.IsVisible() ) // Actor is visible, if not visible then none of its children are visible.
350 } // unnamed namespace
353 /****************************************************************************************************/
354 /****************************************************************************************************/
355 /******************************** TEST CASES BELOW **********************************************/
356 /****************************************************************************************************/
357 /****************************************************************************************************/
359 int UtcDaliRenderTaskDownCast01(void)
361 TestApplication application;
363 tet_infoline("Testing RenderTask::DownCast()");
365 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
367 BaseHandle base = taskList.GetTask( 0u );
368 DALI_TEST_CHECK( base );
370 RenderTask task = RenderTask::DownCast( base );
371 DALI_TEST_CHECK( task );
373 // Try calling a method
374 DALI_TEST_CHECK( task.GetSourceActor() );
378 int UtcDaliRenderTaskDownCast02(void)
380 TestApplication application;
382 tet_infoline("Testing RenderTask::DownCast()");
384 Actor actor = Actor::New();
386 RenderTask task = RenderTask::DownCast( actor );
387 DALI_TEST_CHECK( ! task );
392 int UtcDaliRenderTaskSetSourceActorN(void)
394 TestApplication application;
395 tet_infoline("Testing RenderTask::SetSourceActor() Negative - try with empty actor handle");
396 Stage stage = Stage::GetCurrent();
400 RenderTaskList taskList = stage.GetRenderTaskList();
401 RenderTask renderTask = taskList.CreateTask();
402 renderTask.SetSourceActor(srcActor);
404 application.SendNotification();
405 application.Render();
407 DALI_TEST_CHECK( ! renderTask.GetSourceActor() );
412 int UtcDaliRenderTaskSetSourceActorP01(void)
414 TestApplication application;
416 tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that setting a non-renderable actor stops existing source actor being rendered ");
418 Stage stage = Stage::GetCurrent();
420 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
422 RenderTaskList taskList = stage.GetRenderTaskList();
424 RenderTask task = taskList.GetTask( 0u );
426 Actor actor = task.GetSourceActor();
427 DALI_TEST_CHECK( actor );
429 std::vector<GLuint> ids;
431 application.GetGlAbstraction().SetNextTextureIds( ids );
433 BufferImage img = BufferImage::New( 1,1 );
434 Actor newActor = CreateRenderableActor( img );
435 newActor.SetSize(1,1);
436 stage.Add( newActor );
438 Actor nonRenderableActor = Actor::New();
439 stage.Add( nonRenderableActor );
441 // Stop the newActor from being rendered by changing the source actor
442 DALI_TEST_CHECK( nonRenderableActor );
443 task.SetSourceActor( nonRenderableActor );
444 DALI_TEST_CHECK( task.GetSourceActor() != actor );
445 DALI_TEST_CHECK( task.GetSourceActor() == nonRenderableActor );
447 // Update & Render nothing!
448 application.GetGlAbstraction().ClearBoundTextures();
449 application.SendNotification();
450 application.Render();
452 // Check that nothing was rendered
453 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
459 int UtcDaliRenderTaskSetSourceActorP02(void)
461 TestApplication application;
463 tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that switching source from a non-renderable to a renderable actor causes the texture to be drawn");
465 Stage stage = Stage::GetCurrent();
467 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
469 RenderTaskList taskList = stage.GetRenderTaskList();
471 RenderTask task = taskList.GetTask( 0u );
473 Actor actor = task.GetSourceActor();
474 DALI_TEST_CHECK( actor );
476 std::vector<GLuint> ids;
478 application.GetGlAbstraction().SetNextTextureIds( ids );
480 BufferImage img = BufferImage::New( 1,1 );
481 Actor newActor = CreateRenderableActor( img );
482 newActor.SetSize(1,1);
483 stage.Add( newActor );
485 Actor nonRenderableActor = Actor::New();
486 stage.Add( nonRenderableActor );
488 // Stop the newActor from being rendered by changing the source actor
489 DALI_TEST_CHECK( nonRenderableActor );
490 task.SetSourceActor( nonRenderableActor );
491 DALI_TEST_CHECK( task.GetSourceActor() != actor );
492 DALI_TEST_CHECK( task.GetSourceActor() == nonRenderableActor );
494 // Update & Render nothing!
495 application.GetGlAbstraction().ClearBoundTextures();
496 application.SendNotification();
497 application.Render();
499 // Check that nothing was rendered
500 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
502 // Set newActor as the new source Actor
503 task.SetSourceActor( newActor );
504 DALI_TEST_CHECK( task.GetSourceActor() != actor );
505 DALI_TEST_CHECK( task.GetSourceActor() == newActor );
507 // Update & Render the newActor
508 application.GetGlAbstraction().ClearBoundTextures();
509 application.SendNotification();
510 application.Render();
512 // Check that the newActor was rendered
513 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
514 if ( boundTextures.size() )
516 DALI_TEST_EQUALS( boundTextures[0], 7u, TEST_LOCATION );
521 int UtcDaliRenderTaskSetSourceActorOffStage(void)
523 TestApplication application;
525 tet_infoline("Testing RenderTask::SetSourceActor (on/off stage testing)");
527 Stage stage = Stage::GetCurrent();
529 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
531 RenderTaskList taskList = stage.GetRenderTaskList();
533 RenderTask task = taskList.GetTask( 0u );
535 Actor actor = task.GetSourceActor();
536 DALI_TEST_CHECK( actor );
538 std::vector<GLuint> ids;
539 GLuint expectedTextureId( 3 );
540 ids.push_back( expectedTextureId );
541 application.GetGlAbstraction().SetNextTextureIds( ids );
543 BufferImage img = BufferImage::New( 1,1 );
544 Actor newActor = CreateRenderableActor( img );
545 newActor.SetSize(1,1);
546 task.SetSourceActor( newActor );
547 // Don't add newActor to stage yet //'
549 // Update & Render with the actor initially off-stage
550 application.GetGlAbstraction().ClearBoundTextures();
551 application.SendNotification();
552 application.Render();
554 // Check that nothing was rendered
555 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
558 stage.Add( newActor );
560 // Update & Render with the actor on-stage
561 application.GetGlAbstraction().ClearBoundTextures();
562 application.SendNotification();
563 application.Render();
565 // Check that the newActor was rendered
566 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
567 if ( boundTextures.size() )
569 DALI_TEST_EQUALS( boundTextures[0], expectedTextureId, TEST_LOCATION );
572 // Now remove from stage
573 stage.Remove( newActor );
575 // Update & Render with the actor off-stage
576 application.GetGlAbstraction().ClearBoundTextures();
577 application.SendNotification();
578 application.Render();
582 int UtcDaliRenderTaskSetSourceActorEmpty(void)
584 TestApplication application;
586 tet_infoline("Testing RenderTask::SetSourceActor (empty handle case)");
588 Stage stage = Stage::GetCurrent();
590 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
592 RenderTaskList taskList = stage.GetRenderTaskList();
594 RenderTask task = taskList.GetTask( 0u );
596 Actor actor = task.GetSourceActor();
597 DALI_TEST_CHECK( actor );
599 std::vector<GLuint> ids;
600 GLuint expectedTextureId( 5 );
601 ids.push_back( expectedTextureId );
602 application.GetGlAbstraction().SetNextTextureIds( ids );
604 BufferImage img = BufferImage::New( 1,1 );
605 Actor newActor = CreateRenderableActor( img );
606 newActor.SetSize(1,1);
607 stage.Add( newActor );
609 Actor nonRenderableActor = Actor::New();
610 stage.Add( nonRenderableActor );
612 // Set with empty handle
613 task.SetSourceActor( Actor() );
614 DALI_TEST_CHECK( ! task.GetSourceActor() );
616 // Update & Render nothing!
617 application.GetGlAbstraction().ClearBoundTextures();
618 application.SendNotification();
619 application.Render();
621 // Check that nothing was rendered
622 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
624 // Set with non-empty handle
625 task.SetSourceActor( newActor );
626 DALI_TEST_CHECK( task.GetSourceActor() == newActor );
628 // Update & Render the newActor
629 application.GetGlAbstraction().ClearBoundTextures();
630 application.SendNotification();
631 application.Render();
633 // Check that the newActor was rendered
634 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
635 if ( boundTextures.size() )
637 DALI_TEST_EQUALS( boundTextures[0], expectedTextureId, TEST_LOCATION );
642 int UtcDaliRenderTaskGetSourceActorP01(void)
644 TestApplication application;
646 tet_infoline("Testing RenderTask::GetSourceActor() Check the default render task has a valid source actor");
648 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
650 RenderTask task = taskList.GetTask( 0u );
652 Actor actor = task.GetSourceActor();
653 DALI_TEST_CHECK( actor );
655 // By default the entire scene should be rendered
656 Actor root = Stage::GetCurrent().GetLayer( 0 );
657 DALI_TEST_CHECK( root == actor );
661 int UtcDaliRenderTaskGetSourceActorP02(void)
663 TestApplication application;
665 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.");
667 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
668 RenderTask task = taskList.CreateTask();
669 Actor actor = Actor::New();
670 Stage::GetCurrent().Add(actor);
671 task.SetSourceActor( actor );
673 DALI_TEST_EQUALS( actor, task.GetSourceActor(), TEST_LOCATION );
678 int UtcDaliRenderTaskGetSourceActorN(void)
680 TestApplication application;
682 tet_infoline("Testing RenderTask::GetSourceActor() Try with empty handle");
687 Actor actor = task.GetSourceActor();
689 catch (Dali::DaliException(e))
691 DALI_TEST_PRINT_ASSERT( e );
692 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
698 int UtcDaliRenderTaskSetExclusive(void)
700 TestApplication application;
702 tet_infoline("Testing RenderTask::SetExclusive() Check that exclusion works");
704 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
706 // Manipulate the GenTextures behaviour, to identify different actors
708 std::vector<GLuint> ids;
709 ids.push_back( 8 ); // 8 = actor1
710 ids.push_back( 9 ); // 9 = actor2
711 ids.push_back( 10 ); // 10 = actor3
712 application.GetGlAbstraction().SetNextTextureIds( ids );
714 BufferImage img1 = BufferImage::New( 1,1 );
715 Actor actor1 = CreateRenderableActor( img1 );
717 Stage::GetCurrent().Add( actor1 );
719 // Update & Render actor1
720 application.SendNotification();
721 application.Render();
723 // Check that the actor1 was rendered
724 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
725 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
727 if ( boundTextures.size() )
729 DALI_TEST_EQUALS( boundTextures[0], 8u/*unique to actor1*/, TEST_LOCATION );
732 BufferImage img2 = BufferImage::New( 1,1 );
733 Actor actor2 = CreateRenderableActor( img2 );
736 // Force actor2 to be rendered before actor1
737 Layer layer = Layer::New();
738 Stage::GetCurrent().Add( layer );
740 layer.LowerToBottom();
743 application.GetGlAbstraction().ClearBoundTextures();
744 application.SendNotification();
745 application.Render();
747 // Check that the actors were rendered
748 DALI_TEST_EQUALS( boundTextures.size(), 2u, TEST_LOCATION );
750 if ( boundTextures.size() )
752 DALI_TEST_EQUALS( boundTextures[0], 9u/*unique to actor2*/, TEST_LOCATION );
753 DALI_TEST_EQUALS( boundTextures[1], 8u/*unique to actor1*/, TEST_LOCATION );
756 BufferImage img3 = BufferImage::New( 1,1 );
757 Actor actor3 = CreateRenderableActor( img3 );
760 // Force actor3 to be rendered before actor2
761 layer = Layer::New();
762 Stage::GetCurrent().Add( layer );
764 layer.LowerToBottom();
766 // Update & Render all actors
767 application.GetGlAbstraction().ClearBoundTextures();
768 application.SendNotification();
769 application.Render();
771 // Check that the actors were rendered
772 DALI_TEST_EQUALS( boundTextures.size(), 3u, TEST_LOCATION );
774 if ( boundTextures.size() )
776 DALI_TEST_EQUALS( boundTextures[0], 10u/*unique to actor3*/, TEST_LOCATION );
777 DALI_TEST_EQUALS( boundTextures[1], 9u/*unique to actor2*/, TEST_LOCATION );
778 DALI_TEST_EQUALS( boundTextures[2], 8u/*unique to actor1*/, TEST_LOCATION );
781 // Both actors are now connected to the root node
782 // Setup 2 render-tasks - the first will render from the root-node, and the second from actor2
784 // Not exclusive is the default
785 RenderTask task1 = taskList.GetTask( 0u );
786 DALI_TEST_CHECK( false == task1.IsExclusive() );
788 RenderTask task2 = taskList.CreateTask();
789 DALI_TEST_CHECK( false == task2.IsExclusive() );
790 task2.SetSourceActor( actor2 );
792 // Task1 should render all actors, and task 2 should render only actor2
794 application.GetGlAbstraction().ClearBoundTextures();
795 application.SendNotification();
796 application.Render();
798 DALI_TEST_EQUALS( boundTextures.size(), 4u, TEST_LOCATION );
800 if ( boundTextures.size() == 4 )
802 // Test that task 1 renders actor3, then actor2 & then actor1
803 DALI_TEST_CHECK( boundTextures[0] == 10u );
804 DALI_TEST_CHECK( boundTextures[1] == 9u );
805 DALI_TEST_CHECK( boundTextures[2] == 8u );
807 // Test that task 2 renders actor2
808 DALI_TEST_EQUALS( boundTextures[3], 9u, TEST_LOCATION );
811 // Make actor2 exclusive to task2
813 task2.SetExclusive( true );
814 DALI_TEST_CHECK( true == task2.IsExclusive() );
816 // Task1 should render only actor1, and task 2 should render only actor2
818 application.GetGlAbstraction().ClearBoundTextures();
819 application.SendNotification();
820 application.Render();
822 DALI_TEST_EQUALS( boundTextures.size(), 3u, TEST_LOCATION );
823 if ( boundTextures.size() == 3 )
825 // Test that task 1 renders actor3 & actor1
826 DALI_TEST_CHECK( boundTextures[0] == 10u );
827 DALI_TEST_CHECK( boundTextures[1] == 8u );
829 // Test that task 2 renders actor2
830 DALI_TEST_CHECK( boundTextures[2] == 9u );
835 int UtcDaliRenderTaskSetExclusive02(void)
837 TestApplication application;
839 tet_infoline("Testing RenderTask::SetExclusive() Check that changing from exclusive to not-exclusive works");
841 std::vector<GLuint> ids;
842 ids.push_back( 8 ); // 8 = actor1
843 application.GetGlAbstraction().SetNextTextureIds( ids );
845 BufferImage img1 = BufferImage::New( 1,1 );
846 Actor actor1 = CreateRenderableActor( img1 );
848 Stage::GetCurrent().Add( actor1 );
850 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
851 RenderTask task = taskList.CreateTask();
853 task.SetSourceActor( actor1 );
854 task.SetExclusive(true); // Actor should only render once
856 TestGlAbstraction& gl = application.GetGlAbstraction();
857 TraceCallStack& drawTrace = gl.GetDrawTrace();
858 drawTrace.Enable(true);
860 // Update & Render actor1
861 application.SendNotification();
862 application.Render();
864 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION );
866 // Set task to non-exclusive - actor1 should render twice:
868 task.SetExclusive(false);
869 application.SendNotification();
870 application.Render();
872 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 2, TEST_LOCATION );
877 int UtcDaliRenderTaskSetExclusiveN(void)
879 TestApplication application;
881 tet_infoline("Testing RenderTask::SetExclusive() on empty handle");
886 task.SetExclusive(true);
888 catch (Dali::DaliException(e))
890 DALI_TEST_PRINT_ASSERT( e );
891 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
896 int UtcDaliRenderTaskIsExclusive01(void)
898 TestApplication application;
900 tet_infoline("Testing RenderTask::IsExclusive() Check default values are non-exclusive");
902 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
904 // Not exclusive is the default
905 RenderTask task = taskList.GetTask( 0u );
906 DALI_TEST_CHECK( false == task.IsExclusive() );
908 RenderTask newTask = taskList.CreateTask();
909 DALI_TEST_CHECK( false == newTask.IsExclusive() );
914 int UtcDaliRenderTaskIsExclusive02(void)
916 TestApplication application;
918 tet_infoline("Testing RenderTask::IsExclusive() Check the getter returns set values");
920 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
922 // Not exclusive is the default
923 RenderTask newTask = taskList.CreateTask();
924 DALI_TEST_EQUALS( newTask.IsExclusive(), false, TEST_LOCATION );
926 newTask.SetExclusive(true);
927 DALI_TEST_EQUALS( newTask.IsExclusive(), true, TEST_LOCATION );
931 int UtcDaliRenderTaskIsExclusiveN(void)
933 TestApplication application;
935 tet_infoline("Testing RenderTask::IsExclusive() on empty handle");
940 bool x = task.IsExclusive();
943 catch (Dali::DaliException(e))
945 DALI_TEST_PRINT_ASSERT( e );
946 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
951 int UtcDaliRenderTaskSetInputEnabled(void)
953 TestApplication application;
955 tet_infoline("Testing RenderTask::SetInputEnabled()");
957 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
959 // Input is enabled by default
960 RenderTask task = taskList.GetTask( 0u );
961 DALI_TEST_CHECK( true == task.GetInputEnabled() );
963 task.SetInputEnabled( false );
964 DALI_TEST_CHECK( false == task.GetInputEnabled() );
966 task.SetInputEnabled( true );
967 DALI_TEST_CHECK( true == task.GetInputEnabled() );
971 int UtcDaliRenderTaskGetInputEnabled(void)
973 TestApplication application;
975 tet_infoline("Testing RenderTask::GetInputEnabled()");
977 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
979 // Input is enabled by default
980 RenderTask task = taskList.GetTask( 0u );
981 DALI_TEST_EQUALS( true, task.GetInputEnabled(), TEST_LOCATION );
983 RenderTask newTask = taskList.CreateTask();
984 DALI_TEST_EQUALS( true, newTask.GetInputEnabled(), TEST_LOCATION );
986 newTask.SetInputEnabled(false);
987 DALI_TEST_EQUALS( false, newTask.GetInputEnabled(), TEST_LOCATION );
992 int UtcDaliRenderTaskSetCameraActorP(void)
994 TestApplication application;
996 tet_infoline("Testing RenderTask::SetCameraActor()");
998 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1000 RenderTask task = taskList.GetTask( 0u );
1002 Actor defaultCameraActor = task.GetCameraActor();
1003 DALI_TEST_CHECK( defaultCameraActor );
1005 CameraActor newCameraActor = CameraActor::New();
1006 DALI_TEST_CHECK( newCameraActor );
1008 task.SetCameraActor( newCameraActor );
1009 DALI_TEST_CHECK( task.GetCameraActor() != defaultCameraActor );
1010 DALI_TEST_EQUALS( task.GetCameraActor(), newCameraActor, TEST_LOCATION );
1015 int UtcDaliRenderTaskSetCameraActorN(void)
1017 TestApplication application;
1019 tet_infoline("Testing RenderTask::SetCameraActor() with empty actor handle");
1021 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1023 RenderTask task = taskList.GetTask( 0u );
1025 Actor actor = task.GetCameraActor();
1026 DALI_TEST_CHECK( actor );
1028 CameraActor cameraActor;
1030 task.SetCameraActor( cameraActor );
1031 DALI_TEST_EQUALS( (bool)task.GetCameraActor(), false, TEST_LOCATION );
1032 DALI_TEST_EQUALS( task.GetCameraActor(), cameraActor, TEST_LOCATION );
1037 int UtcDaliRenderTaskGetCameraActorP(void)
1039 TestApplication application;
1041 tet_infoline("Testing RenderTask::GetCameraActor()");
1043 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1045 RenderTask task = taskList.GetTask( 0u );
1047 CameraActor actor = task.GetCameraActor();
1048 DALI_TEST_CHECK( actor );
1049 DALI_TEST_EQUALS( actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION );
1050 DALI_TEST_GREATER( actor.GetFieldOfView(), 0.0f, TEST_LOCATION );
1054 int UtcDaliRenderTaskGetCameraActorN(void)
1056 TestApplication application;
1058 tet_infoline("Testing RenderTask::GetCameraActor() with empty handle");
1063 Actor actor = task.GetCameraActor();
1065 catch (Dali::DaliException(e))
1067 DALI_TEST_PRINT_ASSERT( e );
1068 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1074 int UtcDaliRenderTaskSetTargetFrameBufferP(void)
1076 TestApplication application;
1078 tet_infoline("Testing RenderTask::SetTargetFrameBuffer()");
1080 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1082 RenderTask task = taskList.GetTask( 0u );
1084 FrameBufferImage newImage = FrameBufferImage::New();
1085 task.SetTargetFrameBuffer( newImage );
1086 DALI_TEST_CHECK( task.GetTargetFrameBuffer() == newImage );
1090 int UtcDaliRenderTaskSetTargetFrameBufferN(void)
1092 TestApplication application;
1094 tet_infoline("Testing RenderTask::SetTargetFrameBuffer()");
1096 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1098 RenderTask task = taskList.GetTask( 0u );
1099 FrameBufferImage newImage; // Empty handle
1100 task.SetTargetFrameBuffer( newImage );
1101 DALI_TEST_EQUALS( (bool)task.GetTargetFrameBuffer(), false, TEST_LOCATION );
1105 int UtcDaliRenderTaskGetTargetFrameBufferP(void)
1107 TestApplication application;
1109 tet_infoline("Testing RenderTask::GetTargetFrameBuffer()");
1111 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1113 RenderTask newTask = taskList.CreateTask();
1114 FrameBufferImage fb = FrameBufferImage::New(128, 128, Pixel::RGBA8888);
1115 newTask.SetTargetFrameBuffer( fb );
1116 DALI_TEST_EQUALS( newTask.GetTargetFrameBuffer(), fb, TEST_LOCATION );
1120 int UtcDaliRenderTaskGetTargetFrameBufferN(void)
1122 TestApplication application;
1124 tet_infoline("Testing RenderTask::GetTargetFrameBuffer()");
1126 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1128 RenderTask task = taskList.GetTask( 0u );
1130 // By default render-tasks do not render off-screen
1131 FrameBufferImage image = task.GetTargetFrameBuffer();
1132 DALI_TEST_CHECK( !image );
1137 int UtcDaliRenderTaskSetFrameBufferP(void)
1139 TestApplication application;
1141 tet_infoline("Testing RenderTask::SetFrameBuffer()");
1143 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1145 RenderTask task = taskList.GetTask( 0u );
1147 FrameBuffer newFrameBuffer = FrameBuffer::New( 128u, 128u, FrameBuffer::Attachment::NONE );
1148 task.SetFrameBuffer( newFrameBuffer );
1149 DALI_TEST_CHECK( task.GetFrameBuffer() == newFrameBuffer );
1153 int UtcDaliRenderTaskSetFrameBufferN(void)
1155 TestApplication application;
1157 tet_infoline("Testing RenderTask::SetFrameBuffer()");
1159 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1161 RenderTask task = taskList.GetTask( 0u );
1162 FrameBuffer newFrameBuffer; // Empty handle
1163 task.SetFrameBuffer( newFrameBuffer );
1164 DALI_TEST_EQUALS( (bool)task.GetFrameBuffer(), false, TEST_LOCATION );
1168 int UtcDaliRenderTaskGetFrameBufferP(void)
1170 TestApplication application;
1172 tet_infoline("Testing RenderTask::GetFrameBuffer()");
1174 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1176 RenderTask task = taskList.GetTask( 0u );
1178 FrameBuffer newFrameBuffer = FrameBuffer::New( 1u, 1u, FrameBuffer::Attachment::NONE );
1179 task.SetFrameBuffer( newFrameBuffer );
1180 DALI_TEST_CHECK( task.GetFrameBuffer() == newFrameBuffer );
1184 int UtcDaliRenderTaskGetFrameBufferN(void)
1186 TestApplication application;
1188 tet_infoline("Testing RenderTask::GetFrameBuffer()");
1190 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1192 RenderTask task = taskList.GetTask( 0u );
1194 // By default render-tasks do not render off-screen
1195 FrameBuffer frameBuffer = task.GetFrameBuffer();
1196 DALI_TEST_CHECK( !frameBuffer );
1201 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionP(void)
1203 TestApplication application;
1205 tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1207 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1209 RenderTask task = taskList.GetTask( 0u );
1211 task.SetScreenToFrameBufferFunction( TestScreenToFrameBufferFunction );
1213 Vector2 coordinates( 5, 10 );
1214 Vector2 convertedCoordinates( 6, 12 ); // + Vector(1, 2)
1216 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1217 DALI_TEST_CHECK( func( coordinates ) );
1218 DALI_TEST_CHECK( coordinates == convertedCoordinates );
1220 task.SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
1221 func = task.GetScreenToFrameBufferFunction();
1222 DALI_TEST_CHECK( func( coordinates ) );
1224 task.SetScreenToFrameBufferFunction( RenderTask::DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION );
1225 func = task.GetScreenToFrameBufferFunction();
1226 DALI_TEST_CHECK( ! func( coordinates ) );
1230 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionN(void)
1232 TestApplication application;
1234 tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1236 RenderTask task; // Empty handle
1239 task.SetScreenToFrameBufferFunction( TestScreenToFrameBufferFunction );
1241 catch (Dali::DaliException(e))
1243 DALI_TEST_PRINT_ASSERT( e );
1244 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1249 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionP(void)
1251 TestApplication application;
1253 tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction()");
1255 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1257 RenderTask task = taskList.GetTask( 0u );
1259 Vector2 originalCoordinates( 5, 10 );
1260 Vector2 coordinates( 5, 10 );
1262 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1263 DALI_TEST_CHECK( !func( coordinates ) ); // conversion should fail by default
1264 DALI_TEST_CHECK( coordinates == originalCoordinates ); // coordinates should not be modified
1268 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionN(void)
1270 TestApplication application;
1272 tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction() on empty handle");
1277 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1280 catch (Dali::DaliException(e))
1282 DALI_TEST_PRINT_ASSERT( e );
1283 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1289 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorP(void)
1291 TestApplication application;
1292 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor ");
1294 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1295 RenderTask renderTask = taskList.CreateTask();
1296 Actor mappingActor = Actor::New();
1297 renderTask.SetScreenToFrameBufferMappingActor(mappingActor);
1299 DALI_TEST_EQUALS( mappingActor, renderTask.GetScreenToFrameBufferMappingActor(), TEST_LOCATION );
1304 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorN(void)
1306 TestApplication application;
1307 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1313 task.SetScreenToFrameBufferMappingActor(mappingActor);
1315 catch (Dali::DaliException(e))
1317 DALI_TEST_PRINT_ASSERT( e );
1318 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1323 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActor02N(void)
1325 TestApplication application;
1326 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1328 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1329 RenderTask renderTask = taskList.CreateTask();
1331 renderTask.SetScreenToFrameBufferMappingActor(actor);
1333 DALI_TEST_EQUALS( (bool)renderTask.GetScreenToFrameBufferMappingActor(), false, TEST_LOCATION);
1337 int UtcDaliRenderTaskGetViewportP01(void)
1339 TestApplication application;
1341 tet_infoline("Testing RenderTask::GetViewport() on default task");
1343 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1344 RenderTask task = taskList.GetTask( 0u );
1345 Viewport viewport = task.GetViewport();
1347 // By default the viewport should match the stage width/height
1348 Vector2 stageSize = Stage::GetCurrent().GetSize();
1349 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1350 DALI_TEST_CHECK( viewport == expectedViewport );
1354 int UtcDaliRenderTaskGetViewportP02(void)
1356 TestApplication application;
1358 tet_infoline("Testing RenderTask::GetViewport() on new task");
1360 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1361 RenderTask task = taskList.CreateTask();
1362 Viewport viewport = task.GetViewport();
1364 // By default the viewport should match the stage width/height
1365 Vector2 stageSize = Stage::GetCurrent().GetSize();
1366 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1367 DALI_TEST_CHECK( viewport == expectedViewport );
1371 int UtcDaliRenderTaskGetViewportN(void)
1373 TestApplication application;
1375 tet_infoline("Testing RenderTask::GetViewport() on empty handle");
1380 Viewport viewport = task.GetViewport();
1381 viewport = viewport;
1383 catch (Dali::DaliException(e))
1385 DALI_TEST_PRINT_ASSERT( e );
1386 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1392 int UtcDaliRenderTaskSetViewportP(void)
1394 TestApplication application;
1396 tet_infoline("Testing RenderTask::SetViewport()");
1398 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1400 RenderTask task = taskList.GetTask( 0u );
1401 Vector2 stageSize = Stage::GetCurrent().GetSize();
1402 Viewport newViewport( 0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f );
1403 task.SetViewport( newViewport );
1405 // Update (viewport is a property)
1406 application.SendNotification();
1407 application.Render();
1409 DALI_TEST_CHECK( task.GetViewport() == newViewport );
1413 int UtcDaliRenderTaskSetViewportN(void)
1415 TestApplication application;
1417 tet_infoline("Testing RenderTask::SetViewport()");
1419 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1424 Vector2 stageSize = Stage::GetCurrent().GetSize();
1425 Viewport newViewport( 0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f );
1426 task.SetViewport( newViewport );
1428 catch (Dali::DaliException(e))
1430 DALI_TEST_PRINT_ASSERT( e );
1431 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1438 int UtcDaliRenderTaskSetViewportPosition(void)
1440 TestApplication application;
1442 tet_infoline("Testing RenderTask::SetViewportPosition()");
1444 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1446 RenderTask task = taskList.GetTask( 0u );
1448 Viewport viewport = task.GetViewport();
1450 // By default the viewport should match the stage width/height
1452 Vector2 stageSize = Stage::GetCurrent().GetSize();
1453 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1454 DALI_TEST_CHECK( viewport == expectedViewport );
1457 Vector2 newPosition(25.0f, 50.0f);
1458 task.SetViewportPosition( newPosition );
1460 // Update (viewport is a property)
1461 application.SendNotification();
1462 application.Render();
1464 DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1466 // Set by Property test
1467 Vector2 newPosition2(32.0f, 32.0f);
1468 task.SetProperty( RenderTask::Property::VIEWPORT_POSITION, newPosition2 );
1471 application.SendNotification();
1472 application.Render();
1474 DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition2, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1476 Vector2 newPosition3(64.0f, 0.0f);
1477 Animation animation = Animation::New(1.0f);
1478 animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_POSITION ), newPosition3, AlphaFunction::LINEAR );
1481 // Perform 1000ms worth of updates at which point animation should have completed.
1482 Wait(application, 1000);
1483 DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1487 int UtcDaliRenderTaskSetViewportSize(void)
1489 TestApplication application;
1491 tet_infoline("Testing RenderTask::SetViewportSize()");
1493 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1495 RenderTask task = taskList.GetTask( 0u );
1497 Viewport viewport = task.GetViewport();
1499 // By default the viewport should match the stage width/height
1501 Vector2 stageSize = Stage::GetCurrent().GetSize();
1502 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1503 DALI_TEST_CHECK( viewport == expectedViewport );
1505 Vector2 newSize(128.0f, 64.0f);
1506 task.SetViewportSize( newSize );
1508 // Update (viewport is a property)
1509 application.SendNotification();
1510 application.Render();
1512 DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1514 // Set by Property test
1515 Vector2 newSize2(50.0f, 50.0f);
1516 task.SetProperty( RenderTask::Property::VIEWPORT_SIZE, newSize2 );
1519 application.SendNotification();
1520 application.Render();
1522 DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize2, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1524 Vector2 newSize3(10.0f, 10.0f);
1525 Animation animation = Animation::New(1.0f);
1526 animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_SIZE ), newSize3, AlphaFunction::LINEAR );
1529 // Perform 1000ms worth of updates at which point animation should have completed.
1530 Wait(application, 1000);
1531 DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1536 int UtcDaliRenderTaskSetClearColorP(void)
1538 TestApplication application;
1540 tet_infoline("Testing RenderTask::SetClearColor()");
1542 Vector4 testColor( 1.0f, 2.0f, 3.0f, 4.0f );
1543 Vector4 testColor2( 5.0f, 6.0f, 7.0f, 8.0f );
1545 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1547 RenderTask task = taskList.GetTask( 0u );
1548 DALI_TEST_CHECK( task.GetClearColor() != testColor );
1550 task.SetClearColor( testColor );
1555 DALI_TEST_EQUALS( task.GetClearColor(), testColor, TEST_LOCATION );
1557 task.SetProperty( RenderTask::Property::CLEAR_COLOR, testColor2 );
1562 DALI_TEST_EQUALS( task.GetClearColor(), testColor2, TEST_LOCATION );
1566 int UtcDaliRenderTaskSetClearColorN(void)
1568 TestApplication application;
1570 tet_infoline("Testing RenderTask::SetClearColor() on empty handle");
1575 task.SetClearColor( Vector4::ZERO );
1577 catch (Dali::DaliException(e))
1579 DALI_TEST_PRINT_ASSERT( e );
1580 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1585 int UtcDaliRenderTaskGetClearColorP(void)
1587 TestApplication application;
1589 tet_infoline("Testing RenderTask::GetClearColor()");
1591 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1592 RenderTask task = taskList.GetTask( 0u );
1593 DALI_TEST_EQUALS( task.GetClearColor(), RenderTask::DEFAULT_CLEAR_COLOR, TEST_LOCATION );
1597 int UtcDaliRenderTaskGetClearColorN(void)
1599 TestApplication application;
1601 tet_infoline("Testing RenderTask::GetClearColor()");
1606 Vector4 color = task.GetClearColor();
1609 catch (Dali::DaliException(e))
1611 DALI_TEST_PRINT_ASSERT( e );
1612 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1617 int UtcDaliRenderTaskSetClearEnabledP(void)
1619 TestApplication application;
1621 tet_infoline("Testing RenderTask::SetClearEnabled()");
1623 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1625 RenderTask task = taskList.GetTask( 0u );
1626 DALI_TEST_CHECK( !task.GetClearEnabled() ); // defaults to false
1628 task.SetClearEnabled( true );
1629 DALI_TEST_EQUALS( task.GetClearEnabled(), true, TEST_LOCATION );
1631 task.SetClearEnabled( false );
1632 DALI_TEST_EQUALS( task.GetClearEnabled(), false, TEST_LOCATION );
1636 int UtcDaliRenderTaskSetClearEnabledN(void)
1638 TestApplication application;
1640 tet_infoline("Testing RenderTask::SetClearEnabled() with empty handle");
1645 task.SetClearEnabled(true);
1647 catch (Dali::DaliException(e))
1649 DALI_TEST_PRINT_ASSERT( e );
1650 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1655 int UtcDaliRenderTaskGetClearEnabledP(void)
1657 TestApplication application;
1659 tet_infoline("Testing RenderTask::GetClearEnabled()");
1661 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1663 RenderTask task = taskList.GetTask( 0u );
1664 DALI_TEST_CHECK( !task.GetClearEnabled() ); // defaults to false
1669 int UtcDaliRenderTaskGetClearEnabledN(void)
1671 TestApplication application;
1673 tet_infoline("Testing RenderTask::GetClearEnabled() with empty handle");
1678 bool x = task.GetClearEnabled();
1681 catch (Dali::DaliException(e))
1683 DALI_TEST_PRINT_ASSERT( e );
1684 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1689 int UtcDaliRenderTaskSetCullModeP(void)
1691 TestApplication application;
1693 tet_infoline("Testing RenderTask::SetCullMode()");
1695 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1696 RenderTask task = taskList.GetTask( 0u );
1697 DALI_TEST_EQUALS( task.GetCullMode(), true, TEST_LOCATION );
1699 task.SetCullMode( false );
1701 DALI_TEST_EQUALS( task.GetCullMode(), false, TEST_LOCATION );
1706 int UtcDaliRenderTaskSetCullModeN(void)
1708 TestApplication application;
1710 tet_infoline("Testing RenderTask::SetCullMode() on empty handle");
1715 task.SetCullMode( false );
1717 catch (Dali::DaliException(e))
1719 DALI_TEST_PRINT_ASSERT( e );
1720 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1725 int UtcDaliRenderTaskGetCullModeP(void)
1727 TestApplication application;
1729 tet_infoline("Testing RenderTask::GetCullMode()");
1731 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1732 RenderTask task = taskList.GetTask( 0u );
1733 DALI_TEST_EQUALS( task.GetCullMode(), true, TEST_LOCATION );
1737 int UtcDaliRenderTaskGetCullModeN(void)
1739 TestApplication application;
1741 tet_infoline("Testing RenderTask::GetCullMode() with empty handle");
1746 bool x = task.GetCullMode();
1749 catch (Dali::DaliException(e))
1751 DALI_TEST_PRINT_ASSERT( e );
1752 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1758 int UtcDaliRenderTaskSetRefreshRate(void)
1760 TestApplication application;
1762 tet_infoline("Testing RenderTask::SetRefreshRate()");
1764 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1766 // By default tasks will be processed every frame
1767 RenderTask task = taskList.GetTask( 0u );
1768 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1770 task.SetRefreshRate( 2u ); // every-other frame
1771 DALI_TEST_CHECK( 2u == task.GetRefreshRate() );
1773 task.SetRefreshRate( RenderTask::REFRESH_ALWAYS );
1774 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1778 int UtcDaliRenderTaskGetRefreshRate(void)
1780 TestApplication application;
1782 tet_infoline("Testing RenderTask::GetRefreshRate()");
1784 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1786 // By default tasks will be processed every frame
1787 RenderTask task = taskList.GetTask( 0u );
1788 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1790 RenderTask newTask = taskList.CreateTask();
1791 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == newTask.GetRefreshRate() );
1795 int UtcDaliRenderTaskSignalFinished(void)
1797 TestApplication application;
1799 tet_infoline("Testing RenderTask::SignalFinished()");
1801 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1802 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
1804 CameraActor offscreenCameraActor = CameraActor::New();
1806 Stage::GetCurrent().Add( offscreenCameraActor );
1808 BufferImage image = BufferImage::New( 10, 10 );
1810 Actor rootActor = CreateRenderableActor( image );
1811 rootActor.SetSize( 10, 10 );
1812 Stage::GetCurrent().Add( rootActor );
1814 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1815 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
1816 FrameBufferImage frameBufferImage = FrameBufferImage::New( *testNativeImagePtr.Get() );
1818 RenderTask newTask = taskList.CreateTask();
1819 newTask.SetCameraActor( offscreenCameraActor );
1820 newTask.SetSourceActor( rootActor );
1821 newTask.SetInputEnabled( false );
1822 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
1823 newTask.SetClearEnabled( true );
1824 newTask.SetExclusive( true );
1825 newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
1826 newTask.SetTargetFrameBuffer( frameBufferImage );
1827 newTask.SetProperty( RenderTask::Property::REQUIRES_SYNC, true );
1829 bool finished = false;
1830 RenderTaskFinished renderTaskFinished( finished );
1831 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1833 // Flush the queue and render.
1834 application.SendNotification();
1836 // 1 render to process render task, then wait for sync before finished msg is sent
1837 // from update to the event thread.
1839 application.Render();
1840 application.SendNotification();
1841 DALI_TEST_CHECK( !finished );
1843 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
1844 DALI_TEST_CHECK( lastSyncObj != NULL );
1846 application.Render();
1847 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
1848 application.SendNotification();
1849 DALI_TEST_CHECK( !finished );
1851 application.Render();
1852 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
1853 application.SendNotification();
1854 DALI_TEST_CHECK( ! finished );
1856 sync.SetObjectSynced( lastSyncObj, true );
1858 application.Render();
1859 application.SendNotification();
1860 DALI_TEST_CHECK( !finished );
1862 application.Render();
1863 application.SendNotification();
1864 DALI_TEST_CHECK( finished );
1867 DALI_TEST_EQUALS( application.GetUpdateStatus(), 0, TEST_LOCATION );
1872 int UtcDaliRenderTaskContinuous01(void)
1874 TestApplication application;
1876 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not staged)\nPOST:continuous renders, no Finished signal");
1878 // SETUP AN OFFSCREEN RENDER TASK
1879 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1880 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1881 drawTrace.Enable(true);
1883 Actor rootActor = Actor::New();
1884 Stage::GetCurrent().Add( rootActor );
1886 CameraActor offscreenCameraActor = CameraActor::New();
1887 Stage::GetCurrent().Add( offscreenCameraActor );
1889 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1890 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1891 Integration::ResourceId imageRequestId = imageRequest->GetId();
1892 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1894 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1895 bool finished = false;
1896 RenderTaskFinished renderTaskFinished( finished );
1897 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1898 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1899 application.SendNotification();
1901 // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating
1902 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false, __LINE__ ) );
1903 application.GetPlatform().ClearReadyResources();
1905 // ADD SOURCE ACTOR TO STAGE - expect continuous renders to start, no finished signal
1906 Stage::GetCurrent().Add(secondRootActor);
1907 application.SendNotification();
1909 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1910 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
1915 int UtcDaliRenderTaskContinuous02(void)
1917 TestApplication application;
1919 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not visible)\nPOST:continuous renders, no Finished signal");
1921 // SETUP AN OFFSCREEN RENDER TASK
1922 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1923 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1924 drawTrace.Enable(true);
1926 Actor rootActor = Actor::New();
1927 Stage::GetCurrent().Add( rootActor );
1929 CameraActor offscreenCameraActor = CameraActor::New();
1930 Stage::GetCurrent().Add( offscreenCameraActor );
1932 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1933 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1934 Integration::ResourceId imageRequestId = imageRequest->GetId();
1935 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1936 Stage::GetCurrent().Add(secondRootActor);
1937 secondRootActor.SetVisible(false);
1939 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1940 bool finished = false;
1941 RenderTaskFinished renderTaskFinished( finished );
1942 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1943 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1944 application.SendNotification();
1946 // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating
1947 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false, __LINE__ ) );
1948 application.GetPlatform().ClearReadyResources();
1950 // MAKE SOURCE ACTOR VISIBLE - expect continuous renders to start, no finished signal
1951 secondRootActor.SetVisible(true);
1952 application.SendNotification();
1954 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1955 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
1959 int UtcDaliRenderTaskContinuous03(void)
1961 TestApplication application;
1963 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (camera actor not staged)\nPOST:continuous renders, no Finished signal");
1965 // SETUP AN OFFSCREEN RENDER TASK
1966 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1967 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1968 drawTrace.Enable(true);
1970 Actor rootActor = Actor::New();
1971 Stage::GetCurrent().Add( rootActor );
1973 CameraActor offscreenCameraActor = CameraActor::New();
1974 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1975 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1976 Integration::ResourceId imageRequestId = imageRequest->GetId();
1977 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1978 Stage::GetCurrent().Add(secondRootActor);
1980 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1981 bool finished = false;
1982 RenderTaskFinished renderTaskFinished( finished );
1983 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1984 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1985 application.SendNotification();
1987 // START PROCESS/RENDER Input, Expected Input, Expected
1988 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false, __LINE__ ) );
1989 application.GetPlatform().ClearReadyResources();
1991 // ADD CAMERA ACTOR TO STAGE - expect continuous renders to start, no finished signal
1992 Stage::GetCurrent().Add( offscreenCameraActor );
1993 application.SendNotification();
1995 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1996 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2001 int UtcDaliRenderTaskContinuous04(void)
2003 TestApplication application;
2005 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: Resource not ready\nPOST:continuous renders, no Finished signal");
2007 // SETUP AN OFFSCREEN RENDER TASK
2008 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2009 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2010 drawTrace.Enable(true);
2012 Actor rootActor = Actor::New();
2013 Stage::GetCurrent().Add( rootActor );
2015 CameraActor offscreenCameraActor = CameraActor::New();
2016 Stage::GetCurrent().Add( offscreenCameraActor );
2017 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2018 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2019 Integration::ResourceId imageRequestId = imageRequest->GetId();
2020 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2021 Stage::GetCurrent().Add(secondRootActor);
2023 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2024 bool finished = false;
2025 RenderTaskFinished renderTaskFinished( finished );
2026 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2027 application.SendNotification();
2029 // START PROCESS/RENDER Input, Expected Input, Expected
2030 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2031 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2033 // FINISH RESOURCE LOADING - expect 'continuous' renders to start, no finished signal
2034 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2035 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2039 int UtcDaliRenderTaskContinous05(void)
2041 TestApplication application;
2043 tet_infoline("Testing RenderTask Render Continuous using Mesh which accesses texture through sampler with loading image\n"
2044 "PRE: Resource not ready\nPOST:continuous renders, no Finished signal");
2046 // SETUP AN OFFSCREEN RENDER TASK
2047 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2048 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2049 drawTrace.Enable(true);
2051 Actor rootActor = Actor::New();
2052 Stage::GetCurrent().Add( rootActor );
2054 CameraActor offscreenCameraActor = CameraActor::New();
2055 Stage::GetCurrent().Add( offscreenCameraActor );
2057 Shader shader = CreateShader();
2060 Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2061 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2062 Integration::ResourceId imageRequestId = imageRequest->GetId();
2063 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2064 TextureSet textureSet = CreateTextureSet( image );
2066 Geometry geometry = CreateQuadGeometry();
2067 Renderer renderer = Renderer::New(geometry, shader);
2068 renderer.SetTextures( textureSet );
2069 Actor secondRootActor = Actor::New();
2070 secondRootActor.AddRenderer(renderer);
2071 secondRootActor.SetSize(100, 100);
2072 Stage::GetCurrent().Add(secondRootActor);
2074 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2075 bool finished = false;
2076 RenderTaskFinished renderTaskFinished( finished );
2077 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2078 application.SendNotification();
2080 // START PROCESS/RENDER Input, Expected Input, Expected
2081 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2082 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2084 // FINISH RESOURCE LOADING - expect 'continuous' renders to start, no finished signal
2085 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2086 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2092 int UtcDaliRenderTaskOnce01(void)
2094 TestApplication application;
2096 tet_infoline("Testing RenderTask Render Once GlSync, using loading image\nPRE: Resources not ready, Source not visible\nPOST: Finished signal sent once only");
2098 // SETUP AN OFFSCREEN RENDER TASK
2099 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2100 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2101 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2102 drawTrace.Enable(true);
2104 Actor rootActor = Actor::New();
2105 Stage::GetCurrent().Add( rootActor );
2107 CameraActor offscreenCameraActor = CameraActor::New();
2108 Stage::GetCurrent().Add( offscreenCameraActor );
2109 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2110 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2111 Integration::ResourceId imageRequestId = imageRequest->GetId();
2112 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2114 Stage::GetCurrent().Add(secondRootActor);
2116 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
2117 bool finished = false;
2118 RenderTaskFinished renderTaskFinished( finished );
2119 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2120 application.SendNotification();
2122 // START PROCESS/RENDER Input, Expected Input, Expected
2123 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2124 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2126 // MAKE SOURCE VISIBLE
2127 secondRootActor.SetVisible(true);
2128 application.SendNotification();
2129 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2130 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2132 // FINISH RESOURCE LOADING - expect no rendering yet
2133 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2134 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2135 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2136 DALI_TEST_CHECK( lastSyncObj != NULL );
2138 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2139 application.GetPlatform().ClearReadyResources();
2140 sync.SetObjectSynced( lastSyncObj, true );
2141 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2142 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2146 int UtcDaliRenderTaskOnce02(void)
2148 TestApplication application;
2150 tet_infoline("Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loading image.\n"
2151 "PRE: Resources not ready\nPOST: Finished signal sent once only");
2153 // SETUP AN OFFSCREEN RENDER TASK
2154 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2155 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2156 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2157 drawTrace.Enable(true);
2159 Actor rootActor = Actor::New();
2160 Stage::GetCurrent().Add( rootActor );
2162 CameraActor offscreenCameraActor = CameraActor::New();
2163 Stage::GetCurrent().Add( offscreenCameraActor );
2165 Shader shader = CreateShader();
2166 Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2167 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2168 Integration::ResourceId imageRequestId = imageRequest->GetId();
2169 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2170 TextureSet textureSet = CreateTextureSet( image );
2172 Geometry geometry = CreateQuadGeometry();
2173 Renderer renderer = Renderer::New(geometry, shader);
2174 renderer.SetTextures( textureSet );
2175 Actor secondRootActor = Actor::New();
2176 secondRootActor.AddRenderer(renderer);
2177 secondRootActor.SetSize(100, 100);
2178 Stage::GetCurrent().Add(secondRootActor);
2180 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
2181 bool finished = false;
2182 RenderTaskFinished renderTaskFinished( finished );
2183 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2184 application.SendNotification();
2186 // START PROCESS/RENDER Input, Expected Input, Expected
2187 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2188 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2190 // FINISH RESOURCE LOADING - expect no rendering yet
2191 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2192 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2193 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2194 DALI_TEST_CHECK( lastSyncObj != NULL );
2196 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2197 application.GetPlatform().ClearReadyResources();
2198 sync.SetObjectSynced( lastSyncObj, true );
2199 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2200 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2205 int UtcDaliRenderTaskOnce03(void)
2207 TestApplication application;
2209 tet_infoline("Testing RenderTask Render Once GlSync, using loading image. Switch from render always after ready to render once\n"
2210 "PRE: Render task ready, Image not loaded\n"
2211 "POST: Finished signal sent only once");
2213 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2214 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2215 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2216 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2217 drawTrace.Enable(true);
2219 Actor rootActor = Actor::New();
2220 Stage::GetCurrent().Add( rootActor );
2222 CameraActor offscreenCameraActor = CameraActor::New();
2223 Stage::GetCurrent().Add( offscreenCameraActor );
2224 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2225 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2226 Integration::ResourceId imageRequestId = imageRequest->GetId();
2227 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2228 Stage::GetCurrent().Add(secondRootActor);
2230 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2231 bool finished = false;
2232 RenderTaskFinished renderTaskFinished( finished );
2233 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2234 application.SendNotification();
2236 // START PROCESS/RENDER Input, Expected Input, Expected
2237 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2238 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2240 // FINISH RESOURCE LOADING
2241 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2242 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2243 application.GetPlatform().ClearReadyResources();
2244 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2246 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2247 application.SendNotification(); // Input, Expected Input, Expected
2248 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2249 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2250 DALI_TEST_CHECK( lastSyncObj != NULL );
2252 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2253 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2254 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2255 sync.SetObjectSynced( lastSyncObj, true );
2256 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2257 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2263 int UtcDaliRenderTaskOnce04(void)
2265 TestApplication application;
2266 tet_infoline("Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loading image.\n"
2267 "Switch from render always after ready to render once\n"
2268 "PRE: Render task ready, Image not loaded\n"
2269 "POST: Finished signal sent only once");
2271 // SETUP AN OFFSCREEN RENDER TASK
2272 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2273 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2274 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2275 drawTrace.Enable(true);
2277 Actor rootActor = Actor::New();
2278 Stage::GetCurrent().Add( rootActor );
2280 CameraActor offscreenCameraActor = CameraActor::New();
2281 Stage::GetCurrent().Add( offscreenCameraActor );
2283 Shader shader = CreateShader();
2284 Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2285 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2286 Integration::ResourceId imageRequestId = imageRequest->GetId();
2287 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2288 TextureSet textureSet = CreateTextureSet( image );
2290 Geometry geometry = CreateQuadGeometry();
2291 Renderer renderer = Renderer::New(geometry, shader);
2292 renderer.SetTextures( textureSet );
2293 Actor secondRootActor = Actor::New();
2294 secondRootActor.AddRenderer(renderer);
2295 secondRootActor.SetSize(100, 100);
2296 Stage::GetCurrent().Add(secondRootActor);
2298 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2299 bool finished = false;
2300 RenderTaskFinished renderTaskFinished( finished );
2301 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2302 application.SendNotification();
2304 // START PROCESS/RENDER Input, Expected Input, Expected
2305 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2306 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2308 // FINISH RESOURCE LOADING
2309 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2310 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2311 application.GetPlatform().ClearReadyResources();
2312 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2314 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2315 application.SendNotification(); // Input, Expected Input, Expected
2316 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2317 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2318 DALI_TEST_CHECK( lastSyncObj != NULL );
2320 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2321 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2322 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2323 sync.SetObjectSynced( lastSyncObj, true );
2324 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2325 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2330 int UtcDaliRenderTaskOnce05(void)
2332 TestApplication application;
2334 tet_infoline("Testing RenderTask Render Once GlSync\n"
2335 "Switch from Render always after ready to render once with resources unready\n"
2336 "PRE: Everything ready to render\n"
2337 "POST: Finished signal sent once");
2339 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2340 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2341 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2342 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2343 drawTrace.Enable(true);
2345 Actor rootActor = Actor::New();
2346 Stage::GetCurrent().Add( rootActor );
2348 CameraActor offscreenCameraActor = CameraActor::New();
2349 Stage::GetCurrent().Add( offscreenCameraActor );
2350 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2351 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2352 Integration::ResourceId imageRequestId = imageRequest->GetId();
2353 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2354 Stage::GetCurrent().Add(secondRootActor);
2356 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2357 bool finished = false;
2358 RenderTaskFinished renderTaskFinished( finished );
2359 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2360 application.SendNotification();
2362 // START PROCESS/RENDER Input, Expected Input, Expected
2363 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2364 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2366 // CHANGE TO RENDER ONCE
2367 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2368 application.SendNotification(); // Input, Expected Input, Expected
2369 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2370 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2372 // FINISH RESOURCE LOADING
2373 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2374 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2375 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2376 DALI_TEST_CHECK( lastSyncObj != NULL );
2377 application.GetPlatform().ClearReadyResources();
2379 sync.SetObjectSynced( lastSyncObj, true );
2381 // Expect: No draw - we've just drawn our render task once, above. No finished signal -
2382 // we won't read the gl sync until the next frame. Continue rendering - we're waiting for
2384 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2386 // Expect: 1 final draw - this Update doesn't update the scene, hence render instructions
2387 // from last frame but 1 are still present.
2388 // Finished signal should be true - we've just done the sync.
2389 // Should now stop rendering and updating - nothing left to do.
2390 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, true, false, __LINE__ ) );
2396 //int UtcDaliRenderTaskOnce06(void)
2398 TestApplication application;
2400 tet_infoline("Testing RenderTask Render Once GlSync\n"
2401 "During RenderOnce, make ready resources unready before sending first finished signal\n"
2402 "PRE: Everything ready.\n"
2403 "POST: Finished signal sent only once");
2405 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2406 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2407 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2408 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2409 drawTrace.Enable(true);
2411 Actor rootActor = Actor::New();
2412 Stage::GetCurrent().Add( rootActor );
2414 CameraActor offscreenCameraActor = CameraActor::New();
2415 Stage::GetCurrent().Add( offscreenCameraActor );
2416 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2417 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2418 Integration::ResourceId imageRequestId = imageRequest->GetId();
2419 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2420 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2421 application.Render();
2423 Stage::GetCurrent().Add(secondRootActor);
2424 application.GetPlatform().ClearReadyResources();
2426 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2427 bool finished = false;
2428 RenderTaskFinished renderTaskFinished( finished );
2429 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2430 application.SendNotification();
2432 // START PROCESS/RENDER Input, Expected Input, Expected
2433 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2434 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2436 // CHANGE TO RENDER ONCE, RESOURCES BECOME NOT READY
2437 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2440 ReloadImage(application, secondRootActor.GetImage());
2441 application.SendNotification(); // Input, Expected Input, Expected
2443 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2444 DALI_TEST_EQUALS( secondRootActor.GetImage().GetLoadingState(), Dali::ResourceLoading, TEST_LOCATION);
2445 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2447 // FINISH RESOURCE LOADING
2448 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2449 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2450 application.GetPlatform().ClearReadyResources();
2451 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2452 DALI_TEST_CHECK( lastSyncObj != NULL );
2454 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2455 sync.SetObjectSynced( lastSyncObj, true );
2456 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2457 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, true, __LINE__ ) );
2459 // Finished rendering - expect no more renders, no more signals:
2460 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2461 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2462 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2463 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2464 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2465 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2470 int UtcDaliRenderTaskOnce07(void)
2472 TestApplication application;
2474 tet_infoline("Testing RenderTask Render Once GLSync\n"
2475 "Render once, Second call to SetRefreshRate(ONCE) triggers only one more finished signal\n"
2476 "PRE: Everything ready\n"
2477 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
2479 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2480 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2481 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2482 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2483 drawTrace.Enable(true);
2485 Actor rootActor = Actor::New();
2486 Stage::GetCurrent().Add( rootActor );
2488 CameraActor offscreenCameraActor = CameraActor::New();
2489 Stage::GetCurrent().Add( offscreenCameraActor );
2490 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2491 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2492 Integration::ResourceId imageRequestId = imageRequest->GetId();
2493 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2494 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2495 application.Render();
2496 application.GetPlatform().ClearReadyResources();
2498 Stage::GetCurrent().Add(secondRootActor);
2500 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2501 bool finished = false;
2502 RenderTaskFinished renderTaskFinished( finished );
2503 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2504 application.SendNotification();
2506 // START PROCESS/RENDER Input, Expected Input, Expected
2507 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2509 // CHANGE TO RENDER ONCE,
2510 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2511 application.SendNotification();
2512 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2513 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2514 DALI_TEST_CHECK( lastSyncObj != NULL );
2516 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2517 sync.SetObjectSynced( lastSyncObj, true );
2518 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2519 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2521 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2522 application.SendNotification();
2523 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2524 lastSyncObj = sync.GetLastSyncObject();
2525 DALI_TEST_CHECK( lastSyncObj != NULL );
2527 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2528 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2529 sync.SetObjectSynced( lastSyncObj, true );
2530 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2531 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2535 int UtcDaliRenderTaskOnce08(void)
2537 TestApplication application;
2539 tet_infoline("Testing RenderTask Render Once GLSync\n"
2540 "Render once, Call to SetRefreshRate(ONCE) in Finished signal callback triggers "
2541 "another render & another finished signal\n"
2542 "PRE: Everything ready\n"
2543 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
2546 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2547 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2548 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2549 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2550 sync.GetTrace().Enable(true);
2551 drawTrace.Enable(true);
2553 Actor rootActor = Actor::New();
2554 Stage::GetCurrent().Add( rootActor );
2556 CameraActor offscreenCameraActor = CameraActor::New();
2557 Stage::GetCurrent().Add( offscreenCameraActor );
2558 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2559 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2560 Integration::ResourceId imageRequestId = imageRequest->GetId();
2561 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2562 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2563 application.Render();
2564 application.GetPlatform().ClearReadyResources();
2566 Stage::GetCurrent().Add(secondRootActor);
2568 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, /*GL-SYNC*/ true);
2569 bool finished = false;
2571 ConnectionTracker connectionTracker;
2572 RenderTaskFinishedRenderAgain renderTaskFinishedRenderAgain( finished );
2573 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinishedRenderAgain );
2575 application.SendNotification();
2577 // START PROCESS/RENDER Input, Expected Input, Expected
2578 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2579 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2580 DALI_TEST_CHECK( lastSyncObj == NULL );
2581 DALI_TEST_EQUALS( sync.GetTrace().CountMethod( "CreateSyncObject" ), 0, TEST_LOCATION );
2584 // CHANGE TO RENDER ONCE,
2585 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2586 application.SendNotification();
2587 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2588 lastSyncObj = sync.GetLastSyncObject();
2589 DALI_TEST_CHECK( lastSyncObj != NULL );
2590 DALI_TEST_EQUALS( sync.GetNumberOfSyncObjects(), 1, TEST_LOCATION );
2591 DALI_TEST_EQUALS( sync.GetTrace().CountMethod( "CreateSyncObject" ), 1, TEST_LOCATION );
2593 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2596 DALI_TEST_EQUALS( sync.GetNumberOfSyncObjects(), 1, TEST_LOCATION );
2597 DALI_TEST_EQUALS( sync.GetTrace().CountMethod( "CreateSyncObject" ), 1, TEST_LOCATION );
2599 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2601 DALI_TEST_EQUALS( sync.GetNumberOfSyncObjects(), 1, TEST_LOCATION );
2602 DALI_TEST_EQUALS( sync.GetTrace().CountMethod( "CreateSyncObject" ), 1, TEST_LOCATION );
2604 sync.SetObjectSynced( lastSyncObj, true );
2605 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2606 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2607 application.SendNotification();
2609 // Expect SetRefreshRate to have been called again
2610 // Prevent next finished signal calling refresh once again
2611 RenderTaskFinished renderTaskFinished( finished );
2612 connectionTracker.DisconnectAll();
2613 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinished );
2614 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2615 lastSyncObj = sync.GetLastSyncObject();
2616 DALI_TEST_CHECK( lastSyncObj != NULL );
2618 sync.SetObjectSynced( lastSyncObj, true );
2619 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2620 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2625 int UtcDaliRenderTaskOnce09(void)
2627 TestApplication application;
2629 tet_infoline("Testing RenderTask Render Once GlSync\n"
2630 "SetRefreshRate(ONCE) again before first finished signal has been sent.\n"
2631 "PRE: resources ready\n"
2632 "POST: Only 1 finished signal sent.");
2634 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2635 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2636 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2637 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2638 drawTrace.Enable(true);
2640 Actor rootActor = Actor::New();
2641 Stage::GetCurrent().Add( rootActor );
2643 CameraActor offscreenCameraActor = CameraActor::New();
2644 Stage::GetCurrent().Add( offscreenCameraActor );
2645 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2646 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2647 Integration::ResourceId imageRequestId = imageRequest->GetId();
2648 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2649 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2650 application.Render();
2651 application.GetPlatform().ClearReadyResources();
2653 Stage::GetCurrent().Add(secondRootActor);
2655 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2656 bool finished = false;
2657 RenderTaskFinished renderTaskFinished( finished );
2658 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2659 application.SendNotification();
2661 // START PROCESS/RENDER Input, Expected Input, Expected
2662 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2664 // CHANGE TO RENDER ONCE,
2665 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2666 application.SendNotification();
2667 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2668 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2669 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2671 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2672 application.SendNotification();
2673 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2674 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2675 DALI_TEST_CHECK( lastSyncObj != NULL );
2677 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2678 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2679 sync.SetObjectSynced( lastSyncObj, true );
2680 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2681 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2686 int UtcDaliRenderTaskOnce10(void)
2688 TestApplication application;
2690 tet_infoline("Testing RenderTask Render Once GlSync\n"
2691 "SetRefreshRate(ONCE), resource load failed completes render task.\n"
2692 "PRE: resources not ready\n"
2693 "POST: Only 1 finished signal sent.");
2695 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2696 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2697 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2698 drawTrace.Enable(true);
2700 Actor rootActor = Actor::New();
2701 Stage::GetCurrent().Add( rootActor );
2703 CameraActor offscreenCameraActor = CameraActor::New();
2704 Stage::GetCurrent().Add( offscreenCameraActor );
2705 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2706 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2707 Integration::ResourceId imageRequestId = imageRequest->GetId();
2708 Stage::GetCurrent().Add(secondRootActor);
2710 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2711 bool finished = false;
2712 RenderTaskFinished renderTaskFinished( finished );
2713 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2714 application.SendNotification();
2716 // START PROCESS/RENDER Input, Expected Input, Expected
2717 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2718 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2720 // CHANGE TO RENDER ONCE,
2721 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2722 application.SendNotification();
2723 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2724 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2725 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2727 tet_printf(" FailImageLoad\n");
2729 FailImageLoad(application, imageRequestId); // Need to run Update again for this to complete
2731 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); // nothing to draw
2732 application.SendNotification();
2734 // load is now failed so there's nothing more to render in the render task
2735 // Expect finished signal, as all resources are complete
2736 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2741 int UtcDaliRenderTaskOnceNoSync01(void)
2743 TestApplication application;
2745 tet_infoline("Testing RenderTask Render Once, using loading image\nPRE: Resources not ready, Source not visible\nPOST: Finished signal sent once only");
2747 // SETUP AN OFFSCREEN RENDER TASK
2748 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2749 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2750 drawTrace.Enable(true);
2752 Actor rootActor = Actor::New();
2753 Stage::GetCurrent().Add( rootActor );
2755 CameraActor offscreenCameraActor = CameraActor::New();
2756 Stage::GetCurrent().Add( offscreenCameraActor );
2757 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2758 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2759 Integration::ResourceId imageRequestId = imageRequest->GetId();
2760 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2762 Stage::GetCurrent().Add(secondRootActor);
2764 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2765 bool finished = false;
2766 RenderTaskFinished renderTaskFinished( finished );
2767 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2768 application.SendNotification();
2770 // START PROCESS/RENDER Input, Expected Input, Expected
2771 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2772 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2774 // FINISH RESOURCE LOADING - expect immediate rendering yet
2775 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2776 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2777 application.GetPlatform().ClearReadyResources();
2778 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2782 int UtcDaliRenderTaskOnceNoSync02(void)
2784 TestApplication application;
2786 tet_infoline("Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loading image.\n"
2787 "PRE: Resources not ready\nPOST: Finished signal sent once only");
2788 // SETUP AN OFFSCREEN RENDER TASK
2789 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2790 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2791 drawTrace.Enable(true);
2793 Actor rootActor = Actor::New();
2794 Stage::GetCurrent().Add( rootActor );
2796 CameraActor offscreenCameraActor = CameraActor::New();
2797 Stage::GetCurrent().Add( offscreenCameraActor );
2799 Shader shader = CreateShader();
2800 Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2801 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2802 Integration::ResourceId imageRequestId = imageRequest->GetId();
2803 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2804 TextureSet textureSet = CreateTextureSet( image );
2806 Geometry geometry = CreateQuadGeometry();
2807 Renderer renderer = Renderer::New(geometry, shader);
2808 renderer.SetTextures( textureSet );
2809 Actor secondRootActor = Actor::New();
2810 secondRootActor.AddRenderer(renderer);
2811 secondRootActor.SetSize(100, 100);
2812 Stage::GetCurrent().Add(secondRootActor);
2814 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2815 bool finished = false;
2816 RenderTaskFinished renderTaskFinished( finished );
2817 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2818 application.SendNotification();
2820 // START PROCESS/RENDER Input, Expected Input, Expected
2821 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2822 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2824 // FINISH RESOURCE LOADING - expect immediate rendering yet
2825 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2826 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2827 application.GetPlatform().ClearReadyResources();
2828 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2833 int UtcDaliRenderTaskOnceNoSync03(void)
2835 TestApplication application;
2837 tet_infoline("Testing RenderTask Render Once, using loading image. Switch from render always after ready to render once\n"
2838 "PRE: Render task ready, Image not loaded\n"
2839 "POST: Finished signal sent only once");
2841 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2842 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2843 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2844 drawTrace.Enable(true);
2846 Actor rootActor = Actor::New();
2847 Stage::GetCurrent().Add( rootActor );
2849 CameraActor offscreenCameraActor = CameraActor::New();
2850 Stage::GetCurrent().Add( offscreenCameraActor );
2851 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2852 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2853 Integration::ResourceId imageRequestId = imageRequest->GetId();
2854 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2855 Stage::GetCurrent().Add(secondRootActor);
2857 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2858 bool finished = false;
2859 RenderTaskFinished renderTaskFinished( finished );
2860 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2861 application.SendNotification();
2863 // START PROCESS/RENDER Input, Expected Input, Expected
2864 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2865 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2867 // FINISH RESOURCE LOADING
2868 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2869 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2870 application.GetPlatform().ClearReadyResources();
2872 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2873 application.SendNotification(); // Input, Expected Input, Expected
2874 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2875 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2879 int UtcDaliRenderTaskOnceNoSync04(void)
2881 TestApplication application;
2883 tet_infoline("Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loading image.\n"
2884 "Switch from render always after ready to render once\n"
2885 "PRE: Render task ready, Image not loaded\n"
2886 "POST: Finished signal sent only once");
2888 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2889 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2890 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2891 drawTrace.Enable(true);
2893 Actor rootActor = Actor::New();
2894 Stage::GetCurrent().Add( rootActor );
2896 CameraActor offscreenCameraActor = CameraActor::New();
2897 Stage::GetCurrent().Add( offscreenCameraActor );
2899 Shader shader = CreateShader();
2900 Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2901 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2902 Integration::ResourceId imageRequestId = imageRequest->GetId();
2903 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2904 TextureSet textureSet = CreateTextureSet( image );
2906 Geometry geometry = CreateQuadGeometry();
2907 Renderer renderer = Renderer::New(geometry, shader);
2908 renderer.SetTextures( textureSet );
2909 Actor secondRootActor = Actor::New();
2910 secondRootActor.AddRenderer(renderer);
2911 secondRootActor.SetSize(100, 100);
2912 Stage::GetCurrent().Add(secondRootActor);
2915 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2916 bool finished = false;
2917 RenderTaskFinished renderTaskFinished( finished );
2918 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2919 application.SendNotification();
2921 // START PROCESS/RENDER Input, Expected Input, Expected
2922 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2923 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2925 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2926 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2927 DALI_TEST_CHECK( lastSyncObj == NULL );
2929 // FINISH RESOURCE LOADING
2930 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2931 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2932 application.GetPlatform().ClearReadyResources();
2934 lastSyncObj = sync.GetLastSyncObject();
2935 DALI_TEST_CHECK( lastSyncObj == NULL );
2937 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2938 application.SendNotification(); // Input, Expected Input, Expected
2939 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2940 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2942 lastSyncObj = sync.GetLastSyncObject();
2943 DALI_TEST_CHECK( lastSyncObj == NULL );
2948 int UtcDaliRenderTaskOnceNoSync05(void)
2950 TestApplication application;
2952 tet_infoline("Testing RenderTask Render Once\n"
2953 "Switch from Render always after ready to render once with resources unready\n"
2954 "PRE: Everything ready to render\n"
2955 "POST: Finished signal sent once");
2957 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2958 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2959 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2960 drawTrace.Enable(true);
2962 Actor rootActor = Actor::New();
2963 Stage::GetCurrent().Add( rootActor );
2965 CameraActor offscreenCameraActor = CameraActor::New();
2966 Stage::GetCurrent().Add( offscreenCameraActor );
2967 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2968 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2969 Integration::ResourceId imageRequestId = imageRequest->GetId();
2970 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2971 Stage::GetCurrent().Add(secondRootActor);
2973 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2974 bool finished = false;
2975 RenderTaskFinished renderTaskFinished( finished );
2976 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2977 application.SendNotification();
2979 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2980 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2981 DALI_TEST_CHECK( lastSyncObj == NULL );
2983 // START PROCESS/RENDER Input, Expected Input, Expected
2984 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2985 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2987 // CHANGE TO RENDER ONCE
2988 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2989 application.SendNotification(); // Input, Expected Input, Expected
2990 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2991 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2993 // FINISH RESOURCE LOADING
2994 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2995 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2996 application.GetPlatform().ClearReadyResources();
2997 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3002 //int UtcDaliRenderTaskOnceNoSync06(void)
3004 TestApplication application;
3006 tet_infoline("Testing RenderTask Render Once\n"
3007 "During RenderOnce, make ready resources unready before sending first finished signal\n"
3008 "PRE: Everything ready.\n"
3009 "POST: Finished signal sent only once");
3011 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3012 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3013 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3014 drawTrace.Enable(true);
3016 Actor rootActor = Actor::New();
3017 Stage::GetCurrent().Add( rootActor );
3019 CameraActor offscreenCameraActor = CameraActor::New();
3020 Stage::GetCurrent().Add( offscreenCameraActor );
3021 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3022 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3023 Integration::ResourceId imageRequestId = imageRequest->GetId();
3024 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
3025 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
3026 application.Render();
3027 application.GetPlatform().ClearReadyResources();
3029 Stage::GetCurrent().Add(secondRootActor);
3031 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3032 bool finished = false;
3033 RenderTaskFinished renderTaskFinished( finished );
3034 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3035 application.SendNotification();
3037 // START PROCESS/RENDER Input, Expected Input, Expected
3038 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3039 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
3041 // CHANGE TO RENDER ONCE, RESOURCES BECOME NOT READY
3042 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3045 ReloadImage(application, secondRootActor.GetImage());
3046 application.SendNotification(); // Input, Expected Input, Expected
3048 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3049 DALI_TEST_EQUALS( secondRootActor.GetImage().GetLoadingState(), Dali::ResourceLoading, TEST_LOCATION);
3050 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3052 // FINISH RESOURCE LOADING
3053 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
3054 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, true, true, __LINE__ ) );
3055 application.GetPlatform().ClearReadyResources();
3056 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3057 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3058 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3059 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3064 int UtcDaliRenderTaskOnceNoSync07(void)
3066 TestApplication application;
3068 tet_infoline("Testing RenderTask Render Once\n"
3069 "Render once, Second call to SetRefreshRate(ONCE) triggers only one more finished signal\n"
3070 "PRE: Everything ready\n"
3071 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
3073 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3074 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3075 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3076 drawTrace.Enable(true);
3078 Actor rootActor = Actor::New();
3079 Stage::GetCurrent().Add( rootActor );
3081 CameraActor offscreenCameraActor = CameraActor::New();
3082 Stage::GetCurrent().Add( offscreenCameraActor );
3083 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3084 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3085 Integration::ResourceId imageRequestId = imageRequest->GetId();
3086 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
3087 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
3088 application.Render();
3089 application.GetPlatform().ClearReadyResources();
3091 Stage::GetCurrent().Add(secondRootActor);
3093 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3094 bool finished = false;
3095 RenderTaskFinished renderTaskFinished( finished );
3096 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3097 application.SendNotification();
3099 // START PROCESS/RENDER Input, Expected Input, Expected
3100 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
3102 // CHANGE TO RENDER ONCE,
3103 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3104 application.SendNotification();
3105 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3106 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3108 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3109 application.SendNotification();
3110 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3111 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3115 int UtcDaliRenderTaskOnceNoSync08(void)
3117 TestApplication application;
3119 tet_infoline("Testing RenderTask Render Once\n"
3120 "Render once, Call to SetRefreshRate(ONCE) in Finished signal callback triggers\n"
3121 "another render & another finished signal\n"
3122 "PRE: Everything ready\n"
3123 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
3126 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3127 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3128 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3129 drawTrace.Enable(true);
3131 Actor rootActor = Actor::New();
3132 Stage::GetCurrent().Add( rootActor );
3134 CameraActor offscreenCameraActor = CameraActor::New();
3135 Stage::GetCurrent().Add( offscreenCameraActor );
3136 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3137 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3138 Integration::ResourceId imageRequestId = imageRequest->GetId();
3139 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
3140 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
3141 application.Render();
3142 application.GetPlatform().ClearReadyResources();
3144 Stage::GetCurrent().Add(secondRootActor);
3146 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3147 bool finished = false;
3149 ConnectionTracker connectionTracker;
3150 RenderTaskFinishedRenderAgain renderTaskFinishedRenderAgain( finished );
3151 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinishedRenderAgain );
3153 application.SendNotification();
3155 // START PROCESS/RENDER Input, Expected Input, Expected
3156 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
3158 // CHANGE TO RENDER ONCE,
3159 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3160 application.SendNotification();
3161 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3162 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3164 // Expect SetRefreshRate to have been called again
3165 // Prevent next finished signal calling refresh once again
3166 RenderTaskFinished renderTaskFinished( finished );
3167 connectionTracker.DisconnectAll();
3168 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinished );
3170 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3171 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3176 int UtcDaliRenderTaskOnceNoSync09(void)
3178 TestApplication application;
3180 tet_infoline("Testing RenderTask Render Once\n"
3181 "SetRefreshRate(ONCE) again before first finished signal has been sent.\n"
3182 "PRE: resources ready\n"
3183 "POST: Only 1 finished signal sent.");
3185 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3186 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3187 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3188 drawTrace.Enable(true);
3190 Actor rootActor = Actor::New();
3191 Stage::GetCurrent().Add( rootActor );
3193 CameraActor offscreenCameraActor = CameraActor::New();
3194 Stage::GetCurrent().Add( offscreenCameraActor );
3195 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3196 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3197 Integration::ResourceId imageRequestId = imageRequest->GetId();
3198 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
3199 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
3200 application.Render();
3201 application.GetPlatform().ClearReadyResources();
3203 Stage::GetCurrent().Add(secondRootActor);
3205 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3206 bool finished = false;
3207 RenderTaskFinished renderTaskFinished( finished );
3208 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3209 application.SendNotification();
3211 // START PROCESS/RENDER Input, Expected Input, Expected
3212 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
3214 // CHANGE TO RENDER ONCE,
3215 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3216 application.SendNotification();
3217 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3218 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3220 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3221 application.SendNotification();
3222 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3223 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3227 int UtcDaliRenderTaskOnceNoSync10(void)
3229 TestApplication application;
3231 tet_infoline("Testing RenderTask Render Once\n"
3232 "SetRefreshRate(ONCE), resource load failed, completes render task.\n"
3233 "PRE: resources not ready\n"
3234 "POST: Only 1 finished signal sent.");
3236 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3237 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3238 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3239 drawTrace.Enable(true);
3241 Actor rootActor = Actor::New();
3242 Stage::GetCurrent().Add( rootActor );
3244 CameraActor offscreenCameraActor = CameraActor::New();
3245 Stage::GetCurrent().Add( offscreenCameraActor );
3246 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3247 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3248 Integration::ResourceId imageRequestId = imageRequest->GetId();
3249 Stage::GetCurrent().Add(secondRootActor);
3251 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3252 bool finished = false;
3253 RenderTaskFinished renderTaskFinished( finished );
3254 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3255 application.SendNotification();
3257 // START PROCESS/RENDER Input, Expected Input, Expected
3258 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3259 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3261 // CHANGE TO RENDER ONCE,
3262 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3263 application.SendNotification();
3264 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3265 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3266 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3268 FailImageLoad(application, imageRequestId); // Need to run Update again for this to complete
3269 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); // nothing to draw
3270 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3277 int UtcDaliRenderTaskOnceChain01(void)
3279 TestApplication application;
3281 tet_infoline("Testing RenderTask Render Once Chained render tasks\n"
3282 "SetRefreshRate(ONCE), resource load completes, both render tasks render.\n"
3283 "PRE: resources not ready\n"
3284 "POST: 2 finished signals sent.");
3286 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3287 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3288 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3289 drawTrace.Enable(true);
3291 Actor defaultRootActor = Actor::New(); // Root for default RT
3292 Stage::GetCurrent().Add( defaultRootActor );
3294 CameraActor offscreenCameraActor = CameraActor::New();
3295 Stage::GetCurrent().Add( offscreenCameraActor );
3296 Actor firstRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3297 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3298 Integration::ResourceId imageRequestId = imageRequest->GetId();
3299 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
3300 Stage::GetCurrent().Add(firstRootActor);
3302 // first render task
3303 RenderTask firstTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, firstRootActor, RenderTask::REFRESH_ONCE, false);
3304 bool firstFinished = false;
3305 RenderTaskFinished renderTask1Finished( firstFinished );
3306 firstTask.FinishedSignal().Connect( &application, renderTask1Finished );
3308 // Second render task
3309 FrameBufferImage fbo = firstTask.GetTargetFrameBuffer();
3310 Actor secondRootActor = CreateRenderableActor( fbo );
3311 Stage::GetCurrent().Add(secondRootActor);
3312 RenderTask secondTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
3313 bool secondFinished = false;
3314 RenderTaskFinished renderTask2Finished( secondFinished );
3315 secondTask.FinishedSignal().Connect( &application, renderTask2Finished );
3317 application.SendNotification();
3319 // START PROCESS/RENDER Input, Expected Input, Expected
3320 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__ ) );
3321 DALI_TEST_CHECK( firstFinished == false );
3322 DALI_TEST_CHECK( secondFinished == false );
3323 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__ ) );
3324 DALI_TEST_CHECK( firstFinished == false );
3325 DALI_TEST_CHECK( secondFinished == false );
3327 CompleteImageLoad(application, imageRequestId, imageType);
3328 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__ ) );
3329 DALI_TEST_CHECK( firstFinished == false );
3330 DALI_TEST_CHECK( secondFinished == false );
3332 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, true, true, __LINE__ ) );
3333 DALI_TEST_CHECK( firstFinished == true );
3334 DALI_TEST_CHECK( secondFinished == false );
3336 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, secondFinished, true, false, __LINE__ ) );
3337 DALI_TEST_CHECK( secondFinished == true );
3342 int UtcDaliRenderTaskProperties(void)
3344 TestApplication application;
3346 RenderTask task = Stage::GetCurrent().GetRenderTaskList().CreateTask();
3348 Property::IndexContainer indices;
3349 task.GetPropertyIndices( indices );
3350 DALI_TEST_CHECK( indices.Size() );
3351 DALI_TEST_EQUALS( indices.Size(), task.GetPropertyCount(), TEST_LOCATION );
3355 int UtcDaliRenderTaskSetScreenToFrameBufferMappingActor(void)
3357 TestApplication application;
3358 tet_infoline("Testing RenderTask::SetScreenToFrameBufferMappingActor ");
3360 Stage stage = Stage::GetCurrent();
3361 Size stageSize = stage.GetSize();
3362 Actor mappingActor = Actor::New();
3363 Vector2 scale( 0.6f, 0.75f);
3364 Vector2 offset( stageSize.x*0.1f, stageSize.y*0.15f);
3365 mappingActor.SetSize( stageSize * scale );
3366 mappingActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
3367 mappingActor.SetPosition( offset.x, offset.y );
3368 stage.Add( mappingActor );
3370 Actor offscreenActor = Actor::New();
3371 offscreenActor.SetSize( stageSize );
3372 offscreenActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
3373 stage.Add( offscreenActor );
3375 RenderTaskList taskList = stage.GetRenderTaskList();
3376 RenderTask renderTask = taskList.CreateTask();
3377 FrameBufferImage frameBufferImage = FrameBufferImage::New(stageSize.width*scale.x, stageSize.height*scale.y, Pixel::A8, Image::NEVER);
3378 renderTask.SetSourceActor( offscreenActor );
3379 renderTask.SetExclusive( true );
3380 renderTask.SetInputEnabled( true );
3381 renderTask.SetTargetFrameBuffer( frameBufferImage );
3382 renderTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
3383 renderTask.SetScreenToFrameBufferMappingActor( mappingActor );
3384 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3386 // Render and notify
3387 application.SendNotification();
3388 application.Render();
3389 application.Render();
3390 application.SendNotification();
3392 Vector2 screenCoordinates( stageSize.x * 0.05f, stageSize.y * 0.05f );
3393 Dali::HitTestAlgorithm::Results results;
3394 DALI_TEST_CHECK( !results.actor );
3395 DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
3396 // miss expected, results not changed
3397 DALI_TEST_CHECK( false == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3398 DALI_TEST_CHECK( !results.actor );
3399 DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
3401 screenCoordinates.x = stageSize.x * 0.265f;
3402 screenCoordinates.y = stageSize.y * 0.33f;
3403 results.actor = Actor();
3404 results.actorCoordinates = Vector2::ZERO;
3405 // hit expected, results changed
3406 DALI_TEST_CHECK( true == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3407 DALI_TEST_CHECK( results.actor == offscreenActor );
3408 DALI_TEST_EQUALS( (screenCoordinates-offset)/scale , results.actorCoordinates, 0.1f, TEST_LOCATION );
3410 screenCoordinates.x = stageSize.x * 0.435f;
3411 screenCoordinates.y = stageSize.y * 0.52f;
3412 // hit expected, results changed
3413 DALI_TEST_CHECK( true == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3414 DALI_TEST_CHECK( results.actor == offscreenActor );
3415 const Vector2 expectedCoordinates = (screenCoordinates-offset)/scale;
3416 DALI_TEST_EQUALS( expectedCoordinates , results.actorCoordinates, 0.1f, TEST_LOCATION );
3418 screenCoordinates.x = stageSize.x * 0.65f;
3419 screenCoordinates.y = stageSize.y * 0.95f;
3420 // miss expected, results not changed
3421 DALI_TEST_CHECK( false == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3422 DALI_TEST_CHECK( results.actor == offscreenActor );
3423 DALI_TEST_EQUALS( expectedCoordinates , results.actorCoordinates, 0.1f, TEST_LOCATION );
3427 int UtcDaliRenderTaskFinishInvisibleSourceActor(void)
3429 TestApplication application;
3431 tet_infoline("Testing RenderTask::FinishInvisibleSourceActor()");
3433 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3434 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
3436 CameraActor offscreenCameraActor = CameraActor::New();
3438 Stage::GetCurrent().Add( offscreenCameraActor );
3440 BufferImage image = BufferImage::New( 10, 10 );
3441 Actor rootActor = CreateRenderableActor( image );
3442 rootActor.SetSize( 10, 10 );
3443 rootActor.SetVisible(false);
3444 Stage::GetCurrent().Add( rootActor );
3446 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3447 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
3448 FrameBufferImage frameBufferImage = FrameBufferImage::New( *testNativeImagePtr.Get() );
3450 // Flush all outstanding messages
3451 application.SendNotification();
3452 application.Render();
3454 RenderTask newTask = taskList.CreateTask();
3455 newTask.SetCameraActor( offscreenCameraActor );
3456 newTask.SetSourceActor( rootActor );
3457 newTask.SetInputEnabled( false );
3458 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
3459 newTask.SetClearEnabled( true );
3460 newTask.SetExclusive( true );
3461 newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
3462 newTask.SetTargetFrameBuffer( frameBufferImage );
3463 newTask.SetProperty( RenderTask::Property::REQUIRES_SYNC, true );
3465 // Framebuffer doesn't actually get created until Connected, i.e. by previous line
3467 bool finished = false;
3468 RenderTaskFinished renderTaskFinished( finished );
3469 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3471 // Flush the queue and render.
3472 application.SendNotification();
3474 // 1 render to process render task, then wait for sync before finished msg is sent
3475 // from update to the event thread.
3477 application.Render();
3478 application.SendNotification();
3479 DALI_TEST_CHECK( !finished );
3481 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
3482 DALI_TEST_CHECK( lastSyncObj != NULL );
3484 application.Render();
3485 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
3486 application.SendNotification();
3487 DALI_TEST_CHECK( !finished );
3489 application.Render();
3490 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
3491 application.SendNotification();
3492 DALI_TEST_CHECK( ! finished );
3494 sync.SetObjectSynced( lastSyncObj, true );
3496 application.Render();
3497 application.SendNotification();
3498 DALI_TEST_CHECK( !finished );
3500 application.Render();
3501 application.SendNotification();
3502 DALI_TEST_CHECK( finished );
3505 application.Render(); // Double check no more finished signal
3506 application.SendNotification();
3507 DALI_TEST_CHECK( ! finished );
3512 int UtcDaliRenderTaskFinishMissingImage(void)
3514 TestApplication application;
3516 // Previously we had bugs where not having a resource ID would cause render-tasks to wait forever
3517 tet_infoline("Testing RenderTask::SignalFinished() when an Actor has no Image set");
3519 Stage stage = Stage::GetCurrent();
3521 BufferImage image = BufferImage::New( 10, 10 );
3522 Actor rootActor = CreateRenderableActor( image );
3523 rootActor.SetSize( 10, 10 );
3524 stage.Add( rootActor );
3526 Actor actorWithMissingImage = CreateRenderableActor( Image() );
3527 actorWithMissingImage.SetSize( 10, 10 );
3528 stage.Add( actorWithMissingImage );
3530 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3531 RenderTask newTask = taskList.CreateTask();
3532 newTask.SetInputEnabled( false );
3533 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
3534 newTask.SetClearEnabled( true );
3535 newTask.SetExclusive( true );
3536 newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
3538 bool finished = false;
3539 RenderTaskFinished renderTaskFinished( finished );
3540 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3542 // 1 render to process render task, then 1 before finished msg is sent from update to the event thread.
3543 application.SendNotification();
3544 application.Render();
3545 application.Render();
3547 application.SendNotification();
3548 DALI_TEST_CHECK( finished );
3553 int UtcDaliRenderTaskWorldToViewport(void)
3555 TestApplication application( static_cast<size_t>(400), static_cast<size_t>(400) ); // square surface
3557 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3559 Actor actor = Actor::New();
3560 actor.SetSize(100.0f, 100.0f);
3561 actor.SetPosition( Vector3(0.0, 0.0, 0.0) );
3563 actor.SetParentOrigin( Vector3(0.5, 0.5, 0.5) );
3564 actor.SetAnchorPoint( Vector3(0.5, 0.5, 0.5) );
3566 Stage::GetCurrent().Add(actor);
3568 application.SendNotification();
3569 application.Render();
3570 application.SendNotification();
3572 RenderTask task = taskList.GetTask( 0u );
3574 CameraActor camera = task.GetCameraActor();
3576 Vector2 screenSize = task.GetCurrentViewportSize();
3578 float screenX = 0.0;
3579 float screenY = 0.0;
3581 bool ok = task.WorldToViewport(actor.GetCurrentWorldPosition(), screenX, screenY);
3582 DALI_TEST_CHECK(ok == true);
3584 DALI_TEST_EQUALS(screenX, screenSize.x/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
3585 DALI_TEST_EQUALS(screenY, screenSize.y/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
3587 Actor actor2 = Actor::New();
3588 float actor2Size = 100.f;
3589 actor2.SetSize( actor2Size, actor2Size );
3590 actor2.SetPosition( Vector3(0.0, 0.0, 0.0) );
3591 actor2.SetParentOrigin( Vector3(0.5, 0.5, 0.0) );
3592 actor2.SetAnchorPoint( Vector3(0.5, 0.5, 0.0) );
3593 Stage::GetCurrent().Add( actor2 );
3595 actor.SetParentOrigin( Vector3(0,0,0) );
3597 application.SendNotification();
3598 application.Render();
3599 application.SendNotification();
3601 ok = task.WorldToViewport(actor.GetCurrentWorldPosition(), screenX, screenY);
3602 DALI_TEST_CHECK(ok == true);
3604 DALI_TEST_EQUALS(screenX, screenSize.x/2 - actor2Size/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
3605 DALI_TEST_EQUALS(screenY, screenSize.y/2 - actor2Size/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
3611 int UtcDaliRenderTaskViewportToLocal(void)
3613 TestApplication application;
3614 Actor actor = Actor::New();
3615 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
3616 actor.SetSize(100.0f, 100.0f);
3617 actor.SetPosition(10.0f, 10.0f);
3618 Stage::GetCurrent().Add(actor);
3620 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3621 RenderTask task = taskList.GetTask( 0u );
3623 // flush the queue and render once
3624 application.SendNotification();
3625 application.Render();
3626 application.SendNotification();
3627 application.Render();
3635 float screenX = 50.0f;
3636 float screenY = 50.0f;
3638 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, screenX, screenY) );
3640 DALI_TEST_CHECK( task.ViewportToLocal(actor, screenX, screenY, rtLocalX, rtLocalY ) );
3642 DALI_TEST_EQUALS(localX, rtLocalX, 0.01f, TEST_LOCATION);
3643 DALI_TEST_EQUALS(localY, rtLocalY, 0.01f, TEST_LOCATION);