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")
34 void utc_dali_render_task_startup(void)
36 test_return_value = TET_UNDEF;
39 void utc_dali_render_task_cleanup(void)
41 test_return_value = TET_PASS;
47 * Constructor, Destructor, DownCast, New, copy constructor, assignment operator
49 * SetSourceActor 2+ve, 1-ve
50 * GetSourceActor 1+ve, 1-ve
51 * SetExclusive 2+ve, 0-ve
52 * IsExclusive 2+ve, 0-ve
53 * SetInputEnabled 1+ve, 0-ve
54 * GetInputEnabled 1+ve, 0-ve
55 * SetCameraActor 1+ve, 1-ve
56 * GetCameraActor 1+ve, 1-ve
57 * SetTargetFrameBuffer 1+ve, 1-ve
58 * GetTargetFrameBuffer 1+ve, 1-ve
59 * SetScreenToFrameBufferFunction 1+ve, 1-ve
60 * GetScreenToFrameBufferFunction 1+ve, 1-ve
61 * SetScreenToFrameBufferMappingActor 1+ve, 1-ve
62 * GetScreenToFrameBufferMappingActor 1+ve, 1-ve
63 * SetViewportPosition 1+ve
64 * GetCurrentViewportPosition 1+ve
65 * SetViewportSize 1+ve
66 * GetCurrentViewportSize 1+ve
67 * SetViewport 2+ve, 1-ve
68 * GetViewport 2+ve, 1-ve
69 * SetClearColor 1+ve, 1-ve
70 * GetClearColor 1+ve, 1-ve
71 * SetClearEnabled 1+ve, 1-ve
72 * GetClearEnabled 1+ve, 1-ve
80 namespace // unnamed namespace
83 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
86 * Simulate time passed by.
88 * @note this will always process at least 1 frame (1/60 sec)
90 * @param application Test application instance
91 * @param duration Time to pass in milliseconds.
92 * @return The actual time passed in milliseconds
94 int Wait(TestApplication& application, int duration = 0)
98 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
100 application.SendNotification();
101 application.Render(RENDER_FRAME_INTERVAL);
102 time += RENDER_FRAME_INTERVAL;
108 struct RenderTaskFinished
110 RenderTaskFinished( bool& finished )
111 : finished( finished )
115 void operator()( RenderTask& renderTask )
123 struct RenderTaskFinishedRemoveSource
125 RenderTaskFinishedRemoveSource( bool& finished )
126 : finished( finished ),
131 void operator()( RenderTask& renderTask )
133 DALI_TEST_CHECK(finishedOnce == false);
136 Actor srcActor = renderTask.GetSourceActor();
137 UnparentAndReset(srcActor);
144 struct RenderTaskFinishedRenderAgain
146 RenderTaskFinishedRenderAgain( bool& finished )
147 : finished( finished ),
152 void operator()( RenderTask& renderTask )
154 DALI_TEST_CHECK(finishedOnce == false);
157 renderTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
165 bool TestScreenToFrameBufferFunction( Vector2& coordinates )
167 coordinates = coordinates + Vector2( 1, 2 );
172 ImageActor CreateLoadingImage(TestApplication& application, std::string filename, ResourceImage::LoadPolicy loadPolicy, Image::ReleasePolicy releasePolicy)
174 Image image = ResourceImage::New(filename, loadPolicy, releasePolicy);
175 DALI_TEST_CHECK( image );
176 application.SendNotification();
177 application.Render(16);
178 DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
179 ImageActor actor = ImageActor::New(image);
180 actor.SetSize( 80, 80 );
181 application.SendNotification();
182 application.Render(16);
186 Sampler CreateSamplerWithLoadingImage(TestApplication& application, std::string filename, ResourceImage::LoadPolicy loadPolicy, Image::ReleasePolicy releasePolicy)
188 Image image = ResourceImage::New(filename, loadPolicy, releasePolicy);
189 DALI_TEST_CHECK( image );
190 application.SendNotification();
191 application.Render(16);
192 DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
194 Sampler sampler = Sampler::New( image, "sTexture" );
195 application.SendNotification();
196 application.Render(16);
200 void CompleteImageLoad(TestApplication& application, Integration::ResourceId resourceId, Integration::ResourceTypeId requestType)
202 std::vector<GLuint> ids;
204 application.GetGlAbstraction().SetNextTextureIds( ids );
206 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
207 Integration::ResourcePointer resource(bitmap);
208 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80);
210 application.GetPlatform().SetResourceLoaded(resourceId, requestType, resource);
213 void FailImageLoad(TestApplication& application, Integration::ResourceId resourceId )
215 application.GetPlatform().SetResourceLoadFailed(resourceId, Integration::FailureUnknown);
218 void ReloadImage(TestApplication& application, ResourceImage image)
220 application.GetPlatform().ClearReadyResources();
221 application.GetPlatform().DiscardRequest();
222 application.GetPlatform().ResetTrace();
223 application.GetPlatform().SetClosestImageSize(Vector2(80.0f, 80.0f)); // Ensure reload is called.
227 RenderTask CreateRenderTask(TestApplication& application,
228 CameraActor offscreenCamera,
229 Actor rootActor, // Reset default render task to point at this actor
230 Actor secondRootActor, // Source actor
231 unsigned int refreshRate,
234 // Change main render task to use a different root
235 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
236 taskList.GetTask(0u).SetSourceActor( rootActor );
238 FrameBufferImage frameBufferImage;
241 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
242 frameBufferImage= FrameBufferImage::New( *(testNativeImagePtr.Get()) );
246 frameBufferImage = FrameBufferImage::New( 10, 10 );
249 // Don't draw output framebuffer // '
251 RenderTask newTask = taskList.CreateTask();
252 newTask.SetCameraActor( offscreenCamera );
253 newTask.SetSourceActor( secondRootActor );
254 newTask.SetInputEnabled( false );
255 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
256 newTask.SetClearEnabled( true );
257 newTask.SetExclusive( true );
258 newTask.SetRefreshRate( refreshRate );
259 newTask.SetTargetFrameBuffer( frameBufferImage );
263 bool UpdateRender(TestApplication& application, TraceCallStack& callStack, bool testDrawn, bool& finishedSig, bool testFinished, bool testKeepUpdating )
267 application.Render(16);
268 application.SendNotification();
270 bool sigPassed = false;
273 sigPassed = finishedSig;
277 sigPassed = ! finishedSig;
280 bool drawResult = callStack.FindMethod("DrawElements") || callStack.FindMethod("DrawArrays");
282 bool drawPassed = false;
285 drawPassed = drawResult;
289 drawPassed = !drawResult;
292 bool keepUpdating = (application.GetUpdateStatus() != 0);
293 bool keepUpdatingPassed = false;
294 if( testKeepUpdating )
296 keepUpdatingPassed = keepUpdating;
300 keepUpdatingPassed = !keepUpdating;
303 bool result = (sigPassed && drawPassed && keepUpdatingPassed);
305 tet_printf("UpdateRender: Expected: Draw:%s Signal:%s Keep Updating: %s Actual: Draw:%s Signal:%s KeepUpdating: %s %s\n",
306 BOOLSTR(testDrawn), BOOLSTR(testFinished), BOOLSTR(testKeepUpdating),
307 BOOLSTR(drawResult), BOOLSTR(finishedSig), BOOLSTR(keepUpdating),
308 result ? "Passed":"Failed");
313 // The functor to be used in the hit-test algorithm to check whether the actor is hittable.
314 bool IsActorHittableFunction(Actor actor, Dali::HitTestAlgorithm::TraverseType type)
316 bool hittable = false;
320 case Dali::HitTestAlgorithm::CHECK_ACTOR:
322 // Check whether the actor is visible and not fully transparent.
323 if( actor.IsVisible()
324 && actor.GetCurrentWorldColor().a > 0.01f) // not FULLY_TRANSPARENT
331 case Dali::HitTestAlgorithm::DESCEND_ACTOR_TREE:
333 if( actor.IsVisible() ) // Actor is visible, if not visible then none of its children are visible.
348 } // unnamed namespace
351 /****************************************************************************************************/
352 /****************************************************************************************************/
353 /******************************** TEST CASES BELOW **********************************************/
354 /****************************************************************************************************/
355 /****************************************************************************************************/
357 int UtcDaliRenderTaskDownCast01(void)
359 TestApplication application;
361 tet_infoline("Testing RenderTask::DownCast()");
363 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
365 BaseHandle base = taskList.GetTask( 0u );
366 DALI_TEST_CHECK( base );
368 RenderTask task = RenderTask::DownCast( base );
369 DALI_TEST_CHECK( task );
371 // Try calling a method
372 DALI_TEST_CHECK( task.GetSourceActor() );
376 int UtcDaliRenderTaskDownCast02(void)
378 TestApplication application;
380 tet_infoline("Testing RenderTask::DownCast()");
382 Actor actor = Actor::New();
384 RenderTask task = RenderTask::DownCast( actor );
385 DALI_TEST_CHECK( ! task );
390 int UtcDaliRenderTaskSetSourceActorN(void)
392 TestApplication application;
393 tet_infoline("Testing RenderTask::SetSourceActor() Negative - try with empty actor handle");
394 Stage stage = Stage::GetCurrent();
398 RenderTaskList taskList = stage.GetRenderTaskList();
399 RenderTask renderTask = taskList.CreateTask();
400 renderTask.SetSourceActor(srcActor);
402 application.SendNotification();
403 application.Render();
405 DALI_TEST_CHECK( ! renderTask.GetSourceActor() );
410 int UtcDaliRenderTaskSetSourceActorP01(void)
412 TestApplication application;
414 tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that setting a non-renderable actor stops existing source actor being rendered ");
416 Stage stage = Stage::GetCurrent();
418 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
420 RenderTaskList taskList = stage.GetRenderTaskList();
422 RenderTask task = taskList.GetTask( 0u );
424 Actor actor = task.GetSourceActor();
425 DALI_TEST_CHECK( actor );
427 std::vector<GLuint> ids;
429 application.GetGlAbstraction().SetNextTextureIds( ids );
431 BufferImage img = BufferImage::New( 1,1 );
432 ImageActor newActor = ImageActor::New( img );
433 newActor.SetSize(1,1);
434 stage.Add( newActor );
436 Actor nonRenderableActor = Actor::New();
437 stage.Add( nonRenderableActor );
439 // Stop the newActor from being rendered by changing the source actor
440 DALI_TEST_CHECK( nonRenderableActor );
441 task.SetSourceActor( nonRenderableActor );
442 DALI_TEST_CHECK( task.GetSourceActor() != actor );
443 DALI_TEST_CHECK( task.GetSourceActor() == nonRenderableActor );
445 // Update & Render nothing!
446 application.GetGlAbstraction().ClearBoundTextures();
447 application.SendNotification();
448 application.Render();
450 // Check that nothing was rendered
451 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
457 int UtcDaliRenderTaskSetSourceActorP02(void)
459 TestApplication application;
461 tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that switching source from a non-renderable to a renderable actor causes the texture to be drawn");
463 Stage stage = Stage::GetCurrent();
465 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
467 RenderTaskList taskList = stage.GetRenderTaskList();
469 RenderTask task = taskList.GetTask( 0u );
471 Actor actor = task.GetSourceActor();
472 DALI_TEST_CHECK( actor );
474 std::vector<GLuint> ids;
476 application.GetGlAbstraction().SetNextTextureIds( ids );
478 BufferImage img = BufferImage::New( 1,1 );
479 ImageActor newActor = ImageActor::New( img );
480 newActor.SetSize(1,1);
481 stage.Add( newActor );
483 Actor nonRenderableActor = Actor::New();
484 stage.Add( nonRenderableActor );
486 // Stop the newActor from being rendered by changing the source actor
487 DALI_TEST_CHECK( nonRenderableActor );
488 task.SetSourceActor( nonRenderableActor );
489 DALI_TEST_CHECK( task.GetSourceActor() != actor );
490 DALI_TEST_CHECK( task.GetSourceActor() == nonRenderableActor );
492 // Update & Render nothing!
493 application.GetGlAbstraction().ClearBoundTextures();
494 application.SendNotification();
495 application.Render();
497 // Check that nothing was rendered
498 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
500 // Set newActor as the new source Actor
501 task.SetSourceActor( newActor );
502 DALI_TEST_CHECK( task.GetSourceActor() != actor );
503 DALI_TEST_CHECK( task.GetSourceActor() == newActor );
505 // Update & Render the newActor
506 application.GetGlAbstraction().ClearBoundTextures();
507 application.SendNotification();
508 application.Render();
510 // Check that the newActor was rendered
511 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
512 if ( boundTextures.size() )
514 DALI_TEST_EQUALS( boundTextures[0], 7u, TEST_LOCATION );
519 int UtcDaliRenderTaskSetSourceActorOffStage(void)
521 TestApplication application;
523 tet_infoline("Testing RenderTask::SetSourceActor (on/off stage testing)");
525 Stage stage = Stage::GetCurrent();
527 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
529 RenderTaskList taskList = stage.GetRenderTaskList();
531 RenderTask task = taskList.GetTask( 0u );
533 Actor actor = task.GetSourceActor();
534 DALI_TEST_CHECK( actor );
536 std::vector<GLuint> ids;
537 GLuint expectedTextureId( 3 );
538 ids.push_back( expectedTextureId );
539 application.GetGlAbstraction().SetNextTextureIds( ids );
541 BufferImage img = BufferImage::New( 1,1 );
542 ImageActor newActor = ImageActor::New( img );
543 newActor.SetSize(1,1);
544 task.SetSourceActor( newActor );
545 // Don't add newActor to stage yet //'
547 // Update & Render with the actor initially off-stage
548 application.GetGlAbstraction().ClearBoundTextures();
549 application.SendNotification();
550 application.Render();
552 // Check that nothing was rendered
553 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
556 stage.Add( newActor );
558 // Update & Render with the actor on-stage
559 application.GetGlAbstraction().ClearBoundTextures();
560 application.SendNotification();
561 application.Render();
563 // Check that the newActor was rendered
564 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
565 if ( boundTextures.size() )
567 DALI_TEST_EQUALS( boundTextures[0], expectedTextureId, TEST_LOCATION );
570 // Now remove from stage
571 stage.Remove( newActor );
573 // Update & Render with the actor off-stage
574 application.GetGlAbstraction().ClearBoundTextures();
575 application.SendNotification();
576 application.Render();
580 int UtcDaliRenderTaskSetSourceActorEmpty(void)
582 TestApplication application;
584 tet_infoline("Testing RenderTask::SetSourceActor (empty handle case)");
586 Stage stage = Stage::GetCurrent();
588 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
590 RenderTaskList taskList = stage.GetRenderTaskList();
592 RenderTask task = taskList.GetTask( 0u );
594 Actor actor = task.GetSourceActor();
595 DALI_TEST_CHECK( actor );
597 std::vector<GLuint> ids;
598 GLuint expectedTextureId( 5 );
599 ids.push_back( expectedTextureId );
600 application.GetGlAbstraction().SetNextTextureIds( ids );
602 BufferImage img = BufferImage::New( 1,1 );
603 ImageActor newActor = ImageActor::New( img );
604 newActor.SetSize(1,1);
605 stage.Add( newActor );
607 Actor nonRenderableActor = Actor::New();
608 stage.Add( nonRenderableActor );
610 // Set with empty handle
611 task.SetSourceActor( Actor() );
612 DALI_TEST_CHECK( ! task.GetSourceActor() );
614 // Update & Render nothing!
615 application.GetGlAbstraction().ClearBoundTextures();
616 application.SendNotification();
617 application.Render();
619 // Check that nothing was rendered
620 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
622 // Set with non-empty handle
623 task.SetSourceActor( newActor );
624 DALI_TEST_CHECK( task.GetSourceActor() == newActor );
626 // Update & Render the newActor
627 application.GetGlAbstraction().ClearBoundTextures();
628 application.SendNotification();
629 application.Render();
631 // Check that the newActor was rendered
632 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
633 if ( boundTextures.size() )
635 DALI_TEST_EQUALS( boundTextures[0], expectedTextureId, TEST_LOCATION );
640 int UtcDaliRenderTaskGetSourceActorP01(void)
642 TestApplication application;
644 tet_infoline("Testing RenderTask::GetSourceActor() Check the default render task has a valid source actor");
646 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
648 RenderTask task = taskList.GetTask( 0u );
650 Actor actor = task.GetSourceActor();
651 DALI_TEST_CHECK( actor );
653 // By default the entire scene should be rendered
654 Actor root = Stage::GetCurrent().GetLayer( 0 );
655 DALI_TEST_CHECK( root == actor );
659 int UtcDaliRenderTaskGetSourceActorP02(void)
661 TestApplication application;
663 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.");
665 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
666 RenderTask task = taskList.CreateTask();
667 Actor actor = Actor::New();
668 Stage::GetCurrent().Add(actor);
669 task.SetSourceActor( actor );
671 DALI_TEST_EQUALS( actor, task.GetSourceActor(), TEST_LOCATION );
676 int UtcDaliRenderTaskGetSourceActorN(void)
678 TestApplication application;
680 tet_infoline("Testing RenderTask::GetSourceActor() Try with empty handle");
685 Actor actor = task.GetSourceActor();
687 catch (Dali::DaliException(e))
689 DALI_TEST_PRINT_ASSERT( e );
690 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
696 int UtcDaliRenderTaskSetExclusive(void)
698 TestApplication application;
700 tet_infoline("Testing RenderTask::SetExclusive() Check that exclusion works");
702 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
704 // Manipulate the GenTextures behaviour, to identify different ImageActors
706 std::vector<GLuint> ids;
707 ids.push_back( 8 ); // 8 = actor1
708 ids.push_back( 9 ); // 9 = actor2
709 ids.push_back( 10 ); // 10 = actor3
710 application.GetGlAbstraction().SetNextTextureIds( ids );
712 BufferImage img1 = BufferImage::New( 1,1 );
713 ImageActor actor1 = ImageActor::New( img1 );
715 Stage::GetCurrent().Add( actor1 );
717 // Update & Render actor1
718 application.SendNotification();
719 application.Render();
721 // Check that the actor1 was rendered
722 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
723 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
725 if ( boundTextures.size() )
727 DALI_TEST_EQUALS( boundTextures[0], 8u/*unique to actor1*/, TEST_LOCATION );
730 BufferImage img2 = BufferImage::New( 1,1 );
731 ImageActor actor2 = ImageActor::New( img2 );
734 // Force actor2 to be rendered before actor1
735 Layer layer = Layer::New();
736 Stage::GetCurrent().Add( layer );
738 layer.LowerToBottom();
741 application.GetGlAbstraction().ClearBoundTextures();
742 application.SendNotification();
743 application.Render();
745 // Check that the actors were rendered
746 DALI_TEST_EQUALS( boundTextures.size(), 2u, TEST_LOCATION );
748 if ( boundTextures.size() )
750 DALI_TEST_EQUALS( boundTextures[0], 9u/*unique to actor2*/, TEST_LOCATION );
751 DALI_TEST_EQUALS( boundTextures[1], 8u/*unique to actor1*/, TEST_LOCATION );
754 BufferImage img3 = BufferImage::New( 1,1 );
755 ImageActor actor3 = ImageActor::New( img3 );
758 // Force actor3 to be rendered before actor2
759 layer = Layer::New();
760 Stage::GetCurrent().Add( layer );
762 layer.LowerToBottom();
764 // Update & Render all actors
765 application.GetGlAbstraction().ClearBoundTextures();
766 application.SendNotification();
767 application.Render();
769 // Check that the actors were rendered
770 DALI_TEST_EQUALS( boundTextures.size(), 3u, TEST_LOCATION );
772 if ( boundTextures.size() )
774 DALI_TEST_EQUALS( boundTextures[0], 10u/*unique to actor3*/, TEST_LOCATION );
775 DALI_TEST_EQUALS( boundTextures[1], 9u/*unique to actor2*/, TEST_LOCATION );
776 DALI_TEST_EQUALS( boundTextures[2], 8u/*unique to actor1*/, TEST_LOCATION );
779 // Both actors are now connected to the root node
780 // Setup 2 render-tasks - the first will render from the root-node, and the second from actor2
782 // Not exclusive is the default
783 RenderTask task1 = taskList.GetTask( 0u );
784 DALI_TEST_CHECK( false == task1.IsExclusive() );
786 RenderTask task2 = taskList.CreateTask();
787 DALI_TEST_CHECK( false == task2.IsExclusive() );
788 task2.SetSourceActor( actor2 );
790 // Task1 should render all actors, and task 2 should render only actor2
792 application.GetGlAbstraction().ClearBoundTextures();
793 application.SendNotification();
794 application.Render();
796 DALI_TEST_EQUALS( boundTextures.size(), 4u, TEST_LOCATION );
798 if ( boundTextures.size() == 4 )
800 // Test that task 1 renders actor3, then actor2 & then actor1
801 DALI_TEST_CHECK( boundTextures[0] == 10u );
802 DALI_TEST_CHECK( boundTextures[1] == 9u );
803 DALI_TEST_CHECK( boundTextures[2] == 8u );
805 // Test that task 2 renders actor2
806 DALI_TEST_EQUALS( boundTextures[3], 9u, TEST_LOCATION );
809 // Make actor2 exclusive to task2
811 task2.SetExclusive( true );
812 DALI_TEST_CHECK( true == task2.IsExclusive() );
814 // Task1 should render only actor1, and task 2 should render only actor2
816 application.GetGlAbstraction().ClearBoundTextures();
817 application.SendNotification();
818 application.Render();
820 DALI_TEST_EQUALS( boundTextures.size(), 3u, TEST_LOCATION );
821 if ( boundTextures.size() == 3 )
823 // Test that task 1 renders actor3 & actor1
824 DALI_TEST_CHECK( boundTextures[0] == 10u );
825 DALI_TEST_CHECK( boundTextures[1] == 8u );
827 // Test that task 2 renders actor2
828 DALI_TEST_CHECK( boundTextures[2] == 9u );
833 int UtcDaliRenderTaskSetExclusive02(void)
835 TestApplication application;
837 tet_infoline("Testing RenderTask::SetExclusive() Check that changing from exclusive to not-exclusive works");
839 std::vector<GLuint> ids;
840 ids.push_back( 8 ); // 8 = actor1
841 application.GetGlAbstraction().SetNextTextureIds( ids );
843 BufferImage img1 = BufferImage::New( 1,1 );
844 ImageActor actor1 = ImageActor::New( img1 );
846 Stage::GetCurrent().Add( actor1 );
848 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
849 RenderTask task = taskList.CreateTask();
851 task.SetSourceActor( actor1 );
852 task.SetExclusive(true); // Actor should only render once
854 TestGlAbstraction& gl = application.GetGlAbstraction();
855 TraceCallStack& drawTrace = gl.GetDrawTrace();
856 drawTrace.Enable(true);
858 // Update & Render actor1
859 application.SendNotification();
860 application.Render();
862 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawArrays"), 1, TEST_LOCATION );
864 // Set task to non-exclusive - actor1 should render twice:
866 task.SetExclusive(false);
867 application.SendNotification();
868 application.Render();
870 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawArrays"), 2, TEST_LOCATION );
875 int UtcDaliRenderTaskSetExclusiveN(void)
877 TestApplication application;
879 tet_infoline("Testing RenderTask::SetExclusive() on empty handle");
884 task.SetExclusive(true);
886 catch (Dali::DaliException(e))
888 DALI_TEST_PRINT_ASSERT( e );
889 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
894 int UtcDaliRenderTaskIsExclusive01(void)
896 TestApplication application;
898 tet_infoline("Testing RenderTask::IsExclusive() Check default values are non-exclusive");
900 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
902 // Not exclusive is the default
903 RenderTask task = taskList.GetTask( 0u );
904 DALI_TEST_CHECK( false == task.IsExclusive() );
906 RenderTask newTask = taskList.CreateTask();
907 DALI_TEST_CHECK( false == newTask.IsExclusive() );
912 int UtcDaliRenderTaskIsExclusive02(void)
914 TestApplication application;
916 tet_infoline("Testing RenderTask::IsExclusive() Check the getter returns set values");
918 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
920 // Not exclusive is the default
921 RenderTask newTask = taskList.CreateTask();
922 DALI_TEST_EQUALS( newTask.IsExclusive(), false, TEST_LOCATION );
924 newTask.SetExclusive(true);
925 DALI_TEST_EQUALS( newTask.IsExclusive(), true, TEST_LOCATION );
929 int UtcDaliRenderTaskIsExclusiveN(void)
931 TestApplication application;
933 tet_infoline("Testing RenderTask::IsExclusive() on empty handle");
938 bool x = task.IsExclusive();
941 catch (Dali::DaliException(e))
943 DALI_TEST_PRINT_ASSERT( e );
944 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
949 int UtcDaliRenderTaskSetInputEnabled(void)
951 TestApplication application;
953 tet_infoline("Testing RenderTask::SetInputEnabled()");
955 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
957 // Input is enabled by default
958 RenderTask task = taskList.GetTask( 0u );
959 DALI_TEST_CHECK( true == task.GetInputEnabled() );
961 task.SetInputEnabled( false );
962 DALI_TEST_CHECK( false == task.GetInputEnabled() );
964 task.SetInputEnabled( true );
965 DALI_TEST_CHECK( true == task.GetInputEnabled() );
969 int UtcDaliRenderTaskGetInputEnabled(void)
971 TestApplication application;
973 tet_infoline("Testing RenderTask::GetInputEnabled()");
975 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
977 // Input is enabled by default
978 RenderTask task = taskList.GetTask( 0u );
979 DALI_TEST_EQUALS( true, task.GetInputEnabled(), TEST_LOCATION );
981 RenderTask newTask = taskList.CreateTask();
982 DALI_TEST_EQUALS( true, newTask.GetInputEnabled(), TEST_LOCATION );
984 newTask.SetInputEnabled(false);
985 DALI_TEST_EQUALS( false, newTask.GetInputEnabled(), TEST_LOCATION );
990 int UtcDaliRenderTaskSetCameraActorP(void)
992 TestApplication application;
994 tet_infoline("Testing RenderTask::SetCameraActor()");
996 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
998 RenderTask task = taskList.GetTask( 0u );
1000 Actor defaultCameraActor = task.GetCameraActor();
1001 DALI_TEST_CHECK( defaultCameraActor );
1003 CameraActor newCameraActor = CameraActor::New();
1004 DALI_TEST_CHECK( newCameraActor );
1006 task.SetCameraActor( newCameraActor );
1007 DALI_TEST_CHECK( task.GetCameraActor() != defaultCameraActor );
1008 DALI_TEST_EQUALS( task.GetCameraActor(), newCameraActor, TEST_LOCATION );
1013 int UtcDaliRenderTaskSetCameraActorN(void)
1015 TestApplication application;
1017 tet_infoline("Testing RenderTask::SetCameraActor() with empty actor handle");
1019 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1021 RenderTask task = taskList.GetTask( 0u );
1023 Actor actor = task.GetCameraActor();
1024 DALI_TEST_CHECK( actor );
1026 CameraActor cameraActor;
1028 task.SetCameraActor( cameraActor );
1029 DALI_TEST_EQUALS( (bool)task.GetCameraActor(), false, TEST_LOCATION );
1030 DALI_TEST_EQUALS( task.GetCameraActor(), cameraActor, TEST_LOCATION );
1035 int UtcDaliRenderTaskGetCameraActorP(void)
1037 TestApplication application;
1039 tet_infoline("Testing RenderTask::GetCameraActor()");
1041 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1043 RenderTask task = taskList.GetTask( 0u );
1045 CameraActor actor = task.GetCameraActor();
1046 DALI_TEST_CHECK( actor );
1047 DALI_TEST_EQUALS( actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION );
1048 DALI_TEST_GREATER( actor.GetFieldOfView(), 0.0f, TEST_LOCATION );
1052 int UtcDaliRenderTaskGetCameraActorN(void)
1054 TestApplication application;
1056 tet_infoline("Testing RenderTask::GetCameraActor() with empty handle");
1061 Actor actor = task.GetCameraActor();
1063 catch (Dali::DaliException(e))
1065 DALI_TEST_PRINT_ASSERT( e );
1066 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1072 int UtcDaliRenderTaskSetTargetFrameBufferP(void)
1074 TestApplication application;
1076 tet_infoline("Testing RenderTask::SetTargetFrameBuffer()");
1078 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1080 RenderTask task = taskList.GetTask( 0u );
1082 FrameBufferImage newImage = FrameBufferImage::New();
1083 task.SetTargetFrameBuffer( newImage );
1084 DALI_TEST_CHECK( task.GetTargetFrameBuffer() == newImage );
1088 int UtcDaliRenderTaskSetTargetFrameBufferN(void)
1090 TestApplication application;
1092 tet_infoline("Testing RenderTask::SetTargetFrameBuffer()");
1094 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1096 RenderTask task = taskList.GetTask( 0u );
1097 FrameBufferImage newImage; // Empty handle
1098 task.SetTargetFrameBuffer( newImage );
1099 DALI_TEST_EQUALS( (bool)task.GetTargetFrameBuffer(), false, TEST_LOCATION );
1103 int UtcDaliRenderTaskGetTargetFrameBufferP(void)
1105 TestApplication application;
1107 tet_infoline("Testing RenderTask::GetTargetFrameBuffer()");
1109 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1111 RenderTask newTask = taskList.CreateTask();
1112 FrameBufferImage fb = FrameBufferImage::New(128, 128, Pixel::RGBA8888);
1113 newTask.SetTargetFrameBuffer( fb );
1114 DALI_TEST_EQUALS( newTask.GetTargetFrameBuffer(), fb, TEST_LOCATION );
1118 int UtcDaliRenderTaskGetTargetFrameBufferN(void)
1120 TestApplication application;
1122 tet_infoline("Testing RenderTask::GetTargetFrameBuffer()");
1124 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1126 RenderTask task = taskList.GetTask( 0u );
1128 // By default render-tasks do not render off-screen
1129 FrameBufferImage image = task.GetTargetFrameBuffer();
1130 DALI_TEST_CHECK( !image );
1135 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionP(void)
1137 TestApplication application;
1139 tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1141 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1143 RenderTask task = taskList.GetTask( 0u );
1145 task.SetScreenToFrameBufferFunction( TestScreenToFrameBufferFunction );
1147 Vector2 coordinates( 5, 10 );
1148 Vector2 convertedCoordinates( 6, 12 ); // + Vector(1, 2)
1150 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1151 DALI_TEST_CHECK( func( coordinates ) );
1152 DALI_TEST_CHECK( coordinates == convertedCoordinates );
1154 task.SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
1155 func = task.GetScreenToFrameBufferFunction();
1156 DALI_TEST_CHECK( func( coordinates ) );
1158 task.SetScreenToFrameBufferFunction( RenderTask::DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION );
1159 func = task.GetScreenToFrameBufferFunction();
1160 DALI_TEST_CHECK( ! func( coordinates ) );
1164 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionN(void)
1166 TestApplication application;
1168 tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1170 RenderTask task; // Empty handle
1173 task.SetScreenToFrameBufferFunction( TestScreenToFrameBufferFunction );
1175 catch (Dali::DaliException(e))
1177 DALI_TEST_PRINT_ASSERT( e );
1178 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1183 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionP(void)
1185 TestApplication application;
1187 tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction()");
1189 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1191 RenderTask task = taskList.GetTask( 0u );
1193 Vector2 originalCoordinates( 5, 10 );
1194 Vector2 coordinates( 5, 10 );
1196 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1197 DALI_TEST_CHECK( !func( coordinates ) ); // conversion should fail by default
1198 DALI_TEST_CHECK( coordinates == originalCoordinates ); // coordinates should not be modified
1202 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionN(void)
1204 TestApplication application;
1206 tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction() on empty handle");
1211 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1214 catch (Dali::DaliException(e))
1216 DALI_TEST_PRINT_ASSERT( e );
1217 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1223 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorP(void)
1225 TestApplication application;
1226 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor ");
1228 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1229 RenderTask renderTask = taskList.CreateTask();
1230 Actor mappingActor = Actor::New();
1231 renderTask.SetScreenToFrameBufferMappingActor(mappingActor);
1233 DALI_TEST_EQUALS( mappingActor, renderTask.GetScreenToFrameBufferMappingActor(), TEST_LOCATION );
1238 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorN(void)
1240 TestApplication application;
1241 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1247 task.SetScreenToFrameBufferMappingActor(mappingActor);
1249 catch (Dali::DaliException(e))
1251 DALI_TEST_PRINT_ASSERT( e );
1252 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1257 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActor02N(void)
1259 TestApplication application;
1260 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1262 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1263 RenderTask renderTask = taskList.CreateTask();
1265 renderTask.SetScreenToFrameBufferMappingActor(actor);
1267 DALI_TEST_EQUALS( (bool)renderTask.GetScreenToFrameBufferMappingActor(), false, TEST_LOCATION);
1271 int UtcDaliRenderTaskGetViewportP01(void)
1273 TestApplication application;
1275 tet_infoline("Testing RenderTask::GetViewport() on default task");
1277 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1278 RenderTask task = taskList.GetTask( 0u );
1279 Viewport viewport = task.GetViewport();
1281 // By default the viewport should match the stage width/height
1282 Vector2 stageSize = Stage::GetCurrent().GetSize();
1283 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1284 DALI_TEST_CHECK( viewport == expectedViewport );
1288 int UtcDaliRenderTaskGetViewportP02(void)
1290 TestApplication application;
1292 tet_infoline("Testing RenderTask::GetViewport() on new task");
1294 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1295 RenderTask task = taskList.CreateTask();
1296 Viewport viewport = task.GetViewport();
1298 // By default the viewport should match the stage width/height
1299 Vector2 stageSize = Stage::GetCurrent().GetSize();
1300 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1301 DALI_TEST_CHECK( viewport == expectedViewport );
1305 int UtcDaliRenderTaskGetViewportN(void)
1307 TestApplication application;
1309 tet_infoline("Testing RenderTask::GetViewport() on empty handle");
1314 Viewport viewport = task.GetViewport();
1315 viewport = viewport;
1317 catch (Dali::DaliException(e))
1319 DALI_TEST_PRINT_ASSERT( e );
1320 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1326 int UtcDaliRenderTaskSetViewportP(void)
1328 TestApplication application;
1330 tet_infoline("Testing RenderTask::SetViewport()");
1332 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1334 RenderTask task = taskList.GetTask( 0u );
1335 Vector2 stageSize = Stage::GetCurrent().GetSize();
1336 Viewport newViewport( 0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f );
1337 task.SetViewport( newViewport );
1339 // Update (viewport is a property)
1340 application.SendNotification();
1341 application.Render();
1343 DALI_TEST_CHECK( task.GetViewport() == newViewport );
1347 int UtcDaliRenderTaskSetViewportN(void)
1349 TestApplication application;
1351 tet_infoline("Testing RenderTask::SetViewport()");
1353 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1358 Vector2 stageSize = Stage::GetCurrent().GetSize();
1359 Viewport newViewport( 0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f );
1360 task.SetViewport( newViewport );
1362 catch (Dali::DaliException(e))
1364 DALI_TEST_PRINT_ASSERT( e );
1365 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1372 int UtcDaliRenderTaskSetViewportPosition(void)
1374 TestApplication application;
1376 tet_infoline("Testing RenderTask::SetViewportPosition()");
1378 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1380 RenderTask task = taskList.GetTask( 0u );
1382 Viewport viewport = task.GetViewport();
1384 // By default the viewport should match the stage width/height
1386 Vector2 stageSize = Stage::GetCurrent().GetSize();
1387 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1388 DALI_TEST_CHECK( viewport == expectedViewport );
1391 Vector2 newPosition(25.0f, 50.0f);
1392 task.SetViewportPosition( newPosition );
1394 // Update (viewport is a property)
1395 application.SendNotification();
1396 application.Render();
1398 DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1400 // Set by Property test
1401 Vector2 newPosition2(32.0f, 32.0f);
1402 task.SetProperty( RenderTask::Property::VIEWPORT_POSITION, newPosition2 );
1405 application.SendNotification();
1406 application.Render();
1408 DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition2, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1410 Vector2 newPosition3(64.0f, 0.0f);
1411 Animation animation = Animation::New(1.0f);
1412 animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_POSITION ), newPosition3, AlphaFunction::LINEAR );
1415 // Perform 1000ms worth of updates at which point animation should have completed.
1416 Wait(application, 1000);
1417 DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1421 int UtcDaliRenderTaskSetViewportSize(void)
1423 TestApplication application;
1425 tet_infoline("Testing RenderTask::SetViewportSize()");
1427 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1429 RenderTask task = taskList.GetTask( 0u );
1431 Viewport viewport = task.GetViewport();
1433 // By default the viewport should match the stage width/height
1435 Vector2 stageSize = Stage::GetCurrent().GetSize();
1436 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1437 DALI_TEST_CHECK( viewport == expectedViewport );
1439 Vector2 newSize(128.0f, 64.0f);
1440 task.SetViewportSize( newSize );
1442 // Update (viewport is a property)
1443 application.SendNotification();
1444 application.Render();
1446 DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1448 // Set by Property test
1449 Vector2 newSize2(50.0f, 50.0f);
1450 task.SetProperty( RenderTask::Property::VIEWPORT_SIZE, newSize2 );
1453 application.SendNotification();
1454 application.Render();
1456 DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize2, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1458 Vector2 newSize3(10.0f, 10.0f);
1459 Animation animation = Animation::New(1.0f);
1460 animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_SIZE ), newSize3, AlphaFunction::LINEAR );
1463 // Perform 1000ms worth of updates at which point animation should have completed.
1464 Wait(application, 1000);
1465 DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1470 int UtcDaliRenderTaskSetClearColorP(void)
1472 TestApplication application;
1474 tet_infoline("Testing RenderTask::SetClearColor()");
1476 Vector4 testColor( 1.0f, 2.0f, 3.0f, 4.0f );
1477 Vector4 testColor2( 5.0f, 6.0f, 7.0f, 8.0f );
1479 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1481 RenderTask task = taskList.GetTask( 0u );
1482 DALI_TEST_CHECK( task.GetClearColor() != testColor );
1484 task.SetClearColor( testColor );
1489 DALI_TEST_EQUALS( task.GetClearColor(), testColor, TEST_LOCATION );
1491 task.SetProperty( RenderTask::Property::CLEAR_COLOR, testColor2 );
1496 DALI_TEST_EQUALS( task.GetClearColor(), testColor2, TEST_LOCATION );
1500 int UtcDaliRenderTaskSetClearColorN(void)
1502 TestApplication application;
1504 tet_infoline("Testing RenderTask::SetClearColor() on empty handle");
1509 task.SetClearColor( Vector4::ZERO );
1511 catch (Dali::DaliException(e))
1513 DALI_TEST_PRINT_ASSERT( e );
1514 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1519 int UtcDaliRenderTaskGetClearColorP(void)
1521 TestApplication application;
1523 tet_infoline("Testing RenderTask::GetClearColor()");
1525 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1526 RenderTask task = taskList.GetTask( 0u );
1527 DALI_TEST_EQUALS( task.GetClearColor(), RenderTask::DEFAULT_CLEAR_COLOR, TEST_LOCATION );
1531 int UtcDaliRenderTaskGetClearColorN(void)
1533 TestApplication application;
1535 tet_infoline("Testing RenderTask::GetClearColor()");
1540 Vector4 color = task.GetClearColor();
1543 catch (Dali::DaliException(e))
1545 DALI_TEST_PRINT_ASSERT( e );
1546 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1551 int UtcDaliRenderTaskSetClearEnabledP(void)
1553 TestApplication application;
1555 tet_infoline("Testing RenderTask::SetClearEnabled()");
1557 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1559 RenderTask task = taskList.GetTask( 0u );
1560 DALI_TEST_CHECK( !task.GetClearEnabled() ); // defaults to false
1562 task.SetClearEnabled( true );
1563 DALI_TEST_EQUALS( task.GetClearEnabled(), true, TEST_LOCATION );
1565 task.SetClearEnabled( false );
1566 DALI_TEST_EQUALS( task.GetClearEnabled(), false, TEST_LOCATION );
1570 int UtcDaliRenderTaskSetClearEnabledN(void)
1572 TestApplication application;
1574 tet_infoline("Testing RenderTask::SetClearEnabled() with empty handle");
1579 task.SetClearEnabled(true);
1581 catch (Dali::DaliException(e))
1583 DALI_TEST_PRINT_ASSERT( e );
1584 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1589 int UtcDaliRenderTaskGetClearEnabledP(void)
1591 TestApplication application;
1593 tet_infoline("Testing RenderTask::GetClearEnabled()");
1595 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1597 RenderTask task = taskList.GetTask( 0u );
1598 DALI_TEST_CHECK( !task.GetClearEnabled() ); // defaults to false
1603 int UtcDaliRenderTaskGetClearEnabledN(void)
1605 TestApplication application;
1607 tet_infoline("Testing RenderTask::GetClearEnabled() with empty handle");
1612 bool x = task.GetClearEnabled();
1615 catch (Dali::DaliException(e))
1617 DALI_TEST_PRINT_ASSERT( e );
1618 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1623 int UtcDaliRenderTaskSetCullModeP(void)
1625 TestApplication application;
1627 tet_infoline("Testing RenderTask::SetCullMode()");
1629 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1630 RenderTask task = taskList.GetTask( 0u );
1631 DALI_TEST_EQUALS( task.GetCullMode(), true, TEST_LOCATION );
1633 task.SetCullMode( false );
1635 DALI_TEST_EQUALS( task.GetCullMode(), false, TEST_LOCATION );
1640 int UtcDaliRenderTaskSetCullModeN(void)
1642 TestApplication application;
1644 tet_infoline("Testing RenderTask::SetCullMode() on empty handle");
1649 task.SetCullMode( false );
1651 catch (Dali::DaliException(e))
1653 DALI_TEST_PRINT_ASSERT( e );
1654 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1659 int UtcDaliRenderTaskGetCullModeP(void)
1661 TestApplication application;
1663 tet_infoline("Testing RenderTask::GetCullMode()");
1665 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1666 RenderTask task = taskList.GetTask( 0u );
1667 DALI_TEST_EQUALS( task.GetCullMode(), true, TEST_LOCATION );
1671 int UtcDaliRenderTaskGetCullModeN(void)
1673 TestApplication application;
1675 tet_infoline("Testing RenderTask::GetCullMode() with empty handle");
1680 bool x = task.GetCullMode();
1683 catch (Dali::DaliException(e))
1685 DALI_TEST_PRINT_ASSERT( e );
1686 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1692 int UtcDaliRenderTaskSetRefreshRate(void)
1694 TestApplication application;
1696 tet_infoline("Testing RenderTask::SetRefreshRate()");
1698 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1700 // By default tasks will be processed every frame
1701 RenderTask task = taskList.GetTask( 0u );
1702 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1704 task.SetRefreshRate( 2u ); // every-other frame
1705 DALI_TEST_CHECK( 2u == task.GetRefreshRate() );
1707 task.SetRefreshRate( RenderTask::REFRESH_ALWAYS );
1708 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1712 int UtcDaliRenderTaskGetRefreshRate(void)
1714 TestApplication application;
1716 tet_infoline("Testing RenderTask::GetRefreshRate()");
1718 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1720 // By default tasks will be processed every frame
1721 RenderTask task = taskList.GetTask( 0u );
1722 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1724 RenderTask newTask = taskList.CreateTask();
1725 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == newTask.GetRefreshRate() );
1729 int UtcDaliRenderTaskSignalFinished(void)
1731 TestApplication application;
1733 tet_infoline("Testing RenderTask::SignalFinished()");
1735 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1736 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
1738 CameraActor offscreenCameraActor = CameraActor::New();
1740 Stage::GetCurrent().Add( offscreenCameraActor );
1742 BufferImage image = BufferImage::New( 10, 10 );
1743 ImageActor rootActor = ImageActor::New( image );
1744 rootActor.SetSize( 10, 10 );
1745 Stage::GetCurrent().Add( rootActor );
1747 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1748 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
1749 FrameBufferImage frameBufferImage = FrameBufferImage::New( *testNativeImagePtr.Get() );
1751 // Flush all outstanding messages
1752 application.SendNotification();
1753 application.Render();
1755 RenderTask newTask = taskList.CreateTask();
1756 newTask.SetCameraActor( offscreenCameraActor );
1757 newTask.SetSourceActor( rootActor );
1758 newTask.SetInputEnabled( false );
1759 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
1760 newTask.SetClearEnabled( true );
1761 newTask.SetExclusive( true );
1762 newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
1763 newTask.SetTargetFrameBuffer( frameBufferImage );
1765 // Framebuffer doesn't actually get created until Connected, i.e. by previous line
1767 bool finished = false;
1768 RenderTaskFinished renderTaskFinished( finished );
1769 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1771 // Flush the queue and render.
1772 application.SendNotification();
1774 // 1 render to process render task, then wait for sync before finished msg is sent
1775 // from update to the event thread.
1777 application.Render();
1778 application.SendNotification();
1779 DALI_TEST_CHECK( !finished );
1781 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
1782 DALI_TEST_CHECK( lastSyncObj != NULL );
1784 application.Render();
1785 DALI_TEST_EQUALS( (application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
1786 application.SendNotification();
1787 DALI_TEST_CHECK( !finished );
1789 application.Render();
1790 DALI_TEST_EQUALS( (application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
1791 application.SendNotification();
1792 DALI_TEST_CHECK( ! finished );
1794 sync.SetObjectSynced( lastSyncObj, true );
1796 application.Render();
1797 application.SendNotification();
1798 DALI_TEST_CHECK( !finished );
1800 application.Render();
1801 application.SendNotification();
1802 DALI_TEST_CHECK( finished );
1805 application.Render(); // Double check no more finished signal
1806 application.SendNotification();
1807 DALI_TEST_CHECK( ! finished );
1812 int UtcDaliRenderTaskContinuous01(void)
1814 TestApplication application;
1816 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not staged)\nPOST:continuous renders, no Finished signal");
1818 // SETUP AN OFFSCREEN RENDER TASK
1819 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1820 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1821 drawTrace.Enable(true);
1823 Actor rootActor = Actor::New();
1824 Stage::GetCurrent().Add( rootActor );
1826 CameraActor offscreenCameraActor = CameraActor::New();
1827 Stage::GetCurrent().Add( offscreenCameraActor );
1829 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1830 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1831 Integration::ResourceId imageRequestId = imageRequest->GetId();
1832 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1834 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1835 bool finished = false;
1836 RenderTaskFinished renderTaskFinished( finished );
1837 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1838 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1839 application.SendNotification();
1841 // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating
1842 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false ) );
1843 application.GetPlatform().ClearReadyResources();
1845 // ADD SOURCE ACTOR TO STAGE - expect continuous renders to start, no finished signal
1846 Stage::GetCurrent().Add(secondRootActor);
1847 application.SendNotification();
1849 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1850 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
1855 int UtcDaliRenderTaskContinuous02(void)
1857 TestApplication application;
1859 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not visible)\nPOST:continuous renders, no Finished signal");
1861 // SETUP AN OFFSCREEN RENDER TASK
1862 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1863 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1864 drawTrace.Enable(true);
1866 Actor rootActor = Actor::New();
1867 Stage::GetCurrent().Add( rootActor );
1869 CameraActor offscreenCameraActor = CameraActor::New();
1870 Stage::GetCurrent().Add( offscreenCameraActor );
1872 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1873 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1874 Integration::ResourceId imageRequestId = imageRequest->GetId();
1875 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1876 Stage::GetCurrent().Add(secondRootActor);
1877 secondRootActor.SetVisible(false);
1879 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1880 bool finished = false;
1881 RenderTaskFinished renderTaskFinished( finished );
1882 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1883 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1884 application.SendNotification();
1886 // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating
1887 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false ) );
1888 application.GetPlatform().ClearReadyResources();
1890 // MAKE SOURCE ACTOR VISIBLE - expect continuous renders to start, no finished signal
1891 secondRootActor.SetVisible(true);
1892 application.SendNotification();
1894 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1895 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
1899 int UtcDaliRenderTaskContinuous03(void)
1901 TestApplication application;
1903 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (camera actor not staged)\nPOST:continuous renders, no Finished signal");
1905 // SETUP AN OFFSCREEN RENDER TASK
1906 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1907 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1908 drawTrace.Enable(true);
1910 Actor rootActor = Actor::New();
1911 Stage::GetCurrent().Add( rootActor );
1913 CameraActor offscreenCameraActor = CameraActor::New();
1914 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1915 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1916 Integration::ResourceId imageRequestId = imageRequest->GetId();
1917 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1918 Stage::GetCurrent().Add(secondRootActor);
1920 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1921 bool finished = false;
1922 RenderTaskFinished renderTaskFinished( finished );
1923 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1924 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1925 application.SendNotification();
1927 // START PROCESS/RENDER Input, Expected Input, Expected
1928 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false ) );
1929 application.GetPlatform().ClearReadyResources();
1931 // ADD CAMERA ACTOR TO STAGE - expect continuous renders to start, no finished signal
1932 Stage::GetCurrent().Add( offscreenCameraActor );
1933 application.SendNotification();
1935 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1936 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
1941 int UtcDaliRenderTaskContinuous04(void)
1943 TestApplication application;
1945 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: Resource not ready\nPOST:continuous renders, no Finished signal");
1947 // SETUP AN OFFSCREEN RENDER TASK
1948 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1949 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1950 drawTrace.Enable(true);
1952 Actor rootActor = Actor::New();
1953 Stage::GetCurrent().Add( rootActor );
1955 CameraActor offscreenCameraActor = CameraActor::New();
1956 Stage::GetCurrent().Add( offscreenCameraActor );
1957 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1958 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1959 Integration::ResourceId imageRequestId = imageRequest->GetId();
1960 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1961 Stage::GetCurrent().Add(secondRootActor);
1963 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1964 bool finished = false;
1965 RenderTaskFinished renderTaskFinished( finished );
1966 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1967 application.SendNotification();
1969 // START PROCESS/RENDER Input, Expected Input, Expected
1970 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
1971 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
1973 // FINISH RESOURCE LOADING - expect 'continuous' renders to start, no finished signal
1974 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1975 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
1979 int UtcDaliRenderTaskContinous05(void)
1981 TestApplication application;
1983 tet_infoline("Testing RenderTask Render Continuous using Mesh which accesses texture through sampler with loading image\n"
1984 "PRE: Resource not ready\nPOST:continuous renders, no Finished signal");
1986 // SETUP AN OFFSCREEN RENDER TASK
1987 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1988 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1989 drawTrace.Enable(true);
1991 Actor rootActor = Actor::New();
1992 Stage::GetCurrent().Add( rootActor );
1994 CameraActor offscreenCameraActor = CameraActor::New();
1995 Stage::GetCurrent().Add( offscreenCameraActor );
1997 Material material = CreateMaterial(1.0f);
1998 Sampler sampler = CreateSamplerWithLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1999 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2000 Integration::ResourceId imageRequestId = imageRequest->GetId();
2001 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2002 material.AddSampler( sampler );
2004 Geometry geometry = CreateQuadGeometry();
2005 Renderer renderer = Renderer::New(geometry, material);
2006 Actor secondRootActor = Actor::New();
2007 secondRootActor.AddRenderer(renderer);
2008 secondRootActor.SetSize(100, 100);
2009 Stage::GetCurrent().Add(secondRootActor);
2011 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2012 bool finished = false;
2013 RenderTaskFinished renderTaskFinished( finished );
2014 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2015 application.SendNotification();
2017 // START PROCESS/RENDER Input, Expected Input, Expected
2018 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2019 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2021 // FINISH RESOURCE LOADING - expect 'continuous' renders to start, no finished signal
2022 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2023 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
2029 int UtcDaliRenderTaskOnce01(void)
2031 TestApplication application;
2033 tet_infoline("Testing RenderTask Render Once GlSync, using loading image\nPRE: Resources not ready, Source not visible\nPOST: Finished signal sent once only");
2035 // SETUP AN OFFSCREEN RENDER TASK
2036 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2037 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2038 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2039 drawTrace.Enable(true);
2041 Actor rootActor = Actor::New();
2042 Stage::GetCurrent().Add( rootActor );
2044 CameraActor offscreenCameraActor = CameraActor::New();
2045 Stage::GetCurrent().Add( offscreenCameraActor );
2046 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2047 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2048 Integration::ResourceId imageRequestId = imageRequest->GetId();
2049 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2051 Stage::GetCurrent().Add(secondRootActor);
2053 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
2054 bool finished = false;
2055 RenderTaskFinished renderTaskFinished( finished );
2056 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2057 application.SendNotification();
2059 // START PROCESS/RENDER Input, Expected Input, Expected
2060 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2061 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2063 // MAKE SOURCE VISIBLE
2064 secondRootActor.SetVisible(true);
2065 application.SendNotification();
2066 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2067 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2069 // FINISH RESOURCE LOADING - expect no rendering yet
2070 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2071 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2072 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2073 DALI_TEST_CHECK( lastSyncObj != NULL );
2075 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2076 application.GetPlatform().ClearReadyResources();
2077 sync.SetObjectSynced( lastSyncObj, true );
2078 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2079 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2083 int UtcDaliRenderTaskOnce02(void)
2085 TestApplication application;
2087 tet_infoline("Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loading image.\n"
2088 "PRE: Resources not ready\nPOST: Finished signal sent once only");
2090 // SETUP AN OFFSCREEN RENDER TASK
2091 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2092 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2093 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2094 drawTrace.Enable(true);
2096 Actor rootActor = Actor::New();
2097 Stage::GetCurrent().Add( rootActor );
2099 CameraActor offscreenCameraActor = CameraActor::New();
2100 Stage::GetCurrent().Add( offscreenCameraActor );
2102 Material material = CreateMaterial(1.0f);
2103 Sampler sampler = CreateSamplerWithLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2104 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2105 Integration::ResourceId imageRequestId = imageRequest->GetId();
2106 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2107 material.AddSampler( sampler );
2109 Geometry geometry = CreateQuadGeometry();
2110 Renderer renderer = Renderer::New(geometry, material);
2111 Actor secondRootActor = Actor::New();
2112 secondRootActor.AddRenderer(renderer);
2113 secondRootActor.SetSize(100, 100);
2114 Stage::GetCurrent().Add(secondRootActor);
2116 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
2117 bool finished = false;
2118 RenderTaskFinished renderTaskFinished( finished );
2119 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2120 application.SendNotification();
2122 // START PROCESS/RENDER Input, Expected Input, Expected
2123 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2124 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2126 // FINISH RESOURCE LOADING - expect no rendering yet
2127 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2128 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2129 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2130 DALI_TEST_CHECK( lastSyncObj != NULL );
2132 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2133 application.GetPlatform().ClearReadyResources();
2134 sync.SetObjectSynced( lastSyncObj, true );
2135 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2136 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2141 int UtcDaliRenderTaskOnce03(void)
2143 TestApplication application;
2145 tet_infoline("Testing RenderTask Render Once GlSync, using loading image. Switch from render always after ready to render once\n"
2146 "PRE: Render task ready, Image not loaded\n"
2147 "POST: Finished signal sent only once");
2149 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2150 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2151 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2152 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2153 drawTrace.Enable(true);
2155 Actor rootActor = Actor::New();
2156 Stage::GetCurrent().Add( rootActor );
2158 CameraActor offscreenCameraActor = CameraActor::New();
2159 Stage::GetCurrent().Add( offscreenCameraActor );
2160 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2161 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2162 Integration::ResourceId imageRequestId = imageRequest->GetId();
2163 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2164 Stage::GetCurrent().Add(secondRootActor);
2166 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2167 bool finished = false;
2168 RenderTaskFinished renderTaskFinished( finished );
2169 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2170 application.SendNotification();
2172 // START PROCESS/RENDER Input, Expected Input, Expected
2173 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2174 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2176 // FINISH RESOURCE LOADING
2177 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2178 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
2179 application.GetPlatform().ClearReadyResources();
2180 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
2182 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2183 application.SendNotification(); // Input, Expected Input, Expected
2184 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2185 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2186 DALI_TEST_CHECK( lastSyncObj != NULL );
2188 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2189 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2190 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2191 sync.SetObjectSynced( lastSyncObj, true );
2192 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2193 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2199 int UtcDaliRenderTaskOnce04(void)
2201 TestApplication application;
2202 tet_infoline("Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loading image.\n"
2203 "Switch from render always after ready to render once\n"
2204 "PRE: Render task ready, Image not loaded\n"
2205 "POST: Finished signal sent only once");
2207 // SETUP AN OFFSCREEN RENDER TASK
2208 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2209 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2210 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2211 drawTrace.Enable(true);
2213 Actor rootActor = Actor::New();
2214 Stage::GetCurrent().Add( rootActor );
2216 CameraActor offscreenCameraActor = CameraActor::New();
2217 Stage::GetCurrent().Add( offscreenCameraActor );
2219 Material material = CreateMaterial(1.0f);
2220 Sampler sampler = CreateSamplerWithLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2221 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2222 Integration::ResourceId imageRequestId = imageRequest->GetId();
2223 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2224 material.AddSampler( sampler );
2226 Geometry geometry = CreateQuadGeometry();
2227 Renderer renderer = Renderer::New(geometry, material);
2228 Actor secondRootActor = Actor::New();
2229 secondRootActor.AddRenderer(renderer);
2230 secondRootActor.SetSize(100, 100);
2231 Stage::GetCurrent().Add(secondRootActor);
2233 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2234 bool finished = false;
2235 RenderTaskFinished renderTaskFinished( finished );
2236 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2237 application.SendNotification();
2239 // START PROCESS/RENDER Input, Expected Input, Expected
2240 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2241 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2243 // FINISH RESOURCE LOADING
2244 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2245 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
2246 application.GetPlatform().ClearReadyResources();
2247 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
2249 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2250 application.SendNotification(); // Input, Expected Input, Expected
2251 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2252 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2253 DALI_TEST_CHECK( lastSyncObj != NULL );
2255 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2256 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2257 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2258 sync.SetObjectSynced( lastSyncObj, true );
2259 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2260 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2265 int UtcDaliRenderTaskOnce05(void)
2267 TestApplication application;
2269 tet_infoline("Testing RenderTask Render Once GlSync\n"
2270 "Switch from Render always after ready to render once with resources unready\n"
2271 "PRE: Everything ready to render\n"
2272 "POST: Finished signal sent once");
2274 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2275 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2276 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2277 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2278 drawTrace.Enable(true);
2280 Actor rootActor = Actor::New();
2281 Stage::GetCurrent().Add( rootActor );
2283 CameraActor offscreenCameraActor = CameraActor::New();
2284 Stage::GetCurrent().Add( offscreenCameraActor );
2285 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2286 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2287 Integration::ResourceId imageRequestId = imageRequest->GetId();
2288 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2289 Stage::GetCurrent().Add(secondRootActor);
2291 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2292 bool finished = false;
2293 RenderTaskFinished renderTaskFinished( finished );
2294 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2295 application.SendNotification();
2297 // START PROCESS/RENDER Input, Expected Input, Expected
2298 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2299 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2301 // CHANGE TO RENDER ONCE
2302 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2303 application.SendNotification(); // Input, Expected Input, Expected
2304 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2305 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2307 // FINISH RESOURCE LOADING
2308 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2309 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2310 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2311 DALI_TEST_CHECK( lastSyncObj != NULL );
2312 application.GetPlatform().ClearReadyResources();
2314 sync.SetObjectSynced( lastSyncObj, true );
2316 // Expect: No draw - we've just drawn our render task once, above. No finished signal -
2317 // we won't read the gl sync until the next frame. Continue rendering - we're waiting for
2319 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2321 // Expect: 1 final draw - this Update doesn't update the scene, hence render instructions
2322 // from last frame but 1 are still present.
2323 // Finished signal should be true - we've just done the sync.
2324 // Should now stop rendering and updating - nothing left to do.
2325 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, true, false ) );
2331 //int UtcDaliRenderTaskOnce06(void)
2333 TestApplication application;
2335 tet_infoline("Testing RenderTask Render Once GlSync\n"
2336 "During RenderOnce, make ready resources unready before sending first finished signal\n"
2337 "PRE: Everything ready.\n"
2338 "POST: Finished signal sent only once");
2340 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2341 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2342 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2343 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2344 drawTrace.Enable(true);
2346 Actor rootActor = Actor::New();
2347 Stage::GetCurrent().Add( rootActor );
2349 CameraActor offscreenCameraActor = CameraActor::New();
2350 Stage::GetCurrent().Add( offscreenCameraActor );
2351 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2352 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2353 Integration::ResourceId imageRequestId = imageRequest->GetId();
2354 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2355 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2356 application.Render();
2358 Stage::GetCurrent().Add(secondRootActor);
2359 application.GetPlatform().ClearReadyResources();
2361 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2362 bool finished = false;
2363 RenderTaskFinished renderTaskFinished( finished );
2364 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2365 application.SendNotification();
2367 // START PROCESS/RENDER Input, Expected Input, Expected
2368 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2369 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2371 // CHANGE TO RENDER ONCE, RESOURCES BECOME NOT READY
2372 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2375 ReloadImage(application, secondRootActor.GetImage());
2376 application.SendNotification(); // Input, Expected Input, Expected
2378 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2379 DALI_TEST_EQUALS( secondRootActor.GetImage().GetLoadingState(), Dali::ResourceLoading, TEST_LOCATION);
2380 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2382 // FINISH RESOURCE LOADING
2383 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2384 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2385 application.GetPlatform().ClearReadyResources();
2386 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2387 DALI_TEST_CHECK( lastSyncObj != NULL );
2389 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2390 sync.SetObjectSynced( lastSyncObj, true );
2391 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2392 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, true ) );
2394 // Finished rendering - expect no more renders, no more signals:
2395 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2396 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2397 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2398 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2399 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2400 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2405 int UtcDaliRenderTaskOnce07(void)
2407 TestApplication application;
2409 tet_infoline("Testing RenderTask Render Once GLSync\n"
2410 "Render once, Second call to SetRefreshRate(ONCE) triggers only one more finished signal\n"
2411 "PRE: Everything ready\n"
2412 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
2414 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2415 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2416 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2417 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2418 drawTrace.Enable(true);
2420 Actor rootActor = Actor::New();
2421 Stage::GetCurrent().Add( rootActor );
2423 CameraActor offscreenCameraActor = CameraActor::New();
2424 Stage::GetCurrent().Add( offscreenCameraActor );
2425 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2426 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2427 Integration::ResourceId imageRequestId = imageRequest->GetId();
2428 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2429 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2430 application.Render();
2431 application.GetPlatform().ClearReadyResources();
2433 Stage::GetCurrent().Add(secondRootActor);
2435 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2436 bool finished = false;
2437 RenderTaskFinished renderTaskFinished( finished );
2438 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2439 application.SendNotification();
2441 // START PROCESS/RENDER Input, Expected Input, Expected
2442 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
2444 // CHANGE TO RENDER ONCE,
2445 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2446 application.SendNotification();
2447 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2448 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2449 DALI_TEST_CHECK( lastSyncObj != NULL );
2451 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2452 sync.SetObjectSynced( lastSyncObj, true );
2453 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2454 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2456 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2457 application.SendNotification();
2458 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2459 lastSyncObj = sync.GetLastSyncObject();
2460 DALI_TEST_CHECK( lastSyncObj != NULL );
2462 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2463 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2464 sync.SetObjectSynced( lastSyncObj, true );
2465 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2466 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2470 int UtcDaliRenderTaskOnce08(void)
2472 TestApplication application;
2474 tet_infoline("Testing RenderTask Render Once GLSync\n"
2475 "Render once, Call to SetRefreshRate(ONCE) in Finished signal callback triggers "
2476 "another render & another finished signal\n"
2477 "PRE: Everything ready\n"
2478 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
2481 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2482 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2483 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2484 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2485 drawTrace.Enable(true);
2487 Actor rootActor = Actor::New();
2488 Stage::GetCurrent().Add( rootActor );
2490 CameraActor offscreenCameraActor = CameraActor::New();
2491 Stage::GetCurrent().Add( offscreenCameraActor );
2492 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2493 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2494 Integration::ResourceId imageRequestId = imageRequest->GetId();
2495 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2496 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2497 application.Render();
2498 application.GetPlatform().ClearReadyResources();
2500 Stage::GetCurrent().Add(secondRootActor);
2502 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2503 bool finished = false;
2505 ConnectionTracker connectionTracker;
2506 RenderTaskFinishedRenderAgain renderTaskFinishedRenderAgain( finished );
2507 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinishedRenderAgain );
2509 application.SendNotification();
2511 // START PROCESS/RENDER Input, Expected Input, Expected
2512 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
2513 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2514 DALI_TEST_CHECK( lastSyncObj == NULL );
2516 // CHANGE TO RENDER ONCE,
2517 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2518 application.SendNotification();
2519 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2520 lastSyncObj = sync.GetLastSyncObject();
2521 DALI_TEST_CHECK( lastSyncObj != NULL );
2523 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2524 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2526 sync.SetObjectSynced( lastSyncObj, true );
2527 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2528 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2529 application.SendNotification();
2531 // Expect SetRefreshRate to have been called again
2532 // Prevent next finished signal calling refresh once again
2533 RenderTaskFinished renderTaskFinished( finished );
2534 connectionTracker.DisconnectAll();
2535 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinished );
2536 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2537 lastSyncObj = sync.GetLastSyncObject();
2538 DALI_TEST_CHECK( lastSyncObj != NULL );
2540 sync.SetObjectSynced( lastSyncObj, true );
2541 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2542 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2547 int UtcDaliRenderTaskOnce09(void)
2549 TestApplication application;
2551 tet_infoline("Testing RenderTask Render Once GlSync\n"
2552 "SetRefreshRate(ONCE) again before first finished signal has been sent.\n"
2553 "PRE: resources ready\n"
2554 "POST: Only 1 finished signal sent.");
2556 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2557 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2558 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2559 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2560 drawTrace.Enable(true);
2562 Actor rootActor = Actor::New();
2563 Stage::GetCurrent().Add( rootActor );
2565 CameraActor offscreenCameraActor = CameraActor::New();
2566 Stage::GetCurrent().Add( offscreenCameraActor );
2567 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2568 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2569 Integration::ResourceId imageRequestId = imageRequest->GetId();
2570 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2571 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2572 application.Render();
2573 application.GetPlatform().ClearReadyResources();
2575 Stage::GetCurrent().Add(secondRootActor);
2577 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2578 bool finished = false;
2579 RenderTaskFinished renderTaskFinished( finished );
2580 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2581 application.SendNotification();
2583 // START PROCESS/RENDER Input, Expected Input, Expected
2584 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
2586 // CHANGE TO RENDER ONCE,
2587 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2588 application.SendNotification();
2589 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2590 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2591 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2593 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2594 application.SendNotification();
2595 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2596 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2597 DALI_TEST_CHECK( lastSyncObj != NULL );
2599 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2600 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2601 sync.SetObjectSynced( lastSyncObj, true );
2602 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2603 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2608 int UtcDaliRenderTaskOnce10(void)
2610 TestApplication application;
2612 tet_infoline("Testing RenderTask Render Once GlSync\n"
2613 "SetRefreshRate(ONCE), resource load failed completes render task.\n"
2614 "PRE: resources not ready\n"
2615 "POST: Only 1 finished signal sent.");
2617 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2618 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2619 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2620 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2621 drawTrace.Enable(true);
2623 Actor rootActor = Actor::New();
2624 Stage::GetCurrent().Add( rootActor );
2626 CameraActor offscreenCameraActor = CameraActor::New();
2627 Stage::GetCurrent().Add( offscreenCameraActor );
2628 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2629 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2630 Integration::ResourceId imageRequestId = imageRequest->GetId();
2631 Stage::GetCurrent().Add(secondRootActor);
2633 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2634 bool finished = false;
2635 RenderTaskFinished renderTaskFinished( finished );
2636 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2637 application.SendNotification();
2639 // START PROCESS/RENDER Input, Expected Input, Expected
2640 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2641 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2643 // CHANGE TO RENDER ONCE,
2644 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2645 application.SendNotification();
2646 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2647 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2648 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2650 tet_printf(" FailImageLoad\n");
2652 FailImageLoad(application, imageRequestId); // Need to run Update again for this to complete
2654 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) ); // nothing to draw
2655 application.SendNotification();
2657 // Drawing empty framebuffer, so will still get a GL sync
2658 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2659 DALI_TEST_CHECK( lastSyncObj != NULL );
2661 sync.SetObjectSynced( lastSyncObj, true );
2663 // Expect finished signal, as all resources are complete
2664 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2665 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2670 int UtcDaliRenderTaskOnceNoSync01(void)
2672 TestApplication application;
2674 tet_infoline("Testing RenderTask Render Once, using loading image\nPRE: Resources not ready, Source not visible\nPOST: Finished signal sent once only");
2676 // SETUP AN OFFSCREEN RENDER TASK
2677 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2678 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2679 drawTrace.Enable(true);
2681 Actor rootActor = Actor::New();
2682 Stage::GetCurrent().Add( rootActor );
2684 CameraActor offscreenCameraActor = CameraActor::New();
2685 Stage::GetCurrent().Add( offscreenCameraActor );
2686 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2687 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2688 Integration::ResourceId imageRequestId = imageRequest->GetId();
2689 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2691 Stage::GetCurrent().Add(secondRootActor);
2693 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2694 bool finished = false;
2695 RenderTaskFinished renderTaskFinished( finished );
2696 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2697 application.SendNotification();
2699 // START PROCESS/RENDER Input, Expected Input, Expected
2700 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2701 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2703 // FINISH RESOURCE LOADING - expect immediate rendering yet
2704 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2705 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2706 application.GetPlatform().ClearReadyResources();
2707 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2711 int UtcDaliRenderTaskOnceNoSync02(void)
2713 TestApplication application;
2715 tet_infoline("Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loading image.\n"
2716 "PRE: Resources not ready\nPOST: Finished signal sent once only");
2717 // SETUP AN OFFSCREEN RENDER TASK
2718 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2719 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2720 drawTrace.Enable(true);
2722 Actor rootActor = Actor::New();
2723 Stage::GetCurrent().Add( rootActor );
2725 CameraActor offscreenCameraActor = CameraActor::New();
2726 Stage::GetCurrent().Add( offscreenCameraActor );
2728 Material material = CreateMaterial(1.0f);
2729 Sampler sampler = CreateSamplerWithLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2730 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2731 Integration::ResourceId imageRequestId = imageRequest->GetId();
2732 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2733 material.AddSampler( sampler );
2735 Geometry geometry = CreateQuadGeometry();
2736 Renderer renderer = Renderer::New(geometry, material);
2737 Actor secondRootActor = Actor::New();
2738 secondRootActor.AddRenderer(renderer);
2739 secondRootActor.SetSize(100, 100);
2740 Stage::GetCurrent().Add(secondRootActor);
2742 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2743 bool finished = false;
2744 RenderTaskFinished renderTaskFinished( finished );
2745 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2746 application.SendNotification();
2748 // START PROCESS/RENDER Input, Expected Input, Expected
2749 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2750 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2752 // FINISH RESOURCE LOADING - expect immediate rendering yet
2753 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2754 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2755 application.GetPlatform().ClearReadyResources();
2756 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2761 int UtcDaliRenderTaskOnceNoSync03(void)
2763 TestApplication application;
2765 tet_infoline("Testing RenderTask Render Once, using loading image. Switch from render always after ready to render once\n"
2766 "PRE: Render task ready, Image not loaded\n"
2767 "POST: Finished signal sent only once");
2769 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2770 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2771 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2772 drawTrace.Enable(true);
2774 Actor rootActor = Actor::New();
2775 Stage::GetCurrent().Add( rootActor );
2777 CameraActor offscreenCameraActor = CameraActor::New();
2778 Stage::GetCurrent().Add( offscreenCameraActor );
2779 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2780 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2781 Integration::ResourceId imageRequestId = imageRequest->GetId();
2782 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2783 Stage::GetCurrent().Add(secondRootActor);
2785 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2786 bool finished = false;
2787 RenderTaskFinished renderTaskFinished( finished );
2788 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2789 application.SendNotification();
2791 // START PROCESS/RENDER Input, Expected Input, Expected
2792 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2793 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2795 // FINISH RESOURCE LOADING
2796 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2797 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
2798 application.GetPlatform().ClearReadyResources();
2800 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2801 application.SendNotification(); // Input, Expected Input, Expected
2802 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2803 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2807 int UtcDaliRenderTaskOnceNoSync04(void)
2809 TestApplication application;
2811 tet_infoline("Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loading image.\n"
2812 "Switch from render always after ready to render once\n"
2813 "PRE: Render task ready, Image not loaded\n"
2814 "POST: Finished signal sent only once");
2816 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2817 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2818 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2819 drawTrace.Enable(true);
2821 Actor rootActor = Actor::New();
2822 Stage::GetCurrent().Add( rootActor );
2824 CameraActor offscreenCameraActor = CameraActor::New();
2825 Stage::GetCurrent().Add( offscreenCameraActor );
2827 Material material = CreateMaterial(1.0f);
2828 Sampler sampler = CreateSamplerWithLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2829 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2830 Integration::ResourceId imageRequestId = imageRequest->GetId();
2831 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2832 material.AddSampler( sampler );
2834 Geometry geometry = CreateQuadGeometry();
2835 Renderer renderer = Renderer::New(geometry, material);
2836 Actor secondRootActor = Actor::New();
2837 secondRootActor.AddRenderer(renderer);
2838 secondRootActor.SetSize(100, 100);
2839 Stage::GetCurrent().Add(secondRootActor);
2842 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2843 bool finished = false;
2844 RenderTaskFinished renderTaskFinished( finished );
2845 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2846 application.SendNotification();
2848 // START PROCESS/RENDER Input, Expected Input, Expected
2849 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2850 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2852 // FINISH RESOURCE LOADING
2853 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2854 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
2855 application.GetPlatform().ClearReadyResources();
2857 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2858 application.SendNotification(); // Input, Expected Input, Expected
2859 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2860 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2864 int UtcDaliRenderTaskOnceNoSync05(void)
2866 TestApplication application;
2868 tet_infoline("Testing RenderTask Render Once\n"
2869 "Switch from Render always after ready to render once with resources unready\n"
2870 "PRE: Everything ready to render\n"
2871 "POST: Finished signal sent once");
2873 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2874 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2875 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2876 drawTrace.Enable(true);
2878 Actor rootActor = Actor::New();
2879 Stage::GetCurrent().Add( rootActor );
2881 CameraActor offscreenCameraActor = CameraActor::New();
2882 Stage::GetCurrent().Add( offscreenCameraActor );
2883 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2884 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2885 Integration::ResourceId imageRequestId = imageRequest->GetId();
2886 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2887 Stage::GetCurrent().Add(secondRootActor);
2889 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2890 bool finished = false;
2891 RenderTaskFinished renderTaskFinished( finished );
2892 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2893 application.SendNotification();
2895 // START PROCESS/RENDER Input, Expected Input, Expected
2896 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2897 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2899 // CHANGE TO RENDER ONCE
2900 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2901 application.SendNotification(); // Input, Expected Input, Expected
2902 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2903 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2905 // FINISH RESOURCE LOADING
2906 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2907 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2908 application.GetPlatform().ClearReadyResources();
2909 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2914 //int UtcDaliRenderTaskOnceNoSync06(void)
2916 TestApplication application;
2918 tet_infoline("Testing RenderTask Render Once\n"
2919 "During RenderOnce, make ready resources unready before sending first finished signal\n"
2920 "PRE: Everything ready.\n"
2921 "POST: Finished signal sent only once");
2923 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2924 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2925 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2926 drawTrace.Enable(true);
2928 Actor rootActor = Actor::New();
2929 Stage::GetCurrent().Add( rootActor );
2931 CameraActor offscreenCameraActor = CameraActor::New();
2932 Stage::GetCurrent().Add( offscreenCameraActor );
2933 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2934 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2935 Integration::ResourceId imageRequestId = imageRequest->GetId();
2936 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2937 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2938 application.Render();
2939 application.GetPlatform().ClearReadyResources();
2941 Stage::GetCurrent().Add(secondRootActor);
2943 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2944 bool finished = false;
2945 RenderTaskFinished renderTaskFinished( finished );
2946 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2947 application.SendNotification();
2949 // START PROCESS/RENDER Input, Expected Input, Expected
2950 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2951 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
2953 // CHANGE TO RENDER ONCE, RESOURCES BECOME NOT READY
2954 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2957 ReloadImage(application, secondRootActor.GetImage());
2958 application.SendNotification(); // Input, Expected Input, Expected
2960 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2961 DALI_TEST_EQUALS( secondRootActor.GetImage().GetLoadingState(), Dali::ResourceLoading, TEST_LOCATION);
2962 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2964 // FINISH RESOURCE LOADING
2965 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2966 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, true, true ) );
2967 application.GetPlatform().ClearReadyResources();
2968 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2969 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2970 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2971 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2976 int UtcDaliRenderTaskOnceNoSync07(void)
2978 TestApplication application;
2980 tet_infoline("Testing RenderTask Render Once\n"
2981 "Render once, Second call to SetRefreshRate(ONCE) triggers only one more finished signal\n"
2982 "PRE: Everything ready\n"
2983 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
2985 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2986 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2987 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2988 drawTrace.Enable(true);
2990 Actor rootActor = Actor::New();
2991 Stage::GetCurrent().Add( rootActor );
2993 CameraActor offscreenCameraActor = CameraActor::New();
2994 Stage::GetCurrent().Add( offscreenCameraActor );
2995 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2996 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2997 Integration::ResourceId imageRequestId = imageRequest->GetId();
2998 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2999 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
3000 application.Render();
3001 application.GetPlatform().ClearReadyResources();
3003 Stage::GetCurrent().Add(secondRootActor);
3005 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3006 bool finished = false;
3007 RenderTaskFinished renderTaskFinished( finished );
3008 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3009 application.SendNotification();
3011 // START PROCESS/RENDER Input, Expected Input, Expected
3012 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
3014 // CHANGE TO RENDER ONCE,
3015 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3016 application.SendNotification();
3017 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
3018 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
3020 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3021 application.SendNotification();
3022 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
3023 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
3027 int UtcDaliRenderTaskOnceNoSync08(void)
3029 TestApplication application;
3031 tet_infoline("Testing RenderTask Render Once\n"
3032 "Render once, Call to SetRefreshRate(ONCE) in Finished signal callback triggers\n"
3033 "another render & another finished signal\n"
3034 "PRE: Everything ready\n"
3035 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
3038 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3039 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3040 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3041 drawTrace.Enable(true);
3043 Actor rootActor = Actor::New();
3044 Stage::GetCurrent().Add( rootActor );
3046 CameraActor offscreenCameraActor = CameraActor::New();
3047 Stage::GetCurrent().Add( offscreenCameraActor );
3048 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3049 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3050 Integration::ResourceId imageRequestId = imageRequest->GetId();
3051 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
3052 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
3053 application.Render();
3054 application.GetPlatform().ClearReadyResources();
3056 Stage::GetCurrent().Add(secondRootActor);
3058 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3059 bool finished = false;
3061 ConnectionTracker connectionTracker;
3062 RenderTaskFinishedRenderAgain renderTaskFinishedRenderAgain( finished );
3063 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinishedRenderAgain );
3065 application.SendNotification();
3067 // START PROCESS/RENDER Input, Expected Input, Expected
3068 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
3070 // CHANGE TO RENDER ONCE,
3071 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3072 application.SendNotification();
3073 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
3074 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
3076 // Expect SetRefreshRate to have been called again
3077 // Prevent next finished signal calling refresh once again
3078 RenderTaskFinished renderTaskFinished( finished );
3079 connectionTracker.DisconnectAll();
3080 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinished );
3082 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
3083 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
3088 int UtcDaliRenderTaskOnceNoSync09(void)
3090 TestApplication application;
3092 tet_infoline("Testing RenderTask Render Once\n"
3093 "SetRefreshRate(ONCE) again before first finished signal has been sent.\n"
3094 "PRE: resources ready\n"
3095 "POST: Only 1 finished signal sent.");
3097 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3098 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3099 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3100 drawTrace.Enable(true);
3102 Actor rootActor = Actor::New();
3103 Stage::GetCurrent().Add( rootActor );
3105 CameraActor offscreenCameraActor = CameraActor::New();
3106 Stage::GetCurrent().Add( offscreenCameraActor );
3107 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3108 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3109 Integration::ResourceId imageRequestId = imageRequest->GetId();
3110 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
3111 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
3112 application.Render();
3113 application.GetPlatform().ClearReadyResources();
3115 Stage::GetCurrent().Add(secondRootActor);
3117 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3118 bool finished = false;
3119 RenderTaskFinished renderTaskFinished( finished );
3120 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3121 application.SendNotification();
3123 // START PROCESS/RENDER Input, Expected Input, Expected
3124 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
3126 // CHANGE TO RENDER ONCE,
3127 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3128 application.SendNotification();
3129 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
3130 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
3132 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3133 application.SendNotification();
3134 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
3135 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
3139 int UtcDaliRenderTaskOnceNoSync10(void)
3141 TestApplication application;
3143 tet_infoline("Testing RenderTask Render Once\n"
3144 "SetRefreshRate(ONCE), resource load failed, completes render task.\n"
3145 "PRE: resources not ready\n"
3146 "POST: Only 1 finished signal sent.");
3148 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3149 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3150 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3151 drawTrace.Enable(true);
3153 Actor rootActor = Actor::New();
3154 Stage::GetCurrent().Add( rootActor );
3156 CameraActor offscreenCameraActor = CameraActor::New();
3157 Stage::GetCurrent().Add( offscreenCameraActor );
3158 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3159 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3160 Integration::ResourceId imageRequestId = imageRequest->GetId();
3161 Stage::GetCurrent().Add(secondRootActor);
3163 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3164 bool finished = false;
3165 RenderTaskFinished renderTaskFinished( finished );
3166 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3167 application.SendNotification();
3169 // START PROCESS/RENDER Input, Expected Input, Expected
3170 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
3171 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
3173 // CHANGE TO RENDER ONCE,
3174 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3175 application.SendNotification();
3176 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
3177 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
3178 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
3180 FailImageLoad(application, imageRequestId); // Need to run Update again for this to complete
3181 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) ); // nothing to draw
3182 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
3189 int UtcDaliRenderTaskOnceChain01(void)
3191 TestApplication application;
3193 tet_infoline("Testing RenderTask Render Once Chained render tasks\n"
3194 "SetRefreshRate(ONCE), resource load completes, both render tasks render.\n"
3195 "PRE: resources not ready\n"
3196 "POST: 2 finished signals sent.");
3198 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3199 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3200 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3201 drawTrace.Enable(true);
3203 Actor defaultRootActor = Actor::New(); // Root for default RT
3204 Stage::GetCurrent().Add( defaultRootActor );
3206 CameraActor offscreenCameraActor = CameraActor::New();
3207 Stage::GetCurrent().Add( offscreenCameraActor );
3208 ImageActor firstRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3209 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3210 Integration::ResourceId imageRequestId = imageRequest->GetId();
3211 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
3212 Stage::GetCurrent().Add(firstRootActor);
3214 // first render task
3215 RenderTask firstTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, firstRootActor, RenderTask::REFRESH_ONCE, false);
3216 bool firstFinished = false;
3217 RenderTaskFinished renderTask1Finished( firstFinished );
3218 firstTask.FinishedSignal().Connect( &application, renderTask1Finished );
3220 // Second render task
3221 FrameBufferImage fbo = firstTask.GetTargetFrameBuffer();
3222 ImageActor secondRootActor = ImageActor::New( fbo );
3223 Stage::GetCurrent().Add(secondRootActor);
3224 RenderTask secondTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
3225 bool secondFinished = false;
3226 RenderTaskFinished renderTask2Finished( secondFinished );
3227 secondTask.FinishedSignal().Connect( &application, renderTask2Finished );
3229 application.SendNotification();
3231 // START PROCESS/RENDER Input, Expected Input, Expected
3232 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true ) );
3233 DALI_TEST_CHECK( secondFinished == false );
3234 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true ) );
3235 DALI_TEST_CHECK( secondFinished == false );
3237 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
3238 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true ) );
3239 DALI_TEST_CHECK( secondFinished == false );
3240 application.GetPlatform().ClearReadyResources();
3242 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, firstFinished, true, false ) );
3243 DALI_TEST_CHECK( secondFinished == true );
3248 int UtcDaliRenderTaskProperties(void)
3250 TestApplication application;
3252 RenderTask task = Stage::GetCurrent().GetRenderTaskList().CreateTask();
3254 Property::IndexContainer indices;
3255 task.GetPropertyIndices( indices );
3256 DALI_TEST_CHECK( indices.Size() );
3257 DALI_TEST_EQUALS( indices.Size(), task.GetPropertyCount(), TEST_LOCATION );
3261 int UtcDaliRenderTaskSetScreenToFrameBufferMappingActor(void)
3263 TestApplication application;
3264 tet_infoline("Testing RenderTask::SetScreenToFrameBufferMappingActor ");
3266 Stage stage = Stage::GetCurrent();
3267 Size stageSize = stage.GetSize();
3268 Actor mappingActor = Actor::New();
3269 Vector2 scale( 0.6f, 0.75f);
3270 Vector2 offset( stageSize.x*0.1f, stageSize.y*0.15f);
3271 mappingActor.SetSize( stageSize * scale );
3272 mappingActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
3273 mappingActor.SetPosition( offset.x, offset.y );
3274 stage.Add( mappingActor );
3276 Actor offscreenActor = Actor::New();
3277 offscreenActor.SetSize( stageSize );
3278 offscreenActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
3279 stage.Add( offscreenActor );
3281 RenderTaskList taskList = stage.GetRenderTaskList();
3282 RenderTask renderTask = taskList.CreateTask();
3283 FrameBufferImage frameBufferImage = FrameBufferImage::New(stageSize.width*scale.x, stageSize.height*scale.y, Pixel::A8, Image::NEVER);
3284 renderTask.SetSourceActor( offscreenActor );
3285 renderTask.SetExclusive( true );
3286 renderTask.SetInputEnabled( true );
3287 renderTask.SetTargetFrameBuffer( frameBufferImage );
3288 renderTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
3289 renderTask.SetScreenToFrameBufferMappingActor( mappingActor );
3290 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3292 // Render and notify
3293 application.SendNotification();
3294 application.Render();
3295 application.Render();
3296 application.SendNotification();
3298 Vector2 screenCoordinates( stageSize.x * 0.05f, stageSize.y * 0.05f );
3299 Dali::HitTestAlgorithm::Results results;
3300 DALI_TEST_CHECK( !results.actor );
3301 DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
3302 // miss expected, results not changed
3303 DALI_TEST_CHECK( false == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3304 DALI_TEST_CHECK( !results.actor );
3305 DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
3307 screenCoordinates.x = stageSize.x * 0.265f;
3308 screenCoordinates.y = stageSize.y * 0.33f;
3309 results.actor = Actor();
3310 results.actorCoordinates = Vector2::ZERO;
3311 // hit expected, results changed
3312 DALI_TEST_CHECK( true == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3313 DALI_TEST_CHECK( results.actor == offscreenActor );
3314 DALI_TEST_EQUALS( (screenCoordinates-offset)/scale , results.actorCoordinates, 0.1f, TEST_LOCATION );
3316 screenCoordinates.x = stageSize.x * 0.435f;
3317 screenCoordinates.y = stageSize.y * 0.52f;
3318 // hit expected, results changed
3319 DALI_TEST_CHECK( true == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3320 DALI_TEST_CHECK( results.actor == offscreenActor );
3321 const Vector2 expectedCoordinates = (screenCoordinates-offset)/scale;
3322 DALI_TEST_EQUALS( expectedCoordinates , results.actorCoordinates, 0.1f, TEST_LOCATION );
3324 screenCoordinates.x = stageSize.x * 0.65f;
3325 screenCoordinates.y = stageSize.y * 0.95f;
3326 // miss expected, results not changed
3327 DALI_TEST_CHECK( false == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3328 DALI_TEST_CHECK( results.actor == offscreenActor );
3329 DALI_TEST_EQUALS( expectedCoordinates , results.actorCoordinates, 0.1f, TEST_LOCATION );
3333 int UtcDaliRenderTaskFinishInvisibleSourceActor(void)
3335 TestApplication application;
3337 tet_infoline("Testing RenderTask::SignalFinished()");
3339 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3340 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
3342 CameraActor offscreenCameraActor = CameraActor::New();
3344 Stage::GetCurrent().Add( offscreenCameraActor );
3346 BufferImage image = BufferImage::New( 10, 10 );
3347 ImageActor rootActor = ImageActor::New( image );
3348 rootActor.SetSize( 10, 10 );
3349 rootActor.SetVisible(false);
3350 Stage::GetCurrent().Add( rootActor );
3352 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3353 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
3354 FrameBufferImage frameBufferImage = FrameBufferImage::New( *testNativeImagePtr.Get() );
3356 // Flush all outstanding messages
3357 application.SendNotification();
3358 application.Render();
3360 RenderTask newTask = taskList.CreateTask();
3361 newTask.SetCameraActor( offscreenCameraActor );
3362 newTask.SetSourceActor( rootActor );
3363 newTask.SetInputEnabled( false );
3364 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
3365 newTask.SetClearEnabled( true );
3366 newTask.SetExclusive( true );
3367 newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
3368 newTask.SetTargetFrameBuffer( frameBufferImage );
3370 // Framebuffer doesn't actually get created until Connected, i.e. by previous line
3372 bool finished = false;
3373 RenderTaskFinished renderTaskFinished( finished );
3374 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3376 // Flush the queue and render.
3377 application.SendNotification();
3379 // 1 render to process render task, then wait for sync before finished msg is sent
3380 // from update to the event thread.
3382 application.Render();
3383 application.SendNotification();
3384 DALI_TEST_CHECK( !finished );
3386 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
3387 DALI_TEST_CHECK( lastSyncObj != NULL );
3389 application.Render();
3390 DALI_TEST_EQUALS( (application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
3391 application.SendNotification();
3392 DALI_TEST_CHECK( !finished );
3394 application.Render();
3395 DALI_TEST_EQUALS( (application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
3396 application.SendNotification();
3397 DALI_TEST_CHECK( ! finished );
3399 sync.SetObjectSynced( lastSyncObj, true );
3401 application.Render();
3402 application.SendNotification();
3403 DALI_TEST_CHECK( !finished );
3405 application.Render();
3406 application.SendNotification();
3407 DALI_TEST_CHECK( finished );
3410 application.Render(); // Double check no more finished signal
3411 application.SendNotification();
3412 DALI_TEST_CHECK( ! finished );
3417 int UtcDaliRenderTaskFinishMissingImage(void)
3419 TestApplication application;
3421 // Previously we had bugs where not having a resource ID would cause render-tasks to wait forever
3422 tet_infoline("Testing RenderTask::SignalFinished() when an ImageActor has no Image set");
3424 Stage stage = Stage::GetCurrent();
3426 BufferImage image = BufferImage::New( 10, 10 );
3427 ImageActor rootActor = ImageActor::New( image );
3428 rootActor.SetSize( 10, 10 );
3429 stage.Add( rootActor );
3431 ImageActor actorWithMissingImage = ImageActor::New( Image() );
3432 actorWithMissingImage.SetSize( 10, 10 );
3433 stage.Add( actorWithMissingImage );
3435 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3436 RenderTask newTask = taskList.CreateTask();
3437 newTask.SetInputEnabled( false );
3438 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
3439 newTask.SetClearEnabled( true );
3440 newTask.SetExclusive( true );
3441 newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
3443 bool finished = false;
3444 RenderTaskFinished renderTaskFinished( finished );
3445 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3447 // 1 render to process render task, then 1 before finished msg is sent from update to the event thread.
3448 application.SendNotification();
3449 application.Render();
3450 application.Render();
3452 application.SendNotification();
3453 DALI_TEST_CHECK( finished );