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-test-suite-utils.h>
24 #include <dali/integration-api/debug.h>
25 #include <test-native-image.h>
27 #include <mesh-builder.h>
29 #define BOOLSTR(x) ((x)?"T":"F")
31 //& set: DaliRenderTask
35 void utc_dali_render_task_startup(void)
37 test_return_value = TET_UNDEF;
40 void utc_dali_render_task_cleanup(void)
42 test_return_value = TET_PASS;
48 * Constructor, Destructor, DownCast, New, copy constructor, assignment operator
50 * SetSourceActor 2+ve, 1-ve
51 * GetSourceActor 1+ve, 1-ve
52 * SetExclusive 2+ve, 0-ve
53 * IsExclusive 2+ve, 0-ve
54 * SetInputEnabled 1+ve, 0-ve
55 * GetInputEnabled 1+ve, 0-ve
56 * SetCameraActor 1+ve, 1-ve
57 * GetCameraActor 1+ve, 1-ve
58 * SetTargetFrameBuffer 1+ve, 1-ve
59 * GetTargetFrameBuffer 1+ve, 1-ve
60 * SetScreenToFrameBufferFunction 1+ve, 1-ve
61 * GetScreenToFrameBufferFunction 1+ve, 1-ve
62 * SetScreenToFrameBufferMappingActor 1+ve, 1-ve
63 * GetScreenToFrameBufferMappingActor 1+ve, 1-ve
64 * SetViewportPosition 1+ve
65 * GetCurrentViewportPosition 1+ve
66 * SetViewportSize 1+ve
67 * GetCurrentViewportSize 1+ve
68 * SetViewport 2+ve, 1-ve
69 * GetViewport 2+ve, 1-ve
70 * SetClearColor 1+ve, 1-ve
71 * GetClearColor 1+ve, 1-ve
72 * SetClearEnabled 1+ve, 1-ve
73 * GetClearEnabled 1+ve, 1-ve
81 namespace // unnamed namespace
84 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
87 * Simulate time passed by.
89 * @note this will always process at least 1 frame (1/60 sec)
91 * @param application Test application instance
92 * @param duration Time to pass in milliseconds.
93 * @return The actual time passed in milliseconds
95 int Wait(TestApplication& application, int duration = 0)
99 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
101 application.SendNotification();
102 application.Render(RENDER_FRAME_INTERVAL);
103 time += RENDER_FRAME_INTERVAL;
109 struct RenderTaskFinished
111 RenderTaskFinished( bool& finished )
112 : finished( finished )
116 void operator()( RenderTask& renderTask )
124 struct RenderTaskFinishedRemoveSource
126 RenderTaskFinishedRemoveSource( bool& finished )
127 : finished( finished ),
132 void operator()( RenderTask& renderTask )
134 DALI_TEST_CHECK(finishedOnce == false);
137 Actor srcActor = renderTask.GetSourceActor();
138 UnparentAndReset(srcActor);
145 struct RenderTaskFinishedRenderAgain
147 RenderTaskFinishedRenderAgain( bool& finished )
148 : finished( finished ),
153 void operator()( RenderTask& renderTask )
155 DALI_TEST_CHECK(finishedOnce == false);
158 renderTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
166 bool TestScreenToFrameBufferFunction( Vector2& coordinates )
168 coordinates = coordinates + Vector2( 1, 2 );
173 ImageActor CreateLoadingImageActor(TestApplication& application, std::string filename, ResourceImage::LoadPolicy loadPolicy, Image::ReleasePolicy releasePolicy)
175 Image image = ResourceImage::New(filename, loadPolicy, releasePolicy);
176 DALI_TEST_CHECK( image );
177 application.SendNotification();
178 application.Render(16);
179 DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
180 ImageActor actor = ImageActor::New(image);
181 actor.SetSize( 80, 80 );
182 application.SendNotification();
183 application.Render(16);
187 Image CreateLoadingImage(TestApplication& application, std::string filename, ResourceImage::LoadPolicy loadPolicy, Image::ReleasePolicy releasePolicy)
189 Image image = ResourceImage::New(filename, loadPolicy, releasePolicy);
190 DALI_TEST_CHECK( image );
191 application.SendNotification();
192 application.Render(16);
193 DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
198 void CompleteImageLoad(TestApplication& application, Integration::ResourceId resourceId, Integration::ResourceTypeId requestType)
200 std::vector<GLuint> ids;
202 application.GetGlAbstraction().SetNextTextureIds( ids );
204 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
205 Integration::ResourcePointer resource(bitmap);
206 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80);
208 application.GetPlatform().SetResourceLoaded(resourceId, requestType, resource);
211 void FailImageLoad(TestApplication& application, Integration::ResourceId resourceId )
213 application.GetPlatform().SetResourceLoadFailed(resourceId, Integration::FailureUnknown);
216 void ReloadImage(TestApplication& application, ResourceImage image)
218 application.GetPlatform().ClearReadyResources();
219 application.GetPlatform().DiscardRequest();
220 application.GetPlatform().ResetTrace();
221 application.GetPlatform().SetClosestImageSize(Vector2(80.0f, 80.0f)); // Ensure reload is called.
225 RenderTask CreateRenderTask(TestApplication& application,
226 CameraActor offscreenCamera,
227 Actor rootActor, // Reset default render task to point at this actor
228 Actor secondRootActor, // Source actor
229 unsigned int refreshRate,
232 // Change main render task to use a different root
233 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
234 taskList.GetTask(0u).SetSourceActor( rootActor );
236 FrameBufferImage frameBufferImage;
239 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
240 frameBufferImage= FrameBufferImage::New( *(testNativeImagePtr.Get()) );
244 frameBufferImage = FrameBufferImage::New( 10, 10 );
247 // Don't draw output framebuffer // '
249 RenderTask newTask = taskList.CreateTask();
250 newTask.SetCameraActor( offscreenCamera );
251 newTask.SetSourceActor( secondRootActor );
252 newTask.SetInputEnabled( false );
253 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
254 newTask.SetClearEnabled( true );
255 newTask.SetExclusive( true );
256 newTask.SetRefreshRate( refreshRate );
257 newTask.SetTargetFrameBuffer( frameBufferImage );
261 bool UpdateRender(TestApplication& application, TraceCallStack& callStack, bool testDrawn, bool& finishedSig, bool testFinished, bool testKeepUpdating, int lineNumber )
266 tet_printf("TestApplication::UpdateRender().\n");
268 application.Render(16);
269 application.SendNotification();
271 bool sigPassed = false;
274 sigPassed = finishedSig;
278 sigPassed = ! finishedSig;
281 bool drawResult = callStack.FindMethod("DrawElements") || callStack.FindMethod("DrawArrays");
283 bool drawPassed = false;
286 drawPassed = drawResult;
290 drawPassed = !drawResult;
293 bool keepUpdating = (application.GetUpdateStatus() != 0);
294 bool keepUpdatingPassed = false;
295 if( testKeepUpdating )
297 keepUpdatingPassed = keepUpdating;
301 keepUpdatingPassed = !keepUpdating;
304 bool result = (sigPassed && drawPassed && keepUpdatingPassed);
306 tet_printf("UpdateRender: Expected: Draw:%s Signal:%s KeepUpdating: %s Actual: Draw:%s Signal:%s KeepUpdating: %s %s, line %d\n",
307 BOOLSTR(testDrawn), BOOLSTR(testFinished), BOOLSTR(testKeepUpdating),
308 BOOLSTR(drawResult), BOOLSTR(finishedSig), BOOLSTR(keepUpdating),
309 result ? "Passed":"Failed",
315 // The functor to be used in the hit-test algorithm to check whether the actor is hittable.
316 bool IsActorHittableFunction(Actor actor, Dali::HitTestAlgorithm::TraverseType type)
318 bool hittable = false;
322 case Dali::HitTestAlgorithm::CHECK_ACTOR:
324 // Check whether the actor is visible and not fully transparent.
325 if( actor.IsVisible()
326 && actor.GetCurrentWorldColor().a > 0.01f) // not FULLY_TRANSPARENT
333 case Dali::HitTestAlgorithm::DESCEND_ACTOR_TREE:
335 if( actor.IsVisible() ) // Actor is visible, if not visible then none of its children are visible.
350 } // unnamed namespace
353 /****************************************************************************************************/
354 /****************************************************************************************************/
355 /******************************** TEST CASES BELOW **********************************************/
356 /****************************************************************************************************/
357 /****************************************************************************************************/
359 int UtcDaliRenderTaskDownCast01(void)
361 TestApplication application;
363 tet_infoline("Testing RenderTask::DownCast()");
365 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
367 BaseHandle base = taskList.GetTask( 0u );
368 DALI_TEST_CHECK( base );
370 RenderTask task = RenderTask::DownCast( base );
371 DALI_TEST_CHECK( task );
373 // Try calling a method
374 DALI_TEST_CHECK( task.GetSourceActor() );
378 int UtcDaliRenderTaskDownCast02(void)
380 TestApplication application;
382 tet_infoline("Testing RenderTask::DownCast()");
384 Actor actor = Actor::New();
386 RenderTask task = RenderTask::DownCast( actor );
387 DALI_TEST_CHECK( ! task );
392 int UtcDaliRenderTaskSetSourceActorN(void)
394 TestApplication application;
395 tet_infoline("Testing RenderTask::SetSourceActor() Negative - try with empty actor handle");
396 Stage stage = Stage::GetCurrent();
400 RenderTaskList taskList = stage.GetRenderTaskList();
401 RenderTask renderTask = taskList.CreateTask();
402 renderTask.SetSourceActor(srcActor);
404 application.SendNotification();
405 application.Render();
407 DALI_TEST_CHECK( ! renderTask.GetSourceActor() );
412 int UtcDaliRenderTaskSetSourceActorP01(void)
414 TestApplication application;
416 tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that setting a non-renderable actor stops existing source actor being rendered ");
418 Stage stage = Stage::GetCurrent();
420 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
422 RenderTaskList taskList = stage.GetRenderTaskList();
424 RenderTask task = taskList.GetTask( 0u );
426 Actor actor = task.GetSourceActor();
427 DALI_TEST_CHECK( actor );
429 std::vector<GLuint> ids;
431 application.GetGlAbstraction().SetNextTextureIds( ids );
433 BufferImage img = BufferImage::New( 1,1 );
434 ImageActor newActor = ImageActor::New( img );
435 newActor.SetSize(1,1);
436 stage.Add( newActor );
438 Actor nonRenderableActor = Actor::New();
439 stage.Add( nonRenderableActor );
441 // Stop the newActor from being rendered by changing the source actor
442 DALI_TEST_CHECK( nonRenderableActor );
443 task.SetSourceActor( nonRenderableActor );
444 DALI_TEST_CHECK( task.GetSourceActor() != actor );
445 DALI_TEST_CHECK( task.GetSourceActor() == nonRenderableActor );
447 // Update & Render nothing!
448 application.GetGlAbstraction().ClearBoundTextures();
449 application.SendNotification();
450 application.Render();
452 // Check that nothing was rendered
453 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
459 int UtcDaliRenderTaskSetSourceActorP02(void)
461 TestApplication application;
463 tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that switching source from a non-renderable to a renderable actor causes the texture to be drawn");
465 Stage stage = Stage::GetCurrent();
467 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
469 RenderTaskList taskList = stage.GetRenderTaskList();
471 RenderTask task = taskList.GetTask( 0u );
473 Actor actor = task.GetSourceActor();
474 DALI_TEST_CHECK( actor );
476 std::vector<GLuint> ids;
478 application.GetGlAbstraction().SetNextTextureIds( ids );
480 BufferImage img = BufferImage::New( 1,1 );
481 ImageActor newActor = ImageActor::New( img );
482 newActor.SetSize(1,1);
483 stage.Add( newActor );
485 Actor nonRenderableActor = Actor::New();
486 stage.Add( nonRenderableActor );
488 // Stop the newActor from being rendered by changing the source actor
489 DALI_TEST_CHECK( nonRenderableActor );
490 task.SetSourceActor( nonRenderableActor );
491 DALI_TEST_CHECK( task.GetSourceActor() != actor );
492 DALI_TEST_CHECK( task.GetSourceActor() == nonRenderableActor );
494 // Update & Render nothing!
495 application.GetGlAbstraction().ClearBoundTextures();
496 application.SendNotification();
497 application.Render();
499 // Check that nothing was rendered
500 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
502 // Set newActor as the new source Actor
503 task.SetSourceActor( newActor );
504 DALI_TEST_CHECK( task.GetSourceActor() != actor );
505 DALI_TEST_CHECK( task.GetSourceActor() == newActor );
507 // Update & Render the newActor
508 application.GetGlAbstraction().ClearBoundTextures();
509 application.SendNotification();
510 application.Render();
512 // Check that the newActor was rendered
513 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
514 if ( boundTextures.size() )
516 DALI_TEST_EQUALS( boundTextures[0], 7u, TEST_LOCATION );
521 int UtcDaliRenderTaskSetSourceActorOffStage(void)
523 TestApplication application;
525 tet_infoline("Testing RenderTask::SetSourceActor (on/off stage testing)");
527 Stage stage = Stage::GetCurrent();
529 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
531 RenderTaskList taskList = stage.GetRenderTaskList();
533 RenderTask task = taskList.GetTask( 0u );
535 Actor actor = task.GetSourceActor();
536 DALI_TEST_CHECK( actor );
538 std::vector<GLuint> ids;
539 GLuint expectedTextureId( 3 );
540 ids.push_back( expectedTextureId );
541 application.GetGlAbstraction().SetNextTextureIds( ids );
543 BufferImage img = BufferImage::New( 1,1 );
544 ImageActor newActor = ImageActor::New( img );
545 newActor.SetSize(1,1);
546 task.SetSourceActor( newActor );
547 // Don't add newActor to stage yet //'
549 // Update & Render with the actor initially off-stage
550 application.GetGlAbstraction().ClearBoundTextures();
551 application.SendNotification();
552 application.Render();
554 // Check that nothing was rendered
555 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
558 stage.Add( newActor );
560 // Update & Render with the actor on-stage
561 application.GetGlAbstraction().ClearBoundTextures();
562 application.SendNotification();
563 application.Render();
565 // Check that the newActor was rendered
566 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
567 if ( boundTextures.size() )
569 DALI_TEST_EQUALS( boundTextures[0], expectedTextureId, TEST_LOCATION );
572 // Now remove from stage
573 stage.Remove( newActor );
575 // Update & Render with the actor off-stage
576 application.GetGlAbstraction().ClearBoundTextures();
577 application.SendNotification();
578 application.Render();
582 int UtcDaliRenderTaskSetSourceActorEmpty(void)
584 TestApplication application;
586 tet_infoline("Testing RenderTask::SetSourceActor (empty handle case)");
588 Stage stage = Stage::GetCurrent();
590 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
592 RenderTaskList taskList = stage.GetRenderTaskList();
594 RenderTask task = taskList.GetTask( 0u );
596 Actor actor = task.GetSourceActor();
597 DALI_TEST_CHECK( actor );
599 std::vector<GLuint> ids;
600 GLuint expectedTextureId( 5 );
601 ids.push_back( expectedTextureId );
602 application.GetGlAbstraction().SetNextTextureIds( ids );
604 BufferImage img = BufferImage::New( 1,1 );
605 ImageActor newActor = ImageActor::New( img );
606 newActor.SetSize(1,1);
607 stage.Add( newActor );
609 Actor nonRenderableActor = Actor::New();
610 stage.Add( nonRenderableActor );
612 // Set with empty handle
613 task.SetSourceActor( Actor() );
614 DALI_TEST_CHECK( ! task.GetSourceActor() );
616 // Update & Render nothing!
617 application.GetGlAbstraction().ClearBoundTextures();
618 application.SendNotification();
619 application.Render();
621 // Check that nothing was rendered
622 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
624 // Set with non-empty handle
625 task.SetSourceActor( newActor );
626 DALI_TEST_CHECK( task.GetSourceActor() == newActor );
628 // Update & Render the newActor
629 application.GetGlAbstraction().ClearBoundTextures();
630 application.SendNotification();
631 application.Render();
633 // Check that the newActor was rendered
634 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
635 if ( boundTextures.size() )
637 DALI_TEST_EQUALS( boundTextures[0], expectedTextureId, TEST_LOCATION );
642 int UtcDaliRenderTaskGetSourceActorP01(void)
644 TestApplication application;
646 tet_infoline("Testing RenderTask::GetSourceActor() Check the default render task has a valid source actor");
648 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
650 RenderTask task = taskList.GetTask( 0u );
652 Actor actor = task.GetSourceActor();
653 DALI_TEST_CHECK( actor );
655 // By default the entire scene should be rendered
656 Actor root = Stage::GetCurrent().GetLayer( 0 );
657 DALI_TEST_CHECK( root == actor );
661 int UtcDaliRenderTaskGetSourceActorP02(void)
663 TestApplication application;
665 tet_infoline("Testing RenderTask::GetSourceActor() Create a new render task, Add a new actor to the stage and set it as the source of the new render task. Get its source actor and check that it is equivalent to what was set.");
667 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
668 RenderTask task = taskList.CreateTask();
669 Actor actor = Actor::New();
670 Stage::GetCurrent().Add(actor);
671 task.SetSourceActor( actor );
673 DALI_TEST_EQUALS( actor, task.GetSourceActor(), TEST_LOCATION );
678 int UtcDaliRenderTaskGetSourceActorN(void)
680 TestApplication application;
682 tet_infoline("Testing RenderTask::GetSourceActor() Try with empty handle");
687 Actor actor = task.GetSourceActor();
689 catch (Dali::DaliException(e))
691 DALI_TEST_PRINT_ASSERT( e );
692 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
698 int UtcDaliRenderTaskSetExclusive(void)
700 TestApplication application;
702 tet_infoline("Testing RenderTask::SetExclusive() Check that exclusion works");
704 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
706 // Manipulate the GenTextures behaviour, to identify different ImageActors
708 std::vector<GLuint> ids;
709 ids.push_back( 8 ); // 8 = actor1
710 ids.push_back( 9 ); // 9 = actor2
711 ids.push_back( 10 ); // 10 = actor3
712 application.GetGlAbstraction().SetNextTextureIds( ids );
714 BufferImage img1 = BufferImage::New( 1,1 );
715 ImageActor actor1 = ImageActor::New( img1 );
717 Stage::GetCurrent().Add( actor1 );
719 // Update & Render actor1
720 application.SendNotification();
721 application.Render();
723 // Check that the actor1 was rendered
724 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
725 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
727 if ( boundTextures.size() )
729 DALI_TEST_EQUALS( boundTextures[0], 8u/*unique to actor1*/, TEST_LOCATION );
732 BufferImage img2 = BufferImage::New( 1,1 );
733 ImageActor actor2 = ImageActor::New( img2 );
736 // Force actor2 to be rendered before actor1
737 Layer layer = Layer::New();
738 Stage::GetCurrent().Add( layer );
740 layer.LowerToBottom();
743 application.GetGlAbstraction().ClearBoundTextures();
744 application.SendNotification();
745 application.Render();
747 // Check that the actors were rendered
748 DALI_TEST_EQUALS( boundTextures.size(), 2u, TEST_LOCATION );
750 if ( boundTextures.size() )
752 DALI_TEST_EQUALS( boundTextures[0], 9u/*unique to actor2*/, TEST_LOCATION );
753 DALI_TEST_EQUALS( boundTextures[1], 8u/*unique to actor1*/, TEST_LOCATION );
756 BufferImage img3 = BufferImage::New( 1,1 );
757 ImageActor actor3 = ImageActor::New( img3 );
760 // Force actor3 to be rendered before actor2
761 layer = Layer::New();
762 Stage::GetCurrent().Add( layer );
764 layer.LowerToBottom();
766 // Update & Render all actors
767 application.GetGlAbstraction().ClearBoundTextures();
768 application.SendNotification();
769 application.Render();
771 // Check that the actors were rendered
772 DALI_TEST_EQUALS( boundTextures.size(), 3u, TEST_LOCATION );
774 if ( boundTextures.size() )
776 DALI_TEST_EQUALS( boundTextures[0], 10u/*unique to actor3*/, TEST_LOCATION );
777 DALI_TEST_EQUALS( boundTextures[1], 9u/*unique to actor2*/, TEST_LOCATION );
778 DALI_TEST_EQUALS( boundTextures[2], 8u/*unique to actor1*/, TEST_LOCATION );
781 // Both actors are now connected to the root node
782 // Setup 2 render-tasks - the first will render from the root-node, and the second from actor2
784 // Not exclusive is the default
785 RenderTask task1 = taskList.GetTask( 0u );
786 DALI_TEST_CHECK( false == task1.IsExclusive() );
788 RenderTask task2 = taskList.CreateTask();
789 DALI_TEST_CHECK( false == task2.IsExclusive() );
790 task2.SetSourceActor( actor2 );
792 // Task1 should render all actors, and task 2 should render only actor2
794 application.GetGlAbstraction().ClearBoundTextures();
795 application.SendNotification();
796 application.Render();
798 DALI_TEST_EQUALS( boundTextures.size(), 4u, TEST_LOCATION );
800 if ( boundTextures.size() == 4 )
802 // Test that task 1 renders actor3, then actor2 & then actor1
803 DALI_TEST_CHECK( boundTextures[0] == 10u );
804 DALI_TEST_CHECK( boundTextures[1] == 9u );
805 DALI_TEST_CHECK( boundTextures[2] == 8u );
807 // Test that task 2 renders actor2
808 DALI_TEST_EQUALS( boundTextures[3], 9u, TEST_LOCATION );
811 // Make actor2 exclusive to task2
813 task2.SetExclusive( true );
814 DALI_TEST_CHECK( true == task2.IsExclusive() );
816 // Task1 should render only actor1, and task 2 should render only actor2
818 application.GetGlAbstraction().ClearBoundTextures();
819 application.SendNotification();
820 application.Render();
822 DALI_TEST_EQUALS( boundTextures.size(), 3u, TEST_LOCATION );
823 if ( boundTextures.size() == 3 )
825 // Test that task 1 renders actor3 & actor1
826 DALI_TEST_CHECK( boundTextures[0] == 10u );
827 DALI_TEST_CHECK( boundTextures[1] == 8u );
829 // Test that task 2 renders actor2
830 DALI_TEST_CHECK( boundTextures[2] == 9u );
835 int UtcDaliRenderTaskSetExclusive02(void)
837 TestApplication application;
839 tet_infoline("Testing RenderTask::SetExclusive() Check that changing from exclusive to not-exclusive works");
841 std::vector<GLuint> ids;
842 ids.push_back( 8 ); // 8 = actor1
843 application.GetGlAbstraction().SetNextTextureIds( ids );
845 BufferImage img1 = BufferImage::New( 1,1 );
846 ImageActor actor1 = ImageActor::New( img1 );
848 Stage::GetCurrent().Add( actor1 );
850 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
851 RenderTask task = taskList.CreateTask();
853 task.SetSourceActor( actor1 );
854 task.SetExclusive(true); // Actor should only render once
856 TestGlAbstraction& gl = application.GetGlAbstraction();
857 TraceCallStack& drawTrace = gl.GetDrawTrace();
858 drawTrace.Enable(true);
860 // Update & Render actor1
861 application.SendNotification();
862 application.Render();
864 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION );
866 // Set task to non-exclusive - actor1 should render twice:
868 task.SetExclusive(false);
869 application.SendNotification();
870 application.Render();
872 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 2, TEST_LOCATION );
877 int UtcDaliRenderTaskSetExclusiveN(void)
879 TestApplication application;
881 tet_infoline("Testing RenderTask::SetExclusive() on empty handle");
886 task.SetExclusive(true);
888 catch (Dali::DaliException(e))
890 DALI_TEST_PRINT_ASSERT( e );
891 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
896 int UtcDaliRenderTaskIsExclusive01(void)
898 TestApplication application;
900 tet_infoline("Testing RenderTask::IsExclusive() Check default values are non-exclusive");
902 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
904 // Not exclusive is the default
905 RenderTask task = taskList.GetTask( 0u );
906 DALI_TEST_CHECK( false == task.IsExclusive() );
908 RenderTask newTask = taskList.CreateTask();
909 DALI_TEST_CHECK( false == newTask.IsExclusive() );
914 int UtcDaliRenderTaskIsExclusive02(void)
916 TestApplication application;
918 tet_infoline("Testing RenderTask::IsExclusive() Check the getter returns set values");
920 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
922 // Not exclusive is the default
923 RenderTask newTask = taskList.CreateTask();
924 DALI_TEST_EQUALS( newTask.IsExclusive(), false, TEST_LOCATION );
926 newTask.SetExclusive(true);
927 DALI_TEST_EQUALS( newTask.IsExclusive(), true, TEST_LOCATION );
931 int UtcDaliRenderTaskIsExclusiveN(void)
933 TestApplication application;
935 tet_infoline("Testing RenderTask::IsExclusive() on empty handle");
940 bool x = task.IsExclusive();
943 catch (Dali::DaliException(e))
945 DALI_TEST_PRINT_ASSERT( e );
946 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
951 int UtcDaliRenderTaskSetInputEnabled(void)
953 TestApplication application;
955 tet_infoline("Testing RenderTask::SetInputEnabled()");
957 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
959 // Input is enabled by default
960 RenderTask task = taskList.GetTask( 0u );
961 DALI_TEST_CHECK( true == task.GetInputEnabled() );
963 task.SetInputEnabled( false );
964 DALI_TEST_CHECK( false == task.GetInputEnabled() );
966 task.SetInputEnabled( true );
967 DALI_TEST_CHECK( true == task.GetInputEnabled() );
971 int UtcDaliRenderTaskGetInputEnabled(void)
973 TestApplication application;
975 tet_infoline("Testing RenderTask::GetInputEnabled()");
977 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
979 // Input is enabled by default
980 RenderTask task = taskList.GetTask( 0u );
981 DALI_TEST_EQUALS( true, task.GetInputEnabled(), TEST_LOCATION );
983 RenderTask newTask = taskList.CreateTask();
984 DALI_TEST_EQUALS( true, newTask.GetInputEnabled(), TEST_LOCATION );
986 newTask.SetInputEnabled(false);
987 DALI_TEST_EQUALS( false, newTask.GetInputEnabled(), TEST_LOCATION );
992 int UtcDaliRenderTaskSetCameraActorP(void)
994 TestApplication application;
996 tet_infoline("Testing RenderTask::SetCameraActor()");
998 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1000 RenderTask task = taskList.GetTask( 0u );
1002 Actor defaultCameraActor = task.GetCameraActor();
1003 DALI_TEST_CHECK( defaultCameraActor );
1005 CameraActor newCameraActor = CameraActor::New();
1006 DALI_TEST_CHECK( newCameraActor );
1008 task.SetCameraActor( newCameraActor );
1009 DALI_TEST_CHECK( task.GetCameraActor() != defaultCameraActor );
1010 DALI_TEST_EQUALS( task.GetCameraActor(), newCameraActor, TEST_LOCATION );
1015 int UtcDaliRenderTaskSetCameraActorN(void)
1017 TestApplication application;
1019 tet_infoline("Testing RenderTask::SetCameraActor() with empty actor handle");
1021 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1023 RenderTask task = taskList.GetTask( 0u );
1025 Actor actor = task.GetCameraActor();
1026 DALI_TEST_CHECK( actor );
1028 CameraActor cameraActor;
1030 task.SetCameraActor( cameraActor );
1031 DALI_TEST_EQUALS( (bool)task.GetCameraActor(), false, TEST_LOCATION );
1032 DALI_TEST_EQUALS( task.GetCameraActor(), cameraActor, TEST_LOCATION );
1037 int UtcDaliRenderTaskGetCameraActorP(void)
1039 TestApplication application;
1041 tet_infoline("Testing RenderTask::GetCameraActor()");
1043 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1045 RenderTask task = taskList.GetTask( 0u );
1047 CameraActor actor = task.GetCameraActor();
1048 DALI_TEST_CHECK( actor );
1049 DALI_TEST_EQUALS( actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION );
1050 DALI_TEST_GREATER( actor.GetFieldOfView(), 0.0f, TEST_LOCATION );
1054 int UtcDaliRenderTaskGetCameraActorN(void)
1056 TestApplication application;
1058 tet_infoline("Testing RenderTask::GetCameraActor() with empty handle");
1063 Actor actor = task.GetCameraActor();
1065 catch (Dali::DaliException(e))
1067 DALI_TEST_PRINT_ASSERT( e );
1068 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1074 int UtcDaliRenderTaskSetTargetFrameBufferP(void)
1076 TestApplication application;
1078 tet_infoline("Testing RenderTask::SetTargetFrameBuffer()");
1080 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1082 RenderTask task = taskList.GetTask( 0u );
1084 FrameBufferImage newImage = FrameBufferImage::New();
1085 task.SetTargetFrameBuffer( newImage );
1086 DALI_TEST_CHECK( task.GetTargetFrameBuffer() == newImage );
1090 int UtcDaliRenderTaskSetTargetFrameBufferN(void)
1092 TestApplication application;
1094 tet_infoline("Testing RenderTask::SetTargetFrameBuffer()");
1096 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1098 RenderTask task = taskList.GetTask( 0u );
1099 FrameBufferImage newImage; // Empty handle
1100 task.SetTargetFrameBuffer( newImage );
1101 DALI_TEST_EQUALS( (bool)task.GetTargetFrameBuffer(), false, TEST_LOCATION );
1105 int UtcDaliRenderTaskGetTargetFrameBufferP(void)
1107 TestApplication application;
1109 tet_infoline("Testing RenderTask::GetTargetFrameBuffer()");
1111 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1113 RenderTask newTask = taskList.CreateTask();
1114 FrameBufferImage fb = FrameBufferImage::New(128, 128, Pixel::RGBA8888);
1115 newTask.SetTargetFrameBuffer( fb );
1116 DALI_TEST_EQUALS( newTask.GetTargetFrameBuffer(), fb, TEST_LOCATION );
1120 int UtcDaliRenderTaskGetTargetFrameBufferN(void)
1122 TestApplication application;
1124 tet_infoline("Testing RenderTask::GetTargetFrameBuffer()");
1126 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1128 RenderTask task = taskList.GetTask( 0u );
1130 // By default render-tasks do not render off-screen
1131 FrameBufferImage image = task.GetTargetFrameBuffer();
1132 DALI_TEST_CHECK( !image );
1137 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionP(void)
1139 TestApplication application;
1141 tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1143 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1145 RenderTask task = taskList.GetTask( 0u );
1147 task.SetScreenToFrameBufferFunction( TestScreenToFrameBufferFunction );
1149 Vector2 coordinates( 5, 10 );
1150 Vector2 convertedCoordinates( 6, 12 ); // + Vector(1, 2)
1152 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1153 DALI_TEST_CHECK( func( coordinates ) );
1154 DALI_TEST_CHECK( coordinates == convertedCoordinates );
1156 task.SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
1157 func = task.GetScreenToFrameBufferFunction();
1158 DALI_TEST_CHECK( func( coordinates ) );
1160 task.SetScreenToFrameBufferFunction( RenderTask::DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION );
1161 func = task.GetScreenToFrameBufferFunction();
1162 DALI_TEST_CHECK( ! func( coordinates ) );
1166 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionN(void)
1168 TestApplication application;
1170 tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1172 RenderTask task; // Empty handle
1175 task.SetScreenToFrameBufferFunction( TestScreenToFrameBufferFunction );
1177 catch (Dali::DaliException(e))
1179 DALI_TEST_PRINT_ASSERT( e );
1180 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1185 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionP(void)
1187 TestApplication application;
1189 tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction()");
1191 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1193 RenderTask task = taskList.GetTask( 0u );
1195 Vector2 originalCoordinates( 5, 10 );
1196 Vector2 coordinates( 5, 10 );
1198 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1199 DALI_TEST_CHECK( !func( coordinates ) ); // conversion should fail by default
1200 DALI_TEST_CHECK( coordinates == originalCoordinates ); // coordinates should not be modified
1204 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionN(void)
1206 TestApplication application;
1208 tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction() on empty handle");
1213 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1216 catch (Dali::DaliException(e))
1218 DALI_TEST_PRINT_ASSERT( e );
1219 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1225 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorP(void)
1227 TestApplication application;
1228 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor ");
1230 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1231 RenderTask renderTask = taskList.CreateTask();
1232 Actor mappingActor = Actor::New();
1233 renderTask.SetScreenToFrameBufferMappingActor(mappingActor);
1235 DALI_TEST_EQUALS( mappingActor, renderTask.GetScreenToFrameBufferMappingActor(), TEST_LOCATION );
1240 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorN(void)
1242 TestApplication application;
1243 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1249 task.SetScreenToFrameBufferMappingActor(mappingActor);
1251 catch (Dali::DaliException(e))
1253 DALI_TEST_PRINT_ASSERT( e );
1254 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1259 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActor02N(void)
1261 TestApplication application;
1262 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1264 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1265 RenderTask renderTask = taskList.CreateTask();
1267 renderTask.SetScreenToFrameBufferMappingActor(actor);
1269 DALI_TEST_EQUALS( (bool)renderTask.GetScreenToFrameBufferMappingActor(), false, TEST_LOCATION);
1273 int UtcDaliRenderTaskGetViewportP01(void)
1275 TestApplication application;
1277 tet_infoline("Testing RenderTask::GetViewport() on default task");
1279 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1280 RenderTask task = taskList.GetTask( 0u );
1281 Viewport viewport = task.GetViewport();
1283 // By default the viewport should match the stage width/height
1284 Vector2 stageSize = Stage::GetCurrent().GetSize();
1285 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1286 DALI_TEST_CHECK( viewport == expectedViewport );
1290 int UtcDaliRenderTaskGetViewportP02(void)
1292 TestApplication application;
1294 tet_infoline("Testing RenderTask::GetViewport() on new task");
1296 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1297 RenderTask task = taskList.CreateTask();
1298 Viewport viewport = task.GetViewport();
1300 // By default the viewport should match the stage width/height
1301 Vector2 stageSize = Stage::GetCurrent().GetSize();
1302 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1303 DALI_TEST_CHECK( viewport == expectedViewport );
1307 int UtcDaliRenderTaskGetViewportN(void)
1309 TestApplication application;
1311 tet_infoline("Testing RenderTask::GetViewport() on empty handle");
1316 Viewport viewport = task.GetViewport();
1317 viewport = viewport;
1319 catch (Dali::DaliException(e))
1321 DALI_TEST_PRINT_ASSERT( e );
1322 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1328 int UtcDaliRenderTaskSetViewportP(void)
1330 TestApplication application;
1332 tet_infoline("Testing RenderTask::SetViewport()");
1334 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1336 RenderTask task = taskList.GetTask( 0u );
1337 Vector2 stageSize = Stage::GetCurrent().GetSize();
1338 Viewport newViewport( 0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f );
1339 task.SetViewport( newViewport );
1341 // Update (viewport is a property)
1342 application.SendNotification();
1343 application.Render();
1345 DALI_TEST_CHECK( task.GetViewport() == newViewport );
1349 int UtcDaliRenderTaskSetViewportN(void)
1351 TestApplication application;
1353 tet_infoline("Testing RenderTask::SetViewport()");
1355 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1360 Vector2 stageSize = Stage::GetCurrent().GetSize();
1361 Viewport newViewport( 0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f );
1362 task.SetViewport( newViewport );
1364 catch (Dali::DaliException(e))
1366 DALI_TEST_PRINT_ASSERT( e );
1367 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1374 int UtcDaliRenderTaskSetViewportPosition(void)
1376 TestApplication application;
1378 tet_infoline("Testing RenderTask::SetViewportPosition()");
1380 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1382 RenderTask task = taskList.GetTask( 0u );
1384 Viewport viewport = task.GetViewport();
1386 // By default the viewport should match the stage width/height
1388 Vector2 stageSize = Stage::GetCurrent().GetSize();
1389 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1390 DALI_TEST_CHECK( viewport == expectedViewport );
1393 Vector2 newPosition(25.0f, 50.0f);
1394 task.SetViewportPosition( newPosition );
1396 // Update (viewport is a property)
1397 application.SendNotification();
1398 application.Render();
1400 DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1402 // Set by Property test
1403 Vector2 newPosition2(32.0f, 32.0f);
1404 task.SetProperty( RenderTask::Property::VIEWPORT_POSITION, newPosition2 );
1407 application.SendNotification();
1408 application.Render();
1410 DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition2, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1412 Vector2 newPosition3(64.0f, 0.0f);
1413 Animation animation = Animation::New(1.0f);
1414 animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_POSITION ), newPosition3, AlphaFunction::LINEAR );
1417 // Perform 1000ms worth of updates at which point animation should have completed.
1418 Wait(application, 1000);
1419 DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1423 int UtcDaliRenderTaskSetViewportSize(void)
1425 TestApplication application;
1427 tet_infoline("Testing RenderTask::SetViewportSize()");
1429 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1431 RenderTask task = taskList.GetTask( 0u );
1433 Viewport viewport = task.GetViewport();
1435 // By default the viewport should match the stage width/height
1437 Vector2 stageSize = Stage::GetCurrent().GetSize();
1438 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1439 DALI_TEST_CHECK( viewport == expectedViewport );
1441 Vector2 newSize(128.0f, 64.0f);
1442 task.SetViewportSize( newSize );
1444 // Update (viewport is a property)
1445 application.SendNotification();
1446 application.Render();
1448 DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1450 // Set by Property test
1451 Vector2 newSize2(50.0f, 50.0f);
1452 task.SetProperty( RenderTask::Property::VIEWPORT_SIZE, newSize2 );
1455 application.SendNotification();
1456 application.Render();
1458 DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize2, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1460 Vector2 newSize3(10.0f, 10.0f);
1461 Animation animation = Animation::New(1.0f);
1462 animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_SIZE ), newSize3, AlphaFunction::LINEAR );
1465 // Perform 1000ms worth of updates at which point animation should have completed.
1466 Wait(application, 1000);
1467 DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1472 int UtcDaliRenderTaskSetClearColorP(void)
1474 TestApplication application;
1476 tet_infoline("Testing RenderTask::SetClearColor()");
1478 Vector4 testColor( 1.0f, 2.0f, 3.0f, 4.0f );
1479 Vector4 testColor2( 5.0f, 6.0f, 7.0f, 8.0f );
1481 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1483 RenderTask task = taskList.GetTask( 0u );
1484 DALI_TEST_CHECK( task.GetClearColor() != testColor );
1486 task.SetClearColor( testColor );
1491 DALI_TEST_EQUALS( task.GetClearColor(), testColor, TEST_LOCATION );
1493 task.SetProperty( RenderTask::Property::CLEAR_COLOR, testColor2 );
1498 DALI_TEST_EQUALS( task.GetClearColor(), testColor2, TEST_LOCATION );
1502 int UtcDaliRenderTaskSetClearColorN(void)
1504 TestApplication application;
1506 tet_infoline("Testing RenderTask::SetClearColor() on empty handle");
1511 task.SetClearColor( Vector4::ZERO );
1513 catch (Dali::DaliException(e))
1515 DALI_TEST_PRINT_ASSERT( e );
1516 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1521 int UtcDaliRenderTaskGetClearColorP(void)
1523 TestApplication application;
1525 tet_infoline("Testing RenderTask::GetClearColor()");
1527 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1528 RenderTask task = taskList.GetTask( 0u );
1529 DALI_TEST_EQUALS( task.GetClearColor(), RenderTask::DEFAULT_CLEAR_COLOR, TEST_LOCATION );
1533 int UtcDaliRenderTaskGetClearColorN(void)
1535 TestApplication application;
1537 tet_infoline("Testing RenderTask::GetClearColor()");
1542 Vector4 color = task.GetClearColor();
1545 catch (Dali::DaliException(e))
1547 DALI_TEST_PRINT_ASSERT( e );
1548 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1553 int UtcDaliRenderTaskSetClearEnabledP(void)
1555 TestApplication application;
1557 tet_infoline("Testing RenderTask::SetClearEnabled()");
1559 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1561 RenderTask task = taskList.GetTask( 0u );
1562 DALI_TEST_CHECK( !task.GetClearEnabled() ); // defaults to false
1564 task.SetClearEnabled( true );
1565 DALI_TEST_EQUALS( task.GetClearEnabled(), true, TEST_LOCATION );
1567 task.SetClearEnabled( false );
1568 DALI_TEST_EQUALS( task.GetClearEnabled(), false, TEST_LOCATION );
1572 int UtcDaliRenderTaskSetClearEnabledN(void)
1574 TestApplication application;
1576 tet_infoline("Testing RenderTask::SetClearEnabled() with empty handle");
1581 task.SetClearEnabled(true);
1583 catch (Dali::DaliException(e))
1585 DALI_TEST_PRINT_ASSERT( e );
1586 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1591 int UtcDaliRenderTaskGetClearEnabledP(void)
1593 TestApplication application;
1595 tet_infoline("Testing RenderTask::GetClearEnabled()");
1597 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1599 RenderTask task = taskList.GetTask( 0u );
1600 DALI_TEST_CHECK( !task.GetClearEnabled() ); // defaults to false
1605 int UtcDaliRenderTaskGetClearEnabledN(void)
1607 TestApplication application;
1609 tet_infoline("Testing RenderTask::GetClearEnabled() with empty handle");
1614 bool x = task.GetClearEnabled();
1617 catch (Dali::DaliException(e))
1619 DALI_TEST_PRINT_ASSERT( e );
1620 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1625 int UtcDaliRenderTaskSetCullModeP(void)
1627 TestApplication application;
1629 tet_infoline("Testing RenderTask::SetCullMode()");
1631 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1632 RenderTask task = taskList.GetTask( 0u );
1633 DALI_TEST_EQUALS( task.GetCullMode(), true, TEST_LOCATION );
1635 task.SetCullMode( false );
1637 DALI_TEST_EQUALS( task.GetCullMode(), false, TEST_LOCATION );
1642 int UtcDaliRenderTaskSetCullModeN(void)
1644 TestApplication application;
1646 tet_infoline("Testing RenderTask::SetCullMode() on empty handle");
1651 task.SetCullMode( false );
1653 catch (Dali::DaliException(e))
1655 DALI_TEST_PRINT_ASSERT( e );
1656 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1661 int UtcDaliRenderTaskGetCullModeP(void)
1663 TestApplication application;
1665 tet_infoline("Testing RenderTask::GetCullMode()");
1667 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1668 RenderTask task = taskList.GetTask( 0u );
1669 DALI_TEST_EQUALS( task.GetCullMode(), true, TEST_LOCATION );
1673 int UtcDaliRenderTaskGetCullModeN(void)
1675 TestApplication application;
1677 tet_infoline("Testing RenderTask::GetCullMode() with empty handle");
1682 bool x = task.GetCullMode();
1685 catch (Dali::DaliException(e))
1687 DALI_TEST_PRINT_ASSERT( e );
1688 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1694 int UtcDaliRenderTaskSetRefreshRate(void)
1696 TestApplication application;
1698 tet_infoline("Testing RenderTask::SetRefreshRate()");
1700 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1702 // By default tasks will be processed every frame
1703 RenderTask task = taskList.GetTask( 0u );
1704 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1706 task.SetRefreshRate( 2u ); // every-other frame
1707 DALI_TEST_CHECK( 2u == task.GetRefreshRate() );
1709 task.SetRefreshRate( RenderTask::REFRESH_ALWAYS );
1710 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1714 int UtcDaliRenderTaskGetRefreshRate(void)
1716 TestApplication application;
1718 tet_infoline("Testing RenderTask::GetRefreshRate()");
1720 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1722 // By default tasks will be processed every frame
1723 RenderTask task = taskList.GetTask( 0u );
1724 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1726 RenderTask newTask = taskList.CreateTask();
1727 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == newTask.GetRefreshRate() );
1731 int UtcDaliRenderTaskSignalFinished(void)
1733 TestApplication application;
1735 tet_infoline("Testing RenderTask::SignalFinished()");
1737 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1738 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
1740 CameraActor offscreenCameraActor = CameraActor::New();
1742 Stage::GetCurrent().Add( offscreenCameraActor );
1744 BufferImage image = BufferImage::New( 10, 10 );
1746 ImageActor rootActor = ImageActor::New( image );
1747 rootActor.SetSize( 10, 10 );
1748 Stage::GetCurrent().Add( rootActor );
1750 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1751 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
1752 FrameBufferImage frameBufferImage = FrameBufferImage::New( *testNativeImagePtr.Get() );
1754 RenderTask newTask = taskList.CreateTask();
1755 newTask.SetCameraActor( offscreenCameraActor );
1756 newTask.SetSourceActor( rootActor );
1757 newTask.SetInputEnabled( false );
1758 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
1759 newTask.SetClearEnabled( true );
1760 newTask.SetExclusive( true );
1761 newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
1762 newTask.SetTargetFrameBuffer( frameBufferImage );
1764 bool finished = false;
1765 RenderTaskFinished renderTaskFinished( finished );
1766 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1768 // Flush the queue and render.
1769 application.SendNotification();
1771 // 1 render to process render task, then wait for sync before finished msg is sent
1772 // from update to the event thread.
1774 application.Render();
1775 application.SendNotification();
1776 DALI_TEST_CHECK( !finished );
1778 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
1779 DALI_TEST_CHECK( lastSyncObj != NULL );
1781 application.Render();
1782 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
1783 application.SendNotification();
1784 DALI_TEST_CHECK( !finished );
1786 application.Render();
1787 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
1788 application.SendNotification();
1789 DALI_TEST_CHECK( ! finished );
1791 sync.SetObjectSynced( lastSyncObj, true );
1793 application.Render();
1794 application.SendNotification();
1795 DALI_TEST_CHECK( !finished );
1797 application.Render();
1798 application.SendNotification();
1799 DALI_TEST_CHECK( finished );
1802 DALI_TEST_EQUALS( application.GetUpdateStatus(), 0, TEST_LOCATION );
1807 int UtcDaliRenderTaskContinuous01(void)
1809 TestApplication application;
1811 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not staged)\nPOST:continuous renders, no Finished signal");
1813 // SETUP AN OFFSCREEN RENDER TASK
1814 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1815 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1816 drawTrace.Enable(true);
1818 Actor rootActor = Actor::New();
1819 Stage::GetCurrent().Add( rootActor );
1821 CameraActor offscreenCameraActor = CameraActor::New();
1822 Stage::GetCurrent().Add( offscreenCameraActor );
1824 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1825 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1826 Integration::ResourceId imageRequestId = imageRequest->GetId();
1827 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1829 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1830 bool finished = false;
1831 RenderTaskFinished renderTaskFinished( finished );
1832 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1833 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1834 application.SendNotification();
1836 // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating
1837 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false, __LINE__ ) );
1838 application.GetPlatform().ClearReadyResources();
1840 // ADD SOURCE ACTOR TO STAGE - expect continuous renders to start, no finished signal
1841 Stage::GetCurrent().Add(secondRootActor);
1842 application.SendNotification();
1844 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1845 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
1850 int UtcDaliRenderTaskContinuous02(void)
1852 TestApplication application;
1854 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not visible)\nPOST:continuous renders, no Finished signal");
1856 // SETUP AN OFFSCREEN RENDER TASK
1857 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1858 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1859 drawTrace.Enable(true);
1861 Actor rootActor = Actor::New();
1862 Stage::GetCurrent().Add( rootActor );
1864 CameraActor offscreenCameraActor = CameraActor::New();
1865 Stage::GetCurrent().Add( offscreenCameraActor );
1867 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1868 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1869 Integration::ResourceId imageRequestId = imageRequest->GetId();
1870 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1871 Stage::GetCurrent().Add(secondRootActor);
1872 secondRootActor.SetVisible(false);
1874 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1875 bool finished = false;
1876 RenderTaskFinished renderTaskFinished( finished );
1877 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1878 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1879 application.SendNotification();
1881 // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating
1882 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false, __LINE__ ) );
1883 application.GetPlatform().ClearReadyResources();
1885 // MAKE SOURCE ACTOR VISIBLE - expect continuous renders to start, no finished signal
1886 secondRootActor.SetVisible(true);
1887 application.SendNotification();
1889 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1890 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
1894 int UtcDaliRenderTaskContinuous03(void)
1896 TestApplication application;
1898 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (camera actor not staged)\nPOST:continuous renders, no Finished signal");
1900 // SETUP AN OFFSCREEN RENDER TASK
1901 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1902 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1903 drawTrace.Enable(true);
1905 Actor rootActor = Actor::New();
1906 Stage::GetCurrent().Add( rootActor );
1908 CameraActor offscreenCameraActor = CameraActor::New();
1909 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1910 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1911 Integration::ResourceId imageRequestId = imageRequest->GetId();
1912 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1913 Stage::GetCurrent().Add(secondRootActor);
1915 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1916 bool finished = false;
1917 RenderTaskFinished renderTaskFinished( finished );
1918 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1919 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1920 application.SendNotification();
1922 // START PROCESS/RENDER Input, Expected Input, Expected
1923 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false, __LINE__ ) );
1924 application.GetPlatform().ClearReadyResources();
1926 // ADD CAMERA ACTOR TO STAGE - expect continuous renders to start, no finished signal
1927 Stage::GetCurrent().Add( offscreenCameraActor );
1928 application.SendNotification();
1930 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1931 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
1936 int UtcDaliRenderTaskContinuous04(void)
1938 TestApplication application;
1940 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: Resource not ready\nPOST:continuous renders, no Finished signal");
1942 // SETUP AN OFFSCREEN RENDER TASK
1943 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1944 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1945 drawTrace.Enable(true);
1947 Actor rootActor = Actor::New();
1948 Stage::GetCurrent().Add( rootActor );
1950 CameraActor offscreenCameraActor = CameraActor::New();
1951 Stage::GetCurrent().Add( offscreenCameraActor );
1952 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1953 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1954 Integration::ResourceId imageRequestId = imageRequest->GetId();
1955 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1956 Stage::GetCurrent().Add(secondRootActor);
1958 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1959 bool finished = false;
1960 RenderTaskFinished renderTaskFinished( finished );
1961 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1962 application.SendNotification();
1964 // START PROCESS/RENDER Input, Expected Input, Expected
1965 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
1966 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
1968 // FINISH RESOURCE LOADING - expect 'continuous' renders to start, no finished signal
1969 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1970 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
1974 int UtcDaliRenderTaskContinous05(void)
1976 TestApplication application;
1978 tet_infoline("Testing RenderTask Render Continuous using Mesh which accesses texture through sampler with loading image\n"
1979 "PRE: Resource not ready\nPOST:continuous renders, no Finished signal");
1981 // SETUP AN OFFSCREEN RENDER TASK
1982 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1983 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1984 drawTrace.Enable(true);
1986 Actor rootActor = Actor::New();
1987 Stage::GetCurrent().Add( rootActor );
1989 CameraActor offscreenCameraActor = CameraActor::New();
1990 Stage::GetCurrent().Add( offscreenCameraActor );
1992 Material material = CreateMaterial();
1993 Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1994 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1995 Integration::ResourceId imageRequestId = imageRequest->GetId();
1996 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1997 material.AddTexture( image, "sTexture" );
1999 Geometry geometry = CreateQuadGeometry();
2000 Renderer renderer = Renderer::New(geometry, material);
2001 Actor secondRootActor = Actor::New();
2002 secondRootActor.AddRenderer(renderer);
2003 secondRootActor.SetSize(100, 100);
2004 Stage::GetCurrent().Add(secondRootActor);
2006 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2007 bool finished = false;
2008 RenderTaskFinished renderTaskFinished( finished );
2009 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2010 application.SendNotification();
2012 // START PROCESS/RENDER Input, Expected Input, Expected
2013 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2014 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2016 // FINISH RESOURCE LOADING - expect 'continuous' renders to start, no finished signal
2017 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2018 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2024 int UtcDaliRenderTaskOnce01(void)
2026 TestApplication application;
2028 tet_infoline("Testing RenderTask Render Once GlSync, using loading image\nPRE: Resources not ready, Source not visible\nPOST: Finished signal sent once only");
2030 // SETUP AN OFFSCREEN RENDER TASK
2031 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2032 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2033 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2034 drawTrace.Enable(true);
2036 Actor rootActor = Actor::New();
2037 Stage::GetCurrent().Add( rootActor );
2039 CameraActor offscreenCameraActor = CameraActor::New();
2040 Stage::GetCurrent().Add( offscreenCameraActor );
2041 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2042 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2043 Integration::ResourceId imageRequestId = imageRequest->GetId();
2044 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2046 Stage::GetCurrent().Add(secondRootActor);
2048 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
2049 bool finished = false;
2050 RenderTaskFinished renderTaskFinished( finished );
2051 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2052 application.SendNotification();
2054 // START PROCESS/RENDER Input, Expected Input, Expected
2055 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2056 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2058 // MAKE SOURCE VISIBLE
2059 secondRootActor.SetVisible(true);
2060 application.SendNotification();
2061 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2062 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2064 // FINISH RESOURCE LOADING - expect no rendering yet
2065 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2066 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2067 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2068 DALI_TEST_CHECK( lastSyncObj != NULL );
2070 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2071 application.GetPlatform().ClearReadyResources();
2072 sync.SetObjectSynced( lastSyncObj, true );
2073 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2074 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2078 int UtcDaliRenderTaskOnce02(void)
2080 TestApplication application;
2082 tet_infoline("Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loading image.\n"
2083 "PRE: Resources not ready\nPOST: Finished signal sent once only");
2085 // SETUP AN OFFSCREEN RENDER TASK
2086 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2087 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2088 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2089 drawTrace.Enable(true);
2091 Actor rootActor = Actor::New();
2092 Stage::GetCurrent().Add( rootActor );
2094 CameraActor offscreenCameraActor = CameraActor::New();
2095 Stage::GetCurrent().Add( offscreenCameraActor );
2097 Material material = CreateMaterial();
2098 Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2099 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2100 Integration::ResourceId imageRequestId = imageRequest->GetId();
2101 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2102 material.AddTexture( image, "sTexture");
2104 Geometry geometry = CreateQuadGeometry();
2105 Renderer renderer = Renderer::New(geometry, material);
2106 Actor secondRootActor = Actor::New();
2107 secondRootActor.AddRenderer(renderer);
2108 secondRootActor.SetSize(100, 100);
2109 Stage::GetCurrent().Add(secondRootActor);
2111 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
2112 bool finished = false;
2113 RenderTaskFinished renderTaskFinished( finished );
2114 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2115 application.SendNotification();
2117 // START PROCESS/RENDER Input, Expected Input, Expected
2118 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2119 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2121 // FINISH RESOURCE LOADING - expect no rendering yet
2122 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2123 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2124 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2125 DALI_TEST_CHECK( lastSyncObj != NULL );
2127 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2128 application.GetPlatform().ClearReadyResources();
2129 sync.SetObjectSynced( lastSyncObj, true );
2130 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2131 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2136 int UtcDaliRenderTaskOnce03(void)
2138 TestApplication application;
2140 tet_infoline("Testing RenderTask Render Once GlSync, using loading image. Switch from render always after ready to render once\n"
2141 "PRE: Render task ready, Image not loaded\n"
2142 "POST: Finished signal sent only once");
2144 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2145 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2146 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2147 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2148 drawTrace.Enable(true);
2150 Actor rootActor = Actor::New();
2151 Stage::GetCurrent().Add( rootActor );
2153 CameraActor offscreenCameraActor = CameraActor::New();
2154 Stage::GetCurrent().Add( offscreenCameraActor );
2155 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2156 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2157 Integration::ResourceId imageRequestId = imageRequest->GetId();
2158 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2159 Stage::GetCurrent().Add(secondRootActor);
2161 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2162 bool finished = false;
2163 RenderTaskFinished renderTaskFinished( finished );
2164 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2165 application.SendNotification();
2167 // START PROCESS/RENDER Input, Expected Input, Expected
2168 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2169 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2171 // FINISH RESOURCE LOADING
2172 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2173 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2174 application.GetPlatform().ClearReadyResources();
2175 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2177 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2178 application.SendNotification(); // Input, Expected Input, Expected
2179 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2180 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2181 DALI_TEST_CHECK( lastSyncObj != NULL );
2183 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2184 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2185 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2186 sync.SetObjectSynced( lastSyncObj, true );
2187 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2188 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2194 int UtcDaliRenderTaskOnce04(void)
2196 TestApplication application;
2197 tet_infoline("Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loading image.\n"
2198 "Switch from render always after ready to render once\n"
2199 "PRE: Render task ready, Image not loaded\n"
2200 "POST: Finished signal sent only once");
2202 // SETUP AN OFFSCREEN RENDER TASK
2203 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2204 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2205 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2206 drawTrace.Enable(true);
2208 Actor rootActor = Actor::New();
2209 Stage::GetCurrent().Add( rootActor );
2211 CameraActor offscreenCameraActor = CameraActor::New();
2212 Stage::GetCurrent().Add( offscreenCameraActor );
2214 Material material = CreateMaterial();
2215 Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2216 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2217 Integration::ResourceId imageRequestId = imageRequest->GetId();
2218 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2219 material.AddTexture( image, "sTexture" );
2221 Geometry geometry = CreateQuadGeometry();
2222 Renderer renderer = Renderer::New(geometry, material);
2223 Actor secondRootActor = Actor::New();
2224 secondRootActor.AddRenderer(renderer);
2225 secondRootActor.SetSize(100, 100);
2226 Stage::GetCurrent().Add(secondRootActor);
2228 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2229 bool finished = false;
2230 RenderTaskFinished renderTaskFinished( finished );
2231 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2232 application.SendNotification();
2234 // START PROCESS/RENDER Input, Expected Input, Expected
2235 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2236 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2238 // FINISH RESOURCE LOADING
2239 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2240 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2241 application.GetPlatform().ClearReadyResources();
2242 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2244 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2245 application.SendNotification(); // Input, Expected Input, Expected
2246 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2247 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2248 DALI_TEST_CHECK( lastSyncObj != NULL );
2250 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2251 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2252 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2253 sync.SetObjectSynced( lastSyncObj, true );
2254 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2255 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2260 int UtcDaliRenderTaskOnce05(void)
2262 TestApplication application;
2264 tet_infoline("Testing RenderTask Render Once GlSync\n"
2265 "Switch from Render always after ready to render once with resources unready\n"
2266 "PRE: Everything ready to render\n"
2267 "POST: Finished signal sent once");
2269 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2270 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2271 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2272 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2273 drawTrace.Enable(true);
2275 Actor rootActor = Actor::New();
2276 Stage::GetCurrent().Add( rootActor );
2278 CameraActor offscreenCameraActor = CameraActor::New();
2279 Stage::GetCurrent().Add( offscreenCameraActor );
2280 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2281 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2282 Integration::ResourceId imageRequestId = imageRequest->GetId();
2283 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2284 Stage::GetCurrent().Add(secondRootActor);
2286 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2287 bool finished = false;
2288 RenderTaskFinished renderTaskFinished( finished );
2289 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2290 application.SendNotification();
2292 // START PROCESS/RENDER Input, Expected Input, Expected
2293 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2294 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2296 // CHANGE TO RENDER ONCE
2297 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2298 application.SendNotification(); // Input, Expected Input, Expected
2299 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2300 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2302 // FINISH RESOURCE LOADING
2303 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2304 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2305 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2306 DALI_TEST_CHECK( lastSyncObj != NULL );
2307 application.GetPlatform().ClearReadyResources();
2309 sync.SetObjectSynced( lastSyncObj, true );
2311 // Expect: No draw - we've just drawn our render task once, above. No finished signal -
2312 // we won't read the gl sync until the next frame. Continue rendering - we're waiting for
2314 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2316 // Expect: 1 final draw - this Update doesn't update the scene, hence render instructions
2317 // from last frame but 1 are still present.
2318 // Finished signal should be true - we've just done the sync.
2319 // Should now stop rendering and updating - nothing left to do.
2320 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, true, false, __LINE__ ) );
2326 //int UtcDaliRenderTaskOnce06(void)
2328 TestApplication application;
2330 tet_infoline("Testing RenderTask Render Once GlSync\n"
2331 "During RenderOnce, make ready resources unready before sending first finished signal\n"
2332 "PRE: Everything ready.\n"
2333 "POST: Finished signal sent only once");
2335 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2336 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2337 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2338 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2339 drawTrace.Enable(true);
2341 Actor rootActor = Actor::New();
2342 Stage::GetCurrent().Add( rootActor );
2344 CameraActor offscreenCameraActor = CameraActor::New();
2345 Stage::GetCurrent().Add( offscreenCameraActor );
2346 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2347 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2348 Integration::ResourceId imageRequestId = imageRequest->GetId();
2349 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2350 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2351 application.Render();
2353 Stage::GetCurrent().Add(secondRootActor);
2354 application.GetPlatform().ClearReadyResources();
2356 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2357 bool finished = false;
2358 RenderTaskFinished renderTaskFinished( finished );
2359 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2360 application.SendNotification();
2362 // START PROCESS/RENDER Input, Expected Input, Expected
2363 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2364 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2366 // CHANGE TO RENDER ONCE, RESOURCES BECOME NOT READY
2367 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2370 ReloadImage(application, secondRootActor.GetImage());
2371 application.SendNotification(); // Input, Expected Input, Expected
2373 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2374 DALI_TEST_EQUALS( secondRootActor.GetImage().GetLoadingState(), Dali::ResourceLoading, TEST_LOCATION);
2375 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2377 // FINISH RESOURCE LOADING
2378 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2379 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2380 application.GetPlatform().ClearReadyResources();
2381 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2382 DALI_TEST_CHECK( lastSyncObj != NULL );
2384 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2385 sync.SetObjectSynced( lastSyncObj, true );
2386 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2387 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, true, __LINE__ ) );
2389 // Finished rendering - expect no more renders, no more signals:
2390 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2391 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2392 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2393 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2394 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2395 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2400 int UtcDaliRenderTaskOnce07(void)
2402 TestApplication application;
2404 tet_infoline("Testing RenderTask Render Once GLSync\n"
2405 "Render once, Second call to SetRefreshRate(ONCE) triggers only one more finished signal\n"
2406 "PRE: Everything ready\n"
2407 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
2409 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2410 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2411 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2412 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2413 drawTrace.Enable(true);
2415 Actor rootActor = Actor::New();
2416 Stage::GetCurrent().Add( rootActor );
2418 CameraActor offscreenCameraActor = CameraActor::New();
2419 Stage::GetCurrent().Add( offscreenCameraActor );
2420 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2421 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2422 Integration::ResourceId imageRequestId = imageRequest->GetId();
2423 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2424 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2425 application.Render();
2426 application.GetPlatform().ClearReadyResources();
2428 Stage::GetCurrent().Add(secondRootActor);
2430 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2431 bool finished = false;
2432 RenderTaskFinished renderTaskFinished( finished );
2433 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2434 application.SendNotification();
2436 // START PROCESS/RENDER Input, Expected Input, Expected
2437 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2439 // CHANGE TO RENDER ONCE,
2440 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2441 application.SendNotification();
2442 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2443 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2444 DALI_TEST_CHECK( lastSyncObj != NULL );
2446 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2447 sync.SetObjectSynced( lastSyncObj, true );
2448 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2449 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2451 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2452 application.SendNotification();
2453 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2454 lastSyncObj = sync.GetLastSyncObject();
2455 DALI_TEST_CHECK( lastSyncObj != NULL );
2457 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2458 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2459 sync.SetObjectSynced( lastSyncObj, true );
2460 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2461 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2465 int UtcDaliRenderTaskOnce08(void)
2467 TestApplication application;
2469 tet_infoline("Testing RenderTask Render Once GLSync\n"
2470 "Render once, Call to SetRefreshRate(ONCE) in Finished signal callback triggers "
2471 "another render & another finished signal\n"
2472 "PRE: Everything ready\n"
2473 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
2476 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2477 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2478 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2479 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2480 sync.GetTrace().Enable(true);
2481 drawTrace.Enable(true);
2483 Actor rootActor = Actor::New();
2484 Stage::GetCurrent().Add( rootActor );
2486 CameraActor offscreenCameraActor = CameraActor::New();
2487 Stage::GetCurrent().Add( offscreenCameraActor );
2488 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2489 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2490 Integration::ResourceId imageRequestId = imageRequest->GetId();
2491 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2492 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2493 application.Render();
2494 application.GetPlatform().ClearReadyResources();
2496 Stage::GetCurrent().Add(secondRootActor);
2498 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, /*GL-SYNC*/ true);
2499 bool finished = false;
2501 ConnectionTracker connectionTracker;
2502 RenderTaskFinishedRenderAgain renderTaskFinishedRenderAgain( finished );
2503 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinishedRenderAgain );
2505 application.SendNotification();
2507 // START PROCESS/RENDER Input, Expected Input, Expected
2508 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2509 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2510 DALI_TEST_CHECK( lastSyncObj == NULL );
2511 DALI_TEST_EQUALS( sync.GetTrace().CountMethod( "CreateSyncObject" ), 0, TEST_LOCATION );
2514 // CHANGE TO RENDER ONCE,
2515 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2516 application.SendNotification();
2517 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2518 lastSyncObj = sync.GetLastSyncObject();
2519 DALI_TEST_CHECK( lastSyncObj != NULL );
2520 DALI_TEST_EQUALS( sync.GetNumberOfSyncObjects(), 1, TEST_LOCATION );
2521 DALI_TEST_EQUALS( sync.GetTrace().CountMethod( "CreateSyncObject" ), 1, TEST_LOCATION );
2523 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2526 DALI_TEST_EQUALS( sync.GetNumberOfSyncObjects(), 1, TEST_LOCATION );
2527 DALI_TEST_EQUALS( sync.GetTrace().CountMethod( "CreateSyncObject" ), 1, TEST_LOCATION );
2529 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2531 DALI_TEST_EQUALS( sync.GetNumberOfSyncObjects(), 1, TEST_LOCATION );
2532 DALI_TEST_EQUALS( sync.GetTrace().CountMethod( "CreateSyncObject" ), 1, TEST_LOCATION );
2534 sync.SetObjectSynced( lastSyncObj, true );
2535 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2536 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2537 application.SendNotification();
2539 // Expect SetRefreshRate to have been called again
2540 // Prevent next finished signal calling refresh once again
2541 RenderTaskFinished renderTaskFinished( finished );
2542 connectionTracker.DisconnectAll();
2543 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinished );
2544 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2545 lastSyncObj = sync.GetLastSyncObject();
2546 DALI_TEST_CHECK( lastSyncObj != NULL );
2548 sync.SetObjectSynced( lastSyncObj, true );
2549 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2550 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2555 int UtcDaliRenderTaskOnce09(void)
2557 TestApplication application;
2559 tet_infoline("Testing RenderTask Render Once GlSync\n"
2560 "SetRefreshRate(ONCE) again before first finished signal has been sent.\n"
2561 "PRE: resources ready\n"
2562 "POST: Only 1 finished signal sent.");
2564 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2565 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2566 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2567 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2568 drawTrace.Enable(true);
2570 Actor rootActor = Actor::New();
2571 Stage::GetCurrent().Add( rootActor );
2573 CameraActor offscreenCameraActor = CameraActor::New();
2574 Stage::GetCurrent().Add( offscreenCameraActor );
2575 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2576 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2577 Integration::ResourceId imageRequestId = imageRequest->GetId();
2578 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2579 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2580 application.Render();
2581 application.GetPlatform().ClearReadyResources();
2583 Stage::GetCurrent().Add(secondRootActor);
2585 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2586 bool finished = false;
2587 RenderTaskFinished renderTaskFinished( finished );
2588 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2589 application.SendNotification();
2591 // START PROCESS/RENDER Input, Expected Input, Expected
2592 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2594 // CHANGE TO RENDER ONCE,
2595 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2596 application.SendNotification();
2597 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2598 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2599 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2601 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2602 application.SendNotification();
2603 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2604 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2605 DALI_TEST_CHECK( lastSyncObj != NULL );
2607 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2608 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2609 sync.SetObjectSynced( lastSyncObj, true );
2610 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2611 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2616 int UtcDaliRenderTaskOnce10(void)
2618 TestApplication application;
2620 tet_infoline("Testing RenderTask Render Once GlSync\n"
2621 "SetRefreshRate(ONCE), resource load failed completes render task.\n"
2622 "PRE: resources not ready\n"
2623 "POST: Only 1 finished signal sent.");
2625 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2626 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2627 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2628 drawTrace.Enable(true);
2630 Actor rootActor = Actor::New();
2631 Stage::GetCurrent().Add( rootActor );
2633 CameraActor offscreenCameraActor = CameraActor::New();
2634 Stage::GetCurrent().Add( offscreenCameraActor );
2635 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2636 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2637 Integration::ResourceId imageRequestId = imageRequest->GetId();
2638 Stage::GetCurrent().Add(secondRootActor);
2640 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2641 bool finished = false;
2642 RenderTaskFinished renderTaskFinished( finished );
2643 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2644 application.SendNotification();
2646 // START PROCESS/RENDER Input, Expected Input, Expected
2647 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2648 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2650 // CHANGE TO RENDER ONCE,
2651 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2652 application.SendNotification();
2653 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2654 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2655 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2657 tet_printf(" FailImageLoad\n");
2659 FailImageLoad(application, imageRequestId); // Need to run Update again for this to complete
2661 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); // nothing to draw
2662 application.SendNotification();
2664 // load is now failed so there's nothing more to render in the render task
2665 // Expect finished signal, as all resources are complete
2666 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2671 int UtcDaliRenderTaskOnceNoSync01(void)
2673 TestApplication application;
2675 tet_infoline("Testing RenderTask Render Once, using loading image\nPRE: Resources not ready, Source not visible\nPOST: Finished signal sent once only");
2677 // SETUP AN OFFSCREEN RENDER TASK
2678 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2679 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2680 drawTrace.Enable(true);
2682 Actor rootActor = Actor::New();
2683 Stage::GetCurrent().Add( rootActor );
2685 CameraActor offscreenCameraActor = CameraActor::New();
2686 Stage::GetCurrent().Add( offscreenCameraActor );
2687 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2688 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2689 Integration::ResourceId imageRequestId = imageRequest->GetId();
2690 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2692 Stage::GetCurrent().Add(secondRootActor);
2694 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2695 bool finished = false;
2696 RenderTaskFinished renderTaskFinished( finished );
2697 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2698 application.SendNotification();
2700 // START PROCESS/RENDER Input, Expected Input, Expected
2701 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2702 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2704 // FINISH RESOURCE LOADING - expect immediate rendering yet
2705 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2706 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2707 application.GetPlatform().ClearReadyResources();
2708 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2712 int UtcDaliRenderTaskOnceNoSync02(void)
2714 TestApplication application;
2716 tet_infoline("Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loading image.\n"
2717 "PRE: Resources not ready\nPOST: Finished signal sent once only");
2718 // SETUP AN OFFSCREEN RENDER TASK
2719 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2720 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2721 drawTrace.Enable(true);
2723 Actor rootActor = Actor::New();
2724 Stage::GetCurrent().Add( rootActor );
2726 CameraActor offscreenCameraActor = CameraActor::New();
2727 Stage::GetCurrent().Add( offscreenCameraActor );
2729 Material material = CreateMaterial();
2730 Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2731 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2732 Integration::ResourceId imageRequestId = imageRequest->GetId();
2733 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2734 material.AddTexture( image, "sTexture");
2736 Geometry geometry = CreateQuadGeometry();
2737 Renderer renderer = Renderer::New(geometry, material);
2738 Actor secondRootActor = Actor::New();
2739 secondRootActor.AddRenderer(renderer);
2740 secondRootActor.SetSize(100, 100);
2741 Stage::GetCurrent().Add(secondRootActor);
2743 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2744 bool finished = false;
2745 RenderTaskFinished renderTaskFinished( finished );
2746 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2747 application.SendNotification();
2749 // START PROCESS/RENDER Input, Expected Input, Expected
2750 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2751 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2753 // FINISH RESOURCE LOADING - expect immediate rendering yet
2754 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2755 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2756 application.GetPlatform().ClearReadyResources();
2757 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2762 int UtcDaliRenderTaskOnceNoSync03(void)
2764 TestApplication application;
2766 tet_infoline("Testing RenderTask Render Once, using loading image. Switch from render always after ready to render once\n"
2767 "PRE: Render task ready, Image not loaded\n"
2768 "POST: Finished signal sent only once");
2770 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2771 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2772 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2773 drawTrace.Enable(true);
2775 Actor rootActor = Actor::New();
2776 Stage::GetCurrent().Add( rootActor );
2778 CameraActor offscreenCameraActor = CameraActor::New();
2779 Stage::GetCurrent().Add( offscreenCameraActor );
2780 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2781 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2782 Integration::ResourceId imageRequestId = imageRequest->GetId();
2783 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2784 Stage::GetCurrent().Add(secondRootActor);
2786 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2787 bool finished = false;
2788 RenderTaskFinished renderTaskFinished( finished );
2789 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2790 application.SendNotification();
2792 // START PROCESS/RENDER Input, Expected Input, Expected
2793 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2794 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2796 // FINISH RESOURCE LOADING
2797 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2798 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2799 application.GetPlatform().ClearReadyResources();
2801 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2802 application.SendNotification(); // Input, Expected Input, Expected
2803 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2804 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2808 int UtcDaliRenderTaskOnceNoSync04(void)
2810 TestApplication application;
2812 tet_infoline("Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loading image.\n"
2813 "Switch from render always after ready to render once\n"
2814 "PRE: Render task ready, Image not loaded\n"
2815 "POST: Finished signal sent only once");
2817 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2818 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2819 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2820 drawTrace.Enable(true);
2822 Actor rootActor = Actor::New();
2823 Stage::GetCurrent().Add( rootActor );
2825 CameraActor offscreenCameraActor = CameraActor::New();
2826 Stage::GetCurrent().Add( offscreenCameraActor );
2828 Material material = CreateMaterial();
2829 Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2830 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2831 Integration::ResourceId imageRequestId = imageRequest->GetId();
2832 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2833 material.AddTexture( image, "sTexture" );
2835 Geometry geometry = CreateQuadGeometry();
2836 Renderer renderer = Renderer::New(geometry, material);
2837 Actor secondRootActor = Actor::New();
2838 secondRootActor.AddRenderer(renderer);
2839 secondRootActor.SetSize(100, 100);
2840 Stage::GetCurrent().Add(secondRootActor);
2843 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2844 bool finished = false;
2845 RenderTaskFinished renderTaskFinished( finished );
2846 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2847 application.SendNotification();
2849 // START PROCESS/RENDER Input, Expected Input, Expected
2850 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2851 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2853 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2854 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2855 DALI_TEST_CHECK( lastSyncObj == NULL );
2857 // FINISH RESOURCE LOADING
2858 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2859 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2860 application.GetPlatform().ClearReadyResources();
2862 lastSyncObj = sync.GetLastSyncObject();
2863 DALI_TEST_CHECK( lastSyncObj == NULL );
2865 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2866 application.SendNotification(); // Input, Expected Input, Expected
2867 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2868 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2870 lastSyncObj = sync.GetLastSyncObject();
2871 DALI_TEST_CHECK( lastSyncObj == NULL );
2876 int UtcDaliRenderTaskOnceNoSync05(void)
2878 TestApplication application;
2880 tet_infoline("Testing RenderTask Render Once\n"
2881 "Switch from Render always after ready to render once with resources unready\n"
2882 "PRE: Everything ready to render\n"
2883 "POST: Finished signal sent once");
2885 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2886 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2887 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2888 drawTrace.Enable(true);
2890 Actor rootActor = Actor::New();
2891 Stage::GetCurrent().Add( rootActor );
2893 CameraActor offscreenCameraActor = CameraActor::New();
2894 Stage::GetCurrent().Add( offscreenCameraActor );
2895 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2896 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2897 Integration::ResourceId imageRequestId = imageRequest->GetId();
2898 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2899 Stage::GetCurrent().Add(secondRootActor);
2901 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2902 bool finished = false;
2903 RenderTaskFinished renderTaskFinished( finished );
2904 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2905 application.SendNotification();
2907 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2908 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2909 DALI_TEST_CHECK( lastSyncObj == NULL );
2911 // START PROCESS/RENDER Input, Expected Input, Expected
2912 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2913 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2915 // CHANGE TO RENDER ONCE
2916 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2917 application.SendNotification(); // Input, Expected Input, Expected
2918 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2919 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2921 // FINISH RESOURCE LOADING
2922 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2923 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2924 application.GetPlatform().ClearReadyResources();
2925 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2930 //int UtcDaliRenderTaskOnceNoSync06(void)
2932 TestApplication application;
2934 tet_infoline("Testing RenderTask Render Once\n"
2935 "During RenderOnce, make ready resources unready before sending first finished signal\n"
2936 "PRE: Everything ready.\n"
2937 "POST: Finished signal sent only once");
2939 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2940 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2941 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2942 drawTrace.Enable(true);
2944 Actor rootActor = Actor::New();
2945 Stage::GetCurrent().Add( rootActor );
2947 CameraActor offscreenCameraActor = CameraActor::New();
2948 Stage::GetCurrent().Add( offscreenCameraActor );
2949 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2950 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2951 Integration::ResourceId imageRequestId = imageRequest->GetId();
2952 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2953 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2954 application.Render();
2955 application.GetPlatform().ClearReadyResources();
2957 Stage::GetCurrent().Add(secondRootActor);
2959 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2960 bool finished = false;
2961 RenderTaskFinished renderTaskFinished( finished );
2962 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2963 application.SendNotification();
2965 // START PROCESS/RENDER Input, Expected Input, Expected
2966 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2967 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2969 // CHANGE TO RENDER ONCE, RESOURCES BECOME NOT READY
2970 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2973 ReloadImage(application, secondRootActor.GetImage());
2974 application.SendNotification(); // Input, Expected Input, Expected
2976 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2977 DALI_TEST_EQUALS( secondRootActor.GetImage().GetLoadingState(), Dali::ResourceLoading, TEST_LOCATION);
2978 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2980 // FINISH RESOURCE LOADING
2981 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2982 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, true, true, __LINE__ ) );
2983 application.GetPlatform().ClearReadyResources();
2984 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2985 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2986 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2987 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2992 int UtcDaliRenderTaskOnceNoSync07(void)
2994 TestApplication application;
2996 tet_infoline("Testing RenderTask Render Once\n"
2997 "Render once, Second call to SetRefreshRate(ONCE) triggers only one more finished signal\n"
2998 "PRE: Everything ready\n"
2999 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
3001 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3002 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3003 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3004 drawTrace.Enable(true);
3006 Actor rootActor = Actor::New();
3007 Stage::GetCurrent().Add( rootActor );
3009 CameraActor offscreenCameraActor = CameraActor::New();
3010 Stage::GetCurrent().Add( offscreenCameraActor );
3011 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3012 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3013 Integration::ResourceId imageRequestId = imageRequest->GetId();
3014 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
3015 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
3016 application.Render();
3017 application.GetPlatform().ClearReadyResources();
3019 Stage::GetCurrent().Add(secondRootActor);
3021 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3022 bool finished = false;
3023 RenderTaskFinished renderTaskFinished( finished );
3024 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3025 application.SendNotification();
3027 // START PROCESS/RENDER Input, Expected Input, Expected
3028 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
3030 // CHANGE TO RENDER ONCE,
3031 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3032 application.SendNotification();
3033 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3034 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3036 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3037 application.SendNotification();
3038 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3039 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3043 int UtcDaliRenderTaskOnceNoSync08(void)
3045 TestApplication application;
3047 tet_infoline("Testing RenderTask Render Once\n"
3048 "Render once, Call to SetRefreshRate(ONCE) in Finished signal callback triggers\n"
3049 "another render & another finished signal\n"
3050 "PRE: Everything ready\n"
3051 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
3054 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3055 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3056 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3057 drawTrace.Enable(true);
3059 Actor rootActor = Actor::New();
3060 Stage::GetCurrent().Add( rootActor );
3062 CameraActor offscreenCameraActor = CameraActor::New();
3063 Stage::GetCurrent().Add( offscreenCameraActor );
3064 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3065 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3066 Integration::ResourceId imageRequestId = imageRequest->GetId();
3067 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
3068 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
3069 application.Render();
3070 application.GetPlatform().ClearReadyResources();
3072 Stage::GetCurrent().Add(secondRootActor);
3074 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3075 bool finished = false;
3077 ConnectionTracker connectionTracker;
3078 RenderTaskFinishedRenderAgain renderTaskFinishedRenderAgain( finished );
3079 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinishedRenderAgain );
3081 application.SendNotification();
3083 // START PROCESS/RENDER Input, Expected Input, Expected
3084 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
3086 // CHANGE TO RENDER ONCE,
3087 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3088 application.SendNotification();
3089 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3090 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3092 // Expect SetRefreshRate to have been called again
3093 // Prevent next finished signal calling refresh once again
3094 RenderTaskFinished renderTaskFinished( finished );
3095 connectionTracker.DisconnectAll();
3096 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinished );
3098 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3099 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3104 int UtcDaliRenderTaskOnceNoSync09(void)
3106 TestApplication application;
3108 tet_infoline("Testing RenderTask Render Once\n"
3109 "SetRefreshRate(ONCE) again before first finished signal has been sent.\n"
3110 "PRE: resources ready\n"
3111 "POST: Only 1 finished signal sent.");
3113 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3114 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3115 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3116 drawTrace.Enable(true);
3118 Actor rootActor = Actor::New();
3119 Stage::GetCurrent().Add( rootActor );
3121 CameraActor offscreenCameraActor = CameraActor::New();
3122 Stage::GetCurrent().Add( offscreenCameraActor );
3123 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3124 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3125 Integration::ResourceId imageRequestId = imageRequest->GetId();
3126 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
3127 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
3128 application.Render();
3129 application.GetPlatform().ClearReadyResources();
3131 Stage::GetCurrent().Add(secondRootActor);
3133 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3134 bool finished = false;
3135 RenderTaskFinished renderTaskFinished( finished );
3136 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3137 application.SendNotification();
3139 // START PROCESS/RENDER Input, Expected Input, Expected
3140 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
3142 // CHANGE TO RENDER ONCE,
3143 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3144 application.SendNotification();
3145 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3146 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3148 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3149 application.SendNotification();
3150 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3151 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3155 int UtcDaliRenderTaskOnceNoSync10(void)
3157 TestApplication application;
3159 tet_infoline("Testing RenderTask Render Once\n"
3160 "SetRefreshRate(ONCE), resource load failed, completes render task.\n"
3161 "PRE: resources not ready\n"
3162 "POST: Only 1 finished signal sent.");
3164 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3165 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3166 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3167 drawTrace.Enable(true);
3169 Actor rootActor = Actor::New();
3170 Stage::GetCurrent().Add( rootActor );
3172 CameraActor offscreenCameraActor = CameraActor::New();
3173 Stage::GetCurrent().Add( offscreenCameraActor );
3174 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3175 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3176 Integration::ResourceId imageRequestId = imageRequest->GetId();
3177 Stage::GetCurrent().Add(secondRootActor);
3179 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3180 bool finished = false;
3181 RenderTaskFinished renderTaskFinished( finished );
3182 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3183 application.SendNotification();
3185 // START PROCESS/RENDER Input, Expected Input, Expected
3186 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3187 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3189 // CHANGE TO RENDER ONCE,
3190 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3191 application.SendNotification();
3192 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3193 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3194 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3196 FailImageLoad(application, imageRequestId); // Need to run Update again for this to complete
3197 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); // nothing to draw
3198 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3205 int UtcDaliRenderTaskOnceChain01(void)
3207 TestApplication application;
3209 tet_infoline("Testing RenderTask Render Once Chained render tasks\n"
3210 "SetRefreshRate(ONCE), resource load completes, both render tasks render.\n"
3211 "PRE: resources not ready\n"
3212 "POST: 2 finished signals sent.");
3214 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3215 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3216 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3217 drawTrace.Enable(true);
3219 Actor defaultRootActor = Actor::New(); // Root for default RT
3220 Stage::GetCurrent().Add( defaultRootActor );
3222 CameraActor offscreenCameraActor = CameraActor::New();
3223 Stage::GetCurrent().Add( offscreenCameraActor );
3224 ImageActor firstRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3225 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3226 Integration::ResourceId imageRequestId = imageRequest->GetId();
3227 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
3228 Stage::GetCurrent().Add(firstRootActor);
3230 // first render task
3231 RenderTask firstTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, firstRootActor, RenderTask::REFRESH_ONCE, false);
3232 bool firstFinished = false;
3233 RenderTaskFinished renderTask1Finished( firstFinished );
3234 firstTask.FinishedSignal().Connect( &application, renderTask1Finished );
3236 // Second render task
3237 FrameBufferImage fbo = firstTask.GetTargetFrameBuffer();
3238 ImageActor secondRootActor = ImageActor::New( fbo );
3239 Stage::GetCurrent().Add(secondRootActor);
3240 RenderTask secondTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
3241 bool secondFinished = false;
3242 RenderTaskFinished renderTask2Finished( secondFinished );
3243 secondTask.FinishedSignal().Connect( &application, renderTask2Finished );
3245 application.SendNotification();
3247 // START PROCESS/RENDER Input, Expected Input, Expected
3248 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__ ) );
3249 DALI_TEST_CHECK( firstFinished == false );
3250 DALI_TEST_CHECK( secondFinished == false );
3251 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__ ) );
3252 DALI_TEST_CHECK( firstFinished == false );
3253 DALI_TEST_CHECK( secondFinished == false );
3255 CompleteImageLoad(application, imageRequestId, imageType);
3256 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__ ) );
3257 DALI_TEST_CHECK( firstFinished == false );
3258 DALI_TEST_CHECK( secondFinished == false );
3260 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, true, true, __LINE__ ) );
3261 DALI_TEST_CHECK( firstFinished == true );
3262 DALI_TEST_CHECK( secondFinished == false );
3264 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, secondFinished, true, false, __LINE__ ) );
3265 DALI_TEST_CHECK( secondFinished == true );
3270 int UtcDaliRenderTaskProperties(void)
3272 TestApplication application;
3274 RenderTask task = Stage::GetCurrent().GetRenderTaskList().CreateTask();
3276 Property::IndexContainer indices;
3277 task.GetPropertyIndices( indices );
3278 DALI_TEST_CHECK( indices.Size() );
3279 DALI_TEST_EQUALS( indices.Size(), task.GetPropertyCount(), TEST_LOCATION );
3283 int UtcDaliRenderTaskSetScreenToFrameBufferMappingActor(void)
3285 TestApplication application;
3286 tet_infoline("Testing RenderTask::SetScreenToFrameBufferMappingActor ");
3288 Stage stage = Stage::GetCurrent();
3289 Size stageSize = stage.GetSize();
3290 Actor mappingActor = Actor::New();
3291 Vector2 scale( 0.6f, 0.75f);
3292 Vector2 offset( stageSize.x*0.1f, stageSize.y*0.15f);
3293 mappingActor.SetSize( stageSize * scale );
3294 mappingActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
3295 mappingActor.SetPosition( offset.x, offset.y );
3296 stage.Add( mappingActor );
3298 Actor offscreenActor = Actor::New();
3299 offscreenActor.SetSize( stageSize );
3300 offscreenActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
3301 stage.Add( offscreenActor );
3303 RenderTaskList taskList = stage.GetRenderTaskList();
3304 RenderTask renderTask = taskList.CreateTask();
3305 FrameBufferImage frameBufferImage = FrameBufferImage::New(stageSize.width*scale.x, stageSize.height*scale.y, Pixel::A8, Image::NEVER);
3306 renderTask.SetSourceActor( offscreenActor );
3307 renderTask.SetExclusive( true );
3308 renderTask.SetInputEnabled( true );
3309 renderTask.SetTargetFrameBuffer( frameBufferImage );
3310 renderTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
3311 renderTask.SetScreenToFrameBufferMappingActor( mappingActor );
3312 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3314 // Render and notify
3315 application.SendNotification();
3316 application.Render();
3317 application.Render();
3318 application.SendNotification();
3320 Vector2 screenCoordinates( stageSize.x * 0.05f, stageSize.y * 0.05f );
3321 Dali::HitTestAlgorithm::Results results;
3322 DALI_TEST_CHECK( !results.actor );
3323 DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
3324 // miss expected, results not changed
3325 DALI_TEST_CHECK( false == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3326 DALI_TEST_CHECK( !results.actor );
3327 DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
3329 screenCoordinates.x = stageSize.x * 0.265f;
3330 screenCoordinates.y = stageSize.y * 0.33f;
3331 results.actor = Actor();
3332 results.actorCoordinates = Vector2::ZERO;
3333 // hit expected, results changed
3334 DALI_TEST_CHECK( true == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3335 DALI_TEST_CHECK( results.actor == offscreenActor );
3336 DALI_TEST_EQUALS( (screenCoordinates-offset)/scale , results.actorCoordinates, 0.1f, TEST_LOCATION );
3338 screenCoordinates.x = stageSize.x * 0.435f;
3339 screenCoordinates.y = stageSize.y * 0.52f;
3340 // hit expected, results changed
3341 DALI_TEST_CHECK( true == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3342 DALI_TEST_CHECK( results.actor == offscreenActor );
3343 const Vector2 expectedCoordinates = (screenCoordinates-offset)/scale;
3344 DALI_TEST_EQUALS( expectedCoordinates , results.actorCoordinates, 0.1f, TEST_LOCATION );
3346 screenCoordinates.x = stageSize.x * 0.65f;
3347 screenCoordinates.y = stageSize.y * 0.95f;
3348 // miss expected, results not changed
3349 DALI_TEST_CHECK( false == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3350 DALI_TEST_CHECK( results.actor == offscreenActor );
3351 DALI_TEST_EQUALS( expectedCoordinates , results.actorCoordinates, 0.1f, TEST_LOCATION );
3355 int UtcDaliRenderTaskFinishInvisibleSourceActor(void)
3357 TestApplication application;
3359 tet_infoline("Testing RenderTask::FinishInvisibleSourceActor()");
3361 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3362 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
3364 CameraActor offscreenCameraActor = CameraActor::New();
3366 Stage::GetCurrent().Add( offscreenCameraActor );
3368 BufferImage image = BufferImage::New( 10, 10 );
3369 ImageActor rootActor = ImageActor::New( image );
3370 rootActor.SetSize( 10, 10 );
3371 rootActor.SetVisible(false);
3372 Stage::GetCurrent().Add( rootActor );
3374 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3375 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
3376 FrameBufferImage frameBufferImage = FrameBufferImage::New( *testNativeImagePtr.Get() );
3378 // Flush all outstanding messages
3379 application.SendNotification();
3380 application.Render();
3382 RenderTask newTask = taskList.CreateTask();
3383 newTask.SetCameraActor( offscreenCameraActor );
3384 newTask.SetSourceActor( rootActor );
3385 newTask.SetInputEnabled( false );
3386 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
3387 newTask.SetClearEnabled( true );
3388 newTask.SetExclusive( true );
3389 newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
3390 newTask.SetTargetFrameBuffer( frameBufferImage );
3392 // Framebuffer doesn't actually get created until Connected, i.e. by previous line
3394 bool finished = false;
3395 RenderTaskFinished renderTaskFinished( finished );
3396 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3398 // Flush the queue and render.
3399 application.SendNotification();
3401 // 1 render to process render task, then wait for sync before finished msg is sent
3402 // from update to the event thread.
3404 application.Render();
3405 application.SendNotification();
3406 DALI_TEST_CHECK( !finished );
3408 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
3409 DALI_TEST_CHECK( lastSyncObj != NULL );
3411 application.Render();
3412 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
3413 application.SendNotification();
3414 DALI_TEST_CHECK( !finished );
3416 application.Render();
3417 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
3418 application.SendNotification();
3419 DALI_TEST_CHECK( ! finished );
3421 sync.SetObjectSynced( lastSyncObj, true );
3423 application.Render();
3424 application.SendNotification();
3425 DALI_TEST_CHECK( !finished );
3427 application.Render();
3428 application.SendNotification();
3429 DALI_TEST_CHECK( finished );
3432 application.Render(); // Double check no more finished signal
3433 application.SendNotification();
3434 DALI_TEST_CHECK( ! finished );
3439 int UtcDaliRenderTaskFinishMissingImage(void)
3441 TestApplication application;
3443 // Previously we had bugs where not having a resource ID would cause render-tasks to wait forever
3444 tet_infoline("Testing RenderTask::SignalFinished() when an ImageActor has no Image set");
3446 Stage stage = Stage::GetCurrent();
3448 BufferImage image = BufferImage::New( 10, 10 );
3449 ImageActor rootActor = ImageActor::New( image );
3450 rootActor.SetSize( 10, 10 );
3451 stage.Add( rootActor );
3453 ImageActor actorWithMissingImage = ImageActor::New( Image() );
3454 actorWithMissingImage.SetSize( 10, 10 );
3455 stage.Add( actorWithMissingImage );
3457 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3458 RenderTask newTask = taskList.CreateTask();
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 );
3465 bool finished = false;
3466 RenderTaskFinished renderTaskFinished( finished );
3467 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3469 // 1 render to process render task, then 1 before finished msg is sent from update to the event thread.
3470 application.SendNotification();
3471 application.Render();
3472 application.Render();
3474 application.SendNotification();
3475 DALI_TEST_CHECK( finished );
3480 int UtcDaliRenderTaskWorldToViewport(void)
3482 TestApplication application( static_cast<size_t>(400), static_cast<size_t>(400) ); // square surface
3484 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3486 Actor actor = Actor::New();
3487 actor.SetSize(100.0f, 100.0f);
3488 actor.SetPosition( Vector3(0.0, 0.0, 0.0) );
3490 actor.SetParentOrigin( Vector3(0.5, 0.5, 0.5) );
3491 actor.SetAnchorPoint( Vector3(0.5, 0.5, 0.5) );
3493 Stage::GetCurrent().Add(actor);
3495 application.SendNotification();
3496 application.Render();
3497 application.SendNotification();
3499 RenderTask task = taskList.GetTask( 0u );
3501 CameraActor camera = task.GetCameraActor();
3503 Vector2 screenSize = task.GetCurrentViewportSize();
3505 float screenX = 0.0;
3506 float screenY = 0.0;
3508 bool ok = task.WorldToViewport(actor.GetCurrentWorldPosition(), screenX, screenY);
3509 DALI_TEST_CHECK(ok == true);
3511 DALI_TEST_EQUALS(screenX, screenSize.x/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
3512 DALI_TEST_EQUALS(screenY, screenSize.y/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
3514 Actor actor2 = Actor::New();
3515 float actor2Size = 100.f;
3516 actor2.SetSize( actor2Size, actor2Size );
3517 actor2.SetPosition( Vector3(0.0, 0.0, 0.0) );
3518 actor2.SetParentOrigin( Vector3(0.5, 0.5, 0.0) );
3519 actor2.SetAnchorPoint( Vector3(0.5, 0.5, 0.0) );
3520 Stage::GetCurrent().Add( actor2 );
3522 actor.SetParentOrigin( Vector3(0,0,0) );
3524 application.SendNotification();
3525 application.Render();
3526 application.SendNotification();
3528 ok = task.WorldToViewport(actor.GetCurrentWorldPosition(), screenX, screenY);
3529 DALI_TEST_CHECK(ok == true);
3531 DALI_TEST_EQUALS(screenX, screenSize.x/2 - actor2Size/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
3532 DALI_TEST_EQUALS(screenY, screenSize.y/2 - actor2Size/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
3538 int UtcDaliRenderTaskViewportToLocal(void)
3540 TestApplication application;
3541 Actor actor = Actor::New();
3542 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
3543 actor.SetSize(100.0f, 100.0f);
3544 actor.SetPosition(10.0f, 10.0f);
3545 Stage::GetCurrent().Add(actor);
3547 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3548 RenderTask task = taskList.GetTask( 0u );
3550 // flush the queue and render once
3551 application.SendNotification();
3552 application.Render();
3553 application.SendNotification();
3554 application.Render();
3562 float screenX = 50.0f;
3563 float screenY = 50.0f;
3565 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, screenX, screenY) );
3567 DALI_TEST_CHECK( task.ViewportToLocal(actor, screenX, screenY, rtLocalX, rtLocalY ) );
3569 DALI_TEST_EQUALS(localX, rtLocalX, 0.01f, TEST_LOCATION);
3570 DALI_TEST_EQUALS(localY, rtLocalY, 0.01f, TEST_LOCATION);