2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali/public-api/dali-core.h>
22 #include <dali/devel-api/events/hit-test-algorithm.h>
23 #include <dali-test-suite-utils.h>
24 #include <dali/integration-api/debug.h>
25 #include <test-native-image.h>
27 #include <mesh-builder.h>
29 #define BOOLSTR(x) ((x)?"T":"F")
31 //& set: DaliRenderTask
35 void utc_dali_render_task_startup(void)
37 test_return_value = TET_UNDEF;
40 void utc_dali_render_task_cleanup(void)
42 test_return_value = TET_PASS;
48 * Constructor, Destructor, DownCast, New, copy constructor, assignment operator
50 * SetSourceActor 2+ve, 1-ve
51 * GetSourceActor 1+ve, 1-ve
52 * SetExclusive 2+ve, 0-ve
53 * IsExclusive 2+ve, 0-ve
54 * SetInputEnabled 1+ve, 0-ve
55 * GetInputEnabled 1+ve, 0-ve
56 * SetCameraActor 1+ve, 1-ve
57 * GetCameraActor 1+ve, 1-ve
58 * SetTargetFrameBuffer 1+ve, 1-ve
59 * GetTargetFrameBuffer 1+ve, 1-ve
60 * SetScreenToFrameBufferFunction 1+ve, 1-ve
61 * GetScreenToFrameBufferFunction 1+ve, 1-ve
62 * SetScreenToFrameBufferMappingActor 1+ve, 1-ve
63 * GetScreenToFrameBufferMappingActor 1+ve, 1-ve
64 * SetViewportPosition 1+ve
65 * GetCurrentViewportPosition 1+ve
66 * SetViewportSize 1+ve
67 * GetCurrentViewportSize 1+ve
68 * SetViewport 2+ve, 1-ve
69 * GetViewport 2+ve, 1-ve
70 * SetClearColor 1+ve, 1-ve
71 * GetClearColor 1+ve, 1-ve
72 * SetClearEnabled 1+ve, 1-ve
73 * GetClearEnabled 1+ve, 1-ve
81 namespace // unnamed namespace
84 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
87 * Simulate time passed by.
89 * @note this will always process at least 1 frame (1/60 sec)
91 * @param application Test application instance
92 * @param duration Time to pass in milliseconds.
93 * @return The actual time passed in milliseconds
95 int Wait(TestApplication& application, int duration = 0)
99 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
101 application.SendNotification();
102 application.Render(RENDER_FRAME_INTERVAL);
103 time += RENDER_FRAME_INTERVAL;
109 struct RenderTaskFinished
111 RenderTaskFinished( bool& finished )
112 : finished( finished )
116 void operator()( RenderTask& renderTask )
124 struct RenderTaskFinishedRemoveSource
126 RenderTaskFinishedRemoveSource( bool& finished )
127 : finished( finished ),
132 void operator()( RenderTask& renderTask )
134 DALI_TEST_CHECK(finishedOnce == false);
137 Actor srcActor = renderTask.GetSourceActor();
138 UnparentAndReset(srcActor);
145 struct RenderTaskFinishedRenderAgain
147 RenderTaskFinishedRenderAgain( bool& finished )
148 : finished( finished ),
153 void operator()( RenderTask& renderTask )
155 DALI_TEST_CHECK(finishedOnce == false);
158 renderTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
166 bool TestScreenToFrameBufferFunction( Vector2& coordinates )
168 coordinates = coordinates + Vector2( 1, 2 );
173 Actor CreateLoadingActor(TestApplication& application, std::string filename, ResourceImage::LoadPolicy loadPolicy, Image::ReleasePolicy releasePolicy)
175 Image image = ResourceImage::New(filename, loadPolicy, releasePolicy);
176 DALI_TEST_CHECK( image );
177 application.SendNotification();
178 application.Render(16);
179 DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
180 Actor actor = CreateRenderableActor(image);
181 actor.SetSize( 80, 80 );
182 application.SendNotification();
183 application.Render(16);
187 Image CreateLoadingImage(TestApplication& application, std::string filename, ResourceImage::LoadPolicy loadPolicy, Image::ReleasePolicy releasePolicy)
189 Image image = ResourceImage::New(filename, loadPolicy, releasePolicy);
190 DALI_TEST_CHECK( image );
191 application.SendNotification();
192 application.Render(16);
193 DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
198 void CompleteImageLoad(TestApplication& application, Integration::ResourceId resourceId, Integration::ResourceTypeId requestType)
200 std::vector<GLuint> ids;
202 application.GetGlAbstraction().SetNextTextureIds( ids );
204 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
205 Integration::ResourcePointer resource(bitmap);
206 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80);
208 application.GetPlatform().SetResourceLoaded(resourceId, requestType, resource);
211 void FailImageLoad(TestApplication& application, Integration::ResourceId resourceId )
213 application.GetPlatform().SetResourceLoadFailed(resourceId, Integration::FailureUnknown);
216 void ReloadImage(TestApplication& application, ResourceImage image)
218 application.GetPlatform().ClearReadyResources();
219 application.GetPlatform().DiscardRequest();
220 application.GetPlatform().ResetTrace();
221 application.GetPlatform().SetClosestImageSize(Vector2(80.0f, 80.0f)); // Ensure reload is called.
225 RenderTask CreateRenderTask(TestApplication& application,
226 CameraActor offscreenCamera,
227 Actor rootActor, // Reset default render task to point at this actor
228 Actor secondRootActor, // Source actor
229 unsigned int refreshRate,
232 // Change main render task to use a different root
233 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
234 taskList.GetTask(0u).SetSourceActor( rootActor );
236 FrameBufferImage frameBufferImage;
239 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
240 frameBufferImage= FrameBufferImage::New( *(testNativeImagePtr.Get()) );
244 frameBufferImage = FrameBufferImage::New( 10, 10 );
247 // Don't draw output framebuffer // '
249 RenderTask newTask = taskList.CreateTask();
250 newTask.SetCameraActor( offscreenCamera );
251 newTask.SetSourceActor( secondRootActor );
252 newTask.SetInputEnabled( false );
253 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
254 newTask.SetClearEnabled( true );
255 newTask.SetExclusive( true );
256 newTask.SetRefreshRate( refreshRate );
257 newTask.SetTargetFrameBuffer( frameBufferImage );
258 newTask.SetProperty( RenderTask::Property::REQUIRES_SYNC, glSync );
262 bool UpdateRender(TestApplication& application, TraceCallStack& callStack, bool testDrawn, bool& finishedSig, bool testFinished, bool testKeepUpdating, int lineNumber )
267 tet_printf("TestApplication::UpdateRender().\n");
269 application.Render(16);
270 application.SendNotification();
272 bool sigPassed = false;
275 sigPassed = finishedSig;
279 sigPassed = ! finishedSig;
282 bool drawResult = callStack.FindMethod("DrawElements") || callStack.FindMethod("DrawArrays");
284 bool drawPassed = false;
287 drawPassed = drawResult;
291 drawPassed = !drawResult;
294 bool keepUpdating = (application.GetUpdateStatus() != 0);
295 bool keepUpdatingPassed = false;
296 if( testKeepUpdating )
298 keepUpdatingPassed = keepUpdating;
302 keepUpdatingPassed = !keepUpdating;
305 bool result = (sigPassed && drawPassed && keepUpdatingPassed);
307 tet_printf("UpdateRender: Expected: Draw:%s Signal:%s KeepUpdating: %s Actual: Draw:%s Signal:%s KeepUpdating: %s %s, line %d\n",
308 BOOLSTR(testDrawn), BOOLSTR(testFinished), BOOLSTR(testKeepUpdating),
309 BOOLSTR(drawResult), BOOLSTR(finishedSig), BOOLSTR(keepUpdating),
310 result ? "Passed":"Failed",
316 // The functor to be used in the hit-test algorithm to check whether the actor is hittable.
317 bool IsActorHittableFunction(Actor actor, Dali::HitTestAlgorithm::TraverseType type)
319 bool hittable = false;
323 case Dali::HitTestAlgorithm::CHECK_ACTOR:
325 // Check whether the actor is visible and not fully transparent.
326 if( actor.IsVisible()
327 && actor.GetCurrentWorldColor().a > 0.01f) // not FULLY_TRANSPARENT
334 case Dali::HitTestAlgorithm::DESCEND_ACTOR_TREE:
336 if( actor.IsVisible() ) // Actor is visible, if not visible then none of its children are visible.
351 } // unnamed namespace
354 /****************************************************************************************************/
355 /****************************************************************************************************/
356 /******************************** TEST CASES BELOW **********************************************/
357 /****************************************************************************************************/
358 /****************************************************************************************************/
360 int UtcDaliRenderTaskDownCast01(void)
362 TestApplication application;
364 tet_infoline("Testing RenderTask::DownCast()");
366 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
368 BaseHandle base = taskList.GetTask( 0u );
369 DALI_TEST_CHECK( base );
371 RenderTask task = RenderTask::DownCast( base );
372 DALI_TEST_CHECK( task );
374 // Try calling a method
375 DALI_TEST_CHECK( task.GetSourceActor() );
379 int UtcDaliRenderTaskDownCast02(void)
381 TestApplication application;
383 tet_infoline("Testing RenderTask::DownCast()");
385 Actor actor = Actor::New();
387 RenderTask task = RenderTask::DownCast( actor );
388 DALI_TEST_CHECK( ! task );
393 int UtcDaliRenderTaskSetSourceActorN(void)
395 TestApplication application;
396 tet_infoline("Testing RenderTask::SetSourceActor() Negative - try with empty actor handle");
397 Stage stage = Stage::GetCurrent();
401 RenderTaskList taskList = stage.GetRenderTaskList();
402 RenderTask renderTask = taskList.CreateTask();
403 renderTask.SetSourceActor(srcActor);
405 application.SendNotification();
406 application.Render();
408 DALI_TEST_CHECK( ! renderTask.GetSourceActor() );
413 int UtcDaliRenderTaskSetSourceActorP01(void)
415 TestApplication application;
417 tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that setting a non-renderable actor stops existing source actor being rendered ");
419 Stage stage = Stage::GetCurrent();
421 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
423 RenderTaskList taskList = stage.GetRenderTaskList();
425 RenderTask task = taskList.GetTask( 0u );
427 Actor actor = task.GetSourceActor();
428 DALI_TEST_CHECK( actor );
430 std::vector<GLuint> ids;
432 application.GetGlAbstraction().SetNextTextureIds( ids );
434 BufferImage img = BufferImage::New( 1,1 );
435 Actor newActor = CreateRenderableActor( img );
436 newActor.SetSize(1,1);
437 stage.Add( newActor );
439 Actor nonRenderableActor = Actor::New();
440 stage.Add( nonRenderableActor );
442 // Stop the newActor from being rendered by changing the source actor
443 DALI_TEST_CHECK( nonRenderableActor );
444 task.SetSourceActor( nonRenderableActor );
445 DALI_TEST_CHECK( task.GetSourceActor() != actor );
446 DALI_TEST_CHECK( task.GetSourceActor() == nonRenderableActor );
448 // Update & Render nothing!
449 application.GetGlAbstraction().ClearBoundTextures();
450 application.SendNotification();
451 application.Render();
453 // Check that nothing was rendered
454 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
460 int UtcDaliRenderTaskSetSourceActorP02(void)
462 TestApplication application;
464 tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that switching source from a non-renderable to a renderable actor causes the texture to be drawn");
466 Stage stage = Stage::GetCurrent();
468 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
470 RenderTaskList taskList = stage.GetRenderTaskList();
472 RenderTask task = taskList.GetTask( 0u );
474 Actor actor = task.GetSourceActor();
475 DALI_TEST_CHECK( actor );
477 std::vector<GLuint> ids;
479 application.GetGlAbstraction().SetNextTextureIds( ids );
481 BufferImage img = BufferImage::New( 1,1 );
482 Actor newActor = CreateRenderableActor( img );
483 newActor.SetSize(1,1);
484 stage.Add( newActor );
486 Actor nonRenderableActor = Actor::New();
487 stage.Add( nonRenderableActor );
489 // Stop the newActor from being rendered by changing the source actor
490 DALI_TEST_CHECK( nonRenderableActor );
491 task.SetSourceActor( nonRenderableActor );
492 DALI_TEST_CHECK( task.GetSourceActor() != actor );
493 DALI_TEST_CHECK( task.GetSourceActor() == nonRenderableActor );
495 // Update & Render nothing!
496 application.GetGlAbstraction().ClearBoundTextures();
497 application.SendNotification();
498 application.Render();
500 // Check that nothing was rendered
501 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
503 // Set newActor as the new source Actor
504 task.SetSourceActor( newActor );
505 DALI_TEST_CHECK( task.GetSourceActor() != actor );
506 DALI_TEST_CHECK( task.GetSourceActor() == newActor );
508 // Update & Render the newActor
509 application.GetGlAbstraction().ClearBoundTextures();
510 application.SendNotification();
511 application.Render();
513 // Check that the newActor was rendered
514 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
515 if ( boundTextures.size() )
517 DALI_TEST_EQUALS( boundTextures[0], 7u, TEST_LOCATION );
522 int UtcDaliRenderTaskSetSourceActorOffStage(void)
524 TestApplication application;
526 tet_infoline("Testing RenderTask::SetSourceActor (on/off stage testing)");
528 Stage stage = Stage::GetCurrent();
530 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
532 RenderTaskList taskList = stage.GetRenderTaskList();
534 RenderTask task = taskList.GetTask( 0u );
536 Actor actor = task.GetSourceActor();
537 DALI_TEST_CHECK( actor );
539 std::vector<GLuint> ids;
540 GLuint expectedTextureId( 3 );
541 ids.push_back( expectedTextureId );
542 application.GetGlAbstraction().SetNextTextureIds( ids );
544 BufferImage img = BufferImage::New( 1,1 );
545 Actor newActor = CreateRenderableActor( img );
546 newActor.SetSize(1,1);
547 task.SetSourceActor( newActor );
548 // Don't add newActor to stage yet //'
550 // Update & Render with the actor initially off-stage
551 application.GetGlAbstraction().ClearBoundTextures();
552 application.SendNotification();
553 application.Render();
555 // Check that nothing was rendered
556 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
559 stage.Add( newActor );
561 // Update & Render with the actor on-stage
562 application.GetGlAbstraction().ClearBoundTextures();
563 application.SendNotification();
564 application.Render();
566 // Check that the newActor was rendered
567 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
568 if ( boundTextures.size() )
570 DALI_TEST_EQUALS( boundTextures[0], expectedTextureId, TEST_LOCATION );
573 // Now remove from stage
574 stage.Remove( newActor );
576 // Update & Render with the actor off-stage
577 application.GetGlAbstraction().ClearBoundTextures();
578 application.SendNotification();
579 application.Render();
583 int UtcDaliRenderTaskSetSourceActorEmpty(void)
585 TestApplication application;
587 tet_infoline("Testing RenderTask::SetSourceActor (empty handle case)");
589 Stage stage = Stage::GetCurrent();
591 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
593 RenderTaskList taskList = stage.GetRenderTaskList();
595 RenderTask task = taskList.GetTask( 0u );
597 Actor actor = task.GetSourceActor();
598 DALI_TEST_CHECK( actor );
600 std::vector<GLuint> ids;
601 GLuint expectedTextureId( 5 );
602 ids.push_back( expectedTextureId );
603 application.GetGlAbstraction().SetNextTextureIds( ids );
605 BufferImage img = BufferImage::New( 1,1 );
606 Actor newActor = CreateRenderableActor( img );
607 newActor.SetSize(1,1);
608 stage.Add( newActor );
610 Actor nonRenderableActor = Actor::New();
611 stage.Add( nonRenderableActor );
613 // Set with empty handle
614 task.SetSourceActor( Actor() );
615 DALI_TEST_CHECK( ! task.GetSourceActor() );
617 // Update & Render nothing!
618 application.GetGlAbstraction().ClearBoundTextures();
619 application.SendNotification();
620 application.Render();
622 // Check that nothing was rendered
623 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
625 // Set with non-empty handle
626 task.SetSourceActor( newActor );
627 DALI_TEST_CHECK( task.GetSourceActor() == newActor );
629 // Update & Render the newActor
630 application.GetGlAbstraction().ClearBoundTextures();
631 application.SendNotification();
632 application.Render();
634 // Check that the newActor was rendered
635 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
636 if ( boundTextures.size() )
638 DALI_TEST_EQUALS( boundTextures[0], expectedTextureId, TEST_LOCATION );
643 int UtcDaliRenderTaskGetSourceActorP01(void)
645 TestApplication application;
647 tet_infoline("Testing RenderTask::GetSourceActor() Check the default render task has a valid source actor");
649 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
651 RenderTask task = taskList.GetTask( 0u );
653 Actor actor = task.GetSourceActor();
654 DALI_TEST_CHECK( actor );
656 // By default the entire scene should be rendered
657 Actor root = Stage::GetCurrent().GetLayer( 0 );
658 DALI_TEST_CHECK( root == actor );
662 int UtcDaliRenderTaskGetSourceActorP02(void)
664 TestApplication application;
666 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.");
668 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
669 RenderTask task = taskList.CreateTask();
670 Actor actor = Actor::New();
671 Stage::GetCurrent().Add(actor);
672 task.SetSourceActor( actor );
674 DALI_TEST_EQUALS( actor, task.GetSourceActor(), TEST_LOCATION );
679 int UtcDaliRenderTaskGetSourceActorN(void)
681 TestApplication application;
683 tet_infoline("Testing RenderTask::GetSourceActor() Try with empty handle");
688 Actor actor = task.GetSourceActor();
690 catch (Dali::DaliException(e))
692 DALI_TEST_PRINT_ASSERT( e );
693 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
699 int UtcDaliRenderTaskSetExclusive(void)
701 TestApplication application;
703 tet_infoline("Testing RenderTask::SetExclusive() Check that exclusion works");
705 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
707 // Manipulate the GenTextures behaviour, to identify different actors
709 std::vector<GLuint> ids;
710 ids.push_back( 8 ); // 8 = actor1
711 ids.push_back( 9 ); // 9 = actor2
712 ids.push_back( 10 ); // 10 = actor3
713 application.GetGlAbstraction().SetNextTextureIds( ids );
715 BufferImage img1 = BufferImage::New( 1,1 );
716 Actor actor1 = CreateRenderableActor( img1 );
718 Stage::GetCurrent().Add( actor1 );
720 // Update & Render actor1
721 application.SendNotification();
722 application.Render();
724 // Check that the actor1 was rendered
725 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
726 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
728 if ( boundTextures.size() )
730 DALI_TEST_EQUALS( boundTextures[0], 8u/*unique to actor1*/, TEST_LOCATION );
733 BufferImage img2 = BufferImage::New( 1,1 );
734 Actor actor2 = CreateRenderableActor( img2 );
737 // Force actor2 to be rendered before actor1
738 Layer layer = Layer::New();
739 Stage::GetCurrent().Add( layer );
741 layer.LowerToBottom();
744 application.GetGlAbstraction().ClearBoundTextures();
745 application.SendNotification();
746 application.Render();
748 // Check that the actors were rendered
749 DALI_TEST_EQUALS( boundTextures.size(), 2u, TEST_LOCATION );
751 if ( boundTextures.size() )
753 DALI_TEST_EQUALS( boundTextures[0], 9u/*unique to actor2*/, TEST_LOCATION );
754 DALI_TEST_EQUALS( boundTextures[1], 8u/*unique to actor1*/, TEST_LOCATION );
757 BufferImage img3 = BufferImage::New( 1,1 );
758 Actor actor3 = CreateRenderableActor( img3 );
761 // Force actor3 to be rendered before actor2
762 layer = Layer::New();
763 Stage::GetCurrent().Add( layer );
765 layer.LowerToBottom();
767 // Update & Render all actors
768 application.GetGlAbstraction().ClearBoundTextures();
769 application.SendNotification();
770 application.Render();
772 // Check that the actors were rendered
773 DALI_TEST_EQUALS( boundTextures.size(), 3u, TEST_LOCATION );
775 if ( boundTextures.size() )
777 DALI_TEST_EQUALS( boundTextures[0], 10u/*unique to actor3*/, TEST_LOCATION );
778 DALI_TEST_EQUALS( boundTextures[1], 9u/*unique to actor2*/, TEST_LOCATION );
779 DALI_TEST_EQUALS( boundTextures[2], 8u/*unique to actor1*/, TEST_LOCATION );
782 // Both actors are now connected to the root node
783 // Setup 2 render-tasks - the first will render from the root-node, and the second from actor2
785 // Not exclusive is the default
786 RenderTask task1 = taskList.GetTask( 0u );
787 DALI_TEST_CHECK( false == task1.IsExclusive() );
789 RenderTask task2 = taskList.CreateTask();
790 DALI_TEST_CHECK( false == task2.IsExclusive() );
791 task2.SetSourceActor( actor2 );
793 // Task1 should render all actors, and task 2 should render only actor2
795 application.GetGlAbstraction().ClearBoundTextures();
796 application.SendNotification();
797 application.Render();
799 DALI_TEST_EQUALS( boundTextures.size(), 4u, TEST_LOCATION );
801 if ( boundTextures.size() == 4 )
803 // Test that task 1 renders actor3, then actor2 & then actor1
804 DALI_TEST_CHECK( boundTextures[0] == 10u );
805 DALI_TEST_CHECK( boundTextures[1] == 9u );
806 DALI_TEST_CHECK( boundTextures[2] == 8u );
808 // Test that task 2 renders actor2
809 DALI_TEST_EQUALS( boundTextures[3], 9u, TEST_LOCATION );
812 // Make actor2 exclusive to task2
814 task2.SetExclusive( true );
815 DALI_TEST_CHECK( true == task2.IsExclusive() );
817 // Task1 should render only actor1, and task 2 should render only actor2
819 application.GetGlAbstraction().ClearBoundTextures();
820 application.SendNotification();
821 application.Render();
823 DALI_TEST_EQUALS( boundTextures.size(), 3u, TEST_LOCATION );
824 if ( boundTextures.size() == 3 )
826 // Test that task 1 renders actor3 & actor1
827 DALI_TEST_CHECK( boundTextures[0] == 10u );
828 DALI_TEST_CHECK( boundTextures[1] == 8u );
830 // Test that task 2 renders actor2
831 DALI_TEST_CHECK( boundTextures[2] == 9u );
836 int UtcDaliRenderTaskSetExclusive02(void)
838 TestApplication application;
840 tet_infoline("Testing RenderTask::SetExclusive() Check that changing from exclusive to not-exclusive works");
842 std::vector<GLuint> ids;
843 ids.push_back( 8 ); // 8 = actor1
844 application.GetGlAbstraction().SetNextTextureIds( ids );
846 BufferImage img1 = BufferImage::New( 1,1 );
847 Actor actor1 = CreateRenderableActor( img1 );
849 Stage::GetCurrent().Add( actor1 );
851 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
852 RenderTask task = taskList.CreateTask();
854 task.SetSourceActor( actor1 );
855 task.SetExclusive(true); // Actor should only render once
857 TestGlAbstraction& gl = application.GetGlAbstraction();
858 TraceCallStack& drawTrace = gl.GetDrawTrace();
859 drawTrace.Enable(true);
861 // Update & Render actor1
862 application.SendNotification();
863 application.Render();
865 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION );
867 // Set task to non-exclusive - actor1 should render twice:
869 task.SetExclusive(false);
870 application.SendNotification();
871 application.Render();
873 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 2, TEST_LOCATION );
878 int UtcDaliRenderTaskSetExclusiveN(void)
880 TestApplication application;
882 tet_infoline("Testing RenderTask::SetExclusive() on empty handle");
887 task.SetExclusive(true);
889 catch (Dali::DaliException(e))
891 DALI_TEST_PRINT_ASSERT( e );
892 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
897 int UtcDaliRenderTaskIsExclusive01(void)
899 TestApplication application;
901 tet_infoline("Testing RenderTask::IsExclusive() Check default values are non-exclusive");
903 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
905 // Not exclusive is the default
906 RenderTask task = taskList.GetTask( 0u );
907 DALI_TEST_CHECK( false == task.IsExclusive() );
909 RenderTask newTask = taskList.CreateTask();
910 DALI_TEST_CHECK( false == newTask.IsExclusive() );
915 int UtcDaliRenderTaskIsExclusive02(void)
917 TestApplication application;
919 tet_infoline("Testing RenderTask::IsExclusive() Check the getter returns set values");
921 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
923 // Not exclusive is the default
924 RenderTask newTask = taskList.CreateTask();
925 DALI_TEST_EQUALS( newTask.IsExclusive(), false, TEST_LOCATION );
927 newTask.SetExclusive(true);
928 DALI_TEST_EQUALS( newTask.IsExclusive(), true, TEST_LOCATION );
932 int UtcDaliRenderTaskIsExclusiveN(void)
934 TestApplication application;
936 tet_infoline("Testing RenderTask::IsExclusive() on empty handle");
941 bool x = task.IsExclusive();
944 catch (Dali::DaliException(e))
946 DALI_TEST_PRINT_ASSERT( e );
947 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
952 int UtcDaliRenderTaskSetInputEnabled(void)
954 TestApplication application;
956 tet_infoline("Testing RenderTask::SetInputEnabled()");
958 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
960 // Input is enabled by default
961 RenderTask task = taskList.GetTask( 0u );
962 DALI_TEST_CHECK( true == task.GetInputEnabled() );
964 task.SetInputEnabled( false );
965 DALI_TEST_CHECK( false == task.GetInputEnabled() );
967 task.SetInputEnabled( true );
968 DALI_TEST_CHECK( true == task.GetInputEnabled() );
972 int UtcDaliRenderTaskGetInputEnabled(void)
974 TestApplication application;
976 tet_infoline("Testing RenderTask::GetInputEnabled()");
978 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
980 // Input is enabled by default
981 RenderTask task = taskList.GetTask( 0u );
982 DALI_TEST_EQUALS( true, task.GetInputEnabled(), TEST_LOCATION );
984 RenderTask newTask = taskList.CreateTask();
985 DALI_TEST_EQUALS( true, newTask.GetInputEnabled(), TEST_LOCATION );
987 newTask.SetInputEnabled(false);
988 DALI_TEST_EQUALS( false, newTask.GetInputEnabled(), TEST_LOCATION );
993 int UtcDaliRenderTaskSetCameraActorP(void)
995 TestApplication application;
997 tet_infoline("Testing RenderTask::SetCameraActor()");
999 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1001 RenderTask task = taskList.GetTask( 0u );
1003 Actor defaultCameraActor = task.GetCameraActor();
1004 DALI_TEST_CHECK( defaultCameraActor );
1006 CameraActor newCameraActor = CameraActor::New();
1007 DALI_TEST_CHECK( newCameraActor );
1009 task.SetCameraActor( newCameraActor );
1010 DALI_TEST_CHECK( task.GetCameraActor() != defaultCameraActor );
1011 DALI_TEST_EQUALS( task.GetCameraActor(), newCameraActor, TEST_LOCATION );
1016 int UtcDaliRenderTaskSetCameraActorN(void)
1018 TestApplication application;
1020 tet_infoline("Testing RenderTask::SetCameraActor() with empty actor handle");
1022 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1024 RenderTask task = taskList.GetTask( 0u );
1026 Actor actor = task.GetCameraActor();
1027 DALI_TEST_CHECK( actor );
1029 CameraActor cameraActor;
1031 task.SetCameraActor( cameraActor );
1032 DALI_TEST_EQUALS( (bool)task.GetCameraActor(), false, TEST_LOCATION );
1033 DALI_TEST_EQUALS( task.GetCameraActor(), cameraActor, TEST_LOCATION );
1038 int UtcDaliRenderTaskGetCameraActorP(void)
1040 TestApplication application;
1042 tet_infoline("Testing RenderTask::GetCameraActor()");
1044 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1046 RenderTask task = taskList.GetTask( 0u );
1048 CameraActor actor = task.GetCameraActor();
1049 DALI_TEST_CHECK( actor );
1050 DALI_TEST_EQUALS( actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION );
1051 DALI_TEST_GREATER( actor.GetFieldOfView(), 0.0f, TEST_LOCATION );
1055 int UtcDaliRenderTaskGetCameraActorN(void)
1057 TestApplication application;
1059 tet_infoline("Testing RenderTask::GetCameraActor() with empty handle");
1064 Actor actor = task.GetCameraActor();
1066 catch (Dali::DaliException(e))
1068 DALI_TEST_PRINT_ASSERT( e );
1069 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1075 int UtcDaliRenderTaskSetTargetFrameBufferP(void)
1077 TestApplication application;
1079 tet_infoline("Testing RenderTask::SetTargetFrameBuffer()");
1081 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1083 RenderTask task = taskList.GetTask( 0u );
1085 FrameBufferImage newImage = FrameBufferImage::New();
1086 task.SetTargetFrameBuffer( newImage );
1087 DALI_TEST_CHECK( task.GetTargetFrameBuffer() == newImage );
1091 int UtcDaliRenderTaskSetTargetFrameBufferN(void)
1093 TestApplication application;
1095 tet_infoline("Testing RenderTask::SetTargetFrameBuffer()");
1097 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1099 RenderTask task = taskList.GetTask( 0u );
1100 FrameBufferImage newImage; // Empty handle
1101 task.SetTargetFrameBuffer( newImage );
1102 DALI_TEST_EQUALS( (bool)task.GetTargetFrameBuffer(), false, TEST_LOCATION );
1106 int UtcDaliRenderTaskGetTargetFrameBufferP(void)
1108 TestApplication application;
1110 tet_infoline("Testing RenderTask::GetTargetFrameBuffer()");
1112 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1114 RenderTask newTask = taskList.CreateTask();
1115 FrameBufferImage fb = FrameBufferImage::New(128, 128, Pixel::RGBA8888);
1116 newTask.SetTargetFrameBuffer( fb );
1117 DALI_TEST_EQUALS( newTask.GetTargetFrameBuffer(), fb, TEST_LOCATION );
1121 int UtcDaliRenderTaskGetTargetFrameBufferN(void)
1123 TestApplication application;
1125 tet_infoline("Testing RenderTask::GetTargetFrameBuffer()");
1127 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1129 RenderTask task = taskList.GetTask( 0u );
1131 // By default render-tasks do not render off-screen
1132 FrameBufferImage image = task.GetTargetFrameBuffer();
1133 DALI_TEST_CHECK( !image );
1138 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionP(void)
1140 TestApplication application;
1142 tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1144 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1146 RenderTask task = taskList.GetTask( 0u );
1148 task.SetScreenToFrameBufferFunction( TestScreenToFrameBufferFunction );
1150 Vector2 coordinates( 5, 10 );
1151 Vector2 convertedCoordinates( 6, 12 ); // + Vector(1, 2)
1153 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1154 DALI_TEST_CHECK( func( coordinates ) );
1155 DALI_TEST_CHECK( coordinates == convertedCoordinates );
1157 task.SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
1158 func = task.GetScreenToFrameBufferFunction();
1159 DALI_TEST_CHECK( func( coordinates ) );
1161 task.SetScreenToFrameBufferFunction( RenderTask::DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION );
1162 func = task.GetScreenToFrameBufferFunction();
1163 DALI_TEST_CHECK( ! func( coordinates ) );
1167 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionN(void)
1169 TestApplication application;
1171 tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1173 RenderTask task; // Empty handle
1176 task.SetScreenToFrameBufferFunction( TestScreenToFrameBufferFunction );
1178 catch (Dali::DaliException(e))
1180 DALI_TEST_PRINT_ASSERT( e );
1181 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1186 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionP(void)
1188 TestApplication application;
1190 tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction()");
1192 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1194 RenderTask task = taskList.GetTask( 0u );
1196 Vector2 originalCoordinates( 5, 10 );
1197 Vector2 coordinates( 5, 10 );
1199 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1200 DALI_TEST_CHECK( !func( coordinates ) ); // conversion should fail by default
1201 DALI_TEST_CHECK( coordinates == originalCoordinates ); // coordinates should not be modified
1205 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionN(void)
1207 TestApplication application;
1209 tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction() on empty handle");
1214 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1217 catch (Dali::DaliException(e))
1219 DALI_TEST_PRINT_ASSERT( e );
1220 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1226 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorP(void)
1228 TestApplication application;
1229 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor ");
1231 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1232 RenderTask renderTask = taskList.CreateTask();
1233 Actor mappingActor = Actor::New();
1234 renderTask.SetScreenToFrameBufferMappingActor(mappingActor);
1236 DALI_TEST_EQUALS( mappingActor, renderTask.GetScreenToFrameBufferMappingActor(), TEST_LOCATION );
1241 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorN(void)
1243 TestApplication application;
1244 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1250 task.SetScreenToFrameBufferMappingActor(mappingActor);
1252 catch (Dali::DaliException(e))
1254 DALI_TEST_PRINT_ASSERT( e );
1255 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1260 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActor02N(void)
1262 TestApplication application;
1263 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1265 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1266 RenderTask renderTask = taskList.CreateTask();
1268 renderTask.SetScreenToFrameBufferMappingActor(actor);
1270 DALI_TEST_EQUALS( (bool)renderTask.GetScreenToFrameBufferMappingActor(), false, TEST_LOCATION);
1274 int UtcDaliRenderTaskGetViewportP01(void)
1276 TestApplication application;
1278 tet_infoline("Testing RenderTask::GetViewport() on default task");
1280 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1281 RenderTask task = taskList.GetTask( 0u );
1282 Viewport viewport = task.GetViewport();
1284 // By default the viewport should match the stage width/height
1285 Vector2 stageSize = Stage::GetCurrent().GetSize();
1286 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1287 DALI_TEST_CHECK( viewport == expectedViewport );
1291 int UtcDaliRenderTaskGetViewportP02(void)
1293 TestApplication application;
1295 tet_infoline("Testing RenderTask::GetViewport() on new task");
1297 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1298 RenderTask task = taskList.CreateTask();
1299 Viewport viewport = task.GetViewport();
1301 // By default the viewport should match the stage width/height
1302 Vector2 stageSize = Stage::GetCurrent().GetSize();
1303 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1304 DALI_TEST_CHECK( viewport == expectedViewport );
1308 int UtcDaliRenderTaskGetViewportN(void)
1310 TestApplication application;
1312 tet_infoline("Testing RenderTask::GetViewport() on empty handle");
1317 Viewport viewport = task.GetViewport();
1318 viewport = viewport;
1320 catch (Dali::DaliException(e))
1322 DALI_TEST_PRINT_ASSERT( e );
1323 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1329 int UtcDaliRenderTaskSetViewportP(void)
1331 TestApplication application;
1333 tet_infoline("Testing RenderTask::SetViewport()");
1335 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1337 RenderTask task = taskList.GetTask( 0u );
1338 Vector2 stageSize = Stage::GetCurrent().GetSize();
1339 Viewport newViewport( 0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f );
1340 task.SetViewport( newViewport );
1342 // Update (viewport is a property)
1343 application.SendNotification();
1344 application.Render();
1346 DALI_TEST_CHECK( task.GetViewport() == newViewport );
1350 int UtcDaliRenderTaskSetViewportN(void)
1352 TestApplication application;
1354 tet_infoline("Testing RenderTask::SetViewport()");
1356 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1361 Vector2 stageSize = Stage::GetCurrent().GetSize();
1362 Viewport newViewport( 0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f );
1363 task.SetViewport( newViewport );
1365 catch (Dali::DaliException(e))
1367 DALI_TEST_PRINT_ASSERT( e );
1368 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1375 int UtcDaliRenderTaskSetViewportPosition(void)
1377 TestApplication application;
1379 tet_infoline("Testing RenderTask::SetViewportPosition()");
1381 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1383 RenderTask task = taskList.GetTask( 0u );
1385 Viewport viewport = task.GetViewport();
1387 // By default the viewport should match the stage width/height
1389 Vector2 stageSize = Stage::GetCurrent().GetSize();
1390 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1391 DALI_TEST_CHECK( viewport == expectedViewport );
1394 Vector2 newPosition(25.0f, 50.0f);
1395 task.SetViewportPosition( newPosition );
1397 // Update (viewport is a property)
1398 application.SendNotification();
1399 application.Render();
1401 DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1403 // Set by Property test
1404 Vector2 newPosition2(32.0f, 32.0f);
1405 task.SetProperty( RenderTask::Property::VIEWPORT_POSITION, newPosition2 );
1408 application.SendNotification();
1409 application.Render();
1411 DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition2, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1413 Vector2 newPosition3(64.0f, 0.0f);
1414 Animation animation = Animation::New(1.0f);
1415 animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_POSITION ), newPosition3, AlphaFunction::LINEAR );
1418 // Perform 1000ms worth of updates at which point animation should have completed.
1419 Wait(application, 1000);
1420 DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1424 int UtcDaliRenderTaskSetViewportSize(void)
1426 TestApplication application;
1428 tet_infoline("Testing RenderTask::SetViewportSize()");
1430 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1432 RenderTask task = taskList.GetTask( 0u );
1434 Viewport viewport = task.GetViewport();
1436 // By default the viewport should match the stage width/height
1438 Vector2 stageSize = Stage::GetCurrent().GetSize();
1439 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1440 DALI_TEST_CHECK( viewport == expectedViewport );
1442 Vector2 newSize(128.0f, 64.0f);
1443 task.SetViewportSize( newSize );
1445 // Update (viewport is a property)
1446 application.SendNotification();
1447 application.Render();
1449 DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1451 // Set by Property test
1452 Vector2 newSize2(50.0f, 50.0f);
1453 task.SetProperty( RenderTask::Property::VIEWPORT_SIZE, newSize2 );
1456 application.SendNotification();
1457 application.Render();
1459 DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize2, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1461 Vector2 newSize3(10.0f, 10.0f);
1462 Animation animation = Animation::New(1.0f);
1463 animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_SIZE ), newSize3, AlphaFunction::LINEAR );
1466 // Perform 1000ms worth of updates at which point animation should have completed.
1467 Wait(application, 1000);
1468 DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1473 int UtcDaliRenderTaskSetClearColorP(void)
1475 TestApplication application;
1477 tet_infoline("Testing RenderTask::SetClearColor()");
1479 Vector4 testColor( 1.0f, 2.0f, 3.0f, 4.0f );
1480 Vector4 testColor2( 5.0f, 6.0f, 7.0f, 8.0f );
1482 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1484 RenderTask task = taskList.GetTask( 0u );
1485 DALI_TEST_CHECK( task.GetClearColor() != testColor );
1487 task.SetClearColor( testColor );
1492 DALI_TEST_EQUALS( task.GetClearColor(), testColor, TEST_LOCATION );
1494 task.SetProperty( RenderTask::Property::CLEAR_COLOR, testColor2 );
1499 DALI_TEST_EQUALS( task.GetClearColor(), testColor2, TEST_LOCATION );
1503 int UtcDaliRenderTaskSetClearColorN(void)
1505 TestApplication application;
1507 tet_infoline("Testing RenderTask::SetClearColor() on empty handle");
1512 task.SetClearColor( Vector4::ZERO );
1514 catch (Dali::DaliException(e))
1516 DALI_TEST_PRINT_ASSERT( e );
1517 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1522 int UtcDaliRenderTaskGetClearColorP(void)
1524 TestApplication application;
1526 tet_infoline("Testing RenderTask::GetClearColor()");
1528 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1529 RenderTask task = taskList.GetTask( 0u );
1530 DALI_TEST_EQUALS( task.GetClearColor(), RenderTask::DEFAULT_CLEAR_COLOR, TEST_LOCATION );
1534 int UtcDaliRenderTaskGetClearColorN(void)
1536 TestApplication application;
1538 tet_infoline("Testing RenderTask::GetClearColor()");
1543 Vector4 color = task.GetClearColor();
1546 catch (Dali::DaliException(e))
1548 DALI_TEST_PRINT_ASSERT( e );
1549 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1554 int UtcDaliRenderTaskSetClearEnabledP(void)
1556 TestApplication application;
1558 tet_infoline("Testing RenderTask::SetClearEnabled()");
1560 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1562 RenderTask task = taskList.GetTask( 0u );
1563 DALI_TEST_CHECK( !task.GetClearEnabled() ); // defaults to false
1565 task.SetClearEnabled( true );
1566 DALI_TEST_EQUALS( task.GetClearEnabled(), true, TEST_LOCATION );
1568 task.SetClearEnabled( false );
1569 DALI_TEST_EQUALS( task.GetClearEnabled(), false, TEST_LOCATION );
1573 int UtcDaliRenderTaskSetClearEnabledN(void)
1575 TestApplication application;
1577 tet_infoline("Testing RenderTask::SetClearEnabled() with empty handle");
1582 task.SetClearEnabled(true);
1584 catch (Dali::DaliException(e))
1586 DALI_TEST_PRINT_ASSERT( e );
1587 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1592 int UtcDaliRenderTaskGetClearEnabledP(void)
1594 TestApplication application;
1596 tet_infoline("Testing RenderTask::GetClearEnabled()");
1598 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1600 RenderTask task = taskList.GetTask( 0u );
1601 DALI_TEST_CHECK( !task.GetClearEnabled() ); // defaults to false
1606 int UtcDaliRenderTaskGetClearEnabledN(void)
1608 TestApplication application;
1610 tet_infoline("Testing RenderTask::GetClearEnabled() with empty handle");
1615 bool x = task.GetClearEnabled();
1618 catch (Dali::DaliException(e))
1620 DALI_TEST_PRINT_ASSERT( e );
1621 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1626 int UtcDaliRenderTaskSetCullModeP(void)
1628 TestApplication application;
1630 tet_infoline("Testing RenderTask::SetCullMode()");
1632 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1633 RenderTask task = taskList.GetTask( 0u );
1634 DALI_TEST_EQUALS( task.GetCullMode(), true, TEST_LOCATION );
1636 task.SetCullMode( false );
1638 DALI_TEST_EQUALS( task.GetCullMode(), false, TEST_LOCATION );
1643 int UtcDaliRenderTaskSetCullModeN(void)
1645 TestApplication application;
1647 tet_infoline("Testing RenderTask::SetCullMode() on empty handle");
1652 task.SetCullMode( false );
1654 catch (Dali::DaliException(e))
1656 DALI_TEST_PRINT_ASSERT( e );
1657 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1662 int UtcDaliRenderTaskGetCullModeP(void)
1664 TestApplication application;
1666 tet_infoline("Testing RenderTask::GetCullMode()");
1668 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1669 RenderTask task = taskList.GetTask( 0u );
1670 DALI_TEST_EQUALS( task.GetCullMode(), true, TEST_LOCATION );
1674 int UtcDaliRenderTaskGetCullModeN(void)
1676 TestApplication application;
1678 tet_infoline("Testing RenderTask::GetCullMode() with empty handle");
1683 bool x = task.GetCullMode();
1686 catch (Dali::DaliException(e))
1688 DALI_TEST_PRINT_ASSERT( e );
1689 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1695 int UtcDaliRenderTaskSetRefreshRate(void)
1697 TestApplication application;
1699 tet_infoline("Testing RenderTask::SetRefreshRate()");
1701 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1703 // By default tasks will be processed every frame
1704 RenderTask task = taskList.GetTask( 0u );
1705 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1707 task.SetRefreshRate( 2u ); // every-other frame
1708 DALI_TEST_CHECK( 2u == task.GetRefreshRate() );
1710 task.SetRefreshRate( RenderTask::REFRESH_ALWAYS );
1711 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1715 int UtcDaliRenderTaskGetRefreshRate(void)
1717 TestApplication application;
1719 tet_infoline("Testing RenderTask::GetRefreshRate()");
1721 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1723 // By default tasks will be processed every frame
1724 RenderTask task = taskList.GetTask( 0u );
1725 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1727 RenderTask newTask = taskList.CreateTask();
1728 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == newTask.GetRefreshRate() );
1732 int UtcDaliRenderTaskSignalFinished(void)
1734 TestApplication application;
1736 tet_infoline("Testing RenderTask::SignalFinished()");
1738 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1739 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
1741 CameraActor offscreenCameraActor = CameraActor::New();
1743 Stage::GetCurrent().Add( offscreenCameraActor );
1745 BufferImage image = BufferImage::New( 10, 10 );
1747 Actor rootActor = CreateRenderableActor( image );
1748 rootActor.SetSize( 10, 10 );
1749 Stage::GetCurrent().Add( rootActor );
1751 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1752 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
1753 FrameBufferImage frameBufferImage = FrameBufferImage::New( *testNativeImagePtr.Get() );
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 );
1764 newTask.SetProperty( RenderTask::Property::REQUIRES_SYNC, true );
1766 bool finished = false;
1767 RenderTaskFinished renderTaskFinished( finished );
1768 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1770 // Flush the queue and render.
1771 application.SendNotification();
1773 // 1 render to process render task, then wait for sync before finished msg is sent
1774 // from update to the event thread.
1776 application.Render();
1777 application.SendNotification();
1778 DALI_TEST_CHECK( !finished );
1780 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
1781 DALI_TEST_CHECK( lastSyncObj != NULL );
1783 application.Render();
1784 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
1785 application.SendNotification();
1786 DALI_TEST_CHECK( !finished );
1788 application.Render();
1789 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
1790 application.SendNotification();
1791 DALI_TEST_CHECK( ! finished );
1793 sync.SetObjectSynced( lastSyncObj, true );
1795 application.Render();
1796 application.SendNotification();
1797 DALI_TEST_CHECK( !finished );
1799 application.Render();
1800 application.SendNotification();
1801 DALI_TEST_CHECK( finished );
1804 DALI_TEST_EQUALS( application.GetUpdateStatus(), 0, TEST_LOCATION );
1809 int UtcDaliRenderTaskContinuous01(void)
1811 TestApplication application;
1813 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not staged)\nPOST:continuous renders, no Finished signal");
1815 // SETUP AN OFFSCREEN RENDER TASK
1816 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1817 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1818 drawTrace.Enable(true);
1820 Actor rootActor = Actor::New();
1821 Stage::GetCurrent().Add( rootActor );
1823 CameraActor offscreenCameraActor = CameraActor::New();
1824 Stage::GetCurrent().Add( offscreenCameraActor );
1826 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1827 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1828 Integration::ResourceId imageRequestId = imageRequest->GetId();
1829 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1831 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1832 bool finished = false;
1833 RenderTaskFinished renderTaskFinished( finished );
1834 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1835 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1836 application.SendNotification();
1838 // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating
1839 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false, __LINE__ ) );
1840 application.GetPlatform().ClearReadyResources();
1842 // ADD SOURCE ACTOR TO STAGE - expect continuous renders to start, no finished signal
1843 Stage::GetCurrent().Add(secondRootActor);
1844 application.SendNotification();
1846 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1847 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
1852 int UtcDaliRenderTaskContinuous02(void)
1854 TestApplication application;
1856 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not visible)\nPOST:continuous renders, no Finished signal");
1858 // SETUP AN OFFSCREEN RENDER TASK
1859 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1860 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1861 drawTrace.Enable(true);
1863 Actor rootActor = Actor::New();
1864 Stage::GetCurrent().Add( rootActor );
1866 CameraActor offscreenCameraActor = CameraActor::New();
1867 Stage::GetCurrent().Add( offscreenCameraActor );
1869 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1870 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1871 Integration::ResourceId imageRequestId = imageRequest->GetId();
1872 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1873 Stage::GetCurrent().Add(secondRootActor);
1874 secondRootActor.SetVisible(false);
1876 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1877 bool finished = false;
1878 RenderTaskFinished renderTaskFinished( finished );
1879 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1880 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1881 application.SendNotification();
1883 // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating
1884 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false, __LINE__ ) );
1885 application.GetPlatform().ClearReadyResources();
1887 // MAKE SOURCE ACTOR VISIBLE - expect continuous renders to start, no finished signal
1888 secondRootActor.SetVisible(true);
1889 application.SendNotification();
1891 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1892 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
1896 int UtcDaliRenderTaskContinuous03(void)
1898 TestApplication application;
1900 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (camera actor not staged)\nPOST:continuous renders, no Finished signal");
1902 // SETUP AN OFFSCREEN RENDER TASK
1903 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1904 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1905 drawTrace.Enable(true);
1907 Actor rootActor = Actor::New();
1908 Stage::GetCurrent().Add( rootActor );
1910 CameraActor offscreenCameraActor = CameraActor::New();
1911 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1912 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1913 Integration::ResourceId imageRequestId = imageRequest->GetId();
1914 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1915 Stage::GetCurrent().Add(secondRootActor);
1917 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1918 bool finished = false;
1919 RenderTaskFinished renderTaskFinished( finished );
1920 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1921 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1922 application.SendNotification();
1924 // START PROCESS/RENDER Input, Expected Input, Expected
1925 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false, __LINE__ ) );
1926 application.GetPlatform().ClearReadyResources();
1928 // ADD CAMERA ACTOR TO STAGE - expect continuous renders to start, no finished signal
1929 Stage::GetCurrent().Add( offscreenCameraActor );
1930 application.SendNotification();
1932 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1933 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
1938 int UtcDaliRenderTaskContinuous04(void)
1940 TestApplication application;
1942 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: Resource not ready\nPOST:continuous renders, no Finished signal");
1944 // SETUP AN OFFSCREEN RENDER TASK
1945 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1946 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1947 drawTrace.Enable(true);
1949 Actor rootActor = Actor::New();
1950 Stage::GetCurrent().Add( rootActor );
1952 CameraActor offscreenCameraActor = CameraActor::New();
1953 Stage::GetCurrent().Add( offscreenCameraActor );
1954 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1955 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1956 Integration::ResourceId imageRequestId = imageRequest->GetId();
1957 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1958 Stage::GetCurrent().Add(secondRootActor);
1960 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1961 bool finished = false;
1962 RenderTaskFinished renderTaskFinished( finished );
1963 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1964 application.SendNotification();
1966 // START PROCESS/RENDER Input, Expected Input, Expected
1967 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
1968 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
1970 // FINISH RESOURCE LOADING - expect 'continuous' renders to start, no finished signal
1971 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1972 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
1976 int UtcDaliRenderTaskContinous05(void)
1978 TestApplication application;
1980 tet_infoline("Testing RenderTask Render Continuous using Mesh which accesses texture through sampler with loading image\n"
1981 "PRE: Resource not ready\nPOST:continuous renders, no Finished signal");
1983 // SETUP AN OFFSCREEN RENDER TASK
1984 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1985 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1986 drawTrace.Enable(true);
1988 Actor rootActor = Actor::New();
1989 Stage::GetCurrent().Add( rootActor );
1991 CameraActor offscreenCameraActor = CameraActor::New();
1992 Stage::GetCurrent().Add( offscreenCameraActor );
1994 Shader shader = CreateShader();
1997 Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1998 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1999 Integration::ResourceId imageRequestId = imageRequest->GetId();
2000 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2001 TextureSet textureSet = CreateTextureSet( image );
2003 Geometry geometry = CreateQuadGeometry();
2004 Renderer renderer = Renderer::New(geometry, shader);
2005 renderer.SetTextures( textureSet );
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, __LINE__ ) );
2019 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
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, __LINE__ ) );
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 Actor secondRootActor = CreateLoadingActor(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, __LINE__ ) );
2061 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2063 // MAKE SOURCE VISIBLE
2064 secondRootActor.SetVisible(true);
2065 application.SendNotification();
2066 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2067 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
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, __LINE__ ) );
2072 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2073 DALI_TEST_CHECK( lastSyncObj != NULL );
2075 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2076 application.GetPlatform().ClearReadyResources();
2077 sync.SetObjectSynced( lastSyncObj, true );
2078 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2079 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
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 Shader shader = CreateShader();
2103 Image image = CreateLoadingImage(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 TextureSet textureSet = CreateTextureSet( image );
2109 Geometry geometry = CreateQuadGeometry();
2110 Renderer renderer = Renderer::New(geometry, shader);
2111 renderer.SetTextures( textureSet );
2112 Actor secondRootActor = Actor::New();
2113 secondRootActor.AddRenderer(renderer);
2114 secondRootActor.SetSize(100, 100);
2115 Stage::GetCurrent().Add(secondRootActor);
2117 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
2118 bool finished = false;
2119 RenderTaskFinished renderTaskFinished( finished );
2120 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2121 application.SendNotification();
2123 // START PROCESS/RENDER Input, Expected Input, Expected
2124 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2125 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2127 // FINISH RESOURCE LOADING - expect no rendering yet
2128 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2129 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2130 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2131 DALI_TEST_CHECK( lastSyncObj != NULL );
2133 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2134 application.GetPlatform().ClearReadyResources();
2135 sync.SetObjectSynced( lastSyncObj, true );
2136 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2137 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2142 int UtcDaliRenderTaskOnce03(void)
2144 TestApplication application;
2146 tet_infoline("Testing RenderTask Render Once GlSync, using loading image. Switch from render always after ready to render once\n"
2147 "PRE: Render task ready, Image not loaded\n"
2148 "POST: Finished signal sent only once");
2150 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2151 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2152 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2153 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2154 drawTrace.Enable(true);
2156 Actor rootActor = Actor::New();
2157 Stage::GetCurrent().Add( rootActor );
2159 CameraActor offscreenCameraActor = CameraActor::New();
2160 Stage::GetCurrent().Add( offscreenCameraActor );
2161 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2162 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2163 Integration::ResourceId imageRequestId = imageRequest->GetId();
2164 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2165 Stage::GetCurrent().Add(secondRootActor);
2167 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2168 bool finished = false;
2169 RenderTaskFinished renderTaskFinished( finished );
2170 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2171 application.SendNotification();
2173 // START PROCESS/RENDER Input, Expected Input, Expected
2174 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2175 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2177 // FINISH RESOURCE LOADING
2178 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2179 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2180 application.GetPlatform().ClearReadyResources();
2181 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2183 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2184 application.SendNotification(); // Input, Expected Input, Expected
2185 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2186 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2187 DALI_TEST_CHECK( lastSyncObj != NULL );
2189 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2190 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2191 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2192 sync.SetObjectSynced( lastSyncObj, true );
2193 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2194 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2200 int UtcDaliRenderTaskOnce04(void)
2202 TestApplication application;
2203 tet_infoline("Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loading image.\n"
2204 "Switch from render always after ready to render once\n"
2205 "PRE: Render task ready, Image not loaded\n"
2206 "POST: Finished signal sent only once");
2208 // SETUP AN OFFSCREEN RENDER TASK
2209 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2210 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2211 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2212 drawTrace.Enable(true);
2214 Actor rootActor = Actor::New();
2215 Stage::GetCurrent().Add( rootActor );
2217 CameraActor offscreenCameraActor = CameraActor::New();
2218 Stage::GetCurrent().Add( offscreenCameraActor );
2220 Shader shader = CreateShader();
2221 Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2222 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2223 Integration::ResourceId imageRequestId = imageRequest->GetId();
2224 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2225 TextureSet textureSet = CreateTextureSet( image );
2227 Geometry geometry = CreateQuadGeometry();
2228 Renderer renderer = Renderer::New(geometry, shader);
2229 renderer.SetTextures( textureSet );
2230 Actor secondRootActor = Actor::New();
2231 secondRootActor.AddRenderer(renderer);
2232 secondRootActor.SetSize(100, 100);
2233 Stage::GetCurrent().Add(secondRootActor);
2235 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2236 bool finished = false;
2237 RenderTaskFinished renderTaskFinished( finished );
2238 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2239 application.SendNotification();
2241 // START PROCESS/RENDER Input, Expected Input, Expected
2242 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2243 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2245 // FINISH RESOURCE LOADING
2246 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2247 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2248 application.GetPlatform().ClearReadyResources();
2249 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2251 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2252 application.SendNotification(); // Input, Expected Input, Expected
2253 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2254 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2255 DALI_TEST_CHECK( lastSyncObj != NULL );
2257 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2258 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2259 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2260 sync.SetObjectSynced( lastSyncObj, true );
2261 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2262 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2267 int UtcDaliRenderTaskOnce05(void)
2269 TestApplication application;
2271 tet_infoline("Testing RenderTask Render Once GlSync\n"
2272 "Switch from Render always after ready to render once with resources unready\n"
2273 "PRE: Everything ready to render\n"
2274 "POST: Finished signal sent once");
2276 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2277 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2278 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2279 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2280 drawTrace.Enable(true);
2282 Actor rootActor = Actor::New();
2283 Stage::GetCurrent().Add( rootActor );
2285 CameraActor offscreenCameraActor = CameraActor::New();
2286 Stage::GetCurrent().Add( offscreenCameraActor );
2287 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2288 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2289 Integration::ResourceId imageRequestId = imageRequest->GetId();
2290 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2291 Stage::GetCurrent().Add(secondRootActor);
2293 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2294 bool finished = false;
2295 RenderTaskFinished renderTaskFinished( finished );
2296 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2297 application.SendNotification();
2299 // START PROCESS/RENDER Input, Expected Input, Expected
2300 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2301 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2303 // CHANGE TO RENDER ONCE
2304 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2305 application.SendNotification(); // Input, Expected Input, Expected
2306 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2307 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2309 // FINISH RESOURCE LOADING
2310 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2311 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2312 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2313 DALI_TEST_CHECK( lastSyncObj != NULL );
2314 application.GetPlatform().ClearReadyResources();
2316 sync.SetObjectSynced( lastSyncObj, true );
2318 // Expect: No draw - we've just drawn our render task once, above. No finished signal -
2319 // we won't read the gl sync until the next frame. Continue rendering - we're waiting for
2321 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2323 // Expect: 1 final draw - this Update doesn't update the scene, hence render instructions
2324 // from last frame but 1 are still present.
2325 // Finished signal should be true - we've just done the sync.
2326 // Should now stop rendering and updating - nothing left to do.
2327 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, true, false, __LINE__ ) );
2333 //int UtcDaliRenderTaskOnce06(void)
2335 TestApplication application;
2337 tet_infoline("Testing RenderTask Render Once GlSync\n"
2338 "During RenderOnce, make ready resources unready before sending first finished signal\n"
2339 "PRE: Everything ready.\n"
2340 "POST: Finished signal sent only once");
2342 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2343 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2344 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2345 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2346 drawTrace.Enable(true);
2348 Actor rootActor = Actor::New();
2349 Stage::GetCurrent().Add( rootActor );
2351 CameraActor offscreenCameraActor = CameraActor::New();
2352 Stage::GetCurrent().Add( offscreenCameraActor );
2353 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2354 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2355 Integration::ResourceId imageRequestId = imageRequest->GetId();
2356 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2357 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2358 application.Render();
2360 Stage::GetCurrent().Add(secondRootActor);
2361 application.GetPlatform().ClearReadyResources();
2363 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2364 bool finished = false;
2365 RenderTaskFinished renderTaskFinished( finished );
2366 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2367 application.SendNotification();
2369 // START PROCESS/RENDER Input, Expected Input, Expected
2370 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2371 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2373 // CHANGE TO RENDER ONCE, RESOURCES BECOME NOT READY
2374 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2377 ReloadImage(application, secondRootActor.GetImage());
2378 application.SendNotification(); // Input, Expected Input, Expected
2380 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2381 DALI_TEST_EQUALS( secondRootActor.GetImage().GetLoadingState(), Dali::ResourceLoading, TEST_LOCATION);
2382 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2384 // FINISH RESOURCE LOADING
2385 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2386 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2387 application.GetPlatform().ClearReadyResources();
2388 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2389 DALI_TEST_CHECK( lastSyncObj != NULL );
2391 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2392 sync.SetObjectSynced( lastSyncObj, true );
2393 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2394 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, true, __LINE__ ) );
2396 // Finished rendering - expect no more renders, no more signals:
2397 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2398 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2399 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2400 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2401 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2402 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2407 int UtcDaliRenderTaskOnce07(void)
2409 TestApplication application;
2411 tet_infoline("Testing RenderTask Render Once GLSync\n"
2412 "Render once, Second call to SetRefreshRate(ONCE) triggers only one more finished signal\n"
2413 "PRE: Everything ready\n"
2414 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
2416 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2417 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2418 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2419 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2420 drawTrace.Enable(true);
2422 Actor rootActor = Actor::New();
2423 Stage::GetCurrent().Add( rootActor );
2425 CameraActor offscreenCameraActor = CameraActor::New();
2426 Stage::GetCurrent().Add( offscreenCameraActor );
2427 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2428 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2429 Integration::ResourceId imageRequestId = imageRequest->GetId();
2430 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2431 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2432 application.Render();
2433 application.GetPlatform().ClearReadyResources();
2435 Stage::GetCurrent().Add(secondRootActor);
2437 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2438 bool finished = false;
2439 RenderTaskFinished renderTaskFinished( finished );
2440 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2441 application.SendNotification();
2443 // START PROCESS/RENDER Input, Expected Input, Expected
2444 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2446 // CHANGE TO RENDER ONCE,
2447 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2448 application.SendNotification();
2449 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2450 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2451 DALI_TEST_CHECK( lastSyncObj != NULL );
2453 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2454 sync.SetObjectSynced( lastSyncObj, true );
2455 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2456 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2458 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2459 application.SendNotification();
2460 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2461 lastSyncObj = sync.GetLastSyncObject();
2462 DALI_TEST_CHECK( lastSyncObj != NULL );
2464 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2465 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2466 sync.SetObjectSynced( lastSyncObj, true );
2467 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2468 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2472 int UtcDaliRenderTaskOnce08(void)
2474 TestApplication application;
2476 tet_infoline("Testing RenderTask Render Once GLSync\n"
2477 "Render once, Call to SetRefreshRate(ONCE) in Finished signal callback triggers "
2478 "another render & another finished signal\n"
2479 "PRE: Everything ready\n"
2480 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
2483 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2484 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2485 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2486 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2487 sync.GetTrace().Enable(true);
2488 drawTrace.Enable(true);
2490 Actor rootActor = Actor::New();
2491 Stage::GetCurrent().Add( rootActor );
2493 CameraActor offscreenCameraActor = CameraActor::New();
2494 Stage::GetCurrent().Add( offscreenCameraActor );
2495 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2496 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2497 Integration::ResourceId imageRequestId = imageRequest->GetId();
2498 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2499 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2500 application.Render();
2501 application.GetPlatform().ClearReadyResources();
2503 Stage::GetCurrent().Add(secondRootActor);
2505 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, /*GL-SYNC*/ true);
2506 bool finished = false;
2508 ConnectionTracker connectionTracker;
2509 RenderTaskFinishedRenderAgain renderTaskFinishedRenderAgain( finished );
2510 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinishedRenderAgain );
2512 application.SendNotification();
2514 // START PROCESS/RENDER Input, Expected Input, Expected
2515 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2516 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2517 DALI_TEST_CHECK( lastSyncObj == NULL );
2518 DALI_TEST_EQUALS( sync.GetTrace().CountMethod( "CreateSyncObject" ), 0, TEST_LOCATION );
2521 // CHANGE TO RENDER ONCE,
2522 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2523 application.SendNotification();
2524 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2525 lastSyncObj = sync.GetLastSyncObject();
2526 DALI_TEST_CHECK( lastSyncObj != NULL );
2527 DALI_TEST_EQUALS( sync.GetNumberOfSyncObjects(), 1, TEST_LOCATION );
2528 DALI_TEST_EQUALS( sync.GetTrace().CountMethod( "CreateSyncObject" ), 1, TEST_LOCATION );
2530 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2533 DALI_TEST_EQUALS( sync.GetNumberOfSyncObjects(), 1, TEST_LOCATION );
2534 DALI_TEST_EQUALS( sync.GetTrace().CountMethod( "CreateSyncObject" ), 1, TEST_LOCATION );
2536 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2538 DALI_TEST_EQUALS( sync.GetNumberOfSyncObjects(), 1, TEST_LOCATION );
2539 DALI_TEST_EQUALS( sync.GetTrace().CountMethod( "CreateSyncObject" ), 1, TEST_LOCATION );
2541 sync.SetObjectSynced( lastSyncObj, true );
2542 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2543 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2544 application.SendNotification();
2546 // Expect SetRefreshRate to have been called again
2547 // Prevent next finished signal calling refresh once again
2548 RenderTaskFinished renderTaskFinished( finished );
2549 connectionTracker.DisconnectAll();
2550 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinished );
2551 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2552 lastSyncObj = sync.GetLastSyncObject();
2553 DALI_TEST_CHECK( lastSyncObj != NULL );
2555 sync.SetObjectSynced( lastSyncObj, true );
2556 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2557 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2562 int UtcDaliRenderTaskOnce09(void)
2564 TestApplication application;
2566 tet_infoline("Testing RenderTask Render Once GlSync\n"
2567 "SetRefreshRate(ONCE) again before first finished signal has been sent.\n"
2568 "PRE: resources ready\n"
2569 "POST: Only 1 finished signal sent.");
2571 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2572 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2573 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2574 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2575 drawTrace.Enable(true);
2577 Actor rootActor = Actor::New();
2578 Stage::GetCurrent().Add( rootActor );
2580 CameraActor offscreenCameraActor = CameraActor::New();
2581 Stage::GetCurrent().Add( offscreenCameraActor );
2582 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2583 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2584 Integration::ResourceId imageRequestId = imageRequest->GetId();
2585 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2586 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2587 application.Render();
2588 application.GetPlatform().ClearReadyResources();
2590 Stage::GetCurrent().Add(secondRootActor);
2592 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2593 bool finished = false;
2594 RenderTaskFinished renderTaskFinished( finished );
2595 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2596 application.SendNotification();
2598 // START PROCESS/RENDER Input, Expected Input, Expected
2599 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2601 // CHANGE TO RENDER ONCE,
2602 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2603 application.SendNotification();
2604 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2605 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2606 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2608 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2609 application.SendNotification();
2610 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2611 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2612 DALI_TEST_CHECK( lastSyncObj != NULL );
2614 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2615 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2616 sync.SetObjectSynced( lastSyncObj, true );
2617 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2618 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2623 int UtcDaliRenderTaskOnce10(void)
2625 TestApplication application;
2627 tet_infoline("Testing RenderTask Render Once GlSync\n"
2628 "SetRefreshRate(ONCE), resource load failed completes render task.\n"
2629 "PRE: resources not ready\n"
2630 "POST: Only 1 finished signal sent.");
2632 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2633 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2634 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2635 drawTrace.Enable(true);
2637 Actor rootActor = Actor::New();
2638 Stage::GetCurrent().Add( rootActor );
2640 CameraActor offscreenCameraActor = CameraActor::New();
2641 Stage::GetCurrent().Add( offscreenCameraActor );
2642 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2643 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2644 Integration::ResourceId imageRequestId = imageRequest->GetId();
2645 Stage::GetCurrent().Add(secondRootActor);
2647 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2648 bool finished = false;
2649 RenderTaskFinished renderTaskFinished( finished );
2650 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2651 application.SendNotification();
2653 // START PROCESS/RENDER Input, Expected Input, Expected
2654 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2655 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2657 // CHANGE TO RENDER ONCE,
2658 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2659 application.SendNotification();
2660 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2661 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2662 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2664 tet_printf(" FailImageLoad\n");
2666 FailImageLoad(application, imageRequestId); // Need to run Update again for this to complete
2668 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); // nothing to draw
2669 application.SendNotification();
2671 // load is now failed so there's nothing more to render in the render task
2672 // Expect finished signal, as all resources are complete
2673 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2678 int UtcDaliRenderTaskOnceNoSync01(void)
2680 TestApplication application;
2682 tet_infoline("Testing RenderTask Render Once, using loading image\nPRE: Resources not ready, Source not visible\nPOST: Finished signal sent once only");
2684 // SETUP AN OFFSCREEN RENDER TASK
2685 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2686 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2687 drawTrace.Enable(true);
2689 Actor rootActor = Actor::New();
2690 Stage::GetCurrent().Add( rootActor );
2692 CameraActor offscreenCameraActor = CameraActor::New();
2693 Stage::GetCurrent().Add( offscreenCameraActor );
2694 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2695 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2696 Integration::ResourceId imageRequestId = imageRequest->GetId();
2697 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2699 Stage::GetCurrent().Add(secondRootActor);
2701 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2702 bool finished = false;
2703 RenderTaskFinished renderTaskFinished( finished );
2704 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2705 application.SendNotification();
2707 // START PROCESS/RENDER Input, Expected Input, Expected
2708 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2709 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2711 // FINISH RESOURCE LOADING - expect immediate rendering yet
2712 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2713 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2714 application.GetPlatform().ClearReadyResources();
2715 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2719 int UtcDaliRenderTaskOnceNoSync02(void)
2721 TestApplication application;
2723 tet_infoline("Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loading image.\n"
2724 "PRE: Resources not ready\nPOST: Finished signal sent once only");
2725 // SETUP AN OFFSCREEN RENDER TASK
2726 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2727 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2728 drawTrace.Enable(true);
2730 Actor rootActor = Actor::New();
2731 Stage::GetCurrent().Add( rootActor );
2733 CameraActor offscreenCameraActor = CameraActor::New();
2734 Stage::GetCurrent().Add( offscreenCameraActor );
2736 Shader shader = CreateShader();
2737 Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2738 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2739 Integration::ResourceId imageRequestId = imageRequest->GetId();
2740 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2741 TextureSet textureSet = CreateTextureSet( image );
2743 Geometry geometry = CreateQuadGeometry();
2744 Renderer renderer = Renderer::New(geometry, shader);
2745 renderer.SetTextures( textureSet );
2746 Actor secondRootActor = Actor::New();
2747 secondRootActor.AddRenderer(renderer);
2748 secondRootActor.SetSize(100, 100);
2749 Stage::GetCurrent().Add(secondRootActor);
2751 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2752 bool finished = false;
2753 RenderTaskFinished renderTaskFinished( finished );
2754 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2755 application.SendNotification();
2757 // START PROCESS/RENDER Input, Expected Input, Expected
2758 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2759 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2761 // FINISH RESOURCE LOADING - expect immediate rendering yet
2762 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2763 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2764 application.GetPlatform().ClearReadyResources();
2765 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2770 int UtcDaliRenderTaskOnceNoSync03(void)
2772 TestApplication application;
2774 tet_infoline("Testing RenderTask Render Once, using loading image. Switch from render always after ready to render once\n"
2775 "PRE: Render task ready, Image not loaded\n"
2776 "POST: Finished signal sent only once");
2778 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2779 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2780 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2781 drawTrace.Enable(true);
2783 Actor rootActor = Actor::New();
2784 Stage::GetCurrent().Add( rootActor );
2786 CameraActor offscreenCameraActor = CameraActor::New();
2787 Stage::GetCurrent().Add( offscreenCameraActor );
2788 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2789 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2790 Integration::ResourceId imageRequestId = imageRequest->GetId();
2791 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2792 Stage::GetCurrent().Add(secondRootActor);
2794 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2795 bool finished = false;
2796 RenderTaskFinished renderTaskFinished( finished );
2797 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2798 application.SendNotification();
2800 // START PROCESS/RENDER Input, Expected Input, Expected
2801 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2802 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2804 // FINISH RESOURCE LOADING
2805 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2806 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2807 application.GetPlatform().ClearReadyResources();
2809 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2810 application.SendNotification(); // Input, Expected Input, Expected
2811 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2812 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2816 int UtcDaliRenderTaskOnceNoSync04(void)
2818 TestApplication application;
2820 tet_infoline("Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loading image.\n"
2821 "Switch from render always after ready to render once\n"
2822 "PRE: Render task ready, Image not loaded\n"
2823 "POST: Finished signal sent only once");
2825 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2826 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2827 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2828 drawTrace.Enable(true);
2830 Actor rootActor = Actor::New();
2831 Stage::GetCurrent().Add( rootActor );
2833 CameraActor offscreenCameraActor = CameraActor::New();
2834 Stage::GetCurrent().Add( offscreenCameraActor );
2836 Shader shader = CreateShader();
2837 Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2838 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2839 Integration::ResourceId imageRequestId = imageRequest->GetId();
2840 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2841 TextureSet textureSet = CreateTextureSet( image );
2843 Geometry geometry = CreateQuadGeometry();
2844 Renderer renderer = Renderer::New(geometry, shader);
2845 renderer.SetTextures( textureSet );
2846 Actor secondRootActor = Actor::New();
2847 secondRootActor.AddRenderer(renderer);
2848 secondRootActor.SetSize(100, 100);
2849 Stage::GetCurrent().Add(secondRootActor);
2852 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2853 bool finished = false;
2854 RenderTaskFinished renderTaskFinished( finished );
2855 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2856 application.SendNotification();
2858 // START PROCESS/RENDER Input, Expected Input, Expected
2859 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2860 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2862 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2863 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2864 DALI_TEST_CHECK( lastSyncObj == NULL );
2866 // FINISH RESOURCE LOADING
2867 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2868 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2869 application.GetPlatform().ClearReadyResources();
2871 lastSyncObj = sync.GetLastSyncObject();
2872 DALI_TEST_CHECK( lastSyncObj == NULL );
2874 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2875 application.SendNotification(); // Input, Expected Input, Expected
2876 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2877 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2879 lastSyncObj = sync.GetLastSyncObject();
2880 DALI_TEST_CHECK( lastSyncObj == NULL );
2885 int UtcDaliRenderTaskOnceNoSync05(void)
2887 TestApplication application;
2889 tet_infoline("Testing RenderTask Render Once\n"
2890 "Switch from Render always after ready to render once with resources unready\n"
2891 "PRE: Everything ready to render\n"
2892 "POST: Finished signal sent once");
2894 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2895 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2896 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2897 drawTrace.Enable(true);
2899 Actor rootActor = Actor::New();
2900 Stage::GetCurrent().Add( rootActor );
2902 CameraActor offscreenCameraActor = CameraActor::New();
2903 Stage::GetCurrent().Add( offscreenCameraActor );
2904 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2905 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2906 Integration::ResourceId imageRequestId = imageRequest->GetId();
2907 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2908 Stage::GetCurrent().Add(secondRootActor);
2910 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2911 bool finished = false;
2912 RenderTaskFinished renderTaskFinished( finished );
2913 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2914 application.SendNotification();
2916 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2917 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2918 DALI_TEST_CHECK( lastSyncObj == NULL );
2920 // START PROCESS/RENDER Input, Expected Input, Expected
2921 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2922 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2924 // CHANGE TO RENDER ONCE
2925 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2926 application.SendNotification(); // Input, Expected Input, Expected
2927 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2928 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2930 // FINISH RESOURCE LOADING
2931 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2932 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2933 application.GetPlatform().ClearReadyResources();
2934 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2939 //int UtcDaliRenderTaskOnceNoSync06(void)
2941 TestApplication application;
2943 tet_infoline("Testing RenderTask Render Once\n"
2944 "During RenderOnce, make ready resources unready before sending first finished signal\n"
2945 "PRE: Everything ready.\n"
2946 "POST: Finished signal sent only once");
2948 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2949 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2950 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2951 drawTrace.Enable(true);
2953 Actor rootActor = Actor::New();
2954 Stage::GetCurrent().Add( rootActor );
2956 CameraActor offscreenCameraActor = CameraActor::New();
2957 Stage::GetCurrent().Add( offscreenCameraActor );
2958 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2959 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2960 Integration::ResourceId imageRequestId = imageRequest->GetId();
2961 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2962 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2963 application.Render();
2964 application.GetPlatform().ClearReadyResources();
2966 Stage::GetCurrent().Add(secondRootActor);
2968 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2969 bool finished = false;
2970 RenderTaskFinished renderTaskFinished( finished );
2971 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2972 application.SendNotification();
2974 // START PROCESS/RENDER Input, Expected Input, Expected
2975 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2976 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2978 // CHANGE TO RENDER ONCE, RESOURCES BECOME NOT READY
2979 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2982 ReloadImage(application, secondRootActor.GetImage());
2983 application.SendNotification(); // Input, Expected Input, Expected
2985 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2986 DALI_TEST_EQUALS( secondRootActor.GetImage().GetLoadingState(), Dali::ResourceLoading, TEST_LOCATION);
2987 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2989 // FINISH RESOURCE LOADING
2990 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2991 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, true, true, __LINE__ ) );
2992 application.GetPlatform().ClearReadyResources();
2993 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2994 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2995 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2996 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3001 int UtcDaliRenderTaskOnceNoSync07(void)
3003 TestApplication application;
3005 tet_infoline("Testing RenderTask Render Once\n"
3006 "Render once, Second call to SetRefreshRate(ONCE) triggers only one more finished signal\n"
3007 "PRE: Everything ready\n"
3008 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
3010 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3011 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3012 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3013 drawTrace.Enable(true);
3015 Actor rootActor = Actor::New();
3016 Stage::GetCurrent().Add( rootActor );
3018 CameraActor offscreenCameraActor = CameraActor::New();
3019 Stage::GetCurrent().Add( offscreenCameraActor );
3020 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3021 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3022 Integration::ResourceId imageRequestId = imageRequest->GetId();
3023 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
3024 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
3025 application.Render();
3026 application.GetPlatform().ClearReadyResources();
3028 Stage::GetCurrent().Add(secondRootActor);
3030 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3031 bool finished = false;
3032 RenderTaskFinished renderTaskFinished( finished );
3033 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3034 application.SendNotification();
3036 // START PROCESS/RENDER Input, Expected Input, Expected
3037 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
3039 // CHANGE TO RENDER ONCE,
3040 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3041 application.SendNotification();
3042 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3043 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3045 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3046 application.SendNotification();
3047 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3048 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3052 int UtcDaliRenderTaskOnceNoSync08(void)
3054 TestApplication application;
3056 tet_infoline("Testing RenderTask Render Once\n"
3057 "Render once, Call to SetRefreshRate(ONCE) in Finished signal callback triggers\n"
3058 "another render & another finished signal\n"
3059 "PRE: Everything ready\n"
3060 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
3063 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3064 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3065 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3066 drawTrace.Enable(true);
3068 Actor rootActor = Actor::New();
3069 Stage::GetCurrent().Add( rootActor );
3071 CameraActor offscreenCameraActor = CameraActor::New();
3072 Stage::GetCurrent().Add( offscreenCameraActor );
3073 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3074 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3075 Integration::ResourceId imageRequestId = imageRequest->GetId();
3076 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
3077 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
3078 application.Render();
3079 application.GetPlatform().ClearReadyResources();
3081 Stage::GetCurrent().Add(secondRootActor);
3083 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3084 bool finished = false;
3086 ConnectionTracker connectionTracker;
3087 RenderTaskFinishedRenderAgain renderTaskFinishedRenderAgain( finished );
3088 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinishedRenderAgain );
3090 application.SendNotification();
3092 // START PROCESS/RENDER Input, Expected Input, Expected
3093 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
3095 // CHANGE TO RENDER ONCE,
3096 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3097 application.SendNotification();
3098 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3099 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3101 // Expect SetRefreshRate to have been called again
3102 // Prevent next finished signal calling refresh once again
3103 RenderTaskFinished renderTaskFinished( finished );
3104 connectionTracker.DisconnectAll();
3105 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinished );
3107 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3108 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3113 int UtcDaliRenderTaskOnceNoSync09(void)
3115 TestApplication application;
3117 tet_infoline("Testing RenderTask Render Once\n"
3118 "SetRefreshRate(ONCE) again before first finished signal has been sent.\n"
3119 "PRE: resources ready\n"
3120 "POST: Only 1 finished signal sent.");
3122 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3123 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3124 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3125 drawTrace.Enable(true);
3127 Actor rootActor = Actor::New();
3128 Stage::GetCurrent().Add( rootActor );
3130 CameraActor offscreenCameraActor = CameraActor::New();
3131 Stage::GetCurrent().Add( offscreenCameraActor );
3132 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3133 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3134 Integration::ResourceId imageRequestId = imageRequest->GetId();
3135 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
3136 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
3137 application.Render();
3138 application.GetPlatform().ClearReadyResources();
3140 Stage::GetCurrent().Add(secondRootActor);
3142 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3143 bool finished = false;
3144 RenderTaskFinished renderTaskFinished( finished );
3145 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3146 application.SendNotification();
3148 // START PROCESS/RENDER Input, Expected Input, Expected
3149 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
3151 // CHANGE TO RENDER ONCE,
3152 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3153 application.SendNotification();
3154 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3155 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3157 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3158 application.SendNotification();
3159 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3160 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3164 int UtcDaliRenderTaskOnceNoSync10(void)
3166 TestApplication application;
3168 tet_infoline("Testing RenderTask Render Once\n"
3169 "SetRefreshRate(ONCE), resource load failed, completes render task.\n"
3170 "PRE: resources not ready\n"
3171 "POST: Only 1 finished signal sent.");
3173 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3174 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3175 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3176 drawTrace.Enable(true);
3178 Actor rootActor = Actor::New();
3179 Stage::GetCurrent().Add( rootActor );
3181 CameraActor offscreenCameraActor = CameraActor::New();
3182 Stage::GetCurrent().Add( offscreenCameraActor );
3183 Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3184 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3185 Integration::ResourceId imageRequestId = imageRequest->GetId();
3186 Stage::GetCurrent().Add(secondRootActor);
3188 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3189 bool finished = false;
3190 RenderTaskFinished renderTaskFinished( finished );
3191 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3192 application.SendNotification();
3194 // START PROCESS/RENDER Input, Expected Input, Expected
3195 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3196 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3198 // CHANGE TO RENDER ONCE,
3199 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3200 application.SendNotification();
3201 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3202 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3203 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3205 FailImageLoad(application, imageRequestId); // Need to run Update again for this to complete
3206 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); // nothing to draw
3207 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3214 int UtcDaliRenderTaskOnceChain01(void)
3216 TestApplication application;
3218 tet_infoline("Testing RenderTask Render Once Chained render tasks\n"
3219 "SetRefreshRate(ONCE), resource load completes, both render tasks render.\n"
3220 "PRE: resources not ready\n"
3221 "POST: 2 finished signals sent.");
3223 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3224 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3225 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3226 drawTrace.Enable(true);
3228 Actor defaultRootActor = Actor::New(); // Root for default RT
3229 Stage::GetCurrent().Add( defaultRootActor );
3231 CameraActor offscreenCameraActor = CameraActor::New();
3232 Stage::GetCurrent().Add( offscreenCameraActor );
3233 Actor firstRootActor = CreateLoadingActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3234 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3235 Integration::ResourceId imageRequestId = imageRequest->GetId();
3236 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
3237 Stage::GetCurrent().Add(firstRootActor);
3239 // first render task
3240 RenderTask firstTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, firstRootActor, RenderTask::REFRESH_ONCE, false);
3241 bool firstFinished = false;
3242 RenderTaskFinished renderTask1Finished( firstFinished );
3243 firstTask.FinishedSignal().Connect( &application, renderTask1Finished );
3245 // Second render task
3246 FrameBufferImage fbo = firstTask.GetTargetFrameBuffer();
3247 Actor secondRootActor = CreateRenderableActor( fbo );
3248 Stage::GetCurrent().Add(secondRootActor);
3249 RenderTask secondTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
3250 bool secondFinished = false;
3251 RenderTaskFinished renderTask2Finished( secondFinished );
3252 secondTask.FinishedSignal().Connect( &application, renderTask2Finished );
3254 application.SendNotification();
3256 // START PROCESS/RENDER Input, Expected Input, Expected
3257 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__ ) );
3258 DALI_TEST_CHECK( firstFinished == false );
3259 DALI_TEST_CHECK( secondFinished == false );
3260 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__ ) );
3261 DALI_TEST_CHECK( firstFinished == false );
3262 DALI_TEST_CHECK( secondFinished == false );
3264 CompleteImageLoad(application, imageRequestId, imageType);
3265 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__ ) );
3266 DALI_TEST_CHECK( firstFinished == false );
3267 DALI_TEST_CHECK( secondFinished == false );
3269 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, true, true, __LINE__ ) );
3270 DALI_TEST_CHECK( firstFinished == true );
3271 DALI_TEST_CHECK( secondFinished == false );
3273 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, secondFinished, true, false, __LINE__ ) );
3274 DALI_TEST_CHECK( secondFinished == true );
3279 int UtcDaliRenderTaskProperties(void)
3281 TestApplication application;
3283 RenderTask task = Stage::GetCurrent().GetRenderTaskList().CreateTask();
3285 Property::IndexContainer indices;
3286 task.GetPropertyIndices( indices );
3287 DALI_TEST_CHECK( indices.Size() );
3288 DALI_TEST_EQUALS( indices.Size(), task.GetPropertyCount(), TEST_LOCATION );
3292 int UtcDaliRenderTaskSetScreenToFrameBufferMappingActor(void)
3294 TestApplication application;
3295 tet_infoline("Testing RenderTask::SetScreenToFrameBufferMappingActor ");
3297 Stage stage = Stage::GetCurrent();
3298 Size stageSize = stage.GetSize();
3299 Actor mappingActor = Actor::New();
3300 Vector2 scale( 0.6f, 0.75f);
3301 Vector2 offset( stageSize.x*0.1f, stageSize.y*0.15f);
3302 mappingActor.SetSize( stageSize * scale );
3303 mappingActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
3304 mappingActor.SetPosition( offset.x, offset.y );
3305 stage.Add( mappingActor );
3307 Actor offscreenActor = Actor::New();
3308 offscreenActor.SetSize( stageSize );
3309 offscreenActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
3310 stage.Add( offscreenActor );
3312 RenderTaskList taskList = stage.GetRenderTaskList();
3313 RenderTask renderTask = taskList.CreateTask();
3314 FrameBufferImage frameBufferImage = FrameBufferImage::New(stageSize.width*scale.x, stageSize.height*scale.y, Pixel::A8, Image::NEVER);
3315 renderTask.SetSourceActor( offscreenActor );
3316 renderTask.SetExclusive( true );
3317 renderTask.SetInputEnabled( true );
3318 renderTask.SetTargetFrameBuffer( frameBufferImage );
3319 renderTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
3320 renderTask.SetScreenToFrameBufferMappingActor( mappingActor );
3321 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3323 // Render and notify
3324 application.SendNotification();
3325 application.Render();
3326 application.Render();
3327 application.SendNotification();
3329 Vector2 screenCoordinates( stageSize.x * 0.05f, stageSize.y * 0.05f );
3330 Dali::HitTestAlgorithm::Results results;
3331 DALI_TEST_CHECK( !results.actor );
3332 DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
3333 // miss expected, results not changed
3334 DALI_TEST_CHECK( false == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3335 DALI_TEST_CHECK( !results.actor );
3336 DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
3338 screenCoordinates.x = stageSize.x * 0.265f;
3339 screenCoordinates.y = stageSize.y * 0.33f;
3340 results.actor = Actor();
3341 results.actorCoordinates = Vector2::ZERO;
3342 // hit expected, results changed
3343 DALI_TEST_CHECK( true == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3344 DALI_TEST_CHECK( results.actor == offscreenActor );
3345 DALI_TEST_EQUALS( (screenCoordinates-offset)/scale , results.actorCoordinates, 0.1f, TEST_LOCATION );
3347 screenCoordinates.x = stageSize.x * 0.435f;
3348 screenCoordinates.y = stageSize.y * 0.52f;
3349 // hit expected, results changed
3350 DALI_TEST_CHECK( true == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3351 DALI_TEST_CHECK( results.actor == offscreenActor );
3352 const Vector2 expectedCoordinates = (screenCoordinates-offset)/scale;
3353 DALI_TEST_EQUALS( expectedCoordinates , results.actorCoordinates, 0.1f, TEST_LOCATION );
3355 screenCoordinates.x = stageSize.x * 0.65f;
3356 screenCoordinates.y = stageSize.y * 0.95f;
3357 // miss expected, results not changed
3358 DALI_TEST_CHECK( false == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3359 DALI_TEST_CHECK( results.actor == offscreenActor );
3360 DALI_TEST_EQUALS( expectedCoordinates , results.actorCoordinates, 0.1f, TEST_LOCATION );
3364 int UtcDaliRenderTaskFinishInvisibleSourceActor(void)
3366 TestApplication application;
3368 tet_infoline("Testing RenderTask::FinishInvisibleSourceActor()");
3370 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3371 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
3373 CameraActor offscreenCameraActor = CameraActor::New();
3375 Stage::GetCurrent().Add( offscreenCameraActor );
3377 BufferImage image = BufferImage::New( 10, 10 );
3378 Actor rootActor = CreateRenderableActor( image );
3379 rootActor.SetSize( 10, 10 );
3380 rootActor.SetVisible(false);
3381 Stage::GetCurrent().Add( rootActor );
3383 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3384 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
3385 FrameBufferImage frameBufferImage = FrameBufferImage::New( *testNativeImagePtr.Get() );
3387 // Flush all outstanding messages
3388 application.SendNotification();
3389 application.Render();
3391 RenderTask newTask = taskList.CreateTask();
3392 newTask.SetCameraActor( offscreenCameraActor );
3393 newTask.SetSourceActor( rootActor );
3394 newTask.SetInputEnabled( false );
3395 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
3396 newTask.SetClearEnabled( true );
3397 newTask.SetExclusive( true );
3398 newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
3399 newTask.SetTargetFrameBuffer( frameBufferImage );
3400 newTask.SetProperty( RenderTask::Property::REQUIRES_SYNC, true );
3402 // Framebuffer doesn't actually get created until Connected, i.e. by previous line
3404 bool finished = false;
3405 RenderTaskFinished renderTaskFinished( finished );
3406 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3408 // Flush the queue and render.
3409 application.SendNotification();
3411 // 1 render to process render task, then wait for sync before finished msg is sent
3412 // from update to the event thread.
3414 application.Render();
3415 application.SendNotification();
3416 DALI_TEST_CHECK( !finished );
3418 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
3419 DALI_TEST_CHECK( lastSyncObj != NULL );
3421 application.Render();
3422 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
3423 application.SendNotification();
3424 DALI_TEST_CHECK( !finished );
3426 application.Render();
3427 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
3428 application.SendNotification();
3429 DALI_TEST_CHECK( ! finished );
3431 sync.SetObjectSynced( lastSyncObj, true );
3433 application.Render();
3434 application.SendNotification();
3435 DALI_TEST_CHECK( !finished );
3437 application.Render();
3438 application.SendNotification();
3439 DALI_TEST_CHECK( finished );
3442 application.Render(); // Double check no more finished signal
3443 application.SendNotification();
3444 DALI_TEST_CHECK( ! finished );
3449 int UtcDaliRenderTaskFinishMissingImage(void)
3451 TestApplication application;
3453 // Previously we had bugs where not having a resource ID would cause render-tasks to wait forever
3454 tet_infoline("Testing RenderTask::SignalFinished() when an Actor has no Image set");
3456 Stage stage = Stage::GetCurrent();
3458 BufferImage image = BufferImage::New( 10, 10 );
3459 Actor rootActor = CreateRenderableActor( image );
3460 rootActor.SetSize( 10, 10 );
3461 stage.Add( rootActor );
3463 Actor actorWithMissingImage = CreateRenderableActor( Image() );
3464 actorWithMissingImage.SetSize( 10, 10 );
3465 stage.Add( actorWithMissingImage );
3467 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3468 RenderTask newTask = taskList.CreateTask();
3469 newTask.SetInputEnabled( false );
3470 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
3471 newTask.SetClearEnabled( true );
3472 newTask.SetExclusive( true );
3473 newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
3475 bool finished = false;
3476 RenderTaskFinished renderTaskFinished( finished );
3477 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3479 // 1 render to process render task, then 1 before finished msg is sent from update to the event thread.
3480 application.SendNotification();
3481 application.Render();
3482 application.Render();
3484 application.SendNotification();
3485 DALI_TEST_CHECK( finished );
3490 int UtcDaliRenderTaskWorldToViewport(void)
3492 TestApplication application( static_cast<size_t>(400), static_cast<size_t>(400) ); // square surface
3494 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3496 Actor actor = Actor::New();
3497 actor.SetSize(100.0f, 100.0f);
3498 actor.SetPosition( Vector3(0.0, 0.0, 0.0) );
3500 actor.SetParentOrigin( Vector3(0.5, 0.5, 0.5) );
3501 actor.SetAnchorPoint( Vector3(0.5, 0.5, 0.5) );
3503 Stage::GetCurrent().Add(actor);
3505 application.SendNotification();
3506 application.Render();
3507 application.SendNotification();
3509 RenderTask task = taskList.GetTask( 0u );
3511 CameraActor camera = task.GetCameraActor();
3513 Vector2 screenSize = task.GetCurrentViewportSize();
3515 float screenX = 0.0;
3516 float screenY = 0.0;
3518 bool ok = task.WorldToViewport(actor.GetCurrentWorldPosition(), screenX, screenY);
3519 DALI_TEST_CHECK(ok == true);
3521 DALI_TEST_EQUALS(screenX, screenSize.x/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
3522 DALI_TEST_EQUALS(screenY, screenSize.y/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
3524 Actor actor2 = Actor::New();
3525 float actor2Size = 100.f;
3526 actor2.SetSize( actor2Size, actor2Size );
3527 actor2.SetPosition( Vector3(0.0, 0.0, 0.0) );
3528 actor2.SetParentOrigin( Vector3(0.5, 0.5, 0.0) );
3529 actor2.SetAnchorPoint( Vector3(0.5, 0.5, 0.0) );
3530 Stage::GetCurrent().Add( actor2 );
3532 actor.SetParentOrigin( Vector3(0,0,0) );
3534 application.SendNotification();
3535 application.Render();
3536 application.SendNotification();
3538 ok = task.WorldToViewport(actor.GetCurrentWorldPosition(), screenX, screenY);
3539 DALI_TEST_CHECK(ok == true);
3541 DALI_TEST_EQUALS(screenX, screenSize.x/2 - actor2Size/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
3542 DALI_TEST_EQUALS(screenY, screenSize.y/2 - actor2Size/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
3548 int UtcDaliRenderTaskViewportToLocal(void)
3550 TestApplication application;
3551 Actor actor = Actor::New();
3552 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
3553 actor.SetSize(100.0f, 100.0f);
3554 actor.SetPosition(10.0f, 10.0f);
3555 Stage::GetCurrent().Add(actor);
3557 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3558 RenderTask task = taskList.GetTask( 0u );
3560 // flush the queue and render once
3561 application.SendNotification();
3562 application.Render();
3563 application.SendNotification();
3564 application.Render();
3572 float screenX = 50.0f;
3573 float screenY = 50.0f;
3575 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, screenX, screenY) );
3577 DALI_TEST_CHECK( task.ViewportToLocal(actor, screenX, screenY, rtLocalX, rtLocalY ) );
3579 DALI_TEST_EQUALS(localX, rtLocalX, 0.01f, TEST_LOCATION);
3580 DALI_TEST_EQUALS(localY, rtLocalY, 0.01f, TEST_LOCATION);