2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali/public-api/dali-core.h>
22 #include <dali/devel-api/events/hit-test-algorithm.h>
23 #include <dali-test-suite-utils.h>
24 #include <dali/integration-api/debug.h>
25 #include <test-native-image.h>
27 #include <mesh-builder.h>
29 #define BOOLSTR(x) ((x)?"T":"F")
34 void utc_dali_render_task_startup(void)
36 test_return_value = TET_UNDEF;
39 void utc_dali_render_task_cleanup(void)
41 test_return_value = TET_PASS;
47 * Constructor, Destructor, DownCast, New, copy constructor, assignment operator
49 * SetSourceActor 2+ve, 1-ve
50 * GetSourceActor 1+ve, 1-ve
51 * SetExclusive 2+ve, 0-ve
52 * IsExclusive 2+ve, 0-ve
53 * SetInputEnabled 1+ve, 0-ve
54 * GetInputEnabled 1+ve, 0-ve
55 * SetCameraActor 1+ve, 1-ve
56 * GetCameraActor 1+ve, 1-ve
57 * SetTargetFrameBuffer 1+ve, 1-ve
58 * GetTargetFrameBuffer 1+ve, 1-ve
59 * SetScreenToFrameBufferFunction 1+ve, 1-ve
60 * GetScreenToFrameBufferFunction 1+ve, 1-ve
61 * SetScreenToFrameBufferMappingActor 1+ve, 1-ve
62 * GetScreenToFrameBufferMappingActor 1+ve, 1-ve
63 * SetViewportPosition 1+ve
64 * GetCurrentViewportPosition 1+ve
65 * SetViewportSize 1+ve
66 * GetCurrentViewportSize 1+ve
67 * SetViewport 2+ve, 1-ve
68 * GetViewport 2+ve, 1-ve
69 * SetClearColor 1+ve, 1-ve
70 * GetClearColor 1+ve, 1-ve
71 * SetClearEnabled 1+ve, 1-ve
72 * GetClearEnabled 1+ve, 1-ve
80 namespace // unnamed namespace
83 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
86 * Simulate time passed by.
88 * @note this will always process at least 1 frame (1/60 sec)
90 * @param application Test application instance
91 * @param duration Time to pass in milliseconds.
92 * @return The actual time passed in milliseconds
94 int Wait(TestApplication& application, int duration = 0)
98 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
100 application.SendNotification();
101 application.Render(RENDER_FRAME_INTERVAL);
102 time += RENDER_FRAME_INTERVAL;
108 struct RenderTaskFinished
110 RenderTaskFinished( bool& finished )
111 : finished( finished )
115 void operator()( RenderTask& renderTask )
123 struct RenderTaskFinishedRemoveSource
125 RenderTaskFinishedRemoveSource( bool& finished )
126 : finished( finished ),
131 void operator()( RenderTask& renderTask )
133 DALI_TEST_CHECK(finishedOnce == false);
136 Actor srcActor = renderTask.GetSourceActor();
137 UnparentAndReset(srcActor);
144 struct RenderTaskFinishedRenderAgain
146 RenderTaskFinishedRenderAgain( bool& finished )
147 : finished( finished ),
152 void operator()( RenderTask& renderTask )
154 DALI_TEST_CHECK(finishedOnce == false);
157 renderTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
165 bool TestScreenToFrameBufferFunction( Vector2& coordinates )
167 coordinates = coordinates + Vector2( 1, 2 );
172 ImageActor CreateLoadingImageActor(TestApplication& application, std::string filename, ResourceImage::LoadPolicy loadPolicy, Image::ReleasePolicy releasePolicy)
174 Image image = ResourceImage::New(filename, loadPolicy, releasePolicy);
175 DALI_TEST_CHECK( image );
176 application.SendNotification();
177 application.Render(16);
178 DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
179 ImageActor actor = ImageActor::New(image);
180 actor.SetSize( 80, 80 );
181 application.SendNotification();
182 application.Render(16);
186 Image CreateLoadingImage(TestApplication& application, std::string filename, ResourceImage::LoadPolicy loadPolicy, Image::ReleasePolicy releasePolicy)
188 Image image = ResourceImage::New(filename, loadPolicy, releasePolicy);
189 DALI_TEST_CHECK( image );
190 application.SendNotification();
191 application.Render(16);
192 DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
197 void CompleteImageLoad(TestApplication& application, Integration::ResourceId resourceId, Integration::ResourceTypeId requestType)
199 std::vector<GLuint> ids;
201 application.GetGlAbstraction().SetNextTextureIds( ids );
203 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
204 Integration::ResourcePointer resource(bitmap);
205 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80);
207 application.GetPlatform().SetResourceLoaded(resourceId, requestType, resource);
210 void FailImageLoad(TestApplication& application, Integration::ResourceId resourceId )
212 application.GetPlatform().SetResourceLoadFailed(resourceId, Integration::FailureUnknown);
215 void ReloadImage(TestApplication& application, ResourceImage image)
217 application.GetPlatform().ClearReadyResources();
218 application.GetPlatform().DiscardRequest();
219 application.GetPlatform().ResetTrace();
220 application.GetPlatform().SetClosestImageSize(Vector2(80.0f, 80.0f)); // Ensure reload is called.
224 RenderTask CreateRenderTask(TestApplication& application,
225 CameraActor offscreenCamera,
226 Actor rootActor, // Reset default render task to point at this actor
227 Actor secondRootActor, // Source actor
228 unsigned int refreshRate,
231 // Change main render task to use a different root
232 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
233 taskList.GetTask(0u).SetSourceActor( rootActor );
235 FrameBufferImage frameBufferImage;
238 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
239 frameBufferImage= FrameBufferImage::New( *(testNativeImagePtr.Get()) );
243 frameBufferImage = FrameBufferImage::New( 10, 10 );
246 // Don't draw output framebuffer // '
248 RenderTask newTask = taskList.CreateTask();
249 newTask.SetCameraActor( offscreenCamera );
250 newTask.SetSourceActor( secondRootActor );
251 newTask.SetInputEnabled( false );
252 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
253 newTask.SetClearEnabled( true );
254 newTask.SetExclusive( true );
255 newTask.SetRefreshRate( refreshRate );
256 newTask.SetTargetFrameBuffer( frameBufferImage );
260 bool UpdateRender(TestApplication& application, TraceCallStack& callStack, bool testDrawn, bool& finishedSig, bool testFinished, bool testKeepUpdating, int lineNumber )
264 application.Render(16);
265 application.SendNotification();
267 bool sigPassed = false;
270 sigPassed = finishedSig;
274 sigPassed = ! finishedSig;
277 bool drawResult = callStack.FindMethod("DrawElements") || callStack.FindMethod("DrawArrays");
279 bool drawPassed = false;
282 drawPassed = drawResult;
286 drawPassed = !drawResult;
289 bool keepUpdating = (application.GetUpdateStatus() != 0);
290 bool keepUpdatingPassed = false;
291 if( testKeepUpdating )
293 keepUpdatingPassed = keepUpdating;
297 keepUpdatingPassed = !keepUpdating;
300 bool result = (sigPassed && drawPassed && keepUpdatingPassed);
302 tet_printf("UpdateRender: Expected: Draw:%s Signal:%s KeepUpdating: %s Actual: Draw:%s Signal:%s KeepUpdating: %s %s, line %d\n",
303 BOOLSTR(testDrawn), BOOLSTR(testFinished), BOOLSTR(testKeepUpdating),
304 BOOLSTR(drawResult), BOOLSTR(finishedSig), BOOLSTR(keepUpdating),
305 result ? "Passed":"Failed",
311 // The functor to be used in the hit-test algorithm to check whether the actor is hittable.
312 bool IsActorHittableFunction(Actor actor, Dali::HitTestAlgorithm::TraverseType type)
314 bool hittable = false;
318 case Dali::HitTestAlgorithm::CHECK_ACTOR:
320 // Check whether the actor is visible and not fully transparent.
321 if( actor.IsVisible()
322 && actor.GetCurrentWorldColor().a > 0.01f) // not FULLY_TRANSPARENT
329 case Dali::HitTestAlgorithm::DESCEND_ACTOR_TREE:
331 if( actor.IsVisible() ) // Actor is visible, if not visible then none of its children are visible.
346 } // unnamed namespace
349 /****************************************************************************************************/
350 /****************************************************************************************************/
351 /******************************** TEST CASES BELOW **********************************************/
352 /****************************************************************************************************/
353 /****************************************************************************************************/
355 int UtcDaliRenderTaskDownCast01(void)
357 TestApplication application;
359 tet_infoline("Testing RenderTask::DownCast()");
361 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
363 BaseHandle base = taskList.GetTask( 0u );
364 DALI_TEST_CHECK( base );
366 RenderTask task = RenderTask::DownCast( base );
367 DALI_TEST_CHECK( task );
369 // Try calling a method
370 DALI_TEST_CHECK( task.GetSourceActor() );
374 int UtcDaliRenderTaskDownCast02(void)
376 TestApplication application;
378 tet_infoline("Testing RenderTask::DownCast()");
380 Actor actor = Actor::New();
382 RenderTask task = RenderTask::DownCast( actor );
383 DALI_TEST_CHECK( ! task );
388 int UtcDaliRenderTaskSetSourceActorN(void)
390 TestApplication application;
391 tet_infoline("Testing RenderTask::SetSourceActor() Negative - try with empty actor handle");
392 Stage stage = Stage::GetCurrent();
396 RenderTaskList taskList = stage.GetRenderTaskList();
397 RenderTask renderTask = taskList.CreateTask();
398 renderTask.SetSourceActor(srcActor);
400 application.SendNotification();
401 application.Render();
403 DALI_TEST_CHECK( ! renderTask.GetSourceActor() );
408 int UtcDaliRenderTaskSetSourceActorP01(void)
410 TestApplication application;
412 tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that setting a non-renderable actor stops existing source actor being rendered ");
414 Stage stage = Stage::GetCurrent();
416 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
418 RenderTaskList taskList = stage.GetRenderTaskList();
420 RenderTask task = taskList.GetTask( 0u );
422 Actor actor = task.GetSourceActor();
423 DALI_TEST_CHECK( actor );
425 std::vector<GLuint> ids;
427 application.GetGlAbstraction().SetNextTextureIds( ids );
429 BufferImage img = BufferImage::New( 1,1 );
430 ImageActor newActor = ImageActor::New( img );
431 newActor.SetSize(1,1);
432 stage.Add( newActor );
434 Actor nonRenderableActor = Actor::New();
435 stage.Add( nonRenderableActor );
437 // Stop the newActor from being rendered by changing the source actor
438 DALI_TEST_CHECK( nonRenderableActor );
439 task.SetSourceActor( nonRenderableActor );
440 DALI_TEST_CHECK( task.GetSourceActor() != actor );
441 DALI_TEST_CHECK( task.GetSourceActor() == nonRenderableActor );
443 // Update & Render nothing!
444 application.GetGlAbstraction().ClearBoundTextures();
445 application.SendNotification();
446 application.Render();
448 // Check that nothing was rendered
449 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
455 int UtcDaliRenderTaskSetSourceActorP02(void)
457 TestApplication application;
459 tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that switching source from a non-renderable to a renderable actor causes the texture to be drawn");
461 Stage stage = Stage::GetCurrent();
463 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
465 RenderTaskList taskList = stage.GetRenderTaskList();
467 RenderTask task = taskList.GetTask( 0u );
469 Actor actor = task.GetSourceActor();
470 DALI_TEST_CHECK( actor );
472 std::vector<GLuint> ids;
474 application.GetGlAbstraction().SetNextTextureIds( ids );
476 BufferImage img = BufferImage::New( 1,1 );
477 ImageActor newActor = ImageActor::New( img );
478 newActor.SetSize(1,1);
479 stage.Add( newActor );
481 Actor nonRenderableActor = Actor::New();
482 stage.Add( nonRenderableActor );
484 // Stop the newActor from being rendered by changing the source actor
485 DALI_TEST_CHECK( nonRenderableActor );
486 task.SetSourceActor( nonRenderableActor );
487 DALI_TEST_CHECK( task.GetSourceActor() != actor );
488 DALI_TEST_CHECK( task.GetSourceActor() == nonRenderableActor );
490 // Update & Render nothing!
491 application.GetGlAbstraction().ClearBoundTextures();
492 application.SendNotification();
493 application.Render();
495 // Check that nothing was rendered
496 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
498 // Set newActor as the new source Actor
499 task.SetSourceActor( newActor );
500 DALI_TEST_CHECK( task.GetSourceActor() != actor );
501 DALI_TEST_CHECK( task.GetSourceActor() == newActor );
503 // Update & Render the newActor
504 application.GetGlAbstraction().ClearBoundTextures();
505 application.SendNotification();
506 application.Render();
508 // Check that the newActor was rendered
509 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
510 if ( boundTextures.size() )
512 DALI_TEST_EQUALS( boundTextures[0], 7u, TEST_LOCATION );
517 int UtcDaliRenderTaskSetSourceActorOffStage(void)
519 TestApplication application;
521 tet_infoline("Testing RenderTask::SetSourceActor (on/off stage testing)");
523 Stage stage = Stage::GetCurrent();
525 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
527 RenderTaskList taskList = stage.GetRenderTaskList();
529 RenderTask task = taskList.GetTask( 0u );
531 Actor actor = task.GetSourceActor();
532 DALI_TEST_CHECK( actor );
534 std::vector<GLuint> ids;
535 GLuint expectedTextureId( 3 );
536 ids.push_back( expectedTextureId );
537 application.GetGlAbstraction().SetNextTextureIds( ids );
539 BufferImage img = BufferImage::New( 1,1 );
540 ImageActor newActor = ImageActor::New( img );
541 newActor.SetSize(1,1);
542 task.SetSourceActor( newActor );
543 // Don't add newActor to stage yet //'
545 // Update & Render with the actor initially off-stage
546 application.GetGlAbstraction().ClearBoundTextures();
547 application.SendNotification();
548 application.Render();
550 // Check that nothing was rendered
551 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
554 stage.Add( newActor );
556 // Update & Render with the actor on-stage
557 application.GetGlAbstraction().ClearBoundTextures();
558 application.SendNotification();
559 application.Render();
561 // Check that the newActor was rendered
562 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
563 if ( boundTextures.size() )
565 DALI_TEST_EQUALS( boundTextures[0], expectedTextureId, TEST_LOCATION );
568 // Now remove from stage
569 stage.Remove( newActor );
571 // Update & Render with the actor off-stage
572 application.GetGlAbstraction().ClearBoundTextures();
573 application.SendNotification();
574 application.Render();
578 int UtcDaliRenderTaskSetSourceActorEmpty(void)
580 TestApplication application;
582 tet_infoline("Testing RenderTask::SetSourceActor (empty handle case)");
584 Stage stage = Stage::GetCurrent();
586 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
588 RenderTaskList taskList = stage.GetRenderTaskList();
590 RenderTask task = taskList.GetTask( 0u );
592 Actor actor = task.GetSourceActor();
593 DALI_TEST_CHECK( actor );
595 std::vector<GLuint> ids;
596 GLuint expectedTextureId( 5 );
597 ids.push_back( expectedTextureId );
598 application.GetGlAbstraction().SetNextTextureIds( ids );
600 BufferImage img = BufferImage::New( 1,1 );
601 ImageActor newActor = ImageActor::New( img );
602 newActor.SetSize(1,1);
603 stage.Add( newActor );
605 Actor nonRenderableActor = Actor::New();
606 stage.Add( nonRenderableActor );
608 // Set with empty handle
609 task.SetSourceActor( Actor() );
610 DALI_TEST_CHECK( ! task.GetSourceActor() );
612 // Update & Render nothing!
613 application.GetGlAbstraction().ClearBoundTextures();
614 application.SendNotification();
615 application.Render();
617 // Check that nothing was rendered
618 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
620 // Set with non-empty handle
621 task.SetSourceActor( newActor );
622 DALI_TEST_CHECK( task.GetSourceActor() == newActor );
624 // Update & Render the newActor
625 application.GetGlAbstraction().ClearBoundTextures();
626 application.SendNotification();
627 application.Render();
629 // Check that the newActor was rendered
630 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
631 if ( boundTextures.size() )
633 DALI_TEST_EQUALS( boundTextures[0], expectedTextureId, TEST_LOCATION );
638 int UtcDaliRenderTaskGetSourceActorP01(void)
640 TestApplication application;
642 tet_infoline("Testing RenderTask::GetSourceActor() Check the default render task has a valid source actor");
644 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
646 RenderTask task = taskList.GetTask( 0u );
648 Actor actor = task.GetSourceActor();
649 DALI_TEST_CHECK( actor );
651 // By default the entire scene should be rendered
652 Actor root = Stage::GetCurrent().GetLayer( 0 );
653 DALI_TEST_CHECK( root == actor );
657 int UtcDaliRenderTaskGetSourceActorP02(void)
659 TestApplication application;
661 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.");
663 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
664 RenderTask task = taskList.CreateTask();
665 Actor actor = Actor::New();
666 Stage::GetCurrent().Add(actor);
667 task.SetSourceActor( actor );
669 DALI_TEST_EQUALS( actor, task.GetSourceActor(), TEST_LOCATION );
674 int UtcDaliRenderTaskGetSourceActorN(void)
676 TestApplication application;
678 tet_infoline("Testing RenderTask::GetSourceActor() Try with empty handle");
683 Actor actor = task.GetSourceActor();
685 catch (Dali::DaliException(e))
687 DALI_TEST_PRINT_ASSERT( e );
688 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
694 int UtcDaliRenderTaskSetExclusive(void)
696 TestApplication application;
698 tet_infoline("Testing RenderTask::SetExclusive() Check that exclusion works");
700 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
702 // Manipulate the GenTextures behaviour, to identify different ImageActors
704 std::vector<GLuint> ids;
705 ids.push_back( 8 ); // 8 = actor1
706 ids.push_back( 9 ); // 9 = actor2
707 ids.push_back( 10 ); // 10 = actor3
708 application.GetGlAbstraction().SetNextTextureIds( ids );
710 BufferImage img1 = BufferImage::New( 1,1 );
711 ImageActor actor1 = ImageActor::New( img1 );
713 Stage::GetCurrent().Add( actor1 );
715 // Update & Render actor1
716 application.SendNotification();
717 application.Render();
719 // Check that the actor1 was rendered
720 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
721 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
723 if ( boundTextures.size() )
725 DALI_TEST_EQUALS( boundTextures[0], 8u/*unique to actor1*/, TEST_LOCATION );
728 BufferImage img2 = BufferImage::New( 1,1 );
729 ImageActor actor2 = ImageActor::New( img2 );
732 // Force actor2 to be rendered before actor1
733 Layer layer = Layer::New();
734 Stage::GetCurrent().Add( layer );
736 layer.LowerToBottom();
739 application.GetGlAbstraction().ClearBoundTextures();
740 application.SendNotification();
741 application.Render();
743 // Check that the actors were rendered
744 DALI_TEST_EQUALS( boundTextures.size(), 2u, TEST_LOCATION );
746 if ( boundTextures.size() )
748 DALI_TEST_EQUALS( boundTextures[0], 9u/*unique to actor2*/, TEST_LOCATION );
749 DALI_TEST_EQUALS( boundTextures[1], 8u/*unique to actor1*/, TEST_LOCATION );
752 BufferImage img3 = BufferImage::New( 1,1 );
753 ImageActor actor3 = ImageActor::New( img3 );
756 // Force actor3 to be rendered before actor2
757 layer = Layer::New();
758 Stage::GetCurrent().Add( layer );
760 layer.LowerToBottom();
762 // Update & Render all actors
763 application.GetGlAbstraction().ClearBoundTextures();
764 application.SendNotification();
765 application.Render();
767 // Check that the actors were rendered
768 DALI_TEST_EQUALS( boundTextures.size(), 3u, TEST_LOCATION );
770 if ( boundTextures.size() )
772 DALI_TEST_EQUALS( boundTextures[0], 10u/*unique to actor3*/, TEST_LOCATION );
773 DALI_TEST_EQUALS( boundTextures[1], 9u/*unique to actor2*/, TEST_LOCATION );
774 DALI_TEST_EQUALS( boundTextures[2], 8u/*unique to actor1*/, TEST_LOCATION );
777 // Both actors are now connected to the root node
778 // Setup 2 render-tasks - the first will render from the root-node, and the second from actor2
780 // Not exclusive is the default
781 RenderTask task1 = taskList.GetTask( 0u );
782 DALI_TEST_CHECK( false == task1.IsExclusive() );
784 RenderTask task2 = taskList.CreateTask();
785 DALI_TEST_CHECK( false == task2.IsExclusive() );
786 task2.SetSourceActor( actor2 );
788 // Task1 should render all actors, and task 2 should render only actor2
790 application.GetGlAbstraction().ClearBoundTextures();
791 application.SendNotification();
792 application.Render();
794 DALI_TEST_EQUALS( boundTextures.size(), 4u, TEST_LOCATION );
796 if ( boundTextures.size() == 4 )
798 // Test that task 1 renders actor3, then actor2 & then actor1
799 DALI_TEST_CHECK( boundTextures[0] == 10u );
800 DALI_TEST_CHECK( boundTextures[1] == 9u );
801 DALI_TEST_CHECK( boundTextures[2] == 8u );
803 // Test that task 2 renders actor2
804 DALI_TEST_EQUALS( boundTextures[3], 9u, TEST_LOCATION );
807 // Make actor2 exclusive to task2
809 task2.SetExclusive( true );
810 DALI_TEST_CHECK( true == task2.IsExclusive() );
812 // Task1 should render only actor1, and task 2 should render only actor2
814 application.GetGlAbstraction().ClearBoundTextures();
815 application.SendNotification();
816 application.Render();
818 DALI_TEST_EQUALS( boundTextures.size(), 3u, TEST_LOCATION );
819 if ( boundTextures.size() == 3 )
821 // Test that task 1 renders actor3 & actor1
822 DALI_TEST_CHECK( boundTextures[0] == 10u );
823 DALI_TEST_CHECK( boundTextures[1] == 8u );
825 // Test that task 2 renders actor2
826 DALI_TEST_CHECK( boundTextures[2] == 9u );
831 int UtcDaliRenderTaskSetExclusive02(void)
833 TestApplication application;
835 tet_infoline("Testing RenderTask::SetExclusive() Check that changing from exclusive to not-exclusive works");
837 std::vector<GLuint> ids;
838 ids.push_back( 8 ); // 8 = actor1
839 application.GetGlAbstraction().SetNextTextureIds( ids );
841 BufferImage img1 = BufferImage::New( 1,1 );
842 ImageActor actor1 = ImageActor::New( img1 );
844 Stage::GetCurrent().Add( actor1 );
846 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
847 RenderTask task = taskList.CreateTask();
849 task.SetSourceActor( actor1 );
850 task.SetExclusive(true); // Actor should only render once
852 TestGlAbstraction& gl = application.GetGlAbstraction();
853 TraceCallStack& drawTrace = gl.GetDrawTrace();
854 drawTrace.Enable(true);
856 // Update & Render actor1
857 application.SendNotification();
858 application.Render();
860 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawArrays"), 1, TEST_LOCATION );
862 // Set task to non-exclusive - actor1 should render twice:
864 task.SetExclusive(false);
865 application.SendNotification();
866 application.Render();
868 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawArrays"), 2, TEST_LOCATION );
873 int UtcDaliRenderTaskSetExclusiveN(void)
875 TestApplication application;
877 tet_infoline("Testing RenderTask::SetExclusive() on empty handle");
882 task.SetExclusive(true);
884 catch (Dali::DaliException(e))
886 DALI_TEST_PRINT_ASSERT( e );
887 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
892 int UtcDaliRenderTaskIsExclusive01(void)
894 TestApplication application;
896 tet_infoline("Testing RenderTask::IsExclusive() Check default values are non-exclusive");
898 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
900 // Not exclusive is the default
901 RenderTask task = taskList.GetTask( 0u );
902 DALI_TEST_CHECK( false == task.IsExclusive() );
904 RenderTask newTask = taskList.CreateTask();
905 DALI_TEST_CHECK( false == newTask.IsExclusive() );
910 int UtcDaliRenderTaskIsExclusive02(void)
912 TestApplication application;
914 tet_infoline("Testing RenderTask::IsExclusive() Check the getter returns set values");
916 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
918 // Not exclusive is the default
919 RenderTask newTask = taskList.CreateTask();
920 DALI_TEST_EQUALS( newTask.IsExclusive(), false, TEST_LOCATION );
922 newTask.SetExclusive(true);
923 DALI_TEST_EQUALS( newTask.IsExclusive(), true, TEST_LOCATION );
927 int UtcDaliRenderTaskIsExclusiveN(void)
929 TestApplication application;
931 tet_infoline("Testing RenderTask::IsExclusive() on empty handle");
936 bool x = task.IsExclusive();
939 catch (Dali::DaliException(e))
941 DALI_TEST_PRINT_ASSERT( e );
942 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
947 int UtcDaliRenderTaskSetInputEnabled(void)
949 TestApplication application;
951 tet_infoline("Testing RenderTask::SetInputEnabled()");
953 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
955 // Input is enabled by default
956 RenderTask task = taskList.GetTask( 0u );
957 DALI_TEST_CHECK( true == task.GetInputEnabled() );
959 task.SetInputEnabled( false );
960 DALI_TEST_CHECK( false == task.GetInputEnabled() );
962 task.SetInputEnabled( true );
963 DALI_TEST_CHECK( true == task.GetInputEnabled() );
967 int UtcDaliRenderTaskGetInputEnabled(void)
969 TestApplication application;
971 tet_infoline("Testing RenderTask::GetInputEnabled()");
973 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
975 // Input is enabled by default
976 RenderTask task = taskList.GetTask( 0u );
977 DALI_TEST_EQUALS( true, task.GetInputEnabled(), TEST_LOCATION );
979 RenderTask newTask = taskList.CreateTask();
980 DALI_TEST_EQUALS( true, newTask.GetInputEnabled(), TEST_LOCATION );
982 newTask.SetInputEnabled(false);
983 DALI_TEST_EQUALS( false, newTask.GetInputEnabled(), TEST_LOCATION );
988 int UtcDaliRenderTaskSetCameraActorP(void)
990 TestApplication application;
992 tet_infoline("Testing RenderTask::SetCameraActor()");
994 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
996 RenderTask task = taskList.GetTask( 0u );
998 Actor defaultCameraActor = task.GetCameraActor();
999 DALI_TEST_CHECK( defaultCameraActor );
1001 CameraActor newCameraActor = CameraActor::New();
1002 DALI_TEST_CHECK( newCameraActor );
1004 task.SetCameraActor( newCameraActor );
1005 DALI_TEST_CHECK( task.GetCameraActor() != defaultCameraActor );
1006 DALI_TEST_EQUALS( task.GetCameraActor(), newCameraActor, TEST_LOCATION );
1011 int UtcDaliRenderTaskSetCameraActorN(void)
1013 TestApplication application;
1015 tet_infoline("Testing RenderTask::SetCameraActor() with empty actor handle");
1017 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1019 RenderTask task = taskList.GetTask( 0u );
1021 Actor actor = task.GetCameraActor();
1022 DALI_TEST_CHECK( actor );
1024 CameraActor cameraActor;
1026 task.SetCameraActor( cameraActor );
1027 DALI_TEST_EQUALS( (bool)task.GetCameraActor(), false, TEST_LOCATION );
1028 DALI_TEST_EQUALS( task.GetCameraActor(), cameraActor, TEST_LOCATION );
1033 int UtcDaliRenderTaskGetCameraActorP(void)
1035 TestApplication application;
1037 tet_infoline("Testing RenderTask::GetCameraActor()");
1039 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1041 RenderTask task = taskList.GetTask( 0u );
1043 CameraActor actor = task.GetCameraActor();
1044 DALI_TEST_CHECK( actor );
1045 DALI_TEST_EQUALS( actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION );
1046 DALI_TEST_GREATER( actor.GetFieldOfView(), 0.0f, TEST_LOCATION );
1050 int UtcDaliRenderTaskGetCameraActorN(void)
1052 TestApplication application;
1054 tet_infoline("Testing RenderTask::GetCameraActor() with empty handle");
1059 Actor actor = task.GetCameraActor();
1061 catch (Dali::DaliException(e))
1063 DALI_TEST_PRINT_ASSERT( e );
1064 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1070 int UtcDaliRenderTaskSetTargetFrameBufferP(void)
1072 TestApplication application;
1074 tet_infoline("Testing RenderTask::SetTargetFrameBuffer()");
1076 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1078 RenderTask task = taskList.GetTask( 0u );
1080 FrameBufferImage newImage = FrameBufferImage::New();
1081 task.SetTargetFrameBuffer( newImage );
1082 DALI_TEST_CHECK( task.GetTargetFrameBuffer() == newImage );
1086 int UtcDaliRenderTaskSetTargetFrameBufferN(void)
1088 TestApplication application;
1090 tet_infoline("Testing RenderTask::SetTargetFrameBuffer()");
1092 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1094 RenderTask task = taskList.GetTask( 0u );
1095 FrameBufferImage newImage; // Empty handle
1096 task.SetTargetFrameBuffer( newImage );
1097 DALI_TEST_EQUALS( (bool)task.GetTargetFrameBuffer(), false, TEST_LOCATION );
1101 int UtcDaliRenderTaskGetTargetFrameBufferP(void)
1103 TestApplication application;
1105 tet_infoline("Testing RenderTask::GetTargetFrameBuffer()");
1107 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1109 RenderTask newTask = taskList.CreateTask();
1110 FrameBufferImage fb = FrameBufferImage::New(128, 128, Pixel::RGBA8888);
1111 newTask.SetTargetFrameBuffer( fb );
1112 DALI_TEST_EQUALS( newTask.GetTargetFrameBuffer(), fb, TEST_LOCATION );
1116 int UtcDaliRenderTaskGetTargetFrameBufferN(void)
1118 TestApplication application;
1120 tet_infoline("Testing RenderTask::GetTargetFrameBuffer()");
1122 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1124 RenderTask task = taskList.GetTask( 0u );
1126 // By default render-tasks do not render off-screen
1127 FrameBufferImage image = task.GetTargetFrameBuffer();
1128 DALI_TEST_CHECK( !image );
1133 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionP(void)
1135 TestApplication application;
1137 tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1139 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1141 RenderTask task = taskList.GetTask( 0u );
1143 task.SetScreenToFrameBufferFunction( TestScreenToFrameBufferFunction );
1145 Vector2 coordinates( 5, 10 );
1146 Vector2 convertedCoordinates( 6, 12 ); // + Vector(1, 2)
1148 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1149 DALI_TEST_CHECK( func( coordinates ) );
1150 DALI_TEST_CHECK( coordinates == convertedCoordinates );
1152 task.SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
1153 func = task.GetScreenToFrameBufferFunction();
1154 DALI_TEST_CHECK( func( coordinates ) );
1156 task.SetScreenToFrameBufferFunction( RenderTask::DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION );
1157 func = task.GetScreenToFrameBufferFunction();
1158 DALI_TEST_CHECK( ! func( coordinates ) );
1162 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionN(void)
1164 TestApplication application;
1166 tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1168 RenderTask task; // Empty handle
1171 task.SetScreenToFrameBufferFunction( TestScreenToFrameBufferFunction );
1173 catch (Dali::DaliException(e))
1175 DALI_TEST_PRINT_ASSERT( e );
1176 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1181 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionP(void)
1183 TestApplication application;
1185 tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction()");
1187 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1189 RenderTask task = taskList.GetTask( 0u );
1191 Vector2 originalCoordinates( 5, 10 );
1192 Vector2 coordinates( 5, 10 );
1194 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1195 DALI_TEST_CHECK( !func( coordinates ) ); // conversion should fail by default
1196 DALI_TEST_CHECK( coordinates == originalCoordinates ); // coordinates should not be modified
1200 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionN(void)
1202 TestApplication application;
1204 tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction() on empty handle");
1209 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1212 catch (Dali::DaliException(e))
1214 DALI_TEST_PRINT_ASSERT( e );
1215 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1221 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorP(void)
1223 TestApplication application;
1224 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor ");
1226 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1227 RenderTask renderTask = taskList.CreateTask();
1228 Actor mappingActor = Actor::New();
1229 renderTask.SetScreenToFrameBufferMappingActor(mappingActor);
1231 DALI_TEST_EQUALS( mappingActor, renderTask.GetScreenToFrameBufferMappingActor(), TEST_LOCATION );
1236 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorN(void)
1238 TestApplication application;
1239 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1245 task.SetScreenToFrameBufferMappingActor(mappingActor);
1247 catch (Dali::DaliException(e))
1249 DALI_TEST_PRINT_ASSERT( e );
1250 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1255 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActor02N(void)
1257 TestApplication application;
1258 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1260 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1261 RenderTask renderTask = taskList.CreateTask();
1263 renderTask.SetScreenToFrameBufferMappingActor(actor);
1265 DALI_TEST_EQUALS( (bool)renderTask.GetScreenToFrameBufferMappingActor(), false, TEST_LOCATION);
1269 int UtcDaliRenderTaskGetViewportP01(void)
1271 TestApplication application;
1273 tet_infoline("Testing RenderTask::GetViewport() on default task");
1275 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1276 RenderTask task = taskList.GetTask( 0u );
1277 Viewport viewport = task.GetViewport();
1279 // By default the viewport should match the stage width/height
1280 Vector2 stageSize = Stage::GetCurrent().GetSize();
1281 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1282 DALI_TEST_CHECK( viewport == expectedViewport );
1286 int UtcDaliRenderTaskGetViewportP02(void)
1288 TestApplication application;
1290 tet_infoline("Testing RenderTask::GetViewport() on new task");
1292 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1293 RenderTask task = taskList.CreateTask();
1294 Viewport viewport = task.GetViewport();
1296 // By default the viewport should match the stage width/height
1297 Vector2 stageSize = Stage::GetCurrent().GetSize();
1298 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1299 DALI_TEST_CHECK( viewport == expectedViewport );
1303 int UtcDaliRenderTaskGetViewportN(void)
1305 TestApplication application;
1307 tet_infoline("Testing RenderTask::GetViewport() on empty handle");
1312 Viewport viewport = task.GetViewport();
1313 viewport = viewport;
1315 catch (Dali::DaliException(e))
1317 DALI_TEST_PRINT_ASSERT( e );
1318 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1324 int UtcDaliRenderTaskSetViewportP(void)
1326 TestApplication application;
1328 tet_infoline("Testing RenderTask::SetViewport()");
1330 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1332 RenderTask task = taskList.GetTask( 0u );
1333 Vector2 stageSize = Stage::GetCurrent().GetSize();
1334 Viewport newViewport( 0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f );
1335 task.SetViewport( newViewport );
1337 // Update (viewport is a property)
1338 application.SendNotification();
1339 application.Render();
1341 DALI_TEST_CHECK( task.GetViewport() == newViewport );
1345 int UtcDaliRenderTaskSetViewportN(void)
1347 TestApplication application;
1349 tet_infoline("Testing RenderTask::SetViewport()");
1351 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1356 Vector2 stageSize = Stage::GetCurrent().GetSize();
1357 Viewport newViewport( 0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f );
1358 task.SetViewport( newViewport );
1360 catch (Dali::DaliException(e))
1362 DALI_TEST_PRINT_ASSERT( e );
1363 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1370 int UtcDaliRenderTaskSetViewportPosition(void)
1372 TestApplication application;
1374 tet_infoline("Testing RenderTask::SetViewportPosition()");
1376 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1378 RenderTask task = taskList.GetTask( 0u );
1380 Viewport viewport = task.GetViewport();
1382 // By default the viewport should match the stage width/height
1384 Vector2 stageSize = Stage::GetCurrent().GetSize();
1385 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1386 DALI_TEST_CHECK( viewport == expectedViewport );
1389 Vector2 newPosition(25.0f, 50.0f);
1390 task.SetViewportPosition( newPosition );
1392 // Update (viewport is a property)
1393 application.SendNotification();
1394 application.Render();
1396 DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1398 // Set by Property test
1399 Vector2 newPosition2(32.0f, 32.0f);
1400 task.SetProperty( RenderTask::Property::VIEWPORT_POSITION, newPosition2 );
1403 application.SendNotification();
1404 application.Render();
1406 DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition2, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1408 Vector2 newPosition3(64.0f, 0.0f);
1409 Animation animation = Animation::New(1.0f);
1410 animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_POSITION ), newPosition3, AlphaFunction::LINEAR );
1413 // Perform 1000ms worth of updates at which point animation should have completed.
1414 Wait(application, 1000);
1415 DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1419 int UtcDaliRenderTaskSetViewportSize(void)
1421 TestApplication application;
1423 tet_infoline("Testing RenderTask::SetViewportSize()");
1425 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1427 RenderTask task = taskList.GetTask( 0u );
1429 Viewport viewport = task.GetViewport();
1431 // By default the viewport should match the stage width/height
1433 Vector2 stageSize = Stage::GetCurrent().GetSize();
1434 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1435 DALI_TEST_CHECK( viewport == expectedViewport );
1437 Vector2 newSize(128.0f, 64.0f);
1438 task.SetViewportSize( newSize );
1440 // Update (viewport is a property)
1441 application.SendNotification();
1442 application.Render();
1444 DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1446 // Set by Property test
1447 Vector2 newSize2(50.0f, 50.0f);
1448 task.SetProperty( RenderTask::Property::VIEWPORT_SIZE, newSize2 );
1451 application.SendNotification();
1452 application.Render();
1454 DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize2, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1456 Vector2 newSize3(10.0f, 10.0f);
1457 Animation animation = Animation::New(1.0f);
1458 animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_SIZE ), newSize3, AlphaFunction::LINEAR );
1461 // Perform 1000ms worth of updates at which point animation should have completed.
1462 Wait(application, 1000);
1463 DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1468 int UtcDaliRenderTaskSetClearColorP(void)
1470 TestApplication application;
1472 tet_infoline("Testing RenderTask::SetClearColor()");
1474 Vector4 testColor( 1.0f, 2.0f, 3.0f, 4.0f );
1475 Vector4 testColor2( 5.0f, 6.0f, 7.0f, 8.0f );
1477 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1479 RenderTask task = taskList.GetTask( 0u );
1480 DALI_TEST_CHECK( task.GetClearColor() != testColor );
1482 task.SetClearColor( testColor );
1487 DALI_TEST_EQUALS( task.GetClearColor(), testColor, TEST_LOCATION );
1489 task.SetProperty( RenderTask::Property::CLEAR_COLOR, testColor2 );
1494 DALI_TEST_EQUALS( task.GetClearColor(), testColor2, TEST_LOCATION );
1498 int UtcDaliRenderTaskSetClearColorN(void)
1500 TestApplication application;
1502 tet_infoline("Testing RenderTask::SetClearColor() on empty handle");
1507 task.SetClearColor( Vector4::ZERO );
1509 catch (Dali::DaliException(e))
1511 DALI_TEST_PRINT_ASSERT( e );
1512 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1517 int UtcDaliRenderTaskGetClearColorP(void)
1519 TestApplication application;
1521 tet_infoline("Testing RenderTask::GetClearColor()");
1523 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1524 RenderTask task = taskList.GetTask( 0u );
1525 DALI_TEST_EQUALS( task.GetClearColor(), RenderTask::DEFAULT_CLEAR_COLOR, TEST_LOCATION );
1529 int UtcDaliRenderTaskGetClearColorN(void)
1531 TestApplication application;
1533 tet_infoline("Testing RenderTask::GetClearColor()");
1538 Vector4 color = task.GetClearColor();
1541 catch (Dali::DaliException(e))
1543 DALI_TEST_PRINT_ASSERT( e );
1544 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1549 int UtcDaliRenderTaskSetClearEnabledP(void)
1551 TestApplication application;
1553 tet_infoline("Testing RenderTask::SetClearEnabled()");
1555 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1557 RenderTask task = taskList.GetTask( 0u );
1558 DALI_TEST_CHECK( !task.GetClearEnabled() ); // defaults to false
1560 task.SetClearEnabled( true );
1561 DALI_TEST_EQUALS( task.GetClearEnabled(), true, TEST_LOCATION );
1563 task.SetClearEnabled( false );
1564 DALI_TEST_EQUALS( task.GetClearEnabled(), false, TEST_LOCATION );
1568 int UtcDaliRenderTaskSetClearEnabledN(void)
1570 TestApplication application;
1572 tet_infoline("Testing RenderTask::SetClearEnabled() with empty handle");
1577 task.SetClearEnabled(true);
1579 catch (Dali::DaliException(e))
1581 DALI_TEST_PRINT_ASSERT( e );
1582 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1587 int UtcDaliRenderTaskGetClearEnabledP(void)
1589 TestApplication application;
1591 tet_infoline("Testing RenderTask::GetClearEnabled()");
1593 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1595 RenderTask task = taskList.GetTask( 0u );
1596 DALI_TEST_CHECK( !task.GetClearEnabled() ); // defaults to false
1601 int UtcDaliRenderTaskGetClearEnabledN(void)
1603 TestApplication application;
1605 tet_infoline("Testing RenderTask::GetClearEnabled() with empty handle");
1610 bool x = task.GetClearEnabled();
1613 catch (Dali::DaliException(e))
1615 DALI_TEST_PRINT_ASSERT( e );
1616 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1621 int UtcDaliRenderTaskSetCullModeP(void)
1623 TestApplication application;
1625 tet_infoline("Testing RenderTask::SetCullMode()");
1627 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1628 RenderTask task = taskList.GetTask( 0u );
1629 DALI_TEST_EQUALS( task.GetCullMode(), true, TEST_LOCATION );
1631 task.SetCullMode( false );
1633 DALI_TEST_EQUALS( task.GetCullMode(), false, TEST_LOCATION );
1638 int UtcDaliRenderTaskSetCullModeN(void)
1640 TestApplication application;
1642 tet_infoline("Testing RenderTask::SetCullMode() on empty handle");
1647 task.SetCullMode( false );
1649 catch (Dali::DaliException(e))
1651 DALI_TEST_PRINT_ASSERT( e );
1652 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1657 int UtcDaliRenderTaskGetCullModeP(void)
1659 TestApplication application;
1661 tet_infoline("Testing RenderTask::GetCullMode()");
1663 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1664 RenderTask task = taskList.GetTask( 0u );
1665 DALI_TEST_EQUALS( task.GetCullMode(), true, TEST_LOCATION );
1669 int UtcDaliRenderTaskGetCullModeN(void)
1671 TestApplication application;
1673 tet_infoline("Testing RenderTask::GetCullMode() with empty handle");
1678 bool x = task.GetCullMode();
1681 catch (Dali::DaliException(e))
1683 DALI_TEST_PRINT_ASSERT( e );
1684 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1690 int UtcDaliRenderTaskSetRefreshRate(void)
1692 TestApplication application;
1694 tet_infoline("Testing RenderTask::SetRefreshRate()");
1696 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1698 // By default tasks will be processed every frame
1699 RenderTask task = taskList.GetTask( 0u );
1700 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1702 task.SetRefreshRate( 2u ); // every-other frame
1703 DALI_TEST_CHECK( 2u == task.GetRefreshRate() );
1705 task.SetRefreshRate( RenderTask::REFRESH_ALWAYS );
1706 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1710 int UtcDaliRenderTaskGetRefreshRate(void)
1712 TestApplication application;
1714 tet_infoline("Testing RenderTask::GetRefreshRate()");
1716 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1718 // By default tasks will be processed every frame
1719 RenderTask task = taskList.GetTask( 0u );
1720 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1722 RenderTask newTask = taskList.CreateTask();
1723 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == newTask.GetRefreshRate() );
1727 int UtcDaliRenderTaskSignalFinished(void)
1729 TestApplication application;
1731 tet_infoline("Testing RenderTask::SignalFinished()");
1733 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1734 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
1736 CameraActor offscreenCameraActor = CameraActor::New();
1738 Stage::GetCurrent().Add( offscreenCameraActor );
1740 BufferImage image = BufferImage::New( 10, 10 );
1742 ImageActor rootActor = ImageActor::New( image );
1743 rootActor.SetSize( 10, 10 );
1744 Stage::GetCurrent().Add( rootActor );
1746 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1747 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
1748 FrameBufferImage frameBufferImage = FrameBufferImage::New( *testNativeImagePtr.Get() );
1750 RenderTask newTask = taskList.CreateTask();
1751 newTask.SetCameraActor( offscreenCameraActor );
1752 newTask.SetSourceActor( rootActor );
1753 newTask.SetInputEnabled( false );
1754 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
1755 newTask.SetClearEnabled( true );
1756 newTask.SetExclusive( true );
1757 newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
1758 newTask.SetTargetFrameBuffer( frameBufferImage );
1760 bool finished = false;
1761 RenderTaskFinished renderTaskFinished( finished );
1762 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1764 // Flush the queue and render.
1765 application.SendNotification();
1767 // 1 render to process render task, then wait for sync before finished msg is sent
1768 // from update to the event thread.
1770 application.Render();
1771 application.SendNotification();
1772 DALI_TEST_CHECK( !finished );
1774 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
1775 DALI_TEST_CHECK( lastSyncObj != NULL );
1777 application.Render();
1778 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
1779 application.SendNotification();
1780 DALI_TEST_CHECK( !finished );
1782 application.Render();
1783 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
1784 application.SendNotification();
1785 DALI_TEST_CHECK( ! finished );
1787 sync.SetObjectSynced( lastSyncObj, true );
1789 application.Render();
1790 application.SendNotification();
1791 DALI_TEST_CHECK( !finished );
1793 application.Render();
1794 application.SendNotification();
1795 DALI_TEST_CHECK( finished );
1798 application.Render(); // Double check no more finished signal
1799 application.SendNotification();
1800 DALI_TEST_CHECK( ! finished );
1805 int UtcDaliRenderTaskContinuous01(void)
1807 TestApplication application;
1809 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not staged)\nPOST:continuous renders, no Finished signal");
1811 // SETUP AN OFFSCREEN RENDER TASK
1812 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1813 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1814 drawTrace.Enable(true);
1816 Actor rootActor = Actor::New();
1817 Stage::GetCurrent().Add( rootActor );
1819 CameraActor offscreenCameraActor = CameraActor::New();
1820 Stage::GetCurrent().Add( offscreenCameraActor );
1822 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1823 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1824 Integration::ResourceId imageRequestId = imageRequest->GetId();
1825 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1827 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1828 bool finished = false;
1829 RenderTaskFinished renderTaskFinished( finished );
1830 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1831 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1832 application.SendNotification();
1834 // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating
1835 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false, __LINE__ ) );
1836 application.GetPlatform().ClearReadyResources();
1838 // ADD SOURCE ACTOR TO STAGE - expect continuous renders to start, no finished signal
1839 Stage::GetCurrent().Add(secondRootActor);
1840 application.SendNotification();
1842 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1843 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
1848 int UtcDaliRenderTaskContinuous02(void)
1850 TestApplication application;
1852 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not visible)\nPOST:continuous renders, no Finished signal");
1854 // SETUP AN OFFSCREEN RENDER TASK
1855 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1856 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1857 drawTrace.Enable(true);
1859 Actor rootActor = Actor::New();
1860 Stage::GetCurrent().Add( rootActor );
1862 CameraActor offscreenCameraActor = CameraActor::New();
1863 Stage::GetCurrent().Add( offscreenCameraActor );
1865 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1866 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1867 Integration::ResourceId imageRequestId = imageRequest->GetId();
1868 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1869 Stage::GetCurrent().Add(secondRootActor);
1870 secondRootActor.SetVisible(false);
1872 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1873 bool finished = false;
1874 RenderTaskFinished renderTaskFinished( finished );
1875 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1876 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1877 application.SendNotification();
1879 // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating
1880 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false, __LINE__ ) );
1881 application.GetPlatform().ClearReadyResources();
1883 // MAKE SOURCE ACTOR VISIBLE - expect continuous renders to start, no finished signal
1884 secondRootActor.SetVisible(true);
1885 application.SendNotification();
1887 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1888 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
1892 int UtcDaliRenderTaskContinuous03(void)
1894 TestApplication application;
1896 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (camera actor not staged)\nPOST:continuous renders, no Finished signal");
1898 // SETUP AN OFFSCREEN RENDER TASK
1899 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1900 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1901 drawTrace.Enable(true);
1903 Actor rootActor = Actor::New();
1904 Stage::GetCurrent().Add( rootActor );
1906 CameraActor offscreenCameraActor = CameraActor::New();
1907 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1908 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1909 Integration::ResourceId imageRequestId = imageRequest->GetId();
1910 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1911 Stage::GetCurrent().Add(secondRootActor);
1913 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1914 bool finished = false;
1915 RenderTaskFinished renderTaskFinished( finished );
1916 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1917 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1918 application.SendNotification();
1920 // START PROCESS/RENDER Input, Expected Input, Expected
1921 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false, __LINE__ ) );
1922 application.GetPlatform().ClearReadyResources();
1924 // ADD CAMERA ACTOR TO STAGE - expect continuous renders to start, no finished signal
1925 Stage::GetCurrent().Add( offscreenCameraActor );
1926 application.SendNotification();
1928 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1929 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
1934 int UtcDaliRenderTaskContinuous04(void)
1936 TestApplication application;
1938 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: Resource not ready\nPOST:continuous renders, no Finished signal");
1940 // SETUP AN OFFSCREEN RENDER TASK
1941 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1942 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1943 drawTrace.Enable(true);
1945 Actor rootActor = Actor::New();
1946 Stage::GetCurrent().Add( rootActor );
1948 CameraActor offscreenCameraActor = CameraActor::New();
1949 Stage::GetCurrent().Add( offscreenCameraActor );
1950 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1951 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1952 Integration::ResourceId imageRequestId = imageRequest->GetId();
1953 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1954 Stage::GetCurrent().Add(secondRootActor);
1956 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1957 bool finished = false;
1958 RenderTaskFinished renderTaskFinished( finished );
1959 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1960 application.SendNotification();
1962 // START PROCESS/RENDER Input, Expected Input, Expected
1963 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
1964 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
1966 // FINISH RESOURCE LOADING - expect 'continuous' renders to start, no finished signal
1967 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1968 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
1972 int UtcDaliRenderTaskContinous05(void)
1974 TestApplication application;
1976 tet_infoline("Testing RenderTask Render Continuous using Mesh which accesses texture through sampler with loading image\n"
1977 "PRE: Resource not ready\nPOST:continuous renders, no Finished signal");
1979 // SETUP AN OFFSCREEN RENDER TASK
1980 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1981 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1982 drawTrace.Enable(true);
1984 Actor rootActor = Actor::New();
1985 Stage::GetCurrent().Add( rootActor );
1987 CameraActor offscreenCameraActor = CameraActor::New();
1988 Stage::GetCurrent().Add( offscreenCameraActor );
1990 Material material = CreateMaterial();
1991 Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1992 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1993 Integration::ResourceId imageRequestId = imageRequest->GetId();
1994 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1995 material.AddTexture( image, "sTexture" );
1997 Geometry geometry = CreateQuadGeometry();
1998 Renderer renderer = Renderer::New(geometry, material);
1999 Actor secondRootActor = Actor::New();
2000 secondRootActor.AddRenderer(renderer);
2001 secondRootActor.SetSize(100, 100);
2002 Stage::GetCurrent().Add(secondRootActor);
2004 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2005 bool finished = false;
2006 RenderTaskFinished renderTaskFinished( finished );
2007 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2008 application.SendNotification();
2010 // START PROCESS/RENDER Input, Expected Input, Expected
2011 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2012 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2014 // FINISH RESOURCE LOADING - expect 'continuous' renders to start, no finished signal
2015 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2016 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2022 int UtcDaliRenderTaskOnce01(void)
2024 TestApplication application;
2026 tet_infoline("Testing RenderTask Render Once GlSync, using loading image\nPRE: Resources not ready, Source not visible\nPOST: Finished signal sent once only");
2028 // SETUP AN OFFSCREEN RENDER TASK
2029 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2030 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2031 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2032 drawTrace.Enable(true);
2034 Actor rootActor = Actor::New();
2035 Stage::GetCurrent().Add( rootActor );
2037 CameraActor offscreenCameraActor = CameraActor::New();
2038 Stage::GetCurrent().Add( offscreenCameraActor );
2039 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2040 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2041 Integration::ResourceId imageRequestId = imageRequest->GetId();
2042 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2044 Stage::GetCurrent().Add(secondRootActor);
2046 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
2047 bool finished = false;
2048 RenderTaskFinished renderTaskFinished( finished );
2049 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2050 application.SendNotification();
2052 // START PROCESS/RENDER Input, Expected Input, Expected
2053 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2054 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2056 // MAKE SOURCE VISIBLE
2057 secondRootActor.SetVisible(true);
2058 application.SendNotification();
2059 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2060 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2062 // FINISH RESOURCE LOADING - expect no rendering yet
2063 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2064 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2065 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2066 DALI_TEST_CHECK( lastSyncObj != NULL );
2068 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2069 application.GetPlatform().ClearReadyResources();
2070 sync.SetObjectSynced( lastSyncObj, true );
2071 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2072 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2076 int UtcDaliRenderTaskOnce02(void)
2078 TestApplication application;
2080 tet_infoline("Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loading image.\n"
2081 "PRE: Resources not ready\nPOST: Finished signal sent once only");
2083 // SETUP AN OFFSCREEN RENDER TASK
2084 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2085 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2086 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2087 drawTrace.Enable(true);
2089 Actor rootActor = Actor::New();
2090 Stage::GetCurrent().Add( rootActor );
2092 CameraActor offscreenCameraActor = CameraActor::New();
2093 Stage::GetCurrent().Add( offscreenCameraActor );
2095 Material material = CreateMaterial();
2096 Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2097 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2098 Integration::ResourceId imageRequestId = imageRequest->GetId();
2099 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2100 material.AddTexture( image, "sTexture" );
2102 Geometry geometry = CreateQuadGeometry();
2103 Renderer renderer = Renderer::New(geometry, material);
2104 Actor secondRootActor = Actor::New();
2105 secondRootActor.AddRenderer(renderer);
2106 secondRootActor.SetSize(100, 100);
2107 Stage::GetCurrent().Add(secondRootActor);
2109 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
2110 bool finished = false;
2111 RenderTaskFinished renderTaskFinished( finished );
2112 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2113 application.SendNotification();
2115 // START PROCESS/RENDER Input, Expected Input, Expected
2116 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2117 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2119 // FINISH RESOURCE LOADING - expect no rendering yet
2120 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2121 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2122 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2123 DALI_TEST_CHECK( lastSyncObj != NULL );
2125 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2126 application.GetPlatform().ClearReadyResources();
2127 sync.SetObjectSynced( lastSyncObj, true );
2128 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2129 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2134 int UtcDaliRenderTaskOnce03(void)
2136 TestApplication application;
2138 tet_infoline("Testing RenderTask Render Once GlSync, using loading image. Switch from render always after ready to render once\n"
2139 "PRE: Render task ready, Image not loaded\n"
2140 "POST: Finished signal sent only once");
2142 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2143 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2144 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2145 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2146 drawTrace.Enable(true);
2148 Actor rootActor = Actor::New();
2149 Stage::GetCurrent().Add( rootActor );
2151 CameraActor offscreenCameraActor = CameraActor::New();
2152 Stage::GetCurrent().Add( offscreenCameraActor );
2153 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2154 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2155 Integration::ResourceId imageRequestId = imageRequest->GetId();
2156 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2157 Stage::GetCurrent().Add(secondRootActor);
2159 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2160 bool finished = false;
2161 RenderTaskFinished renderTaskFinished( finished );
2162 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2163 application.SendNotification();
2165 // START PROCESS/RENDER Input, Expected Input, Expected
2166 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2167 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2169 // FINISH RESOURCE LOADING
2170 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2171 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2172 application.GetPlatform().ClearReadyResources();
2173 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2175 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2176 application.SendNotification(); // Input, Expected Input, Expected
2177 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2178 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2179 DALI_TEST_CHECK( lastSyncObj != NULL );
2181 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2182 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2183 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2184 sync.SetObjectSynced( lastSyncObj, true );
2185 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2186 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2192 int UtcDaliRenderTaskOnce04(void)
2194 TestApplication application;
2195 tet_infoline("Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loading image.\n"
2196 "Switch from render always after ready to render once\n"
2197 "PRE: Render task ready, Image not loaded\n"
2198 "POST: Finished signal sent only once");
2200 // SETUP AN OFFSCREEN RENDER TASK
2201 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2202 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2203 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2204 drawTrace.Enable(true);
2206 Actor rootActor = Actor::New();
2207 Stage::GetCurrent().Add( rootActor );
2209 CameraActor offscreenCameraActor = CameraActor::New();
2210 Stage::GetCurrent().Add( offscreenCameraActor );
2212 Material material = CreateMaterial();
2213 Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2214 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2215 Integration::ResourceId imageRequestId = imageRequest->GetId();
2216 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2217 material.AddTexture( image, "sTexture" );
2219 Geometry geometry = CreateQuadGeometry();
2220 Renderer renderer = Renderer::New(geometry, material);
2221 Actor secondRootActor = Actor::New();
2222 secondRootActor.AddRenderer(renderer);
2223 secondRootActor.SetSize(100, 100);
2224 Stage::GetCurrent().Add(secondRootActor);
2226 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2227 bool finished = false;
2228 RenderTaskFinished renderTaskFinished( finished );
2229 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2230 application.SendNotification();
2232 // START PROCESS/RENDER Input, Expected Input, Expected
2233 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2234 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2236 // FINISH RESOURCE LOADING
2237 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2238 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2239 application.GetPlatform().ClearReadyResources();
2240 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2242 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2243 application.SendNotification(); // Input, Expected Input, Expected
2244 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2245 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2246 DALI_TEST_CHECK( lastSyncObj != NULL );
2248 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2249 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2250 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2251 sync.SetObjectSynced( lastSyncObj, true );
2252 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2253 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2258 int UtcDaliRenderTaskOnce05(void)
2260 TestApplication application;
2262 tet_infoline("Testing RenderTask Render Once GlSync\n"
2263 "Switch from Render always after ready to render once with resources unready\n"
2264 "PRE: Everything ready to render\n"
2265 "POST: Finished signal sent once");
2267 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2268 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2269 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2270 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2271 drawTrace.Enable(true);
2273 Actor rootActor = Actor::New();
2274 Stage::GetCurrent().Add( rootActor );
2276 CameraActor offscreenCameraActor = CameraActor::New();
2277 Stage::GetCurrent().Add( offscreenCameraActor );
2278 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2279 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2280 Integration::ResourceId imageRequestId = imageRequest->GetId();
2281 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2282 Stage::GetCurrent().Add(secondRootActor);
2284 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2285 bool finished = false;
2286 RenderTaskFinished renderTaskFinished( finished );
2287 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2288 application.SendNotification();
2290 // START PROCESS/RENDER Input, Expected Input, Expected
2291 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2292 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2294 // CHANGE TO RENDER ONCE
2295 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2296 application.SendNotification(); // Input, Expected Input, Expected
2297 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2298 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2300 // FINISH RESOURCE LOADING
2301 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2302 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2303 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2304 DALI_TEST_CHECK( lastSyncObj != NULL );
2305 application.GetPlatform().ClearReadyResources();
2307 sync.SetObjectSynced( lastSyncObj, true );
2309 // Expect: No draw - we've just drawn our render task once, above. No finished signal -
2310 // we won't read the gl sync until the next frame. Continue rendering - we're waiting for
2312 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2314 // Expect: 1 final draw - this Update doesn't update the scene, hence render instructions
2315 // from last frame but 1 are still present.
2316 // Finished signal should be true - we've just done the sync.
2317 // Should now stop rendering and updating - nothing left to do.
2318 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, true, false, __LINE__ ) );
2324 //int UtcDaliRenderTaskOnce06(void)
2326 TestApplication application;
2328 tet_infoline("Testing RenderTask Render Once GlSync\n"
2329 "During RenderOnce, make ready resources unready before sending first finished signal\n"
2330 "PRE: Everything ready.\n"
2331 "POST: Finished signal sent only once");
2333 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2334 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2335 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2336 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2337 drawTrace.Enable(true);
2339 Actor rootActor = Actor::New();
2340 Stage::GetCurrent().Add( rootActor );
2342 CameraActor offscreenCameraActor = CameraActor::New();
2343 Stage::GetCurrent().Add( offscreenCameraActor );
2344 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2345 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2346 Integration::ResourceId imageRequestId = imageRequest->GetId();
2347 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2348 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2349 application.Render();
2351 Stage::GetCurrent().Add(secondRootActor);
2352 application.GetPlatform().ClearReadyResources();
2354 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2355 bool finished = false;
2356 RenderTaskFinished renderTaskFinished( finished );
2357 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2358 application.SendNotification();
2360 // START PROCESS/RENDER Input, Expected Input, Expected
2361 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2362 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2364 // CHANGE TO RENDER ONCE, RESOURCES BECOME NOT READY
2365 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2368 ReloadImage(application, secondRootActor.GetImage());
2369 application.SendNotification(); // Input, Expected Input, Expected
2371 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2372 DALI_TEST_EQUALS( secondRootActor.GetImage().GetLoadingState(), Dali::ResourceLoading, TEST_LOCATION);
2373 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2375 // FINISH RESOURCE LOADING
2376 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2377 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2378 application.GetPlatform().ClearReadyResources();
2379 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2380 DALI_TEST_CHECK( lastSyncObj != NULL );
2382 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2383 sync.SetObjectSynced( lastSyncObj, true );
2384 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2385 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, true, __LINE__ ) );
2387 // Finished rendering - expect no more renders, no more signals:
2388 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2389 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2390 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2391 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2392 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2393 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2398 int UtcDaliRenderTaskOnce07(void)
2400 TestApplication application;
2402 tet_infoline("Testing RenderTask Render Once GLSync\n"
2403 "Render once, Second call to SetRefreshRate(ONCE) triggers only one more finished signal\n"
2404 "PRE: Everything ready\n"
2405 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
2407 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2408 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2409 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2410 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2411 drawTrace.Enable(true);
2413 Actor rootActor = Actor::New();
2414 Stage::GetCurrent().Add( rootActor );
2416 CameraActor offscreenCameraActor = CameraActor::New();
2417 Stage::GetCurrent().Add( offscreenCameraActor );
2418 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2419 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2420 Integration::ResourceId imageRequestId = imageRequest->GetId();
2421 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2422 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2423 application.Render();
2424 application.GetPlatform().ClearReadyResources();
2426 Stage::GetCurrent().Add(secondRootActor);
2428 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2429 bool finished = false;
2430 RenderTaskFinished renderTaskFinished( finished );
2431 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2432 application.SendNotification();
2434 // START PROCESS/RENDER Input, Expected Input, Expected
2435 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2437 // CHANGE TO RENDER ONCE,
2438 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2439 application.SendNotification();
2440 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2441 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2442 DALI_TEST_CHECK( lastSyncObj != NULL );
2444 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2445 sync.SetObjectSynced( lastSyncObj, true );
2446 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2447 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2449 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2450 application.SendNotification();
2451 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2452 lastSyncObj = sync.GetLastSyncObject();
2453 DALI_TEST_CHECK( lastSyncObj != NULL );
2455 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2456 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2457 sync.SetObjectSynced( lastSyncObj, true );
2458 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2459 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2463 int UtcDaliRenderTaskOnce08(void)
2465 TestApplication application;
2467 tet_infoline("Testing RenderTask Render Once GLSync\n"
2468 "Render once, Call to SetRefreshRate(ONCE) in Finished signal callback triggers "
2469 "another render & another finished signal\n"
2470 "PRE: Everything ready\n"
2471 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
2474 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2475 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2476 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2477 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2478 drawTrace.Enable(true);
2480 Actor rootActor = Actor::New();
2481 Stage::GetCurrent().Add( rootActor );
2483 CameraActor offscreenCameraActor = CameraActor::New();
2484 Stage::GetCurrent().Add( offscreenCameraActor );
2485 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2486 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2487 Integration::ResourceId imageRequestId = imageRequest->GetId();
2488 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2489 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2490 application.Render();
2491 application.GetPlatform().ClearReadyResources();
2493 Stage::GetCurrent().Add(secondRootActor);
2495 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2496 bool finished = false;
2498 ConnectionTracker connectionTracker;
2499 RenderTaskFinishedRenderAgain renderTaskFinishedRenderAgain( finished );
2500 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinishedRenderAgain );
2502 application.SendNotification();
2504 // START PROCESS/RENDER Input, Expected Input, Expected
2505 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2506 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2508 // CHANGE TO RENDER ONCE,
2509 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2510 application.SendNotification();
2511 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2512 lastSyncObj = sync.GetLastSyncObject();
2513 DALI_TEST_CHECK( lastSyncObj != NULL );
2515 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2516 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2518 sync.SetObjectSynced( lastSyncObj, true );
2519 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2520 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2521 application.SendNotification();
2523 // Expect SetRefreshRate to have been called again
2524 // Prevent next finished signal calling refresh once again
2525 RenderTaskFinished renderTaskFinished( finished );
2526 connectionTracker.DisconnectAll();
2527 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinished );
2528 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2529 lastSyncObj = sync.GetLastSyncObject();
2530 DALI_TEST_CHECK( lastSyncObj != NULL );
2532 sync.SetObjectSynced( lastSyncObj, true );
2533 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2534 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2539 int UtcDaliRenderTaskOnce09(void)
2541 TestApplication application;
2543 tet_infoline("Testing RenderTask Render Once GlSync\n"
2544 "SetRefreshRate(ONCE) again before first finished signal has been sent.\n"
2545 "PRE: resources ready\n"
2546 "POST: Only 1 finished signal sent.");
2548 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2549 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2550 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2551 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2552 drawTrace.Enable(true);
2554 Actor rootActor = Actor::New();
2555 Stage::GetCurrent().Add( rootActor );
2557 CameraActor offscreenCameraActor = CameraActor::New();
2558 Stage::GetCurrent().Add( offscreenCameraActor );
2559 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2560 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2561 Integration::ResourceId imageRequestId = imageRequest->GetId();
2562 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2563 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2564 application.Render();
2565 application.GetPlatform().ClearReadyResources();
2567 Stage::GetCurrent().Add(secondRootActor);
2569 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2570 bool finished = false;
2571 RenderTaskFinished renderTaskFinished( finished );
2572 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2573 application.SendNotification();
2575 // START PROCESS/RENDER Input, Expected Input, Expected
2576 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2578 // CHANGE TO RENDER ONCE,
2579 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2580 application.SendNotification();
2581 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2582 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2583 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2585 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2586 application.SendNotification();
2587 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2588 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2589 DALI_TEST_CHECK( lastSyncObj != NULL );
2591 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2592 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2593 sync.SetObjectSynced( lastSyncObj, true );
2594 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2595 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2600 int UtcDaliRenderTaskOnce10(void)
2602 TestApplication application;
2604 tet_infoline("Testing RenderTask Render Once GlSync\n"
2605 "SetRefreshRate(ONCE), resource load failed completes render task.\n"
2606 "PRE: resources not ready\n"
2607 "POST: Only 1 finished signal sent.");
2609 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2610 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2611 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2612 drawTrace.Enable(true);
2614 Actor rootActor = Actor::New();
2615 Stage::GetCurrent().Add( rootActor );
2617 CameraActor offscreenCameraActor = CameraActor::New();
2618 Stage::GetCurrent().Add( offscreenCameraActor );
2619 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2620 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2621 Integration::ResourceId imageRequestId = imageRequest->GetId();
2622 Stage::GetCurrent().Add(secondRootActor);
2624 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2625 bool finished = false;
2626 RenderTaskFinished renderTaskFinished( finished );
2627 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2628 application.SendNotification();
2630 // START PROCESS/RENDER Input, Expected Input, Expected
2631 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2632 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2634 // CHANGE TO RENDER ONCE,
2635 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2636 application.SendNotification();
2637 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2638 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2639 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2641 tet_printf(" FailImageLoad\n");
2643 FailImageLoad(application, imageRequestId); // Need to run Update again for this to complete
2645 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); // nothing to draw
2646 application.SendNotification();
2648 // load is now failed so there's nothing more to render in the render task
2649 // Expect finished signal, as all resources are complete
2650 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2655 int UtcDaliRenderTaskOnceNoSync01(void)
2657 TestApplication application;
2659 tet_infoline("Testing RenderTask Render Once, using loading image\nPRE: Resources not ready, Source not visible\nPOST: Finished signal sent once only");
2661 // SETUP AN OFFSCREEN RENDER TASK
2662 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2663 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2664 drawTrace.Enable(true);
2666 Actor rootActor = Actor::New();
2667 Stage::GetCurrent().Add( rootActor );
2669 CameraActor offscreenCameraActor = CameraActor::New();
2670 Stage::GetCurrent().Add( offscreenCameraActor );
2671 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2672 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2673 Integration::ResourceId imageRequestId = imageRequest->GetId();
2674 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2676 Stage::GetCurrent().Add(secondRootActor);
2678 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2679 bool finished = false;
2680 RenderTaskFinished renderTaskFinished( finished );
2681 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2682 application.SendNotification();
2684 // START PROCESS/RENDER Input, Expected Input, Expected
2685 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2686 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2688 // FINISH RESOURCE LOADING - expect immediate rendering yet
2689 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2690 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2691 application.GetPlatform().ClearReadyResources();
2692 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2696 int UtcDaliRenderTaskOnceNoSync02(void)
2698 TestApplication application;
2700 tet_infoline("Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loading image.\n"
2701 "PRE: Resources not ready\nPOST: Finished signal sent once only");
2702 // SETUP AN OFFSCREEN RENDER TASK
2703 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2704 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2705 drawTrace.Enable(true);
2707 Actor rootActor = Actor::New();
2708 Stage::GetCurrent().Add( rootActor );
2710 CameraActor offscreenCameraActor = CameraActor::New();
2711 Stage::GetCurrent().Add( offscreenCameraActor );
2713 Material material = CreateMaterial();
2714 Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2715 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2716 Integration::ResourceId imageRequestId = imageRequest->GetId();
2717 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2718 material.AddTexture(image, "sTexture" );
2720 Geometry geometry = CreateQuadGeometry();
2721 Renderer renderer = Renderer::New(geometry, material);
2722 Actor secondRootActor = Actor::New();
2723 secondRootActor.AddRenderer(renderer);
2724 secondRootActor.SetSize(100, 100);
2725 Stage::GetCurrent().Add(secondRootActor);
2727 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2728 bool finished = false;
2729 RenderTaskFinished renderTaskFinished( finished );
2730 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2731 application.SendNotification();
2733 // START PROCESS/RENDER Input, Expected Input, Expected
2734 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2735 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2737 // FINISH RESOURCE LOADING - expect immediate rendering yet
2738 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2739 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2740 application.GetPlatform().ClearReadyResources();
2741 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2746 int UtcDaliRenderTaskOnceNoSync03(void)
2748 TestApplication application;
2750 tet_infoline("Testing RenderTask Render Once, using loading image. Switch from render always after ready to render once\n"
2751 "PRE: Render task ready, Image not loaded\n"
2752 "POST: Finished signal sent only once");
2754 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2755 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2756 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2757 drawTrace.Enable(true);
2759 Actor rootActor = Actor::New();
2760 Stage::GetCurrent().Add( rootActor );
2762 CameraActor offscreenCameraActor = CameraActor::New();
2763 Stage::GetCurrent().Add( offscreenCameraActor );
2764 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2765 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2766 Integration::ResourceId imageRequestId = imageRequest->GetId();
2767 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2768 Stage::GetCurrent().Add(secondRootActor);
2770 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2771 bool finished = false;
2772 RenderTaskFinished renderTaskFinished( finished );
2773 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2774 application.SendNotification();
2776 // START PROCESS/RENDER Input, Expected Input, Expected
2777 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2778 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2780 // FINISH RESOURCE LOADING
2781 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2782 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2783 application.GetPlatform().ClearReadyResources();
2785 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2786 application.SendNotification(); // Input, Expected Input, Expected
2787 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2788 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2792 int UtcDaliRenderTaskOnceNoSync04(void)
2794 TestApplication application;
2796 tet_infoline("Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loading image.\n"
2797 "Switch from render always after ready to render once\n"
2798 "PRE: Render task ready, Image not loaded\n"
2799 "POST: Finished signal sent only once");
2801 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2802 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2803 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2804 drawTrace.Enable(true);
2806 Actor rootActor = Actor::New();
2807 Stage::GetCurrent().Add( rootActor );
2809 CameraActor offscreenCameraActor = CameraActor::New();
2810 Stage::GetCurrent().Add( offscreenCameraActor );
2812 Material material = CreateMaterial();
2813 Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2814 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2815 Integration::ResourceId imageRequestId = imageRequest->GetId();
2816 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2817 material.AddTexture( image, "sTexture" );
2819 Geometry geometry = CreateQuadGeometry();
2820 Renderer renderer = Renderer::New(geometry, material);
2821 Actor secondRootActor = Actor::New();
2822 secondRootActor.AddRenderer(renderer);
2823 secondRootActor.SetSize(100, 100);
2824 Stage::GetCurrent().Add(secondRootActor);
2827 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2828 bool finished = false;
2829 RenderTaskFinished renderTaskFinished( finished );
2830 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2831 application.SendNotification();
2833 // START PROCESS/RENDER Input, Expected Input, Expected
2834 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2835 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2837 // FINISH RESOURCE LOADING
2838 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2839 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2840 application.GetPlatform().ClearReadyResources();
2842 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2843 application.SendNotification(); // Input, Expected Input, Expected
2844 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2845 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2849 int UtcDaliRenderTaskOnceNoSync05(void)
2851 TestApplication application;
2853 tet_infoline("Testing RenderTask Render Once\n"
2854 "Switch from Render always after ready to render once with resources unready\n"
2855 "PRE: Everything ready to render\n"
2856 "POST: Finished signal sent once");
2858 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2859 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2860 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2861 drawTrace.Enable(true);
2863 Actor rootActor = Actor::New();
2864 Stage::GetCurrent().Add( rootActor );
2866 CameraActor offscreenCameraActor = CameraActor::New();
2867 Stage::GetCurrent().Add( offscreenCameraActor );
2868 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2869 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2870 Integration::ResourceId imageRequestId = imageRequest->GetId();
2871 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2872 Stage::GetCurrent().Add(secondRootActor);
2874 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2875 bool finished = false;
2876 RenderTaskFinished renderTaskFinished( finished );
2877 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2878 application.SendNotification();
2880 // START PROCESS/RENDER Input, Expected Input, Expected
2881 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2882 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2884 // CHANGE TO RENDER ONCE
2885 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2886 application.SendNotification(); // Input, Expected Input, Expected
2887 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2888 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2890 // FINISH RESOURCE LOADING
2891 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2892 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2893 application.GetPlatform().ClearReadyResources();
2894 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2899 //int UtcDaliRenderTaskOnceNoSync06(void)
2901 TestApplication application;
2903 tet_infoline("Testing RenderTask Render Once\n"
2904 "During RenderOnce, make ready resources unready before sending first finished signal\n"
2905 "PRE: Everything ready.\n"
2906 "POST: Finished signal sent only once");
2908 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2909 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2910 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2911 drawTrace.Enable(true);
2913 Actor rootActor = Actor::New();
2914 Stage::GetCurrent().Add( rootActor );
2916 CameraActor offscreenCameraActor = CameraActor::New();
2917 Stage::GetCurrent().Add( offscreenCameraActor );
2918 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2919 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2920 Integration::ResourceId imageRequestId = imageRequest->GetId();
2921 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2922 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2923 application.Render();
2924 application.GetPlatform().ClearReadyResources();
2926 Stage::GetCurrent().Add(secondRootActor);
2928 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2929 bool finished = false;
2930 RenderTaskFinished renderTaskFinished( finished );
2931 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2932 application.SendNotification();
2934 // START PROCESS/RENDER Input, Expected Input, Expected
2935 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2936 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2938 // CHANGE TO RENDER ONCE, RESOURCES BECOME NOT READY
2939 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2942 ReloadImage(application, secondRootActor.GetImage());
2943 application.SendNotification(); // Input, Expected Input, Expected
2945 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2946 DALI_TEST_EQUALS( secondRootActor.GetImage().GetLoadingState(), Dali::ResourceLoading, TEST_LOCATION);
2947 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2949 // FINISH RESOURCE LOADING
2950 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2951 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, true, true, __LINE__ ) );
2952 application.GetPlatform().ClearReadyResources();
2953 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2954 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2955 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2956 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2961 int UtcDaliRenderTaskOnceNoSync07(void)
2963 TestApplication application;
2965 tet_infoline("Testing RenderTask Render Once\n"
2966 "Render once, Second call to SetRefreshRate(ONCE) triggers only one more finished signal\n"
2967 "PRE: Everything ready\n"
2968 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
2970 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2971 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2972 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2973 drawTrace.Enable(true);
2975 Actor rootActor = Actor::New();
2976 Stage::GetCurrent().Add( rootActor );
2978 CameraActor offscreenCameraActor = CameraActor::New();
2979 Stage::GetCurrent().Add( offscreenCameraActor );
2980 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2981 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2982 Integration::ResourceId imageRequestId = imageRequest->GetId();
2983 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2984 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2985 application.Render();
2986 application.GetPlatform().ClearReadyResources();
2988 Stage::GetCurrent().Add(secondRootActor);
2990 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2991 bool finished = false;
2992 RenderTaskFinished renderTaskFinished( finished );
2993 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2994 application.SendNotification();
2996 // START PROCESS/RENDER Input, Expected Input, Expected
2997 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2999 // CHANGE TO RENDER ONCE,
3000 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3001 application.SendNotification();
3002 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3003 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3005 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3006 application.SendNotification();
3007 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3008 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3012 int UtcDaliRenderTaskOnceNoSync08(void)
3014 TestApplication application;
3016 tet_infoline("Testing RenderTask Render Once\n"
3017 "Render once, Call to SetRefreshRate(ONCE) in Finished signal callback triggers\n"
3018 "another render & another finished signal\n"
3019 "PRE: Everything ready\n"
3020 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
3023 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3024 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3025 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3026 drawTrace.Enable(true);
3028 Actor rootActor = Actor::New();
3029 Stage::GetCurrent().Add( rootActor );
3031 CameraActor offscreenCameraActor = CameraActor::New();
3032 Stage::GetCurrent().Add( offscreenCameraActor );
3033 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3034 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3035 Integration::ResourceId imageRequestId = imageRequest->GetId();
3036 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
3037 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
3038 application.Render();
3039 application.GetPlatform().ClearReadyResources();
3041 Stage::GetCurrent().Add(secondRootActor);
3043 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3044 bool finished = false;
3046 ConnectionTracker connectionTracker;
3047 RenderTaskFinishedRenderAgain renderTaskFinishedRenderAgain( finished );
3048 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinishedRenderAgain );
3050 application.SendNotification();
3052 // START PROCESS/RENDER Input, Expected Input, Expected
3053 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
3055 // CHANGE TO RENDER ONCE,
3056 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3057 application.SendNotification();
3058 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3059 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3061 // Expect SetRefreshRate to have been called again
3062 // Prevent next finished signal calling refresh once again
3063 RenderTaskFinished renderTaskFinished( finished );
3064 connectionTracker.DisconnectAll();
3065 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinished );
3067 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3068 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3073 int UtcDaliRenderTaskOnceNoSync09(void)
3075 TestApplication application;
3077 tet_infoline("Testing RenderTask Render Once\n"
3078 "SetRefreshRate(ONCE) again before first finished signal has been sent.\n"
3079 "PRE: resources ready\n"
3080 "POST: Only 1 finished signal sent.");
3082 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3083 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3084 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3085 drawTrace.Enable(true);
3087 Actor rootActor = Actor::New();
3088 Stage::GetCurrent().Add( rootActor );
3090 CameraActor offscreenCameraActor = CameraActor::New();
3091 Stage::GetCurrent().Add( offscreenCameraActor );
3092 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3093 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3094 Integration::ResourceId imageRequestId = imageRequest->GetId();
3095 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
3096 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
3097 application.Render();
3098 application.GetPlatform().ClearReadyResources();
3100 Stage::GetCurrent().Add(secondRootActor);
3102 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3103 bool finished = false;
3104 RenderTaskFinished renderTaskFinished( finished );
3105 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3106 application.SendNotification();
3108 // START PROCESS/RENDER Input, Expected Input, Expected
3109 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
3111 // CHANGE TO RENDER ONCE,
3112 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3113 application.SendNotification();
3114 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3115 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3117 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3118 application.SendNotification();
3119 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3120 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3124 int UtcDaliRenderTaskOnceNoSync10(void)
3126 TestApplication application;
3128 tet_infoline("Testing RenderTask Render Once\n"
3129 "SetRefreshRate(ONCE), resource load failed, completes render task.\n"
3130 "PRE: resources not ready\n"
3131 "POST: Only 1 finished signal sent.");
3133 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3134 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3135 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3136 drawTrace.Enable(true);
3138 Actor rootActor = Actor::New();
3139 Stage::GetCurrent().Add( rootActor );
3141 CameraActor offscreenCameraActor = CameraActor::New();
3142 Stage::GetCurrent().Add( offscreenCameraActor );
3143 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3144 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3145 Integration::ResourceId imageRequestId = imageRequest->GetId();
3146 Stage::GetCurrent().Add(secondRootActor);
3148 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3149 bool finished = false;
3150 RenderTaskFinished renderTaskFinished( finished );
3151 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3152 application.SendNotification();
3154 // START PROCESS/RENDER Input, Expected Input, Expected
3155 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3156 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3158 // CHANGE TO RENDER ONCE,
3159 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3160 application.SendNotification();
3161 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3162 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3163 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3165 FailImageLoad(application, imageRequestId); // Need to run Update again for this to complete
3166 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); // nothing to draw
3167 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3174 int UtcDaliRenderTaskOnceChain01(void)
3176 TestApplication application;
3178 tet_infoline("Testing RenderTask Render Once Chained render tasks\n"
3179 "SetRefreshRate(ONCE), resource load completes, both render tasks render.\n"
3180 "PRE: resources not ready\n"
3181 "POST: 2 finished signals sent.");
3183 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3184 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3185 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3186 drawTrace.Enable(true);
3188 Actor defaultRootActor = Actor::New(); // Root for default RT
3189 Stage::GetCurrent().Add( defaultRootActor );
3191 CameraActor offscreenCameraActor = CameraActor::New();
3192 Stage::GetCurrent().Add( offscreenCameraActor );
3193 ImageActor firstRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3194 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3195 Integration::ResourceId imageRequestId = imageRequest->GetId();
3196 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
3197 Stage::GetCurrent().Add(firstRootActor);
3199 // first render task
3200 RenderTask firstTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, firstRootActor, RenderTask::REFRESH_ONCE, false);
3201 bool firstFinished = false;
3202 RenderTaskFinished renderTask1Finished( firstFinished );
3203 firstTask.FinishedSignal().Connect( &application, renderTask1Finished );
3205 // Second render task
3206 FrameBufferImage fbo = firstTask.GetTargetFrameBuffer();
3207 ImageActor secondRootActor = ImageActor::New( fbo );
3208 Stage::GetCurrent().Add(secondRootActor);
3209 RenderTask secondTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
3210 bool secondFinished = false;
3211 RenderTaskFinished renderTask2Finished( secondFinished );
3212 secondTask.FinishedSignal().Connect( &application, renderTask2Finished );
3214 application.SendNotification();
3216 // START PROCESS/RENDER Input, Expected Input, Expected
3217 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__ ) );
3218 DALI_TEST_CHECK( firstFinished == false );
3219 DALI_TEST_CHECK( secondFinished == false );
3220 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__ ) );
3221 DALI_TEST_CHECK( firstFinished == false );
3222 DALI_TEST_CHECK( secondFinished == false );
3224 CompleteImageLoad(application, imageRequestId, imageType);
3225 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__ ) );
3226 DALI_TEST_CHECK( firstFinished == false );
3227 DALI_TEST_CHECK( secondFinished == false );
3229 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, true, true, __LINE__ ) );
3230 DALI_TEST_CHECK( firstFinished == true );
3231 DALI_TEST_CHECK( secondFinished == false );
3233 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, secondFinished, true, false, __LINE__ ) );
3234 DALI_TEST_CHECK( secondFinished == true );
3239 int UtcDaliRenderTaskProperties(void)
3241 TestApplication application;
3243 RenderTask task = Stage::GetCurrent().GetRenderTaskList().CreateTask();
3245 Property::IndexContainer indices;
3246 task.GetPropertyIndices( indices );
3247 DALI_TEST_CHECK( indices.Size() );
3248 DALI_TEST_EQUALS( indices.Size(), task.GetPropertyCount(), TEST_LOCATION );
3252 int UtcDaliRenderTaskSetScreenToFrameBufferMappingActor(void)
3254 TestApplication application;
3255 tet_infoline("Testing RenderTask::SetScreenToFrameBufferMappingActor ");
3257 Stage stage = Stage::GetCurrent();
3258 Size stageSize = stage.GetSize();
3259 Actor mappingActor = Actor::New();
3260 Vector2 scale( 0.6f, 0.75f);
3261 Vector2 offset( stageSize.x*0.1f, stageSize.y*0.15f);
3262 mappingActor.SetSize( stageSize * scale );
3263 mappingActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
3264 mappingActor.SetPosition( offset.x, offset.y );
3265 stage.Add( mappingActor );
3267 Actor offscreenActor = Actor::New();
3268 offscreenActor.SetSize( stageSize );
3269 offscreenActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
3270 stage.Add( offscreenActor );
3272 RenderTaskList taskList = stage.GetRenderTaskList();
3273 RenderTask renderTask = taskList.CreateTask();
3274 FrameBufferImage frameBufferImage = FrameBufferImage::New(stageSize.width*scale.x, stageSize.height*scale.y, Pixel::A8, Image::NEVER);
3275 renderTask.SetSourceActor( offscreenActor );
3276 renderTask.SetExclusive( true );
3277 renderTask.SetInputEnabled( true );
3278 renderTask.SetTargetFrameBuffer( frameBufferImage );
3279 renderTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
3280 renderTask.SetScreenToFrameBufferMappingActor( mappingActor );
3281 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3283 // Render and notify
3284 application.SendNotification();
3285 application.Render();
3286 application.Render();
3287 application.SendNotification();
3289 Vector2 screenCoordinates( stageSize.x * 0.05f, stageSize.y * 0.05f );
3290 Dali::HitTestAlgorithm::Results results;
3291 DALI_TEST_CHECK( !results.actor );
3292 DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
3293 // miss expected, results not changed
3294 DALI_TEST_CHECK( false == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3295 DALI_TEST_CHECK( !results.actor );
3296 DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
3298 screenCoordinates.x = stageSize.x * 0.265f;
3299 screenCoordinates.y = stageSize.y * 0.33f;
3300 results.actor = Actor();
3301 results.actorCoordinates = Vector2::ZERO;
3302 // hit expected, results changed
3303 DALI_TEST_CHECK( true == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3304 DALI_TEST_CHECK( results.actor == offscreenActor );
3305 DALI_TEST_EQUALS( (screenCoordinates-offset)/scale , results.actorCoordinates, 0.1f, TEST_LOCATION );
3307 screenCoordinates.x = stageSize.x * 0.435f;
3308 screenCoordinates.y = stageSize.y * 0.52f;
3309 // hit expected, results changed
3310 DALI_TEST_CHECK( true == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3311 DALI_TEST_CHECK( results.actor == offscreenActor );
3312 const Vector2 expectedCoordinates = (screenCoordinates-offset)/scale;
3313 DALI_TEST_EQUALS( expectedCoordinates , results.actorCoordinates, 0.1f, TEST_LOCATION );
3315 screenCoordinates.x = stageSize.x * 0.65f;
3316 screenCoordinates.y = stageSize.y * 0.95f;
3317 // miss expected, results not changed
3318 DALI_TEST_CHECK( false == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3319 DALI_TEST_CHECK( results.actor == offscreenActor );
3320 DALI_TEST_EQUALS( expectedCoordinates , results.actorCoordinates, 0.1f, TEST_LOCATION );
3324 int UtcDaliRenderTaskFinishInvisibleSourceActor(void)
3326 TestApplication application;
3328 tet_infoline("Testing RenderTask::SignalFinished()");
3330 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3331 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
3333 CameraActor offscreenCameraActor = CameraActor::New();
3335 Stage::GetCurrent().Add( offscreenCameraActor );
3337 BufferImage image = BufferImage::New( 10, 10 );
3338 ImageActor rootActor = ImageActor::New( image );
3339 rootActor.SetSize( 10, 10 );
3340 rootActor.SetVisible(false);
3341 Stage::GetCurrent().Add( rootActor );
3343 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3344 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
3345 FrameBufferImage frameBufferImage = FrameBufferImage::New( *testNativeImagePtr.Get() );
3347 // Flush all outstanding messages
3348 application.SendNotification();
3349 application.Render();
3351 RenderTask newTask = taskList.CreateTask();
3352 newTask.SetCameraActor( offscreenCameraActor );
3353 newTask.SetSourceActor( rootActor );
3354 newTask.SetInputEnabled( false );
3355 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
3356 newTask.SetClearEnabled( true );
3357 newTask.SetExclusive( true );
3358 newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
3359 newTask.SetTargetFrameBuffer( frameBufferImage );
3361 // Framebuffer doesn't actually get created until Connected, i.e. by previous line
3363 bool finished = false;
3364 RenderTaskFinished renderTaskFinished( finished );
3365 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3367 // Flush the queue and render.
3368 application.SendNotification();
3370 // 1 render to process render task, then wait for sync before finished msg is sent
3371 // from update to the event thread.
3373 application.Render();
3374 application.SendNotification();
3375 DALI_TEST_CHECK( !finished );
3377 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
3378 DALI_TEST_CHECK( lastSyncObj != NULL );
3380 application.Render();
3381 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
3382 application.SendNotification();
3383 DALI_TEST_CHECK( !finished );
3385 application.Render();
3386 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
3387 application.SendNotification();
3388 DALI_TEST_CHECK( ! finished );
3390 sync.SetObjectSynced( lastSyncObj, true );
3392 application.Render();
3393 application.SendNotification();
3394 DALI_TEST_CHECK( !finished );
3396 application.Render();
3397 application.SendNotification();
3398 DALI_TEST_CHECK( finished );
3401 application.Render(); // Double check no more finished signal
3402 application.SendNotification();
3403 DALI_TEST_CHECK( ! finished );
3408 int UtcDaliRenderTaskFinishMissingImage(void)
3410 TestApplication application;
3412 // Previously we had bugs where not having a resource ID would cause render-tasks to wait forever
3413 tet_infoline("Testing RenderTask::SignalFinished() when an ImageActor has no Image set");
3415 Stage stage = Stage::GetCurrent();
3417 BufferImage image = BufferImage::New( 10, 10 );
3418 ImageActor rootActor = ImageActor::New( image );
3419 rootActor.SetSize( 10, 10 );
3420 stage.Add( rootActor );
3422 ImageActor actorWithMissingImage = ImageActor::New( Image() );
3423 actorWithMissingImage.SetSize( 10, 10 );
3424 stage.Add( actorWithMissingImage );
3426 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3427 RenderTask newTask = taskList.CreateTask();
3428 newTask.SetInputEnabled( false );
3429 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
3430 newTask.SetClearEnabled( true );
3431 newTask.SetExclusive( true );
3432 newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
3434 bool finished = false;
3435 RenderTaskFinished renderTaskFinished( finished );
3436 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3438 // 1 render to process render task, then 1 before finished msg is sent from update to the event thread.
3439 application.SendNotification();
3440 application.Render();
3441 application.Render();
3443 application.SendNotification();
3444 DALI_TEST_CHECK( finished );
3449 int UtcDaliRenderTaskWorldToViewport(void)
3451 TestApplication application( static_cast<size_t>(400), static_cast<size_t>(400) ); // square surface
3453 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3455 Actor actor = Actor::New();
3456 actor.SetSize(100.0f, 100.0f);
3457 actor.SetPosition( Vector3(0.0, 0.0, 0.0) );
3459 actor.SetParentOrigin( Vector3(0.5, 0.5, 0.5) );
3460 actor.SetAnchorPoint( Vector3(0.5, 0.5, 0.5) );
3462 Stage::GetCurrent().Add(actor);
3464 application.Render();
3465 application.SendNotification();
3466 application.Render();
3467 application.SendNotification();
3469 RenderTask task = taskList.GetTask( 0u );
3471 CameraActor camera = task.GetCameraActor();
3473 Vector2 screenSize = task.GetCurrentViewportSize();
3475 float screenX = 0.0;
3476 float screenY = 0.0;
3478 bool ok = task.WorldToViewport(actor.GetCurrentWorldPosition(), screenX, screenY);
3479 DALI_TEST_CHECK(ok == true);
3481 DALI_TEST_EQUALS(screenX, screenSize.x/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
3482 DALI_TEST_EQUALS(screenY, screenSize.y/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
3484 Actor actor2 = Actor::New();
3485 float actor2Size = 100.f;
3486 actor2.SetSize( actor2Size, actor2Size );
3487 actor2.SetPosition( Vector3(0.0, 0.0, 0.0) );
3488 actor2.SetParentOrigin( Vector3(0.5, 0.5, 0.0) );
3489 actor2.SetAnchorPoint( Vector3(0.5, 0.5, 0.0) );
3490 Stage::GetCurrent().Add( actor2 );
3492 actor.SetParentOrigin( Vector3(0,0,0) );
3494 application.Render();
3495 application.SendNotification();
3496 application.Render();
3497 application.SendNotification();
3499 ok = task.WorldToViewport(actor.GetCurrentWorldPosition(), screenX, screenY);
3500 DALI_TEST_CHECK(ok == true);
3502 DALI_TEST_EQUALS(screenX, screenSize.x/2 - actor2Size/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
3503 DALI_TEST_EQUALS(screenY, screenSize.y/2 - actor2Size/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
3509 int UtcDaliRenderTaskViewportToLocal(void)
3511 TestApplication application;
3512 Actor actor = Actor::New();
3513 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
3514 actor.SetSize(100.0f, 100.0f);
3515 actor.SetPosition(10.0f, 10.0f);
3516 Stage::GetCurrent().Add(actor);
3518 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3519 RenderTask task = taskList.GetTask( 0u );
3521 // flush the queue and render once
3522 application.SendNotification();
3523 application.Render();
3531 float screenX = 50.0f;
3532 float screenY = 50.0f;
3534 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, screenX, screenY) );
3536 DALI_TEST_CHECK( task.ViewportToLocal(actor, screenX, screenY, rtLocalX, rtLocalY ) );
3538 DALI_TEST_EQUALS(localX, rtLocalX, 0.01f, TEST_LOCATION);
3539 DALI_TEST_EQUALS(localY, rtLocalY, 0.01f, TEST_LOCATION);