2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali/public-api/dali-core.h>
22 #include <dali/devel-api/events/hit-test-algorithm.h>
23 #include <dali/devel-api/rendering/frame-buffer.h>
24 #include <dali-test-suite-utils.h>
25 #include <dali/integration-api/debug.h>
26 #include <test-native-image.h>
28 #include <mesh-builder.h>
30 #define BOOLSTR(x) ((x)?"T":"F")
32 //& set: DaliRenderTask
36 void utc_dali_render_task_startup(void)
38 test_return_value = TET_UNDEF;
41 void utc_dali_render_task_cleanup(void)
43 test_return_value = TET_PASS;
49 * Constructor, Destructor, DownCast, New, copy constructor, assignment operator
51 * SetSourceActor 2+ve, 1-ve
52 * GetSourceActor 1+ve, 1-ve
53 * SetExclusive 2+ve, 0-ve
54 * IsExclusive 2+ve, 0-ve
55 * SetInputEnabled 1+ve, 0-ve
56 * GetInputEnabled 1+ve, 0-ve
57 * SetCameraActor 1+ve, 1-ve
58 * GetCameraActor 1+ve, 1-ve
59 * SetTargetFrameBuffer 1+ve, 1-ve
60 * GetTargetFrameBuffer 1+ve, 1-ve
61 * SetScreenToFrameBufferFunction 1+ve, 1-ve
62 * GetScreenToFrameBufferFunction 1+ve, 1-ve
63 * SetScreenToFrameBufferMappingActor 1+ve, 1-ve
64 * GetScreenToFrameBufferMappingActor 1+ve, 1-ve
65 * SetViewportPosition 1+ve
66 * GetCurrentViewportPosition 1+ve
67 * SetViewportSize 1+ve
68 * GetCurrentViewportSize 1+ve
69 * SetViewport 2+ve, 1-ve
70 * GetViewport 2+ve, 1-ve
71 * SetClearColor 1+ve, 1-ve
72 * GetClearColor 1+ve, 1-ve
73 * SetClearEnabled 1+ve, 1-ve
74 * GetClearEnabled 1+ve, 1-ve
82 namespace // unnamed namespace
85 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
88 * Simulate time passed by.
90 * @note this will always process at least 1 frame (1/60 sec)
92 * @param application Test application instance
93 * @param duration Time to pass in milliseconds.
94 * @return The actual time passed in milliseconds
96 int Wait(TestApplication& application, int duration = 0)
100 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
102 application.SendNotification();
103 application.Render(RENDER_FRAME_INTERVAL);
104 time += RENDER_FRAME_INTERVAL;
110 struct RenderTaskFinished
112 RenderTaskFinished( bool& finished )
113 : finished( finished )
117 void operator()( RenderTask& renderTask )
125 struct RenderTaskFinishedRemoveSource
127 RenderTaskFinishedRemoveSource( bool& finished )
128 : finished( finished ),
133 void operator()( RenderTask& renderTask )
135 DALI_TEST_CHECK(finishedOnce == false);
138 Actor srcActor = renderTask.GetSourceActor();
139 UnparentAndReset(srcActor);
146 struct RenderTaskFinishedRenderAgain
148 RenderTaskFinishedRenderAgain( bool& finished )
149 : finished( finished ),
154 void operator()( RenderTask& renderTask )
156 DALI_TEST_CHECK(finishedOnce == false);
159 renderTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
167 bool TestScreenToFrameBufferFunction( Vector2& coordinates )
169 coordinates = coordinates + Vector2( 1, 2 );
174 Actor CreateLoadingActor(TestApplication& application, std::string filename, ResourceImage::LoadPolicy loadPolicy, Image::ReleasePolicy releasePolicy)
176 Image image = ResourceImage::New(filename, loadPolicy, releasePolicy);
177 DALI_TEST_CHECK( image );
178 application.SendNotification();
179 application.Render(16);
180 DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
181 Actor actor = CreateRenderableActor(image);
182 actor.SetSize( 80, 80 );
183 application.SendNotification();
184 application.Render(16);
188 Image CreateLoadingImage(TestApplication& application, std::string filename, ResourceImage::LoadPolicy loadPolicy, Image::ReleasePolicy releasePolicy)
190 Image image = ResourceImage::New(filename, loadPolicy, releasePolicy);
191 DALI_TEST_CHECK( image );
192 application.SendNotification();
193 application.Render(16);
194 DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
199 void CompleteImageLoad(TestApplication& application, Integration::ResourceId resourceId, Integration::ResourceTypeId requestType)
201 std::vector<GLuint> ids;
203 application.GetGlAbstraction().SetNextTextureIds( ids );
205 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
206 Integration::ResourcePointer resource(bitmap);
207 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80);
209 application.GetPlatform().SetResourceLoaded(resourceId, requestType, resource);
212 void FailImageLoad(TestApplication& application, Integration::ResourceId resourceId )
214 application.GetPlatform().SetResourceLoadFailed(resourceId, Integration::FailureUnknown);
217 void ReloadImage(TestApplication& application, ResourceImage image)
219 application.GetPlatform().ClearReadyResources();
220 application.GetPlatform().DiscardRequest();
221 application.GetPlatform().ResetTrace();
222 application.GetPlatform().SetClosestImageSize(Vector2(80.0f, 80.0f)); // Ensure reload is called.
226 RenderTask CreateRenderTask(TestApplication& application,
227 CameraActor offscreenCamera,
228 Actor rootActor, // Reset default render task to point at this actor
229 Actor secondRootActor, // Source actor
230 unsigned int refreshRate,
233 // Change main render task to use a different root
234 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
235 taskList.GetTask(0u).SetSourceActor( rootActor );
237 FrameBufferImage frameBufferImage;
240 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
241 frameBufferImage= FrameBufferImage::New( *(testNativeImagePtr.Get()) );
245 frameBufferImage = FrameBufferImage::New( 10, 10 );
248 // Don't draw output framebuffer // '
250 RenderTask newTask = taskList.CreateTask();
251 newTask.SetCameraActor( offscreenCamera );
252 newTask.SetSourceActor( secondRootActor );
253 newTask.SetInputEnabled( false );
254 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
255 newTask.SetClearEnabled( true );
256 newTask.SetExclusive( true );
257 newTask.SetRefreshRate( refreshRate );
258 newTask.SetTargetFrameBuffer( frameBufferImage );
259 newTask.SetProperty( RenderTask::Property::REQUIRES_SYNC, glSync );
263 bool UpdateRender(TestApplication& application, TraceCallStack& callStack, bool testDrawn, bool& finishedSig, bool testFinished, bool testKeepUpdating, int lineNumber )
268 tet_printf("TestApplication::UpdateRender().\n");
270 application.Render(16);
271 application.SendNotification();
273 bool sigPassed = false;
276 sigPassed = finishedSig;
280 sigPassed = ! finishedSig;
283 bool drawResult = callStack.FindMethod("DrawElements") || callStack.FindMethod("DrawArrays");
285 bool drawPassed = false;
288 drawPassed = drawResult;
292 drawPassed = !drawResult;
295 bool keepUpdating = (application.GetUpdateStatus() != 0);
296 bool keepUpdatingPassed = false;
297 if( testKeepUpdating )
299 keepUpdatingPassed = keepUpdating;
303 keepUpdatingPassed = !keepUpdating;
306 bool result = (sigPassed && drawPassed && keepUpdatingPassed);
308 tet_printf("UpdateRender: Expected: Draw:%s Signal:%s KeepUpdating: %s Actual: Draw:%s Signal:%s KeepUpdating: %s %s, line %d\n",
309 BOOLSTR(testDrawn), BOOLSTR(testFinished), BOOLSTR(testKeepUpdating),
310 BOOLSTR(drawResult), BOOLSTR(finishedSig), BOOLSTR(keepUpdating),
311 result ? "Passed":"Failed",
317 // The functor to be used in the hit-test algorithm to check whether the actor is hittable.
318 bool IsActorHittableFunction(Actor actor, Dali::HitTestAlgorithm::TraverseType type)
320 bool hittable = false;
324 case Dali::HitTestAlgorithm::CHECK_ACTOR:
326 // Check whether the actor is visible and not fully transparent.
327 if( actor.IsVisible()
328 && actor.GetCurrentWorldColor().a > 0.01f) // not FULLY_TRANSPARENT
335 case Dali::HitTestAlgorithm::DESCEND_ACTOR_TREE:
337 if( actor.IsVisible() ) // Actor is visible, if not visible then none of its children are visible.
352 } // unnamed namespace
355 /****************************************************************************************************/
356 /****************************************************************************************************/
357 /******************************** TEST CASES BELOW **********************************************/
358 /****************************************************************************************************/
359 /****************************************************************************************************/
361 int UtcDaliRenderTaskDownCast01(void)
363 TestApplication application;
365 tet_infoline("Testing RenderTask::DownCast()");
367 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
369 BaseHandle base = taskList.GetTask( 0u );
370 DALI_TEST_CHECK( base );
372 RenderTask task = RenderTask::DownCast( base );
373 DALI_TEST_CHECK( task );
375 // Try calling a method
376 DALI_TEST_CHECK( task.GetSourceActor() );
380 int UtcDaliRenderTaskDownCast02(void)
382 TestApplication application;
384 tet_infoline("Testing RenderTask::DownCast()");
386 Actor actor = Actor::New();
388 RenderTask task = RenderTask::DownCast( actor );
389 DALI_TEST_CHECK( ! task );
394 int UtcDaliRenderTaskSetSourceActorN(void)
396 TestApplication application;
397 tet_infoline("Testing RenderTask::SetSourceActor() Negative - try with empty actor handle");
398 Stage stage = Stage::GetCurrent();
402 RenderTaskList taskList = stage.GetRenderTaskList();
403 RenderTask renderTask = taskList.CreateTask();
404 renderTask.SetSourceActor(srcActor);
406 application.SendNotification();
407 application.Render();
409 DALI_TEST_CHECK( ! renderTask.GetSourceActor() );
414 int UtcDaliRenderTaskSetSourceActorP01(void)
416 TestApplication application;
418 tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that setting a non-renderable actor stops existing source actor being rendered ");
420 Stage stage = Stage::GetCurrent();
422 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
424 RenderTaskList taskList = stage.GetRenderTaskList();
426 RenderTask task = taskList.GetTask( 0u );
428 Actor actor = task.GetSourceActor();
429 DALI_TEST_CHECK( actor );
431 std::vector<GLuint> ids;
433 application.GetGlAbstraction().SetNextTextureIds( ids );
435 BufferImage img = BufferImage::New( 1,1 );
436 Actor newActor = CreateRenderableActor( img );
437 newActor.SetSize(1,1);
438 stage.Add( newActor );
440 Actor nonRenderableActor = Actor::New();
441 stage.Add( nonRenderableActor );
443 // Stop the newActor from being rendered by changing the source actor
444 DALI_TEST_CHECK( nonRenderableActor );
445 task.SetSourceActor( nonRenderableActor );
446 DALI_TEST_CHECK( task.GetSourceActor() != actor );
447 DALI_TEST_CHECK( task.GetSourceActor() == nonRenderableActor );
449 // Update & Render nothing!
450 application.GetGlAbstraction().ClearBoundTextures();
451 application.SendNotification();
452 application.Render();
454 // Check that nothing was rendered
455 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
461 int UtcDaliRenderTaskSetSourceActorP02(void)
463 TestApplication application;
465 tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that switching source from a non-renderable to a renderable actor causes the texture to be drawn");
467 Stage stage = Stage::GetCurrent();
469 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
471 RenderTaskList taskList = stage.GetRenderTaskList();
473 RenderTask task = taskList.GetTask( 0u );
475 Actor actor = task.GetSourceActor();
476 DALI_TEST_CHECK( actor );
478 std::vector<GLuint> ids;
480 application.GetGlAbstraction().SetNextTextureIds( ids );
482 BufferImage img = BufferImage::New( 1,1 );
483 Actor newActor = CreateRenderableActor( img );
484 newActor.SetSize(1,1);
485 stage.Add( newActor );
487 Actor nonRenderableActor = Actor::New();
488 stage.Add( nonRenderableActor );
490 // Stop the newActor from being rendered by changing the source actor
491 DALI_TEST_CHECK( nonRenderableActor );
492 task.SetSourceActor( nonRenderableActor );
493 DALI_TEST_CHECK( task.GetSourceActor() != actor );
494 DALI_TEST_CHECK( task.GetSourceActor() == nonRenderableActor );
496 // Update & Render nothing!
497 application.GetGlAbstraction().ClearBoundTextures();
498 application.SendNotification();
499 application.Render();
501 // Check that nothing was rendered
502 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
504 // Set newActor as the new source Actor
505 task.SetSourceActor( newActor );
506 DALI_TEST_CHECK( task.GetSourceActor() != actor );
507 DALI_TEST_CHECK( task.GetSourceActor() == newActor );
509 // Update & Render the newActor
510 application.GetGlAbstraction().ClearBoundTextures();
511 application.SendNotification();
512 application.Render();
514 // Check that the newActor was rendered
515 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
516 if ( boundTextures.size() )
518 DALI_TEST_EQUALS( boundTextures[0], 7u, TEST_LOCATION );
523 int UtcDaliRenderTaskSetSourceActorOffStage(void)
525 TestApplication application;
527 tet_infoline("Testing RenderTask::SetSourceActor (on/off stage testing)");
529 Stage stage = Stage::GetCurrent();
531 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
533 RenderTaskList taskList = stage.GetRenderTaskList();
535 RenderTask task = taskList.GetTask( 0u );
537 Actor actor = task.GetSourceActor();
538 DALI_TEST_CHECK( actor );
540 std::vector<GLuint> ids;
541 GLuint expectedTextureId( 3 );
542 ids.push_back( expectedTextureId );
543 application.GetGlAbstraction().SetNextTextureIds( ids );
545 BufferImage img = BufferImage::New( 1,1 );
546 Actor newActor = CreateRenderableActor( img );
547 newActor.SetSize(1,1);
548 task.SetSourceActor( newActor );
549 // Don't add newActor to stage yet //'
551 // Update & Render with the actor initially off-stage
552 application.GetGlAbstraction().ClearBoundTextures();
553 application.SendNotification();
554 application.Render();
556 // Check that nothing was rendered
557 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
560 stage.Add( newActor );
562 // Update & Render with the actor on-stage
563 application.GetGlAbstraction().ClearBoundTextures();
564 application.SendNotification();
565 application.Render();
567 // Check that the newActor was rendered
568 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
569 if ( boundTextures.size() )
571 DALI_TEST_EQUALS( boundTextures[0], expectedTextureId, TEST_LOCATION );
574 // Now remove from stage
575 stage.Remove( newActor );
577 // Update & Render with the actor off-stage
578 application.GetGlAbstraction().ClearBoundTextures();
579 application.SendNotification();
580 application.Render();
584 int UtcDaliRenderTaskSetSourceActorEmpty(void)
586 TestApplication application;
588 tet_infoline("Testing RenderTask::SetSourceActor (empty handle case)");
590 Stage stage = Stage::GetCurrent();
592 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
594 RenderTaskList taskList = stage.GetRenderTaskList();
596 RenderTask task = taskList.GetTask( 0u );
598 Actor actor = task.GetSourceActor();
599 DALI_TEST_CHECK( actor );
601 std::vector<GLuint> ids;
602 GLuint expectedTextureId( 5 );
603 ids.push_back( expectedTextureId );
604 application.GetGlAbstraction().SetNextTextureIds( ids );
606 BufferImage img = BufferImage::New( 1,1 );
607 Actor newActor = CreateRenderableActor( img );
608 newActor.SetSize(1,1);
609 stage.Add( newActor );
611 Actor nonRenderableActor = Actor::New();
612 stage.Add( nonRenderableActor );
614 // Set with empty handle
615 task.SetSourceActor( Actor() );
616 DALI_TEST_CHECK( ! task.GetSourceActor() );
618 // Update & Render nothing!
619 application.GetGlAbstraction().ClearBoundTextures();
620 application.SendNotification();
621 application.Render();
623 // Check that nothing was rendered
624 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
626 // Set with non-empty handle
627 task.SetSourceActor( newActor );
628 DALI_TEST_CHECK( task.GetSourceActor() == newActor );
630 // Update & Render the newActor
631 application.GetGlAbstraction().ClearBoundTextures();
632 application.SendNotification();
633 application.Render();
635 // Check that the newActor was rendered
636 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
637 if ( boundTextures.size() )
639 DALI_TEST_EQUALS( boundTextures[0], expectedTextureId, TEST_LOCATION );
644 int UtcDaliRenderTaskGetSourceActorP01(void)
646 TestApplication application;
648 tet_infoline("Testing RenderTask::GetSourceActor() Check the default render task has a valid source actor");
650 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
652 RenderTask task = taskList.GetTask( 0u );
654 Actor actor = task.GetSourceActor();
655 DALI_TEST_CHECK( actor );
657 // By default the entire scene should be rendered
658 Actor root = Stage::GetCurrent().GetLayer( 0 );
659 DALI_TEST_CHECK( root == actor );
663 int UtcDaliRenderTaskGetSourceActorP02(void)
665 TestApplication application;
667 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.");
669 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
670 RenderTask task = taskList.CreateTask();
671 Actor actor = Actor::New();
672 Stage::GetCurrent().Add(actor);
673 task.SetSourceActor( actor );
675 DALI_TEST_EQUALS( actor, task.GetSourceActor(), TEST_LOCATION );
680 int UtcDaliRenderTaskGetSourceActorN(void)
682 TestApplication application;
684 tet_infoline("Testing RenderTask::GetSourceActor() Try with empty handle");
689 Actor actor = task.GetSourceActor();
691 catch (Dali::DaliException(e))
693 DALI_TEST_PRINT_ASSERT( e );
694 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
700 int UtcDaliRenderTaskSetExclusive(void)
702 TestApplication application;
704 tet_infoline("Testing RenderTask::SetExclusive() Check that exclusion works");
706 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
708 // Manipulate the GenTextures behaviour, to identify different actors
710 std::vector<GLuint> ids;
711 ids.push_back( 8 ); // 8 = actor1
712 ids.push_back( 9 ); // 9 = actor2
713 ids.push_back( 10 ); // 10 = actor3
714 application.GetGlAbstraction().SetNextTextureIds( ids );
716 BufferImage img1 = BufferImage::New( 1,1 );
717 Actor actor1 = CreateRenderableActor( img1 );
719 Stage::GetCurrent().Add( actor1 );
721 // Update & Render actor1
722 application.SendNotification();
723 application.Render();
725 // Check that the actor1 was rendered
726 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
727 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
729 if ( boundTextures.size() )
731 DALI_TEST_EQUALS( boundTextures[0], 8u/*unique to actor1*/, TEST_LOCATION );
734 BufferImage img2 = BufferImage::New( 1,1 );
735 Actor actor2 = CreateRenderableActor( img2 );
738 // Force actor2 to be rendered before actor1
739 Layer layer = Layer::New();
740 Stage::GetCurrent().Add( layer );
742 layer.LowerToBottom();
745 application.GetGlAbstraction().ClearBoundTextures();
746 application.SendNotification();
747 application.Render();
749 // Check that the actors were rendered
750 DALI_TEST_EQUALS( boundTextures.size(), 2u, TEST_LOCATION );
752 if ( boundTextures.size() )
754 DALI_TEST_EQUALS( boundTextures[0], 9u/*unique to actor2*/, TEST_LOCATION );
755 DALI_TEST_EQUALS( boundTextures[1], 8u/*unique to actor1*/, TEST_LOCATION );
758 BufferImage img3 = BufferImage::New( 1,1 );
759 Actor actor3 = CreateRenderableActor( img3 );
762 // Force actor3 to be rendered before actor2
763 layer = Layer::New();
764 Stage::GetCurrent().Add( layer );
766 layer.LowerToBottom();
768 // Update & Render all actors
769 application.GetGlAbstraction().ClearBoundTextures();
770 application.SendNotification();
771 application.Render();
773 // Check that the actors were rendered
774 DALI_TEST_EQUALS( boundTextures.size(), 3u, TEST_LOCATION );
776 if ( boundTextures.size() )
778 DALI_TEST_EQUALS( boundTextures[0], 10u/*unique to actor3*/, TEST_LOCATION );
779 DALI_TEST_EQUALS( boundTextures[1], 9u/*unique to actor2*/, TEST_LOCATION );
780 DALI_TEST_EQUALS( boundTextures[2], 8u/*unique to actor1*/, TEST_LOCATION );
783 // Both actors are now connected to the root node
784 // Setup 2 render-tasks - the first will render from the root-node, and the second from actor2
786 // Not exclusive is the default
787 RenderTask task1 = taskList.GetTask( 0u );
788 DALI_TEST_CHECK( false == task1.IsExclusive() );
790 RenderTask task2 = taskList.CreateTask();
791 DALI_TEST_CHECK( false == task2.IsExclusive() );
792 task2.SetSourceActor( actor2 );
794 // Task1 should render all actors, and task 2 should render only actor2
796 application.GetGlAbstraction().ClearBoundTextures();
797 application.SendNotification();
798 application.Render();
800 DALI_TEST_EQUALS( boundTextures.size(), 4u, TEST_LOCATION );
802 if ( boundTextures.size() == 4 )
804 // Test that task 1 renders actor3, then actor2 & then actor1
805 DALI_TEST_CHECK( boundTextures[0] == 10u );
806 DALI_TEST_CHECK( boundTextures[1] == 9u );
807 DALI_TEST_CHECK( boundTextures[2] == 8u );
809 // Test that task 2 renders actor2
810 DALI_TEST_EQUALS( boundTextures[3], 9u, TEST_LOCATION );
813 // Make actor2 exclusive to task2
815 task2.SetExclusive( true );
816 DALI_TEST_CHECK( true == task2.IsExclusive() );
818 // Task1 should render only actor1, and task 2 should render only actor2
820 application.GetGlAbstraction().ClearBoundTextures();
821 application.SendNotification();
822 application.Render();
824 DALI_TEST_EQUALS( boundTextures.size(), 3u, TEST_LOCATION );
825 if ( boundTextures.size() == 3 )
827 // Test that task 1 renders actor3 & actor1
828 DALI_TEST_CHECK( boundTextures[0] == 10u );
829 DALI_TEST_CHECK( boundTextures[1] == 8u );
831 // Test that task 2 renders actor2
832 DALI_TEST_CHECK( boundTextures[2] == 9u );
837 int UtcDaliRenderTaskSetExclusive02(void)
839 TestApplication application;
841 tet_infoline("Testing RenderTask::SetExclusive() Check that changing from exclusive to not-exclusive works");
843 std::vector<GLuint> ids;
844 ids.push_back( 8 ); // 8 = actor1
845 application.GetGlAbstraction().SetNextTextureIds( ids );
847 BufferImage img1 = BufferImage::New( 1,1 );
848 Actor actor1 = CreateRenderableActor( img1 );
850 Stage::GetCurrent().Add( actor1 );
852 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
853 RenderTask task = taskList.CreateTask();
855 task.SetSourceActor( actor1 );
856 task.SetExclusive(true); // Actor should only render once
858 TestGlAbstraction& gl = application.GetGlAbstraction();
859 TraceCallStack& drawTrace = gl.GetDrawTrace();
860 drawTrace.Enable(true);
862 // Update & Render actor1
863 application.SendNotification();
864 application.Render();
866 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawArrays"), 1, TEST_LOCATION );
868 // Set task to non-exclusive - actor1 should render twice:
870 task.SetExclusive(false);
871 application.SendNotification();
872 application.Render();
874 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawArrays"), 2, TEST_LOCATION );
879 int UtcDaliRenderTaskSetExclusiveN(void)
881 TestApplication application;
883 tet_infoline("Testing RenderTask::SetExclusive() on empty handle");
888 task.SetExclusive(true);
890 catch (Dali::DaliException(e))
892 DALI_TEST_PRINT_ASSERT( e );
893 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
898 int UtcDaliRenderTaskIsExclusive01(void)
900 TestApplication application;
902 tet_infoline("Testing RenderTask::IsExclusive() Check default values are non-exclusive");
904 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
906 // Not exclusive is the default
907 RenderTask task = taskList.GetTask( 0u );
908 DALI_TEST_CHECK( false == task.IsExclusive() );
910 RenderTask newTask = taskList.CreateTask();
911 DALI_TEST_CHECK( false == newTask.IsExclusive() );
916 int UtcDaliRenderTaskIsExclusive02(void)
918 TestApplication application;
920 tet_infoline("Testing RenderTask::IsExclusive() Check the getter returns set values");
922 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
924 // Not exclusive is the default
925 RenderTask newTask = taskList.CreateTask();
926 DALI_TEST_EQUALS( newTask.IsExclusive(), false, TEST_LOCATION );
928 newTask.SetExclusive(true);
929 DALI_TEST_EQUALS( newTask.IsExclusive(), true, TEST_LOCATION );
933 int UtcDaliRenderTaskIsExclusiveN(void)
935 TestApplication application;
937 tet_infoline("Testing RenderTask::IsExclusive() on empty handle");
942 bool x = task.IsExclusive();
945 catch (Dali::DaliException(e))
947 DALI_TEST_PRINT_ASSERT( e );
948 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
953 int UtcDaliRenderTaskSetInputEnabled(void)
955 TestApplication application;
957 tet_infoline("Testing RenderTask::SetInputEnabled()");
959 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
961 // Input is enabled by default
962 RenderTask task = taskList.GetTask( 0u );
963 DALI_TEST_CHECK( true == task.GetInputEnabled() );
965 task.SetInputEnabled( false );
966 DALI_TEST_CHECK( false == task.GetInputEnabled() );
968 task.SetInputEnabled( true );
969 DALI_TEST_CHECK( true == task.GetInputEnabled() );
973 int UtcDaliRenderTaskGetInputEnabled(void)
975 TestApplication application;
977 tet_infoline("Testing RenderTask::GetInputEnabled()");
979 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
981 // Input is enabled by default
982 RenderTask task = taskList.GetTask( 0u );
983 DALI_TEST_EQUALS( true, task.GetInputEnabled(), TEST_LOCATION );
985 RenderTask newTask = taskList.CreateTask();
986 DALI_TEST_EQUALS( true, newTask.GetInputEnabled(), TEST_LOCATION );
988 newTask.SetInputEnabled(false);
989 DALI_TEST_EQUALS( false, newTask.GetInputEnabled(), TEST_LOCATION );
994 int UtcDaliRenderTaskSetCameraActorP(void)
996 TestApplication application;
998 tet_infoline("Testing RenderTask::SetCameraActor()");
1000 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1002 RenderTask task = taskList.GetTask( 0u );
1004 Actor defaultCameraActor = task.GetCameraActor();
1005 DALI_TEST_CHECK( defaultCameraActor );
1007 CameraActor newCameraActor = CameraActor::New();
1008 DALI_TEST_CHECK( newCameraActor );
1010 task.SetCameraActor( newCameraActor );
1011 DALI_TEST_CHECK( task.GetCameraActor() != defaultCameraActor );
1012 DALI_TEST_EQUALS( task.GetCameraActor(), newCameraActor, TEST_LOCATION );
1017 int UtcDaliRenderTaskSetCameraActorN(void)
1019 TestApplication application;
1021 tet_infoline("Testing RenderTask::SetCameraActor() with empty actor handle");
1023 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1025 RenderTask task = taskList.GetTask( 0u );
1027 Actor actor = task.GetCameraActor();
1028 DALI_TEST_CHECK( actor );
1030 CameraActor cameraActor;
1032 task.SetCameraActor( cameraActor );
1033 DALI_TEST_EQUALS( (bool)task.GetCameraActor(), false, TEST_LOCATION );
1034 DALI_TEST_EQUALS( task.GetCameraActor(), cameraActor, TEST_LOCATION );
1039 int UtcDaliRenderTaskGetCameraActorP(void)
1041 TestApplication application;
1043 tet_infoline("Testing RenderTask::GetCameraActor()");
1045 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1047 RenderTask task = taskList.GetTask( 0u );
1049 CameraActor actor = task.GetCameraActor();
1050 DALI_TEST_CHECK( actor );
1051 DALI_TEST_EQUALS( actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION );
1052 DALI_TEST_GREATER( actor.GetFieldOfView(), 0.0f, TEST_LOCATION );
1056 int UtcDaliRenderTaskGetCameraActorN(void)
1058 TestApplication application;
1060 tet_infoline("Testing RenderTask::GetCameraActor() with empty handle");
1065 Actor actor = task.GetCameraActor();
1067 catch (Dali::DaliException(e))
1069 DALI_TEST_PRINT_ASSERT( e );
1070 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1076 int UtcDaliRenderTaskSetTargetFrameBufferP(void)
1078 TestApplication application;
1080 tet_infoline("Testing RenderTask::SetTargetFrameBuffer()");
1082 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1084 RenderTask task = taskList.GetTask( 0u );
1086 FrameBufferImage newImage = FrameBufferImage::New();
1087 task.SetTargetFrameBuffer( newImage );
1088 DALI_TEST_CHECK( task.GetTargetFrameBuffer() == newImage );
1092 int UtcDaliRenderTaskSetTargetFrameBufferN(void)
1094 TestApplication application;
1096 tet_infoline("Testing RenderTask::SetTargetFrameBuffer()");
1098 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1100 RenderTask task = taskList.GetTask( 0u );
1101 FrameBufferImage newImage; // Empty handle
1102 task.SetTargetFrameBuffer( newImage );
1103 DALI_TEST_EQUALS( (bool)task.GetTargetFrameBuffer(), false, TEST_LOCATION );
1107 int UtcDaliRenderTaskGetTargetFrameBufferP(void)
1109 TestApplication application;
1111 tet_infoline("Testing RenderTask::GetTargetFrameBuffer()");
1113 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1115 RenderTask newTask = taskList.CreateTask();
1116 FrameBufferImage fb = FrameBufferImage::New(128, 128, Pixel::RGBA8888);
1117 newTask.SetTargetFrameBuffer( fb );
1118 DALI_TEST_EQUALS( newTask.GetTargetFrameBuffer(), fb, TEST_LOCATION );
1122 int UtcDaliRenderTaskGetTargetFrameBufferN(void)
1124 TestApplication application;
1126 tet_infoline("Testing RenderTask::GetTargetFrameBuffer()");
1128 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1130 RenderTask task = taskList.GetTask( 0u );
1132 // By default render-tasks do not render off-screen
1133 FrameBufferImage image = task.GetTargetFrameBuffer();
1134 DALI_TEST_CHECK( !image );
1139 int UtcDaliRenderTaskSetFrameBufferP(void)
1141 TestApplication application;
1143 tet_infoline("Testing RenderTask::SetFrameBuffer()");
1145 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1147 RenderTask task = taskList.GetTask( 0u );
1149 FrameBuffer newFrameBuffer = FrameBuffer::New( 128u, 128u, FrameBuffer::COLOR );
1150 task.SetFrameBuffer( newFrameBuffer );
1151 DALI_TEST_CHECK( task.GetFrameBuffer() == newFrameBuffer );
1155 int UtcDaliRenderTaskSetFrameBufferN(void)
1157 TestApplication application;
1159 tet_infoline("Testing RenderTask::SetFrameBuffer()");
1161 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1163 RenderTask task = taskList.GetTask( 0u );
1164 FrameBuffer newFrameBuffer; // Empty handle
1165 task.SetFrameBuffer( newFrameBuffer );
1166 DALI_TEST_EQUALS( (bool)task.GetFrameBuffer(), false, TEST_LOCATION );
1170 int UtcDaliRenderTaskGetFrameBufferP(void)
1172 TestApplication application;
1174 tet_infoline("Testing RenderTask::GetFrameBuffer()");
1176 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1178 RenderTask task = taskList.GetTask( 0u );
1180 FrameBuffer newFrameBuffer = FrameBuffer::New( 1u, 1u, FrameBuffer::COLOR );
1181 task.SetFrameBuffer( newFrameBuffer );
1182 DALI_TEST_CHECK( task.GetFrameBuffer() == newFrameBuffer );
1186 int UtcDaliRenderTaskGetFrameBufferN(void)
1188 TestApplication application;
1190 tet_infoline("Testing RenderTask::GetFrameBuffer()");
1192 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1194 RenderTask task = taskList.GetTask( 0u );
1196 // By default render-tasks do not render off-screen
1197 FrameBuffer frameBuffer = task.GetFrameBuffer();
1198 DALI_TEST_CHECK( !frameBuffer );
1203 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionP(void)
1205 TestApplication application;
1207 tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1209 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1211 RenderTask task = taskList.GetTask( 0u );
1213 task.SetScreenToFrameBufferFunction( TestScreenToFrameBufferFunction );
1215 Vector2 coordinates( 5, 10 );
1216 Vector2 convertedCoordinates( 6, 12 ); // + Vector(1, 2)
1218 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1219 DALI_TEST_CHECK( func( coordinates ) );
1220 DALI_TEST_CHECK( coordinates == convertedCoordinates );
1222 task.SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
1223 func = task.GetScreenToFrameBufferFunction();
1224 DALI_TEST_CHECK( func( coordinates ) );
1226 task.SetScreenToFrameBufferFunction( RenderTask::DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION );
1227 func = task.GetScreenToFrameBufferFunction();
1228 DALI_TEST_CHECK( ! func( coordinates ) );
1232 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionN(void)
1234 TestApplication application;
1236 tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1238 RenderTask task; // Empty handle
1241 task.SetScreenToFrameBufferFunction( TestScreenToFrameBufferFunction );
1243 catch (Dali::DaliException(e))
1245 DALI_TEST_PRINT_ASSERT( e );
1246 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1251 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionP(void)
1253 TestApplication application;
1255 tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction()");
1257 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1259 RenderTask task = taskList.GetTask( 0u );
1261 Vector2 originalCoordinates( 5, 10 );
1262 Vector2 coordinates( 5, 10 );
1264 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1265 DALI_TEST_CHECK( !func( coordinates ) ); // conversion should fail by default
1266 DALI_TEST_CHECK( coordinates == originalCoordinates ); // coordinates should not be modified
1270 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionN(void)
1272 TestApplication application;
1274 tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction() on empty handle");
1279 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1282 catch (Dali::DaliException(e))
1284 DALI_TEST_PRINT_ASSERT( e );
1285 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1291 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorP(void)
1293 TestApplication application;
1294 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor ");
1296 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1297 RenderTask renderTask = taskList.CreateTask();
1298 Actor mappingActor = Actor::New();
1299 renderTask.SetScreenToFrameBufferMappingActor(mappingActor);
1301 DALI_TEST_EQUALS( mappingActor, renderTask.GetScreenToFrameBufferMappingActor(), TEST_LOCATION );
1306 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorN(void)
1308 TestApplication application;
1309 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1315 task.SetScreenToFrameBufferMappingActor(mappingActor);
1317 catch (Dali::DaliException(e))
1319 DALI_TEST_PRINT_ASSERT( e );
1320 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1325 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActor02N(void)
1327 TestApplication application;
1328 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1330 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1331 RenderTask renderTask = taskList.CreateTask();
1333 renderTask.SetScreenToFrameBufferMappingActor(actor);
1335 DALI_TEST_EQUALS( (bool)renderTask.GetScreenToFrameBufferMappingActor(), false, TEST_LOCATION);
1339 int UtcDaliRenderTaskGetViewportP01(void)
1341 TestApplication application;
1343 tet_infoline("Testing RenderTask::GetViewport() on default task");
1345 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1346 RenderTask task = taskList.GetTask( 0u );
1347 Viewport viewport = task.GetViewport();
1349 // By default the viewport should match the stage width/height
1350 Vector2 stageSize = Stage::GetCurrent().GetSize();
1351 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1352 DALI_TEST_CHECK( viewport == expectedViewport );
1356 int UtcDaliRenderTaskGetViewportP02(void)
1358 TestApplication application;
1360 tet_infoline("Testing RenderTask::GetViewport() on new task");
1362 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1363 RenderTask task = taskList.CreateTask();
1364 Viewport viewport = task.GetViewport();
1366 // By default the viewport should match the stage width/height
1367 Vector2 stageSize = Stage::GetCurrent().GetSize();
1368 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1369 DALI_TEST_CHECK( viewport == expectedViewport );
1373 int UtcDaliRenderTaskGetViewportN(void)
1375 TestApplication application;
1377 tet_infoline("Testing RenderTask::GetViewport() on empty handle");
1382 Viewport viewport = task.GetViewport();
1383 viewport = viewport;
1385 catch (Dali::DaliException(e))
1387 DALI_TEST_PRINT_ASSERT( e );
1388 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1394 int UtcDaliRenderTaskSetViewportP(void)
1396 TestApplication application;
1398 tet_infoline("Testing RenderTask::SetViewport()");
1400 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1402 RenderTask task = taskList.GetTask( 0u );
1403 Vector2 stageSize = Stage::GetCurrent().GetSize();
1404 Viewport newViewport( 0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f );
1405 task.SetViewport( newViewport );
1407 // Update (viewport is a property)
1408 application.SendNotification();
1409 application.Render();
1411 DALI_TEST_CHECK( task.GetViewport() == newViewport );
1415 int UtcDaliRenderTaskSetViewportN(void)
1417 TestApplication application;
1419 tet_infoline("Testing RenderTask::SetViewport()");
1421 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1426 Vector2 stageSize = Stage::GetCurrent().GetSize();
1427 Viewport newViewport( 0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f );
1428 task.SetViewport( newViewport );
1430 catch (Dali::DaliException(e))
1432 DALI_TEST_PRINT_ASSERT( e );
1433 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1440 int UtcDaliRenderTaskSetViewportPosition(void)
1442 TestApplication application;
1444 tet_infoline("Testing RenderTask::SetViewportPosition()");
1446 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1448 RenderTask task = taskList.GetTask( 0u );
1450 Viewport viewport = task.GetViewport();
1452 // By default the viewport should match the stage width/height
1454 Vector2 stageSize = Stage::GetCurrent().GetSize();
1455 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1456 DALI_TEST_CHECK( viewport == expectedViewport );
1459 Vector2 newPosition(25.0f, 50.0f);
1460 task.SetViewportPosition( newPosition );
1462 // Update (viewport is a property)
1463 application.SendNotification();
1464 application.Render();
1466 DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1468 // Set by Property test
1469 Vector2 newPosition2(32.0f, 32.0f);
1470 task.SetProperty( RenderTask::Property::VIEWPORT_POSITION, newPosition2 );
1473 application.SendNotification();
1474 application.Render();
1476 DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition2, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1478 Vector2 newPosition3(64.0f, 0.0f);
1479 Animation animation = Animation::New(1.0f);
1480 animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_POSITION ), newPosition3, AlphaFunction::LINEAR );
1483 // Perform 1000ms worth of updates at which point animation should have completed.
1484 Wait(application, 1000);
1485 DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1489 int UtcDaliRenderTaskSetViewportSize(void)
1491 TestApplication application;
1493 tet_infoline("Testing RenderTask::SetViewportSize()");
1495 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1497 RenderTask task = taskList.GetTask( 0u );
1499 Viewport viewport = task.GetViewport();
1501 // By default the viewport should match the stage width/height
1503 Vector2 stageSize = Stage::GetCurrent().GetSize();
1504 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1505 DALI_TEST_CHECK( viewport == expectedViewport );
1507 Vector2 newSize(128.0f, 64.0f);
1508 task.SetViewportSize( newSize );
1510 // Update (viewport is a property)
1511 application.SendNotification();
1512 application.Render();
1514 DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1516 // Set by Property test
1517 Vector2 newSize2(50.0f, 50.0f);
1518 task.SetProperty( RenderTask::Property::VIEWPORT_SIZE, newSize2 );
1521 application.SendNotification();
1522 application.Render();
1524 DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize2, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1526 Vector2 newSize3(10.0f, 10.0f);
1527 Animation animation = Animation::New(1.0f);
1528 animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_SIZE ), newSize3, AlphaFunction::LINEAR );
1531 // Perform 1000ms worth of updates at which point animation should have completed.
1532 Wait(application, 1000);
1533 DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1538 int UtcDaliRenderTaskSetClearColorP(void)
1540 TestApplication application;
1542 tet_infoline("Testing RenderTask::SetClearColor()");
1544 Vector4 testColor( 1.0f, 2.0f, 3.0f, 4.0f );
1545 Vector4 testColor2( 5.0f, 6.0f, 7.0f, 8.0f );
1547 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1549 RenderTask task = taskList.GetTask( 0u );
1550 DALI_TEST_CHECK( task.GetClearColor() != testColor );
1552 task.SetClearColor( testColor );
1557 DALI_TEST_EQUALS( task.GetClearColor(), testColor, TEST_LOCATION );
1559 task.SetProperty( RenderTask::Property::CLEAR_COLOR, testColor2 );
1564 DALI_TEST_EQUALS( task.GetClearColor(), testColor2, TEST_LOCATION );
1568 int UtcDaliRenderTaskSetClearColorN(void)
1570 TestApplication application;
1572 tet_infoline("Testing RenderTask::SetClearColor() on empty handle");
1577 task.SetClearColor( Vector4::ZERO );
1579 catch (Dali::DaliException(e))
1581 DALI_TEST_PRINT_ASSERT( e );
1582 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1587 int UtcDaliRenderTaskGetClearColorP(void)
1589 TestApplication application;
1591 tet_infoline("Testing RenderTask::GetClearColor()");
1593 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1594 RenderTask task = taskList.GetTask( 0u );
1595 DALI_TEST_EQUALS( task.GetClearColor(), RenderTask::DEFAULT_CLEAR_COLOR, TEST_LOCATION );
1599 int UtcDaliRenderTaskGetClearColorN(void)
1601 TestApplication application;
1603 tet_infoline("Testing RenderTask::GetClearColor()");
1608 Vector4 color = task.GetClearColor();
1611 catch (Dali::DaliException(e))
1613 DALI_TEST_PRINT_ASSERT( e );
1614 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1619 int UtcDaliRenderTaskSetClearEnabledP(void)
1621 TestApplication application;
1623 tet_infoline("Testing RenderTask::SetClearEnabled()");
1625 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1627 RenderTask task = taskList.GetTask( 0u );
1628 DALI_TEST_CHECK( !task.GetClearEnabled() ); // defaults to false
1630 task.SetClearEnabled( true );
1631 DALI_TEST_EQUALS( task.GetClearEnabled(), true, TEST_LOCATION );
1633 task.SetClearEnabled( false );
1634 DALI_TEST_EQUALS( task.GetClearEnabled(), false, TEST_LOCATION );
1638 int UtcDaliRenderTaskSetClearEnabledN(void)
1640 TestApplication application;
1642 tet_infoline("Testing RenderTask::SetClearEnabled() with empty handle");
1647 task.SetClearEnabled(true);
1649 catch (Dali::DaliException(e))
1651 DALI_TEST_PRINT_ASSERT( e );
1652 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1657 int UtcDaliRenderTaskGetClearEnabledP(void)
1659 TestApplication application;
1661 tet_infoline("Testing RenderTask::GetClearEnabled()");
1663 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1665 RenderTask task = taskList.GetTask( 0u );
1666 DALI_TEST_CHECK( !task.GetClearEnabled() ); // defaults to false
1671 int UtcDaliRenderTaskGetClearEnabledN(void)
1673 TestApplication application;
1675 tet_infoline("Testing RenderTask::GetClearEnabled() with empty handle");
1680 bool x = task.GetClearEnabled();
1683 catch (Dali::DaliException(e))
1685 DALI_TEST_PRINT_ASSERT( e );
1686 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1691 int UtcDaliRenderTaskSetCullModeP(void)
1693 TestApplication application;
1695 tet_infoline("Testing RenderTask::SetCullMode()");
1697 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1698 RenderTask task = taskList.GetTask( 0u );
1699 DALI_TEST_EQUALS( task.GetCullMode(), true, TEST_LOCATION );
1701 task.SetCullMode( false );
1703 DALI_TEST_EQUALS( task.GetCullMode(), false, TEST_LOCATION );
1708 int UtcDaliRenderTaskSetCullModeN(void)
1710 TestApplication application;
1712 tet_infoline("Testing RenderTask::SetCullMode() on empty handle");
1717 task.SetCullMode( false );
1719 catch (Dali::DaliException(e))
1721 DALI_TEST_PRINT_ASSERT( e );
1722 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1727 int UtcDaliRenderTaskGetCullModeP(void)
1729 TestApplication application;
1731 tet_infoline("Testing RenderTask::GetCullMode()");
1733 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1734 RenderTask task = taskList.GetTask( 0u );
1735 DALI_TEST_EQUALS( task.GetCullMode(), true, TEST_LOCATION );
1739 int UtcDaliRenderTaskGetCullModeN(void)
1741 TestApplication application;
1743 tet_infoline("Testing RenderTask::GetCullMode() with empty handle");
1748 bool x = task.GetCullMode();
1751 catch (Dali::DaliException(e))
1753 DALI_TEST_PRINT_ASSERT( e );
1754 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1760 int UtcDaliRenderTaskSetRefreshRate(void)
1762 TestApplication application;
1764 tet_infoline("Testing RenderTask::SetRefreshRate()");
1766 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1768 // By default tasks will be processed every frame
1769 RenderTask task = taskList.GetTask( 0u );
1770 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1772 task.SetRefreshRate( 2u ); // every-other frame
1773 DALI_TEST_CHECK( 2u == task.GetRefreshRate() );
1775 task.SetRefreshRate( RenderTask::REFRESH_ALWAYS );
1776 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1780 int UtcDaliRenderTaskGetRefreshRate(void)
1782 TestApplication application;
1784 tet_infoline("Testing RenderTask::GetRefreshRate()");
1786 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1788 // By default tasks will be processed every frame
1789 RenderTask task = taskList.GetTask( 0u );
1790 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1792 RenderTask newTask = taskList.CreateTask();
1793 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == newTask.GetRefreshRate() );
1797 int UtcDaliRenderTaskSignalFinished(void)
1799 TestApplication application;
1801 tet_infoline("Testing RenderTask::SignalFinished()");
1803 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1804 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
1806 CameraActor offscreenCameraActor = CameraActor::New();
1808 Stage::GetCurrent().Add( offscreenCameraActor );
1810 BufferImage image = BufferImage::New( 10, 10 );
1812 Actor rootActor = CreateRenderableActor( image );
1813 rootActor.SetSize( 10, 10 );
1814 Stage::GetCurrent().Add( rootActor );
1816 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1817 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
1818 FrameBufferImage frameBufferImage = FrameBufferImage::New( *testNativeImagePtr.Get() );
1820 RenderTask newTask = taskList.CreateTask();
1821 newTask.SetCameraActor( offscreenCameraActor );
1822 newTask.SetSourceActor( rootActor );
1823 newTask.SetInputEnabled( false );
1824 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
1825 newTask.SetClearEnabled( true );
1826 newTask.SetExclusive( true );
1827 newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
1828 newTask.SetTargetFrameBuffer( frameBufferImage );
1829 newTask.SetProperty( RenderTask::Property::REQUIRES_SYNC, true );
1831 bool finished = false;
1832 RenderTaskFinished renderTaskFinished( finished );
1833 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1835 // Flush the queue and render.
1836 application.SendNotification();
1838 // 1 render to process render task, then wait for sync before finished msg is sent
1839 // from update to the event thread.
1841 application.Render();
1842 application.SendNotification();
1843 DALI_TEST_CHECK( !finished );
1845 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
1846 DALI_TEST_CHECK( lastSyncObj != NULL );
1848 application.Render();
1849 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
1850 application.SendNotification();
1851 DALI_TEST_CHECK( !finished );
1853 application.Render();
1854 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
1855 application.SendNotification();
1856 DALI_TEST_CHECK( ! finished );
1858 sync.SetObjectSynced( lastSyncObj, true );
1860 application.Render();
1861 application.SendNotification();
1862 DALI_TEST_CHECK( !finished );
1864 application.Render();
1865 application.SendNotification();
1866 DALI_TEST_CHECK( finished );
1869 DALI_TEST_EQUALS( application.GetUpdateStatus(), 0, TEST_LOCATION );
1874 int UtcDaliRenderTaskContinuous01(void)
1876 TestApplication application;
1878 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not staged)\nPOST:continuous renders, no Finished signal");
1880 // SETUP AN OFFSCREEN RENDER TASK
1881 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1882 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1883 drawTrace.Enable(true);
1885 Actor rootActor = Actor::New();
1886 Stage::GetCurrent().Add( rootActor );
1888 CameraActor offscreenCameraActor = CameraActor::New();
1889 Stage::GetCurrent().Add( offscreenCameraActor );
1891 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1892 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1893 Integration::ResourceId imageRequestId = imageRequest->GetId();
1894 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1896 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1897 bool finished = false;
1898 RenderTaskFinished renderTaskFinished( finished );
1899 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1900 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1901 application.SendNotification();
1903 // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating
1904 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false, __LINE__ ) );
1905 application.GetPlatform().ClearReadyResources();
1907 // ADD SOURCE ACTOR TO STAGE - expect continuous renders to start, no finished signal
1908 Stage::GetCurrent().Add(secondRootActor);
1909 application.SendNotification();
1911 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1912 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
1917 int UtcDaliRenderTaskContinuous02(void)
1919 TestApplication application;
1921 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not visible)\nPOST:continuous renders, no Finished signal");
1923 // SETUP AN OFFSCREEN RENDER TASK
1924 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1925 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1926 drawTrace.Enable(true);
1928 Actor rootActor = Actor::New();
1929 Stage::GetCurrent().Add( rootActor );
1931 CameraActor offscreenCameraActor = CameraActor::New();
1932 Stage::GetCurrent().Add( offscreenCameraActor );
1934 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1935 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1936 Integration::ResourceId imageRequestId = imageRequest->GetId();
1937 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1938 Stage::GetCurrent().Add(secondRootActor);
1939 secondRootActor.SetVisible(false);
1941 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1942 bool finished = false;
1943 RenderTaskFinished renderTaskFinished( finished );
1944 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1945 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1946 application.SendNotification();
1948 // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating
1949 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false, __LINE__ ) );
1950 application.GetPlatform().ClearReadyResources();
1952 // MAKE SOURCE ACTOR VISIBLE - expect continuous renders to start, no finished signal
1953 secondRootActor.SetVisible(true);
1954 application.SendNotification();
1956 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1957 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
1961 int UtcDaliRenderTaskContinuous03(void)
1963 TestApplication application;
1965 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (camera actor not staged)\nPOST:continuous renders, no Finished signal");
1967 // SETUP AN OFFSCREEN RENDER TASK
1968 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1969 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1970 drawTrace.Enable(true);
1972 Actor rootActor = Actor::New();
1973 Stage::GetCurrent().Add( rootActor );
1975 CameraActor offscreenCameraActor = CameraActor::New();
1976 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1977 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1978 Integration::ResourceId imageRequestId = imageRequest->GetId();
1979 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1980 Stage::GetCurrent().Add(secondRootActor);
1982 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1983 bool finished = false;
1984 RenderTaskFinished renderTaskFinished( finished );
1985 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1986 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1987 application.SendNotification();
1989 // START PROCESS/RENDER Input, Expected Input, Expected
1990 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false, __LINE__ ) );
1991 application.GetPlatform().ClearReadyResources();
1993 // ADD CAMERA ACTOR TO STAGE - expect continuous renders to start, no finished signal
1994 Stage::GetCurrent().Add( offscreenCameraActor );
1995 application.SendNotification();
1997 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1998 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2003 int UtcDaliRenderTaskContinuous04(void)
2005 TestApplication application;
2007 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: Resource not ready\nPOST:continuous renders, no Finished signal");
2009 // SETUP AN OFFSCREEN RENDER TASK
2010 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2011 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2012 drawTrace.Enable(true);
2014 Actor rootActor = Actor::New();
2015 Stage::GetCurrent().Add( rootActor );
2017 CameraActor offscreenCameraActor = CameraActor::New();
2018 Stage::GetCurrent().Add( offscreenCameraActor );
2019 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2020 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2021 Integration::ResourceId imageRequestId = imageRequest->GetId();
2022 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2023 Stage::GetCurrent().Add(secondRootActor);
2025 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2026 bool finished = false;
2027 RenderTaskFinished renderTaskFinished( finished );
2028 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2029 application.SendNotification();
2031 // START PROCESS/RENDER Input, Expected Input, Expected
2032 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2033 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2035 // FINISH RESOURCE LOADING - expect 'continuous' renders to start, no finished signal
2036 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2037 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2041 int UtcDaliRenderTaskContinous05(void)
2043 TestApplication application;
2045 tet_infoline("Testing RenderTask Render Continuous using Mesh which accesses texture through sampler with loading image\n"
2046 "PRE: Resource not ready\nPOST:continuous renders, no Finished signal");
2048 // SETUP AN OFFSCREEN RENDER TASK
2049 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2050 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2051 drawTrace.Enable(true);
2053 Actor rootActor = Actor::New();
2054 Stage::GetCurrent().Add( rootActor );
2056 CameraActor offscreenCameraActor = CameraActor::New();
2057 Stage::GetCurrent().Add( offscreenCameraActor );
2059 Shader shader = CreateShader();
2062 Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2063 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2064 Integration::ResourceId imageRequestId = imageRequest->GetId();
2065 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2066 TextureSet textureSet = CreateTextureSet( image );
2068 Geometry geometry = Geometry::QUAD();
2069 Renderer renderer = Renderer::New(geometry, shader);
2070 renderer.SetTextures( textureSet );
2071 Actor secondRootActor = Actor::New();
2072 secondRootActor.AddRenderer(renderer);
2073 secondRootActor.SetSize(100, 100);
2074 Stage::GetCurrent().Add(secondRootActor);
2076 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2077 bool finished = false;
2078 RenderTaskFinished renderTaskFinished( finished );
2079 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2080 application.SendNotification();
2082 // START PROCESS/RENDER Input, Expected Input, Expected
2083 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2084 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2086 // FINISH RESOURCE LOADING - expect 'continuous' renders to start, no finished signal
2087 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2088 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2094 int UtcDaliRenderTaskOnce01(void)
2096 TestApplication application;
2098 tet_infoline("Testing RenderTask Render Once GlSync, using loading image\nPRE: Resources not ready, Source not visible\nPOST: Finished signal sent once only");
2100 // SETUP AN OFFSCREEN RENDER TASK
2101 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2102 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2103 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2104 drawTrace.Enable(true);
2106 Actor rootActor = Actor::New();
2107 Stage::GetCurrent().Add( rootActor );
2109 CameraActor offscreenCameraActor = CameraActor::New();
2110 Stage::GetCurrent().Add( offscreenCameraActor );
2111 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2112 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2113 Integration::ResourceId imageRequestId = imageRequest->GetId();
2114 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2116 Stage::GetCurrent().Add(secondRootActor);
2118 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
2119 bool finished = false;
2120 RenderTaskFinished renderTaskFinished( finished );
2121 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2122 application.SendNotification();
2124 // START PROCESS/RENDER Input, Expected Input, Expected
2125 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2126 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2128 // MAKE SOURCE VISIBLE
2129 secondRootActor.SetVisible(true);
2130 application.SendNotification();
2131 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2132 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2134 // FINISH RESOURCE LOADING - expect no rendering yet
2135 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2136 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2137 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2138 DALI_TEST_CHECK( lastSyncObj != NULL );
2140 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2141 application.GetPlatform().ClearReadyResources();
2142 sync.SetObjectSynced( lastSyncObj, true );
2143 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2144 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2148 int UtcDaliRenderTaskOnce02(void)
2150 TestApplication application;
2152 tet_infoline("Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loading image.\n"
2153 "PRE: Resources not ready\nPOST: Finished signal sent once only");
2155 // SETUP AN OFFSCREEN RENDER TASK
2156 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2157 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2158 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2159 drawTrace.Enable(true);
2161 Actor rootActor = Actor::New();
2162 Stage::GetCurrent().Add( rootActor );
2164 CameraActor offscreenCameraActor = CameraActor::New();
2165 Stage::GetCurrent().Add( offscreenCameraActor );
2167 Shader shader = CreateShader();
2168 Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2169 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2170 Integration::ResourceId imageRequestId = imageRequest->GetId();
2171 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2172 TextureSet textureSet = CreateTextureSet( image );
2174 Geometry geometry = Geometry::QUAD();
2175 Renderer renderer = Renderer::New(geometry, shader);
2176 renderer.SetTextures( textureSet );
2177 Actor secondRootActor = Actor::New();
2178 secondRootActor.AddRenderer(renderer);
2179 secondRootActor.SetSize(100, 100);
2180 Stage::GetCurrent().Add(secondRootActor);
2182 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
2183 bool finished = false;
2184 RenderTaskFinished renderTaskFinished( finished );
2185 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2186 application.SendNotification();
2188 // START PROCESS/RENDER Input, Expected Input, Expected
2189 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2190 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2192 // FINISH RESOURCE LOADING - expect no rendering yet
2193 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2194 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2195 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2196 DALI_TEST_CHECK( lastSyncObj != NULL );
2198 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2199 application.GetPlatform().ClearReadyResources();
2200 sync.SetObjectSynced( lastSyncObj, true );
2201 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2202 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2207 int UtcDaliRenderTaskOnce03(void)
2209 TestApplication application;
2211 tet_infoline("Testing RenderTask Render Once GlSync, using loading image. Switch from render always after ready to render once\n"
2212 "PRE: Render task ready, Image not loaded\n"
2213 "POST: Finished signal sent only once");
2215 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2216 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2217 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2218 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2219 drawTrace.Enable(true);
2221 Actor rootActor = Actor::New();
2222 Stage::GetCurrent().Add( rootActor );
2224 CameraActor offscreenCameraActor = CameraActor::New();
2225 Stage::GetCurrent().Add( offscreenCameraActor );
2226 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2227 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2228 Integration::ResourceId imageRequestId = imageRequest->GetId();
2229 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2230 Stage::GetCurrent().Add(secondRootActor);
2232 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2233 bool finished = false;
2234 RenderTaskFinished renderTaskFinished( finished );
2235 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2236 application.SendNotification();
2238 // START PROCESS/RENDER Input, Expected Input, Expected
2239 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2240 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2242 // FINISH RESOURCE LOADING
2243 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2244 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2245 application.GetPlatform().ClearReadyResources();
2246 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2248 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2249 application.SendNotification(); // Input, Expected Input, Expected
2250 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2251 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2252 DALI_TEST_CHECK( lastSyncObj != NULL );
2254 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2255 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2256 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2257 sync.SetObjectSynced( lastSyncObj, true );
2258 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2259 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2265 int UtcDaliRenderTaskOnce04(void)
2267 TestApplication application;
2268 tet_infoline("Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loading image.\n"
2269 "Switch from render always after ready to render once\n"
2270 "PRE: Render task ready, Image not loaded\n"
2271 "POST: Finished signal sent only once");
2273 // SETUP AN OFFSCREEN RENDER TASK
2274 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2275 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2276 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2277 drawTrace.Enable(true);
2279 Actor rootActor = Actor::New();
2280 Stage::GetCurrent().Add( rootActor );
2282 CameraActor offscreenCameraActor = CameraActor::New();
2283 Stage::GetCurrent().Add( offscreenCameraActor );
2285 Shader shader = CreateShader();
2286 Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2287 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2288 Integration::ResourceId imageRequestId = imageRequest->GetId();
2289 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2290 TextureSet textureSet = CreateTextureSet( image );
2292 Geometry geometry = Geometry::QUAD();
2293 Renderer renderer = Renderer::New(geometry, shader);
2294 renderer.SetTextures( textureSet );
2295 Actor secondRootActor = Actor::New();
2296 secondRootActor.AddRenderer(renderer);
2297 secondRootActor.SetSize(100, 100);
2298 Stage::GetCurrent().Add(secondRootActor);
2300 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2301 bool finished = false;
2302 RenderTaskFinished renderTaskFinished( finished );
2303 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2304 application.SendNotification();
2306 // START PROCESS/RENDER Input, Expected Input, Expected
2307 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2308 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2310 // FINISH RESOURCE LOADING
2311 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2312 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2313 application.GetPlatform().ClearReadyResources();
2314 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2316 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2317 application.SendNotification(); // Input, Expected Input, Expected
2318 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2319 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2320 DALI_TEST_CHECK( lastSyncObj != NULL );
2322 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2323 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2324 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2325 sync.SetObjectSynced( lastSyncObj, true );
2326 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2327 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2332 int UtcDaliRenderTaskOnce05(void)
2334 TestApplication application;
2336 tet_infoline("Testing RenderTask Render Once GlSync\n"
2337 "Switch from Render always after ready to render once with resources unready\n"
2338 "PRE: Everything ready to render\n"
2339 "POST: Finished signal sent once");
2341 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2342 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2343 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2344 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2345 drawTrace.Enable(true);
2347 Actor rootActor = Actor::New();
2348 Stage::GetCurrent().Add( rootActor );
2350 CameraActor offscreenCameraActor = CameraActor::New();
2351 Stage::GetCurrent().Add( offscreenCameraActor );
2352 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2353 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2354 Integration::ResourceId imageRequestId = imageRequest->GetId();
2355 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2356 Stage::GetCurrent().Add(secondRootActor);
2358 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2359 bool finished = false;
2360 RenderTaskFinished renderTaskFinished( finished );
2361 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2362 application.SendNotification();
2364 // START PROCESS/RENDER Input, Expected Input, Expected
2365 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2366 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2368 // CHANGE TO RENDER ONCE
2369 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2370 application.SendNotification(); // Input, Expected Input, Expected
2371 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2372 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2374 // FINISH RESOURCE LOADING
2375 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2376 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2377 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2378 DALI_TEST_CHECK( lastSyncObj != NULL );
2379 application.GetPlatform().ClearReadyResources();
2381 sync.SetObjectSynced( lastSyncObj, true );
2383 // Expect: No draw - we've just drawn our render task once, above. No finished signal -
2384 // we won't read the gl sync until the next frame. Continue rendering - we're waiting for
2386 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2388 // Expect: 1 final draw - this Update doesn't update the scene, hence render instructions
2389 // from last frame but 1 are still present.
2390 // Finished signal should be true - we've just done the sync.
2391 // Should now stop rendering and updating - nothing left to do.
2392 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, true, false, __LINE__ ) );
2398 //int UtcDaliRenderTaskOnce06(void)
2400 TestApplication application;
2402 tet_infoline("Testing RenderTask Render Once GlSync\n"
2403 "During RenderOnce, make ready resources unready before sending first finished signal\n"
2404 "PRE: Everything ready.\n"
2405 "POST: Finished signal sent only once");
2407 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2408 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2409 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2410 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2411 drawTrace.Enable(true);
2413 Actor rootActor = Actor::New();
2414 Stage::GetCurrent().Add( rootActor );
2416 CameraActor offscreenCameraActor = CameraActor::New();
2417 Stage::GetCurrent().Add( offscreenCameraActor );
2418 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2419 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2420 Integration::ResourceId imageRequestId = imageRequest->GetId();
2421 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2422 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2423 application.Render();
2425 Stage::GetCurrent().Add(secondRootActor);
2426 application.GetPlatform().ClearReadyResources();
2428 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2429 bool finished = false;
2430 RenderTaskFinished renderTaskFinished( finished );
2431 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2432 application.SendNotification();
2434 // START PROCESS/RENDER Input, Expected Input, Expected
2435 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2436 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2438 // CHANGE TO RENDER ONCE, RESOURCES BECOME NOT READY
2439 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2442 ReloadImage(application, secondRootActor.GetImage());
2443 application.SendNotification(); // Input, Expected Input, Expected
2445 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2446 DALI_TEST_EQUALS( secondRootActor.GetImage().GetLoadingState(), Dali::ResourceLoading, TEST_LOCATION);
2447 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2449 // FINISH RESOURCE LOADING
2450 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2451 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2452 application.GetPlatform().ClearReadyResources();
2453 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2454 DALI_TEST_CHECK( lastSyncObj != NULL );
2456 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2457 sync.SetObjectSynced( lastSyncObj, true );
2458 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2459 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, true, __LINE__ ) );
2461 // Finished rendering - expect no more renders, no more signals:
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__ ) );
2466 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2467 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2472 int UtcDaliRenderTaskOnce07(void)
2474 TestApplication application;
2476 tet_infoline("Testing RenderTask Render Once GLSync\n"
2477 "Render once, Second call to SetRefreshRate(ONCE) triggers only one more finished signal\n"
2478 "PRE: Everything ready\n"
2479 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
2481 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2482 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2483 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2484 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2485 drawTrace.Enable(true);
2487 Actor rootActor = Actor::New();
2488 Stage::GetCurrent().Add( rootActor );
2490 CameraActor offscreenCameraActor = CameraActor::New();
2491 Stage::GetCurrent().Add( offscreenCameraActor );
2492 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2493 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2494 Integration::ResourceId imageRequestId = imageRequest->GetId();
2495 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2496 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2497 application.Render();
2498 application.GetPlatform().ClearReadyResources();
2500 Stage::GetCurrent().Add(secondRootActor);
2502 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2503 bool finished = false;
2504 RenderTaskFinished renderTaskFinished( finished );
2505 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2506 application.SendNotification();
2508 // START PROCESS/RENDER Input, Expected Input, Expected
2509 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2511 // CHANGE TO RENDER ONCE,
2512 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2513 application.SendNotification();
2514 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2515 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2516 DALI_TEST_CHECK( lastSyncObj != NULL );
2518 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2519 sync.SetObjectSynced( lastSyncObj, true );
2520 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2521 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2523 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2524 application.SendNotification();
2525 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2526 lastSyncObj = sync.GetLastSyncObject();
2527 DALI_TEST_CHECK( lastSyncObj != NULL );
2529 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2530 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2531 sync.SetObjectSynced( lastSyncObj, true );
2532 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2533 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2537 int UtcDaliRenderTaskOnce08(void)
2539 TestApplication application;
2541 tet_infoline("Testing RenderTask Render Once GLSync\n"
2542 "Render once, Call to SetRefreshRate(ONCE) in Finished signal callback triggers "
2543 "another render & another finished signal\n"
2544 "PRE: Everything ready\n"
2545 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
2548 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2549 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2550 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2551 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2552 sync.GetTrace().Enable(true);
2553 drawTrace.Enable(true);
2555 Actor rootActor = Actor::New();
2556 Stage::GetCurrent().Add( rootActor );
2558 CameraActor offscreenCameraActor = CameraActor::New();
2559 Stage::GetCurrent().Add( offscreenCameraActor );
2560 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2561 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2562 Integration::ResourceId imageRequestId = imageRequest->GetId();
2563 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2564 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2565 application.Render();
2566 application.GetPlatform().ClearReadyResources();
2568 Stage::GetCurrent().Add(secondRootActor);
2570 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, /*GL-SYNC*/ true);
2571 bool finished = false;
2573 ConnectionTracker connectionTracker;
2574 RenderTaskFinishedRenderAgain renderTaskFinishedRenderAgain( finished );
2575 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinishedRenderAgain );
2577 application.SendNotification();
2579 // START PROCESS/RENDER Input, Expected Input, Expected
2580 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2581 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2582 DALI_TEST_CHECK( lastSyncObj == NULL );
2583 DALI_TEST_EQUALS( sync.GetTrace().CountMethod( "CreateSyncObject" ), 0, TEST_LOCATION );
2586 // CHANGE TO RENDER ONCE,
2587 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2588 application.SendNotification();
2589 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2590 lastSyncObj = sync.GetLastSyncObject();
2591 DALI_TEST_CHECK( lastSyncObj != NULL );
2592 DALI_TEST_EQUALS( sync.GetNumberOfSyncObjects(), 1, TEST_LOCATION );
2593 DALI_TEST_EQUALS( sync.GetTrace().CountMethod( "CreateSyncObject" ), 1, TEST_LOCATION );
2595 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2598 DALI_TEST_EQUALS( sync.GetNumberOfSyncObjects(), 1, TEST_LOCATION );
2599 DALI_TEST_EQUALS( sync.GetTrace().CountMethod( "CreateSyncObject" ), 1, TEST_LOCATION );
2601 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2603 DALI_TEST_EQUALS( sync.GetNumberOfSyncObjects(), 1, TEST_LOCATION );
2604 DALI_TEST_EQUALS( sync.GetTrace().CountMethod( "CreateSyncObject" ), 1, TEST_LOCATION );
2606 sync.SetObjectSynced( lastSyncObj, true );
2607 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2608 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2609 application.SendNotification();
2611 // Expect SetRefreshRate to have been called again
2612 // Prevent next finished signal calling refresh once again
2613 RenderTaskFinished renderTaskFinished( finished );
2614 connectionTracker.DisconnectAll();
2615 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinished );
2616 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2617 lastSyncObj = sync.GetLastSyncObject();
2618 DALI_TEST_CHECK( lastSyncObj != NULL );
2620 sync.SetObjectSynced( lastSyncObj, true );
2621 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2622 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2627 int UtcDaliRenderTaskOnce09(void)
2629 TestApplication application;
2631 tet_infoline("Testing RenderTask Render Once GlSync\n"
2632 "SetRefreshRate(ONCE) again before first finished signal has been sent.\n"
2633 "PRE: resources ready\n"
2634 "POST: Only 1 finished signal sent.");
2636 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2637 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2638 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2639 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2640 drawTrace.Enable(true);
2642 Actor rootActor = Actor::New();
2643 Stage::GetCurrent().Add( rootActor );
2645 CameraActor offscreenCameraActor = CameraActor::New();
2646 Stage::GetCurrent().Add( offscreenCameraActor );
2647 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2648 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2649 Integration::ResourceId imageRequestId = imageRequest->GetId();
2650 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2651 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2652 application.Render();
2653 application.GetPlatform().ClearReadyResources();
2655 Stage::GetCurrent().Add(secondRootActor);
2657 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2658 bool finished = false;
2659 RenderTaskFinished renderTaskFinished( finished );
2660 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2661 application.SendNotification();
2663 // START PROCESS/RENDER Input, Expected Input, Expected
2664 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2666 // CHANGE TO RENDER ONCE,
2667 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2668 application.SendNotification();
2669 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2670 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2671 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2673 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2674 application.SendNotification();
2675 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2676 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2677 DALI_TEST_CHECK( lastSyncObj != NULL );
2679 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2680 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2681 sync.SetObjectSynced( lastSyncObj, true );
2682 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2683 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2688 int UtcDaliRenderTaskOnce10(void)
2690 TestApplication application;
2692 tet_infoline("Testing RenderTask Render Once GlSync\n"
2693 "SetRefreshRate(ONCE), resource load failed completes render task.\n"
2694 "PRE: resources not ready\n"
2695 "POST: Only 1 finished signal sent.");
2697 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2698 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2699 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2700 drawTrace.Enable(true);
2702 Actor rootActor = Actor::New();
2703 Stage::GetCurrent().Add( rootActor );
2705 CameraActor offscreenCameraActor = CameraActor::New();
2706 Stage::GetCurrent().Add( offscreenCameraActor );
2707 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2708 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2709 Integration::ResourceId imageRequestId = imageRequest->GetId();
2710 Stage::GetCurrent().Add(secondRootActor);
2712 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2713 bool finished = false;
2714 RenderTaskFinished renderTaskFinished( finished );
2715 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2716 application.SendNotification();
2718 // START PROCESS/RENDER Input, Expected Input, Expected
2719 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2720 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2722 // CHANGE TO RENDER ONCE,
2723 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2724 application.SendNotification();
2725 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2726 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2727 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2729 tet_printf(" FailImageLoad\n");
2731 FailImageLoad(application, imageRequestId); // Need to run Update again for this to complete
2733 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); // nothing to draw
2734 application.SendNotification();
2736 // load is now failed so there's nothing more to render in the render task
2737 // Expect finished signal, as all resources are complete
2738 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2743 int UtcDaliRenderTaskOnceNoSync01(void)
2745 TestApplication application;
2747 tet_infoline("Testing RenderTask Render Once, using loading image\nPRE: Resources not ready, Source not visible\nPOST: Finished signal sent once only");
2749 // SETUP AN OFFSCREEN RENDER TASK
2750 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2751 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2752 drawTrace.Enable(true);
2754 Actor rootActor = Actor::New();
2755 Stage::GetCurrent().Add( rootActor );
2757 CameraActor offscreenCameraActor = CameraActor::New();
2758 Stage::GetCurrent().Add( offscreenCameraActor );
2759 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2760 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2761 Integration::ResourceId imageRequestId = imageRequest->GetId();
2762 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2764 Stage::GetCurrent().Add(secondRootActor);
2766 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2767 bool finished = false;
2768 RenderTaskFinished renderTaskFinished( finished );
2769 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2770 application.SendNotification();
2772 // START PROCESS/RENDER Input, Expected Input, Expected
2773 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2774 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2776 // FINISH RESOURCE LOADING - expect immediate rendering yet
2777 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2778 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2779 application.GetPlatform().ClearReadyResources();
2780 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2784 int UtcDaliRenderTaskOnceNoSync02(void)
2786 TestApplication application;
2788 tet_infoline("Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loading image.\n"
2789 "PRE: Resources not ready\nPOST: Finished signal sent once only");
2790 // SETUP AN OFFSCREEN RENDER TASK
2791 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2792 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2793 drawTrace.Enable(true);
2795 Actor rootActor = Actor::New();
2796 Stage::GetCurrent().Add( rootActor );
2798 CameraActor offscreenCameraActor = CameraActor::New();
2799 Stage::GetCurrent().Add( offscreenCameraActor );
2801 Shader shader = CreateShader();
2802 Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2803 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2804 Integration::ResourceId imageRequestId = imageRequest->GetId();
2805 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2806 TextureSet textureSet = CreateTextureSet( image );
2808 Geometry geometry = Geometry::QUAD();
2809 Renderer renderer = Renderer::New(geometry, shader);
2810 renderer.SetTextures( textureSet );
2811 Actor secondRootActor = Actor::New();
2812 secondRootActor.AddRenderer(renderer);
2813 secondRootActor.SetSize(100, 100);
2814 Stage::GetCurrent().Add(secondRootActor);
2816 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2817 bool finished = false;
2818 RenderTaskFinished renderTaskFinished( finished );
2819 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2820 application.SendNotification();
2822 // START PROCESS/RENDER Input, Expected Input, Expected
2823 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2824 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2826 // FINISH RESOURCE LOADING - expect immediate rendering yet
2827 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2828 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2829 application.GetPlatform().ClearReadyResources();
2830 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2835 int UtcDaliRenderTaskOnceNoSync03(void)
2837 TestApplication application;
2839 tet_infoline("Testing RenderTask Render Once, using loading image. Switch from render always after ready to render once\n"
2840 "PRE: Render task ready, Image not loaded\n"
2841 "POST: Finished signal sent only once");
2843 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2844 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2845 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2846 drawTrace.Enable(true);
2848 Actor rootActor = Actor::New();
2849 Stage::GetCurrent().Add( rootActor );
2851 CameraActor offscreenCameraActor = CameraActor::New();
2852 Stage::GetCurrent().Add( offscreenCameraActor );
2853 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2854 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2855 Integration::ResourceId imageRequestId = imageRequest->GetId();
2856 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2857 Stage::GetCurrent().Add(secondRootActor);
2859 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2860 bool finished = false;
2861 RenderTaskFinished renderTaskFinished( finished );
2862 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2863 application.SendNotification();
2865 // START PROCESS/RENDER Input, Expected Input, Expected
2866 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2867 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2869 // FINISH RESOURCE LOADING
2870 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2871 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2872 application.GetPlatform().ClearReadyResources();
2874 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2875 application.SendNotification(); // Input, Expected Input, Expected
2876 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2877 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2881 int UtcDaliRenderTaskOnceNoSync04(void)
2883 TestApplication application;
2885 tet_infoline("Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loading image.\n"
2886 "Switch from render always after ready to render once\n"
2887 "PRE: Render task ready, Image not loaded\n"
2888 "POST: Finished signal sent only once");
2890 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2891 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2892 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2893 drawTrace.Enable(true);
2895 Actor rootActor = Actor::New();
2896 Stage::GetCurrent().Add( rootActor );
2898 CameraActor offscreenCameraActor = CameraActor::New();
2899 Stage::GetCurrent().Add( offscreenCameraActor );
2901 Shader shader = CreateShader();
2902 Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2903 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2904 Integration::ResourceId imageRequestId = imageRequest->GetId();
2905 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2906 TextureSet textureSet = CreateTextureSet( image );
2908 Geometry geometry = Geometry::QUAD();
2909 Renderer renderer = Renderer::New(geometry, shader);
2910 renderer.SetTextures( textureSet );
2911 Actor secondRootActor = Actor::New();
2912 secondRootActor.AddRenderer(renderer);
2913 secondRootActor.SetSize(100, 100);
2914 Stage::GetCurrent().Add(secondRootActor);
2917 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2918 bool finished = false;
2919 RenderTaskFinished renderTaskFinished( finished );
2920 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2921 application.SendNotification();
2923 // START PROCESS/RENDER Input, Expected Input, Expected
2924 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2925 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2927 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2928 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2929 DALI_TEST_CHECK( lastSyncObj == NULL );
2931 // FINISH RESOURCE LOADING
2932 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2933 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2934 application.GetPlatform().ClearReadyResources();
2936 lastSyncObj = sync.GetLastSyncObject();
2937 DALI_TEST_CHECK( lastSyncObj == NULL );
2939 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2940 application.SendNotification(); // Input, Expected Input, Expected
2941 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2942 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2944 lastSyncObj = sync.GetLastSyncObject();
2945 DALI_TEST_CHECK( lastSyncObj == NULL );
2950 int UtcDaliRenderTaskOnceNoSync05(void)
2952 TestApplication application;
2954 tet_infoline("Testing RenderTask Render Once\n"
2955 "Switch from Render always after ready to render once with resources unready\n"
2956 "PRE: Everything ready to render\n"
2957 "POST: Finished signal sent once");
2959 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2960 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2961 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2962 drawTrace.Enable(true);
2964 Actor rootActor = Actor::New();
2965 Stage::GetCurrent().Add( rootActor );
2967 CameraActor offscreenCameraActor = CameraActor::New();
2968 Stage::GetCurrent().Add( offscreenCameraActor );
2969 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2970 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2971 Integration::ResourceId imageRequestId = imageRequest->GetId();
2972 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2973 Stage::GetCurrent().Add(secondRootActor);
2975 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2976 bool finished = false;
2977 RenderTaskFinished renderTaskFinished( finished );
2978 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2979 application.SendNotification();
2981 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2982 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2983 DALI_TEST_CHECK( lastSyncObj == NULL );
2985 // START PROCESS/RENDER Input, Expected Input, Expected
2986 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2987 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2989 // CHANGE TO RENDER ONCE
2990 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2991 application.SendNotification(); // Input, Expected Input, Expected
2992 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2993 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2995 // FINISH RESOURCE LOADING
2996 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2997 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2998 application.GetPlatform().ClearReadyResources();
2999 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3004 //int UtcDaliRenderTaskOnceNoSync06(void)
3006 TestApplication application;
3008 tet_infoline("Testing RenderTask Render Once\n"
3009 "During RenderOnce, make ready resources unready before sending first finished signal\n"
3010 "PRE: Everything ready.\n"
3011 "POST: Finished signal sent only once");
3013 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3014 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3015 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3016 drawTrace.Enable(true);
3018 Actor rootActor = Actor::New();
3019 Stage::GetCurrent().Add( rootActor );
3021 CameraActor offscreenCameraActor = CameraActor::New();
3022 Stage::GetCurrent().Add( offscreenCameraActor );
3023 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3024 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3025 Integration::ResourceId imageRequestId = imageRequest->GetId();
3026 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
3027 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
3028 application.Render();
3029 application.GetPlatform().ClearReadyResources();
3031 Stage::GetCurrent().Add(secondRootActor);
3033 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3034 bool finished = false;
3035 RenderTaskFinished renderTaskFinished( finished );
3036 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3037 application.SendNotification();
3039 // START PROCESS/RENDER Input, Expected Input, Expected
3040 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3041 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
3043 // CHANGE TO RENDER ONCE, RESOURCES BECOME NOT READY
3044 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3047 ReloadImage(application, secondRootActor.GetImage());
3048 application.SendNotification(); // Input, Expected Input, Expected
3050 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3051 DALI_TEST_EQUALS( secondRootActor.GetImage().GetLoadingState(), Dali::ResourceLoading, TEST_LOCATION);
3052 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3054 // FINISH RESOURCE LOADING
3055 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
3056 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, true, true, __LINE__ ) );
3057 application.GetPlatform().ClearReadyResources();
3058 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3059 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3060 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3061 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3066 int UtcDaliRenderTaskOnceNoSync07(void)
3068 TestApplication application;
3070 tet_infoline("Testing RenderTask Render Once\n"
3071 "Render once, Second call to SetRefreshRate(ONCE) triggers only one more finished signal\n"
3072 "PRE: Everything ready\n"
3073 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
3075 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3076 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3077 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3078 drawTrace.Enable(true);
3080 Actor rootActor = Actor::New();
3081 Stage::GetCurrent().Add( rootActor );
3083 CameraActor offscreenCameraActor = CameraActor::New();
3084 Stage::GetCurrent().Add( offscreenCameraActor );
3085 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3086 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3087 Integration::ResourceId imageRequestId = imageRequest->GetId();
3088 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
3089 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
3090 application.Render();
3091 application.GetPlatform().ClearReadyResources();
3093 Stage::GetCurrent().Add(secondRootActor);
3095 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3096 bool finished = false;
3097 RenderTaskFinished renderTaskFinished( finished );
3098 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3099 application.SendNotification();
3101 // START PROCESS/RENDER Input, Expected Input, Expected
3102 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
3104 // CHANGE TO RENDER ONCE,
3105 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3106 application.SendNotification();
3107 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3108 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3110 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3111 application.SendNotification();
3112 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3113 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3117 int UtcDaliRenderTaskOnceNoSync08(void)
3119 TestApplication application;
3121 tet_infoline("Testing RenderTask Render Once\n"
3122 "Render once, Call to SetRefreshRate(ONCE) in Finished signal callback triggers\n"
3123 "another render & another finished signal\n"
3124 "PRE: Everything ready\n"
3125 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
3128 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3129 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3130 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3131 drawTrace.Enable(true);
3133 Actor rootActor = Actor::New();
3134 Stage::GetCurrent().Add( rootActor );
3136 CameraActor offscreenCameraActor = CameraActor::New();
3137 Stage::GetCurrent().Add( offscreenCameraActor );
3138 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3139 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3140 Integration::ResourceId imageRequestId = imageRequest->GetId();
3141 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
3142 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
3143 application.Render();
3144 application.GetPlatform().ClearReadyResources();
3146 Stage::GetCurrent().Add(secondRootActor);
3148 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3149 bool finished = false;
3151 ConnectionTracker connectionTracker;
3152 RenderTaskFinishedRenderAgain renderTaskFinishedRenderAgain( finished );
3153 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinishedRenderAgain );
3155 application.SendNotification();
3157 // START PROCESS/RENDER Input, Expected Input, Expected
3158 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
3160 // CHANGE TO RENDER ONCE,
3161 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3162 application.SendNotification();
3163 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3164 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3166 // Expect SetRefreshRate to have been called again
3167 // Prevent next finished signal calling refresh once again
3168 RenderTaskFinished renderTaskFinished( finished );
3169 connectionTracker.DisconnectAll();
3170 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinished );
3172 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3173 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3178 int UtcDaliRenderTaskOnceNoSync09(void)
3180 TestApplication application;
3182 tet_infoline("Testing RenderTask Render Once\n"
3183 "SetRefreshRate(ONCE) again before first finished signal has been sent.\n"
3184 "PRE: resources ready\n"
3185 "POST: Only 1 finished signal sent.");
3187 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3188 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3189 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3190 drawTrace.Enable(true);
3192 Actor rootActor = Actor::New();
3193 Stage::GetCurrent().Add( rootActor );
3195 CameraActor offscreenCameraActor = CameraActor::New();
3196 Stage::GetCurrent().Add( offscreenCameraActor );
3197 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3198 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3199 Integration::ResourceId imageRequestId = imageRequest->GetId();
3200 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
3201 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
3202 application.Render();
3203 application.GetPlatform().ClearReadyResources();
3205 Stage::GetCurrent().Add(secondRootActor);
3207 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3208 bool finished = false;
3209 RenderTaskFinished renderTaskFinished( finished );
3210 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3211 application.SendNotification();
3213 // START PROCESS/RENDER Input, Expected Input, Expected
3214 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
3216 // CHANGE TO RENDER ONCE,
3217 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3218 application.SendNotification();
3219 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3220 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3222 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3223 application.SendNotification();
3224 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3225 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3229 int UtcDaliRenderTaskOnceNoSync10(void)
3231 TestApplication application;
3233 tet_infoline("Testing RenderTask Render Once\n"
3234 "SetRefreshRate(ONCE), resource load failed, completes render task.\n"
3235 "PRE: resources not ready\n"
3236 "POST: Only 1 finished signal sent.");
3238 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3239 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3240 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3241 drawTrace.Enable(true);
3243 Actor rootActor = Actor::New();
3244 Stage::GetCurrent().Add( rootActor );
3246 CameraActor offscreenCameraActor = CameraActor::New();
3247 Stage::GetCurrent().Add( offscreenCameraActor );
3248 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3249 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3250 Integration::ResourceId imageRequestId = imageRequest->GetId();
3251 Stage::GetCurrent().Add(secondRootActor);
3253 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3254 bool finished = false;
3255 RenderTaskFinished renderTaskFinished( finished );
3256 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3257 application.SendNotification();
3259 // START PROCESS/RENDER Input, Expected Input, Expected
3260 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3261 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3263 // CHANGE TO RENDER ONCE,
3264 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3265 application.SendNotification();
3266 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3267 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3268 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3270 FailImageLoad(application, imageRequestId); // Need to run Update again for this to complete
3271 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); // nothing to draw
3272 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3279 int UtcDaliRenderTaskOnceChain01(void)
3281 TestApplication application;
3283 tet_infoline("Testing RenderTask Render Once Chained render tasks\n"
3284 "SetRefreshRate(ONCE), resource load completes, both render tasks render.\n"
3285 "PRE: resources not ready\n"
3286 "POST: 2 finished signals sent.");
3288 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3289 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3290 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3291 drawTrace.Enable(true);
3293 Actor defaultRootActor = Actor::New(); // Root for default RT
3294 Stage::GetCurrent().Add( defaultRootActor );
3296 CameraActor offscreenCameraActor = CameraActor::New();
3297 Stage::GetCurrent().Add( offscreenCameraActor );
3298 Actor firstRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3299 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3300 Integration::ResourceId imageRequestId = imageRequest->GetId();
3301 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
3302 Stage::GetCurrent().Add(firstRootActor);
3304 // first render task
3305 RenderTask firstTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, firstRootActor, RenderTask::REFRESH_ONCE, false);
3306 bool firstFinished = false;
3307 RenderTaskFinished renderTask1Finished( firstFinished );
3308 firstTask.FinishedSignal().Connect( &application, renderTask1Finished );
3310 // Second render task
3311 FrameBufferImage fbo = firstTask.GetTargetFrameBuffer();
3312 Actor secondRootActor = CreateRenderableActor( fbo );
3313 Stage::GetCurrent().Add(secondRootActor);
3314 RenderTask secondTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
3315 bool secondFinished = false;
3316 RenderTaskFinished renderTask2Finished( secondFinished );
3317 secondTask.FinishedSignal().Connect( &application, renderTask2Finished );
3319 application.SendNotification();
3321 // START PROCESS/RENDER Input, Expected Input, Expected
3322 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__ ) );
3323 DALI_TEST_CHECK( firstFinished == false );
3324 DALI_TEST_CHECK( secondFinished == false );
3325 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__ ) );
3326 DALI_TEST_CHECK( firstFinished == false );
3327 DALI_TEST_CHECK( secondFinished == false );
3329 CompleteImageLoad(application, imageRequestId, imageType);
3330 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__ ) );
3331 DALI_TEST_CHECK( firstFinished == false );
3332 DALI_TEST_CHECK( secondFinished == false );
3334 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, true, true, __LINE__ ) );
3335 DALI_TEST_CHECK( firstFinished == true );
3336 DALI_TEST_CHECK( secondFinished == false );
3338 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, secondFinished, true, false, __LINE__ ) );
3339 DALI_TEST_CHECK( secondFinished == true );
3344 int UtcDaliRenderTaskProperties(void)
3346 TestApplication application;
3348 RenderTask task = Stage::GetCurrent().GetRenderTaskList().CreateTask();
3350 Property::IndexContainer indices;
3351 task.GetPropertyIndices( indices );
3352 DALI_TEST_CHECK( indices.Size() );
3353 DALI_TEST_EQUALS( indices.Size(), task.GetPropertyCount(), TEST_LOCATION );
3357 int UtcDaliRenderTaskSetScreenToFrameBufferMappingActor(void)
3359 TestApplication application;
3360 tet_infoline("Testing RenderTask::SetScreenToFrameBufferMappingActor ");
3362 Stage stage = Stage::GetCurrent();
3363 Size stageSize = stage.GetSize();
3364 Actor mappingActor = Actor::New();
3365 Vector2 scale( 0.6f, 0.75f);
3366 Vector2 offset( stageSize.x*0.1f, stageSize.y*0.15f);
3367 mappingActor.SetSize( stageSize * scale );
3368 mappingActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
3369 mappingActor.SetPosition( offset.x, offset.y );
3370 stage.Add( mappingActor );
3372 Actor offscreenActor = Actor::New();
3373 offscreenActor.SetSize( stageSize );
3374 offscreenActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
3375 stage.Add( offscreenActor );
3377 RenderTaskList taskList = stage.GetRenderTaskList();
3378 RenderTask renderTask = taskList.CreateTask();
3379 FrameBufferImage frameBufferImage = FrameBufferImage::New(stageSize.width*scale.x, stageSize.height*scale.y, Pixel::A8, Image::NEVER);
3380 renderTask.SetSourceActor( offscreenActor );
3381 renderTask.SetExclusive( true );
3382 renderTask.SetInputEnabled( true );
3383 renderTask.SetTargetFrameBuffer( frameBufferImage );
3384 renderTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
3385 renderTask.SetScreenToFrameBufferMappingActor( mappingActor );
3386 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3388 // Render and notify
3389 application.SendNotification();
3390 application.Render();
3391 application.Render();
3392 application.SendNotification();
3394 Vector2 screenCoordinates( stageSize.x * 0.05f, stageSize.y * 0.05f );
3395 Dali::HitTestAlgorithm::Results results;
3396 DALI_TEST_CHECK( !results.actor );
3397 DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
3398 // miss expected, results not changed
3399 DALI_TEST_CHECK( false == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3400 DALI_TEST_CHECK( !results.actor );
3401 DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
3403 screenCoordinates.x = stageSize.x * 0.265f;
3404 screenCoordinates.y = stageSize.y * 0.33f;
3405 results.actor = Actor();
3406 results.actorCoordinates = Vector2::ZERO;
3407 // hit expected, results changed
3408 DALI_TEST_CHECK( true == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3409 DALI_TEST_CHECK( results.actor == offscreenActor );
3410 DALI_TEST_EQUALS( (screenCoordinates-offset)/scale , results.actorCoordinates, 0.1f, TEST_LOCATION );
3412 screenCoordinates.x = stageSize.x * 0.435f;
3413 screenCoordinates.y = stageSize.y * 0.52f;
3414 // hit expected, results changed
3415 DALI_TEST_CHECK( true == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3416 DALI_TEST_CHECK( results.actor == offscreenActor );
3417 const Vector2 expectedCoordinates = (screenCoordinates-offset)/scale;
3418 DALI_TEST_EQUALS( expectedCoordinates , results.actorCoordinates, 0.1f, TEST_LOCATION );
3420 screenCoordinates.x = stageSize.x * 0.65f;
3421 screenCoordinates.y = stageSize.y * 0.95f;
3422 // miss expected, results not changed
3423 DALI_TEST_CHECK( false == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3424 DALI_TEST_CHECK( results.actor == offscreenActor );
3425 DALI_TEST_EQUALS( expectedCoordinates , results.actorCoordinates, 0.1f, TEST_LOCATION );
3429 int UtcDaliRenderTaskFinishInvisibleSourceActor(void)
3431 TestApplication application;
3433 tet_infoline("Testing RenderTask::FinishInvisibleSourceActor()");
3435 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3436 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
3438 CameraActor offscreenCameraActor = CameraActor::New();
3440 Stage::GetCurrent().Add( offscreenCameraActor );
3442 BufferImage image = BufferImage::New( 10, 10 );
3443 Actor rootActor = CreateRenderableActor( image );
3444 rootActor.SetSize( 10, 10 );
3445 rootActor.SetVisible(false);
3446 Stage::GetCurrent().Add( rootActor );
3448 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3449 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
3450 FrameBufferImage frameBufferImage = FrameBufferImage::New( *testNativeImagePtr.Get() );
3452 // Flush all outstanding messages
3453 application.SendNotification();
3454 application.Render();
3456 RenderTask newTask = taskList.CreateTask();
3457 newTask.SetCameraActor( offscreenCameraActor );
3458 newTask.SetSourceActor( rootActor );
3459 newTask.SetInputEnabled( false );
3460 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
3461 newTask.SetClearEnabled( true );
3462 newTask.SetExclusive( true );
3463 newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
3464 newTask.SetTargetFrameBuffer( frameBufferImage );
3465 newTask.SetProperty( RenderTask::Property::REQUIRES_SYNC, true );
3467 // Framebuffer doesn't actually get created until Connected, i.e. by previous line
3469 bool finished = false;
3470 RenderTaskFinished renderTaskFinished( finished );
3471 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3473 // Flush the queue and render.
3474 application.SendNotification();
3476 // 1 render to process render task, then wait for sync before finished msg is sent
3477 // from update to the event thread.
3479 application.Render();
3480 application.SendNotification();
3481 DALI_TEST_CHECK( !finished );
3483 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
3484 DALI_TEST_CHECK( lastSyncObj != NULL );
3486 application.Render();
3487 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
3488 application.SendNotification();
3489 DALI_TEST_CHECK( !finished );
3491 application.Render();
3492 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
3493 application.SendNotification();
3494 DALI_TEST_CHECK( ! finished );
3496 sync.SetObjectSynced( lastSyncObj, true );
3498 application.Render();
3499 application.SendNotification();
3500 DALI_TEST_CHECK( !finished );
3502 application.Render();
3503 application.SendNotification();
3504 DALI_TEST_CHECK( finished );
3507 application.Render(); // Double check no more finished signal
3508 application.SendNotification();
3509 DALI_TEST_CHECK( ! finished );
3514 int UtcDaliRenderTaskFinishMissingImage(void)
3516 TestApplication application;
3518 // Previously we had bugs where not having a resource ID would cause render-tasks to wait forever
3519 tet_infoline("Testing RenderTask::SignalFinished() when an Actor has no Image set");
3521 Stage stage = Stage::GetCurrent();
3523 BufferImage image = BufferImage::New( 10, 10 );
3524 Actor rootActor = CreateRenderableActor( image );
3525 rootActor.SetSize( 10, 10 );
3526 stage.Add( rootActor );
3528 Actor actorWithMissingImage = CreateRenderableActor( Image() );
3529 actorWithMissingImage.SetSize( 10, 10 );
3530 stage.Add( actorWithMissingImage );
3532 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3533 RenderTask newTask = taskList.CreateTask();
3534 newTask.SetInputEnabled( false );
3535 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
3536 newTask.SetClearEnabled( true );
3537 newTask.SetExclusive( true );
3538 newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
3540 bool finished = false;
3541 RenderTaskFinished renderTaskFinished( finished );
3542 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3544 // 1 render to process render task, then 1 before finished msg is sent from update to the event thread.
3545 application.SendNotification();
3546 application.Render();
3547 application.Render();
3549 application.SendNotification();
3550 DALI_TEST_CHECK( finished );
3555 int UtcDaliRenderTaskWorldToViewport(void)
3557 TestApplication application( static_cast<size_t>(400), static_cast<size_t>(400) ); // square surface
3559 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3561 Actor actor = Actor::New();
3562 actor.SetSize(100.0f, 100.0f);
3563 actor.SetPosition( Vector3(0.0, 0.0, 0.0) );
3565 actor.SetParentOrigin( Vector3(0.5, 0.5, 0.5) );
3566 actor.SetAnchorPoint( Vector3(0.5, 0.5, 0.5) );
3568 Stage::GetCurrent().Add(actor);
3570 application.SendNotification();
3571 application.Render();
3572 application.SendNotification();
3574 RenderTask task = taskList.GetTask( 0u );
3576 CameraActor camera = task.GetCameraActor();
3578 Vector2 screenSize = task.GetCurrentViewportSize();
3580 float screenX = 0.0;
3581 float screenY = 0.0;
3583 bool ok = task.WorldToViewport(actor.GetCurrentWorldPosition(), screenX, screenY);
3584 DALI_TEST_CHECK(ok == true);
3586 DALI_TEST_EQUALS(screenX, screenSize.x/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
3587 DALI_TEST_EQUALS(screenY, screenSize.y/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
3589 Actor actor2 = Actor::New();
3590 float actor2Size = 100.f;
3591 actor2.SetSize( actor2Size, actor2Size );
3592 actor2.SetPosition( Vector3(0.0, 0.0, 0.0) );
3593 actor2.SetParentOrigin( Vector3(0.5, 0.5, 0.0) );
3594 actor2.SetAnchorPoint( Vector3(0.5, 0.5, 0.0) );
3595 Stage::GetCurrent().Add( actor2 );
3597 actor.SetParentOrigin( Vector3(0,0,0) );
3599 application.SendNotification();
3600 application.Render();
3601 application.SendNotification();
3603 ok = task.WorldToViewport(actor.GetCurrentWorldPosition(), screenX, screenY);
3604 DALI_TEST_CHECK(ok == true);
3606 DALI_TEST_EQUALS(screenX, screenSize.x/2 - actor2Size/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
3607 DALI_TEST_EQUALS(screenY, screenSize.y/2 - actor2Size/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
3613 int UtcDaliRenderTaskViewportToLocal(void)
3615 TestApplication application;
3616 Actor actor = Actor::New();
3617 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
3618 actor.SetSize(100.0f, 100.0f);
3619 actor.SetPosition(10.0f, 10.0f);
3620 Stage::GetCurrent().Add(actor);
3622 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3623 RenderTask task = taskList.GetTask( 0u );
3625 // flush the queue and render once
3626 application.SendNotification();
3627 application.Render();
3628 application.SendNotification();
3629 application.Render();
3637 float screenX = 50.0f;
3638 float screenY = 50.0f;
3640 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, screenX, screenY) );
3642 DALI_TEST_CHECK( task.ViewportToLocal(actor, screenX, screenY, rtLocalX, rtLocalY ) );
3644 DALI_TEST_EQUALS(localX, rtLocalX, 0.01f, TEST_LOCATION);
3645 DALI_TEST_EQUALS(localY, rtLocalY, 0.01f, TEST_LOCATION);