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 #define BOOLSTR(x) ((x)?"T":"F")
32 void utc_dali_render_task_startup(void)
34 test_return_value = TET_UNDEF;
37 void utc_dali_render_task_cleanup(void)
39 test_return_value = TET_PASS;
45 * Constructor, Destructor, DownCast, New, copy constructor, assignment operator
47 * SetSourceActor 2+ve, 1-ve
48 * GetSourceActor 1+ve, 1-ve
49 * SetExclusive 2+ve, 0-ve
50 * IsExclusive 2+ve, 0-ve
51 * SetInputEnabled 1+ve, 0-ve
52 * GetInputEnabled 1+ve, 0-ve
53 * SetCameraActor 1+ve, 1-ve
54 * GetCameraActor 1+ve, 1-ve
55 * SetTargetFrameBuffer 1+ve, 1-ve
56 * GetTargetFrameBuffer 1+ve, 1-ve
57 * SetScreenToFrameBufferFunction 1+ve, 1-ve
58 * GetScreenToFrameBufferFunction 1+ve, 1-ve
59 * SetScreenToFrameBufferMappingActor 1+ve, 1-ve
60 * GetScreenToFrameBufferMappingActor 1+ve, 1-ve
61 * SetViewportPosition 1+ve
62 * GetCurrentViewportPosition 1+ve
63 * SetViewportSize 1+ve
64 * GetCurrentViewportSize 1+ve
65 * SetViewport 2+ve, 1-ve
66 * GetViewport 2+ve, 1-ve
67 * SetClearColor 1+ve, 1-ve
68 * GetClearColor 1+ve, 1-ve
69 * SetClearEnabled 1+ve, 1-ve
70 * GetClearEnabled 1+ve, 1-ve
78 namespace // unnamed namespace
81 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
84 * Simulate time passed by.
86 * @note this will always process at least 1 frame (1/60 sec)
88 * @param application Test application instance
89 * @param duration Time to pass in milliseconds.
90 * @return The actual time passed in milliseconds
92 int Wait(TestApplication& application, int duration = 0)
96 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
98 application.SendNotification();
99 application.Render(RENDER_FRAME_INTERVAL);
100 time += RENDER_FRAME_INTERVAL;
106 struct RenderTaskFinished
108 RenderTaskFinished( bool& finished )
109 : finished( finished )
113 void operator()( RenderTask& renderTask )
121 struct RenderTaskFinishedRemoveSource
123 RenderTaskFinishedRemoveSource( bool& finished )
124 : finished( finished ),
129 void operator()( RenderTask& renderTask )
131 DALI_TEST_CHECK(finishedOnce == false);
134 Actor srcActor = renderTask.GetSourceActor();
135 UnparentAndReset(srcActor);
142 struct RenderTaskFinishedRenderAgain
144 RenderTaskFinishedRenderAgain( bool& finished )
145 : finished( finished ),
150 void operator()( RenderTask& renderTask )
152 DALI_TEST_CHECK(finishedOnce == false);
155 renderTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
163 bool TestScreenToFrameBufferFunction( Vector2& coordinates )
165 coordinates = coordinates + Vector2( 1, 2 );
170 ImageActor CreateLoadingImage(TestApplication& application, std::string filename, ResourceImage::LoadPolicy loadPolicy, Image::ReleasePolicy releasePolicy)
172 Image image = ResourceImage::New(filename, loadPolicy, releasePolicy);
173 DALI_TEST_CHECK( image );
174 application.SendNotification();
175 application.Render(16);
176 DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
177 ImageActor actor = ImageActor::New(image);
178 actor.SetSize( 80, 80 );
179 application.SendNotification();
180 application.Render(16);
184 void CompleteImageLoad(TestApplication& application, Integration::ResourceId resourceId, Integration::ResourceTypeId requestType)
186 std::vector<GLuint> ids;
188 application.GetGlAbstraction().SetNextTextureIds( ids );
190 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
191 Integration::ResourcePointer resource(bitmap);
192 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80);
194 application.GetPlatform().SetResourceLoaded(resourceId, requestType, resource);
197 void FailImageLoad(TestApplication& application, Integration::ResourceId resourceId )
199 application.GetPlatform().SetResourceLoadFailed(resourceId, Integration::FailureUnknown);
202 void ReloadImage(TestApplication& application, ResourceImage image)
204 application.GetPlatform().ClearReadyResources();
205 application.GetPlatform().DiscardRequest();
206 application.GetPlatform().ResetTrace();
207 application.GetPlatform().SetClosestImageSize(Vector2(80.0f, 80.0f)); // Ensure reload is called.
211 RenderTask CreateRenderTask(TestApplication& application,
212 CameraActor offscreenCamera,
213 Actor rootActor, // Reset default render task to point at this actor
214 Actor secondRootActor, // Source actor
215 unsigned int refreshRate,
218 // Change main render task to use a different root
219 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
220 taskList.GetTask(0u).SetSourceActor( rootActor );
222 FrameBufferImage frameBufferImage;
225 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
226 frameBufferImage= FrameBufferImage::New( *(testNativeImagePtr.Get()) );
230 frameBufferImage = FrameBufferImage::New( 10, 10 );
233 // Don't draw output framebuffer // '
235 RenderTask newTask = taskList.CreateTask();
236 newTask.SetCameraActor( offscreenCamera );
237 newTask.SetSourceActor( secondRootActor );
238 newTask.SetInputEnabled( false );
239 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
240 newTask.SetClearEnabled( true );
241 newTask.SetExclusive( true );
242 newTask.SetRefreshRate( refreshRate );
243 newTask.SetTargetFrameBuffer( frameBufferImage );
247 bool UpdateRender(TestApplication& application, TraceCallStack& callStack, bool testDrawn, bool& finishedSig, bool testFinished, bool testKeepUpdating )
251 application.Render(16);
252 application.SendNotification();
254 bool sigPassed = false;
257 sigPassed = finishedSig;
261 sigPassed = ! finishedSig;
264 bool drawResult = callStack.FindMethod("DrawElements") || callStack.FindMethod("DrawArrays");
266 bool drawPassed = false;
269 drawPassed = drawResult;
273 drawPassed = !drawResult;
276 bool keepUpdating = (application.GetUpdateStatus() != 0);
277 bool keepUpdatingPassed = false;
278 if( testKeepUpdating )
280 keepUpdatingPassed = keepUpdating;
284 keepUpdatingPassed = !keepUpdating;
287 bool result = (sigPassed && drawPassed && keepUpdatingPassed);
289 tet_printf("UpdateRender: Expected: Draw:%s Signal:%s Keep Updating: %s Actual: Draw:%s Signal:%s KeepUpdating: %s %s\n",
290 BOOLSTR(testDrawn), BOOLSTR(testFinished), BOOLSTR(testKeepUpdating),
291 BOOLSTR(drawResult), BOOLSTR(finishedSig), BOOLSTR(keepUpdating),
292 result ? "Passed":"Failed");
297 // The functor to be used in the hit-test algorithm to check whether the actor is hittable.
298 bool IsActorHittableFunction(Actor actor, Dali::HitTestAlgorithm::TraverseType type)
300 bool hittable = false;
304 case Dali::HitTestAlgorithm::CHECK_ACTOR:
306 // Check whether the actor is visible and not fully transparent.
307 if( actor.IsVisible()
308 && actor.GetCurrentWorldColor().a > 0.01f) // not FULLY_TRANSPARENT
315 case Dali::HitTestAlgorithm::DESCEND_ACTOR_TREE:
317 if( actor.IsVisible() ) // Actor is visible, if not visible then none of its children are visible.
332 } // unnamed namespace
335 /****************************************************************************************************/
336 /****************************************************************************************************/
337 /******************************** TEST CASES BELOW **********************************************/
338 /****************************************************************************************************/
339 /****************************************************************************************************/
341 int UtcDaliRenderTaskDownCast01(void)
343 TestApplication application;
345 tet_infoline("Testing RenderTask::DownCast()");
347 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
349 BaseHandle base = taskList.GetTask( 0u );
350 DALI_TEST_CHECK( base );
352 RenderTask task = RenderTask::DownCast( base );
353 DALI_TEST_CHECK( task );
355 // Try calling a method
356 DALI_TEST_CHECK( task.GetSourceActor() );
360 int UtcDaliRenderTaskDownCast02(void)
362 TestApplication application;
364 tet_infoline("Testing RenderTask::DownCast()");
366 Actor actor = Actor::New();
368 RenderTask task = RenderTask::DownCast( actor );
369 DALI_TEST_CHECK( ! task );
374 int UtcDaliRenderTaskSetSourceActorN(void)
376 TestApplication application;
377 tet_infoline("Testing RenderTask::SetSourceActor() Negative - try with empty actor handle");
378 Stage stage = Stage::GetCurrent();
382 RenderTaskList taskList = stage.GetRenderTaskList();
383 RenderTask renderTask = taskList.CreateTask();
384 renderTask.SetSourceActor(srcActor);
386 application.SendNotification();
387 application.Render();
389 DALI_TEST_CHECK( ! renderTask.GetSourceActor() );
394 int UtcDaliRenderTaskSetSourceActorP01(void)
396 TestApplication application;
398 tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that setting a non-renderable actor stops existing source actor being rendered ");
400 Stage stage = Stage::GetCurrent();
402 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
404 RenderTaskList taskList = stage.GetRenderTaskList();
406 RenderTask task = taskList.GetTask( 0u );
408 Actor actor = task.GetSourceActor();
409 DALI_TEST_CHECK( actor );
411 std::vector<GLuint> ids;
413 application.GetGlAbstraction().SetNextTextureIds( ids );
415 BufferImage img = BufferImage::New( 1,1 );
416 ImageActor newActor = ImageActor::New( img );
417 newActor.SetSize(1,1);
418 stage.Add( newActor );
420 Actor nonRenderableActor = Actor::New();
421 stage.Add( nonRenderableActor );
423 // Stop the newActor from being rendered by changing the source actor
424 DALI_TEST_CHECK( nonRenderableActor );
425 task.SetSourceActor( nonRenderableActor );
426 DALI_TEST_CHECK( task.GetSourceActor() != actor );
427 DALI_TEST_CHECK( task.GetSourceActor() == nonRenderableActor );
429 // Update & Render nothing!
430 application.GetGlAbstraction().ClearBoundTextures();
431 application.SendNotification();
432 application.Render();
434 // Check that nothing was rendered
435 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
441 int UtcDaliRenderTaskSetSourceActorP02(void)
443 TestApplication application;
445 tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that switching source from a non-renderable to a renderable actor causes the texture to be drawn");
447 Stage stage = Stage::GetCurrent();
449 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
451 RenderTaskList taskList = stage.GetRenderTaskList();
453 RenderTask task = taskList.GetTask( 0u );
455 Actor actor = task.GetSourceActor();
456 DALI_TEST_CHECK( actor );
458 std::vector<GLuint> ids;
460 application.GetGlAbstraction().SetNextTextureIds( ids );
462 BufferImage img = BufferImage::New( 1,1 );
463 ImageActor newActor = ImageActor::New( img );
464 newActor.SetSize(1,1);
465 stage.Add( newActor );
467 Actor nonRenderableActor = Actor::New();
468 stage.Add( nonRenderableActor );
470 // Stop the newActor from being rendered by changing the source actor
471 DALI_TEST_CHECK( nonRenderableActor );
472 task.SetSourceActor( nonRenderableActor );
473 DALI_TEST_CHECK( task.GetSourceActor() != actor );
474 DALI_TEST_CHECK( task.GetSourceActor() == nonRenderableActor );
476 // Update & Render nothing!
477 application.GetGlAbstraction().ClearBoundTextures();
478 application.SendNotification();
479 application.Render();
481 // Check that nothing was rendered
482 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
484 // Set newActor as the new source Actor
485 task.SetSourceActor( newActor );
486 DALI_TEST_CHECK( task.GetSourceActor() != actor );
487 DALI_TEST_CHECK( task.GetSourceActor() == newActor );
489 // Update & Render the newActor
490 application.GetGlAbstraction().ClearBoundTextures();
491 application.SendNotification();
492 application.Render();
494 // Check that the newActor was rendered
495 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
496 if ( boundTextures.size() )
498 DALI_TEST_EQUALS( boundTextures[0], 7u, TEST_LOCATION );
503 int UtcDaliRenderTaskSetSourceActorOffStage(void)
505 TestApplication application;
507 tet_infoline("Testing RenderTask::SetSourceActor (on/off stage testing)");
509 Stage stage = Stage::GetCurrent();
511 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
513 RenderTaskList taskList = stage.GetRenderTaskList();
515 RenderTask task = taskList.GetTask( 0u );
517 Actor actor = task.GetSourceActor();
518 DALI_TEST_CHECK( actor );
520 std::vector<GLuint> ids;
521 GLuint expectedTextureId( 3 );
522 ids.push_back( expectedTextureId );
523 application.GetGlAbstraction().SetNextTextureIds( ids );
525 BufferImage img = BufferImage::New( 1,1 );
526 ImageActor newActor = ImageActor::New( img );
527 newActor.SetSize(1,1);
528 task.SetSourceActor( newActor );
529 // Don't add newActor to stage yet //'
531 // Update & Render with the actor initially off-stage
532 application.GetGlAbstraction().ClearBoundTextures();
533 application.SendNotification();
534 application.Render();
536 // Check that nothing was rendered
537 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
540 stage.Add( newActor );
542 // Update & Render with the actor on-stage
543 application.GetGlAbstraction().ClearBoundTextures();
544 application.SendNotification();
545 application.Render();
547 // Check that the newActor was rendered
548 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
549 if ( boundTextures.size() )
551 DALI_TEST_EQUALS( boundTextures[0], expectedTextureId, TEST_LOCATION );
554 // Now remove from stage
555 stage.Remove( newActor );
557 // Update & Render with the actor off-stage
558 application.GetGlAbstraction().ClearBoundTextures();
559 application.SendNotification();
560 application.Render();
564 int UtcDaliRenderTaskSetSourceActorEmpty(void)
566 TestApplication application;
568 tet_infoline("Testing RenderTask::SetSourceActor (empty handle case)");
570 Stage stage = Stage::GetCurrent();
572 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
574 RenderTaskList taskList = stage.GetRenderTaskList();
576 RenderTask task = taskList.GetTask( 0u );
578 Actor actor = task.GetSourceActor();
579 DALI_TEST_CHECK( actor );
581 std::vector<GLuint> ids;
582 GLuint expectedTextureId( 5 );
583 ids.push_back( expectedTextureId );
584 application.GetGlAbstraction().SetNextTextureIds( ids );
586 BufferImage img = BufferImage::New( 1,1 );
587 ImageActor newActor = ImageActor::New( img );
588 newActor.SetSize(1,1);
589 stage.Add( newActor );
591 Actor nonRenderableActor = Actor::New();
592 stage.Add( nonRenderableActor );
594 // Set with empty handle
595 task.SetSourceActor( Actor() );
596 DALI_TEST_CHECK( ! task.GetSourceActor() );
598 // Update & Render nothing!
599 application.GetGlAbstraction().ClearBoundTextures();
600 application.SendNotification();
601 application.Render();
603 // Check that nothing was rendered
604 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
606 // Set with non-empty handle
607 task.SetSourceActor( newActor );
608 DALI_TEST_CHECK( task.GetSourceActor() == newActor );
610 // Update & Render the newActor
611 application.GetGlAbstraction().ClearBoundTextures();
612 application.SendNotification();
613 application.Render();
615 // Check that the newActor was rendered
616 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
617 if ( boundTextures.size() )
619 DALI_TEST_EQUALS( boundTextures[0], expectedTextureId, TEST_LOCATION );
624 int UtcDaliRenderTaskGetSourceActorP01(void)
626 TestApplication application;
628 tet_infoline("Testing RenderTask::GetSourceActor() Check the default render task has a valid source actor");
630 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
632 RenderTask task = taskList.GetTask( 0u );
634 Actor actor = task.GetSourceActor();
635 DALI_TEST_CHECK( actor );
637 // By default the entire scene should be rendered
638 Actor root = Stage::GetCurrent().GetLayer( 0 );
639 DALI_TEST_CHECK( root == actor );
643 int UtcDaliRenderTaskGetSourceActorP02(void)
645 TestApplication application;
647 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.");
649 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
650 RenderTask task = taskList.CreateTask();
651 Actor actor = Actor::New();
652 Stage::GetCurrent().Add(actor);
653 task.SetSourceActor( actor );
655 DALI_TEST_EQUALS( actor, task.GetSourceActor(), TEST_LOCATION );
660 int UtcDaliRenderTaskGetSourceActorN(void)
662 TestApplication application;
664 tet_infoline("Testing RenderTask::GetSourceActor() Try with empty handle");
669 Actor actor = task.GetSourceActor();
671 catch (Dali::DaliException(e))
673 DALI_TEST_PRINT_ASSERT( e );
674 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
680 int UtcDaliRenderTaskSetExclusive(void)
682 TestApplication application;
684 tet_infoline("Testing RenderTask::SetExclusive() Check that exclusion works");
686 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
688 // Manipulate the GenTextures behaviour, to identify different ImageActors
690 std::vector<GLuint> ids;
691 ids.push_back( 8 ); // 8 = actor1
692 ids.push_back( 9 ); // 9 = actor2
693 ids.push_back( 10 ); // 10 = actor3
694 application.GetGlAbstraction().SetNextTextureIds( ids );
696 BufferImage img1 = BufferImage::New( 1,1 );
697 ImageActor actor1 = ImageActor::New( img1 );
699 Stage::GetCurrent().Add( actor1 );
701 // Update & Render actor1
702 application.SendNotification();
703 application.Render();
705 // Check that the actor1 was rendered
706 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
707 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
709 if ( boundTextures.size() )
711 DALI_TEST_EQUALS( boundTextures[0], 8u/*unique to actor1*/, TEST_LOCATION );
714 BufferImage img2 = BufferImage::New( 1,1 );
715 ImageActor actor2 = ImageActor::New( img2 );
718 // Force actor2 to be rendered before actor1
719 Layer layer = Layer::New();
720 Stage::GetCurrent().Add( layer );
722 layer.LowerToBottom();
725 application.GetGlAbstraction().ClearBoundTextures();
726 application.SendNotification();
727 application.Render();
729 // Check that the actors were rendered
730 DALI_TEST_EQUALS( boundTextures.size(), 2u, TEST_LOCATION );
732 if ( boundTextures.size() )
734 DALI_TEST_EQUALS( boundTextures[0], 9u/*unique to actor2*/, TEST_LOCATION );
735 DALI_TEST_EQUALS( boundTextures[1], 8u/*unique to actor1*/, TEST_LOCATION );
738 BufferImage img3 = BufferImage::New( 1,1 );
739 ImageActor actor3 = ImageActor::New( img3 );
742 // Force actor3 to be rendered before actor2
743 layer = Layer::New();
744 Stage::GetCurrent().Add( layer );
746 layer.LowerToBottom();
748 // Update & Render all actors
749 application.GetGlAbstraction().ClearBoundTextures();
750 application.SendNotification();
751 application.Render();
753 // Check that the actors were rendered
754 DALI_TEST_EQUALS( boundTextures.size(), 3u, TEST_LOCATION );
756 if ( boundTextures.size() )
758 DALI_TEST_EQUALS( boundTextures[0], 10u/*unique to actor3*/, TEST_LOCATION );
759 DALI_TEST_EQUALS( boundTextures[1], 9u/*unique to actor2*/, TEST_LOCATION );
760 DALI_TEST_EQUALS( boundTextures[2], 8u/*unique to actor1*/, TEST_LOCATION );
763 // Both actors are now connected to the root node
764 // Setup 2 render-tasks - the first will render from the root-node, and the second from actor2
766 // Not exclusive is the default
767 RenderTask task1 = taskList.GetTask( 0u );
768 DALI_TEST_CHECK( false == task1.IsExclusive() );
770 RenderTask task2 = taskList.CreateTask();
771 DALI_TEST_CHECK( false == task2.IsExclusive() );
772 task2.SetSourceActor( actor2 );
774 // Task1 should render all actors, and task 2 should render only actor2
776 application.GetGlAbstraction().ClearBoundTextures();
777 application.SendNotification();
778 application.Render();
780 DALI_TEST_EQUALS( boundTextures.size(), 4u, TEST_LOCATION );
782 if ( boundTextures.size() == 4 )
784 // Test that task 1 renders actor3, then actor2 & then actor1
785 DALI_TEST_CHECK( boundTextures[0] == 10u );
786 DALI_TEST_CHECK( boundTextures[1] == 9u );
787 DALI_TEST_CHECK( boundTextures[2] == 8u );
789 // Test that task 2 renders actor2
790 DALI_TEST_EQUALS( boundTextures[3], 9u, TEST_LOCATION );
793 // Make actor2 exclusive to task2
795 task2.SetExclusive( true );
796 DALI_TEST_CHECK( true == task2.IsExclusive() );
798 // Task1 should render only actor1, and task 2 should render only actor2
800 application.GetGlAbstraction().ClearBoundTextures();
801 application.SendNotification();
802 application.Render();
804 DALI_TEST_EQUALS( boundTextures.size(), 3u, TEST_LOCATION );
805 if ( boundTextures.size() == 3 )
807 // Test that task 1 renders actor3 & actor1
808 DALI_TEST_CHECK( boundTextures[0] == 10u );
809 DALI_TEST_CHECK( boundTextures[1] == 8u );
811 // Test that task 2 renders actor2
812 DALI_TEST_CHECK( boundTextures[2] == 9u );
817 int UtcDaliRenderTaskSetExclusive02(void)
819 TestApplication application;
821 tet_infoline("Testing RenderTask::SetExclusive() Check that changing from exclusive to not-exclusive works");
823 std::vector<GLuint> ids;
824 ids.push_back( 8 ); // 8 = actor1
825 application.GetGlAbstraction().SetNextTextureIds( ids );
827 BufferImage img1 = BufferImage::New( 1,1 );
828 ImageActor actor1 = ImageActor::New( img1 );
830 Stage::GetCurrent().Add( actor1 );
832 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
833 RenderTask task = taskList.CreateTask();
835 task.SetSourceActor( actor1 );
836 task.SetExclusive(true); // Actor should only render once
838 TestGlAbstraction& gl = application.GetGlAbstraction();
839 TraceCallStack& drawTrace = gl.GetDrawTrace();
840 drawTrace.Enable(true);
842 // Update & Render actor1
843 application.SendNotification();
844 application.Render();
846 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawArrays"), 1, TEST_LOCATION );
848 // Set task to non-exclusive - actor1 should render twice:
850 task.SetExclusive(false);
851 application.SendNotification();
852 application.Render();
854 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawArrays"), 2, TEST_LOCATION );
859 int UtcDaliRenderTaskSetExclusiveN(void)
861 TestApplication application;
863 tet_infoline("Testing RenderTask::SetExclusive() on empty handle");
868 task.SetExclusive(true);
870 catch (Dali::DaliException(e))
872 DALI_TEST_PRINT_ASSERT( e );
873 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
878 int UtcDaliRenderTaskIsExclusive01(void)
880 TestApplication application;
882 tet_infoline("Testing RenderTask::IsExclusive() Check default values are non-exclusive");
884 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
886 // Not exclusive is the default
887 RenderTask task = taskList.GetTask( 0u );
888 DALI_TEST_CHECK( false == task.IsExclusive() );
890 RenderTask newTask = taskList.CreateTask();
891 DALI_TEST_CHECK( false == newTask.IsExclusive() );
896 int UtcDaliRenderTaskIsExclusive02(void)
898 TestApplication application;
900 tet_infoline("Testing RenderTask::IsExclusive() Check the getter returns set values");
902 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
904 // Not exclusive is the default
905 RenderTask newTask = taskList.CreateTask();
906 DALI_TEST_EQUALS( newTask.IsExclusive(), false, TEST_LOCATION );
908 newTask.SetExclusive(true);
909 DALI_TEST_EQUALS( newTask.IsExclusive(), true, TEST_LOCATION );
913 int UtcDaliRenderTaskIsExclusiveN(void)
915 TestApplication application;
917 tet_infoline("Testing RenderTask::IsExclusive() on empty handle");
922 bool x = task.IsExclusive();
925 catch (Dali::DaliException(e))
927 DALI_TEST_PRINT_ASSERT( e );
928 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
933 int UtcDaliRenderTaskSetInputEnabled(void)
935 TestApplication application;
937 tet_infoline("Testing RenderTask::SetInputEnabled()");
939 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
941 // Input is enabled by default
942 RenderTask task = taskList.GetTask( 0u );
943 DALI_TEST_CHECK( true == task.GetInputEnabled() );
945 task.SetInputEnabled( false );
946 DALI_TEST_CHECK( false == task.GetInputEnabled() );
948 task.SetInputEnabled( true );
949 DALI_TEST_CHECK( true == task.GetInputEnabled() );
953 int UtcDaliRenderTaskGetInputEnabled(void)
955 TestApplication application;
957 tet_infoline("Testing RenderTask::GetInputEnabled()");
959 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
961 // Input is enabled by default
962 RenderTask task = taskList.GetTask( 0u );
963 DALI_TEST_EQUALS( true, task.GetInputEnabled(), TEST_LOCATION );
965 RenderTask newTask = taskList.CreateTask();
966 DALI_TEST_EQUALS( true, newTask.GetInputEnabled(), TEST_LOCATION );
968 newTask.SetInputEnabled(false);
969 DALI_TEST_EQUALS( false, newTask.GetInputEnabled(), TEST_LOCATION );
974 int UtcDaliRenderTaskSetCameraActorP(void)
976 TestApplication application;
978 tet_infoline("Testing RenderTask::SetCameraActor()");
980 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
982 RenderTask task = taskList.GetTask( 0u );
984 Actor defaultCameraActor = task.GetCameraActor();
985 DALI_TEST_CHECK( defaultCameraActor );
987 CameraActor newCameraActor = CameraActor::New();
988 DALI_TEST_CHECK( newCameraActor );
990 task.SetCameraActor( newCameraActor );
991 DALI_TEST_CHECK( task.GetCameraActor() != defaultCameraActor );
992 DALI_TEST_EQUALS( task.GetCameraActor(), newCameraActor, TEST_LOCATION );
997 int UtcDaliRenderTaskSetCameraActorN(void)
999 TestApplication application;
1001 tet_infoline("Testing RenderTask::SetCameraActor() with empty actor handle");
1003 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1005 RenderTask task = taskList.GetTask( 0u );
1007 Actor actor = task.GetCameraActor();
1008 DALI_TEST_CHECK( actor );
1010 CameraActor cameraActor;
1012 task.SetCameraActor( cameraActor );
1013 DALI_TEST_EQUALS( (bool)task.GetCameraActor(), false, TEST_LOCATION );
1014 DALI_TEST_EQUALS( task.GetCameraActor(), cameraActor, TEST_LOCATION );
1019 int UtcDaliRenderTaskGetCameraActorP(void)
1021 TestApplication application;
1023 tet_infoline("Testing RenderTask::GetCameraActor()");
1025 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1027 RenderTask task = taskList.GetTask( 0u );
1029 CameraActor actor = task.GetCameraActor();
1030 DALI_TEST_CHECK( actor );
1031 DALI_TEST_EQUALS( actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION );
1032 DALI_TEST_GREATER( actor.GetFieldOfView(), 0.0f, TEST_LOCATION );
1036 int UtcDaliRenderTaskGetCameraActorN(void)
1038 TestApplication application;
1040 tet_infoline("Testing RenderTask::GetCameraActor() with empty handle");
1045 Actor actor = task.GetCameraActor();
1047 catch (Dali::DaliException(e))
1049 DALI_TEST_PRINT_ASSERT( e );
1050 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1056 int UtcDaliRenderTaskSetTargetFrameBufferP(void)
1058 TestApplication application;
1060 tet_infoline("Testing RenderTask::SetTargetFrameBuffer()");
1062 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1064 RenderTask task = taskList.GetTask( 0u );
1066 FrameBufferImage newImage = FrameBufferImage::New();
1067 task.SetTargetFrameBuffer( newImage );
1068 DALI_TEST_CHECK( task.GetTargetFrameBuffer() == newImage );
1072 int UtcDaliRenderTaskSetTargetFrameBufferN(void)
1074 TestApplication application;
1076 tet_infoline("Testing RenderTask::SetTargetFrameBuffer()");
1078 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1080 RenderTask task = taskList.GetTask( 0u );
1081 FrameBufferImage newImage; // Empty handle
1082 task.SetTargetFrameBuffer( newImage );
1083 DALI_TEST_EQUALS( (bool)task.GetTargetFrameBuffer(), false, TEST_LOCATION );
1087 int UtcDaliRenderTaskGetTargetFrameBufferP(void)
1089 TestApplication application;
1091 tet_infoline("Testing RenderTask::GetTargetFrameBuffer()");
1093 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1095 RenderTask newTask = taskList.CreateTask();
1096 FrameBufferImage fb = FrameBufferImage::New(128, 128, Pixel::RGBA8888);
1097 newTask.SetTargetFrameBuffer( fb );
1098 DALI_TEST_EQUALS( newTask.GetTargetFrameBuffer(), fb, TEST_LOCATION );
1102 int UtcDaliRenderTaskGetTargetFrameBufferN(void)
1104 TestApplication application;
1106 tet_infoline("Testing RenderTask::GetTargetFrameBuffer()");
1108 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1110 RenderTask task = taskList.GetTask( 0u );
1112 // By default render-tasks do not render off-screen
1113 FrameBufferImage image = task.GetTargetFrameBuffer();
1114 DALI_TEST_CHECK( !image );
1119 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionP(void)
1121 TestApplication application;
1123 tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1125 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1127 RenderTask task = taskList.GetTask( 0u );
1129 task.SetScreenToFrameBufferFunction( TestScreenToFrameBufferFunction );
1131 Vector2 coordinates( 5, 10 );
1132 Vector2 convertedCoordinates( 6, 12 ); // + Vector(1, 2)
1134 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1135 DALI_TEST_CHECK( func( coordinates ) );
1136 DALI_TEST_CHECK( coordinates == convertedCoordinates );
1138 task.SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
1139 func = task.GetScreenToFrameBufferFunction();
1140 DALI_TEST_CHECK( func( coordinates ) );
1142 task.SetScreenToFrameBufferFunction( RenderTask::DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION );
1143 func = task.GetScreenToFrameBufferFunction();
1144 DALI_TEST_CHECK( ! func( coordinates ) );
1148 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionN(void)
1150 TestApplication application;
1152 tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1154 RenderTask task; // Empty handle
1157 task.SetScreenToFrameBufferFunction( TestScreenToFrameBufferFunction );
1159 catch (Dali::DaliException(e))
1161 DALI_TEST_PRINT_ASSERT( e );
1162 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1167 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionP(void)
1169 TestApplication application;
1171 tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction()");
1173 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1175 RenderTask task = taskList.GetTask( 0u );
1177 Vector2 originalCoordinates( 5, 10 );
1178 Vector2 coordinates( 5, 10 );
1180 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1181 DALI_TEST_CHECK( !func( coordinates ) ); // conversion should fail by default
1182 DALI_TEST_CHECK( coordinates == originalCoordinates ); // coordinates should not be modified
1186 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionN(void)
1188 TestApplication application;
1190 tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction() on empty handle");
1195 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1198 catch (Dali::DaliException(e))
1200 DALI_TEST_PRINT_ASSERT( e );
1201 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1207 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorP(void)
1209 TestApplication application;
1210 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor ");
1212 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1213 RenderTask renderTask = taskList.CreateTask();
1214 Actor mappingActor = Actor::New();
1215 renderTask.SetScreenToFrameBufferMappingActor(mappingActor);
1217 DALI_TEST_EQUALS( mappingActor, renderTask.GetScreenToFrameBufferMappingActor(), TEST_LOCATION );
1222 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorN(void)
1224 TestApplication application;
1225 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1231 task.SetScreenToFrameBufferMappingActor(mappingActor);
1233 catch (Dali::DaliException(e))
1235 DALI_TEST_PRINT_ASSERT( e );
1236 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1241 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActor02N(void)
1243 TestApplication application;
1244 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1246 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1247 RenderTask renderTask = taskList.CreateTask();
1249 renderTask.SetScreenToFrameBufferMappingActor(actor);
1251 DALI_TEST_EQUALS( (bool)renderTask.GetScreenToFrameBufferMappingActor(), false, TEST_LOCATION);
1255 int UtcDaliRenderTaskGetViewportP01(void)
1257 TestApplication application;
1259 tet_infoline("Testing RenderTask::GetViewport() on default task");
1261 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1262 RenderTask task = taskList.GetTask( 0u );
1263 Viewport viewport = task.GetViewport();
1265 // By default the viewport should match the stage width/height
1266 Vector2 stageSize = Stage::GetCurrent().GetSize();
1267 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1268 DALI_TEST_CHECK( viewport == expectedViewport );
1272 int UtcDaliRenderTaskGetViewportP02(void)
1274 TestApplication application;
1276 tet_infoline("Testing RenderTask::GetViewport() on new task");
1278 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1279 RenderTask task = taskList.CreateTask();
1280 Viewport viewport = task.GetViewport();
1282 // By default the viewport should match the stage width/height
1283 Vector2 stageSize = Stage::GetCurrent().GetSize();
1284 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1285 DALI_TEST_CHECK( viewport == expectedViewport );
1289 int UtcDaliRenderTaskGetViewportN(void)
1291 TestApplication application;
1293 tet_infoline("Testing RenderTask::GetViewport() on empty handle");
1298 Viewport viewport = task.GetViewport();
1299 viewport = viewport;
1301 catch (Dali::DaliException(e))
1303 DALI_TEST_PRINT_ASSERT( e );
1304 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1310 int UtcDaliRenderTaskSetViewportP(void)
1312 TestApplication application;
1314 tet_infoline("Testing RenderTask::SetViewport()");
1316 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1318 RenderTask task = taskList.GetTask( 0u );
1319 Vector2 stageSize = Stage::GetCurrent().GetSize();
1320 Viewport newViewport( 0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f );
1321 task.SetViewport( newViewport );
1323 // Update (viewport is a property)
1324 application.SendNotification();
1325 application.Render();
1327 DALI_TEST_CHECK( task.GetViewport() == newViewport );
1331 int UtcDaliRenderTaskSetViewportN(void)
1333 TestApplication application;
1335 tet_infoline("Testing RenderTask::SetViewport()");
1337 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1342 Vector2 stageSize = Stage::GetCurrent().GetSize();
1343 Viewport newViewport( 0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f );
1344 task.SetViewport( newViewport );
1346 catch (Dali::DaliException(e))
1348 DALI_TEST_PRINT_ASSERT( e );
1349 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1356 int UtcDaliRenderTaskSetViewportPosition(void)
1358 TestApplication application;
1360 tet_infoline("Testing RenderTask::SetViewportPosition()");
1362 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1364 RenderTask task = taskList.GetTask( 0u );
1366 Viewport viewport = task.GetViewport();
1368 // By default the viewport should match the stage width/height
1370 Vector2 stageSize = Stage::GetCurrent().GetSize();
1371 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1372 DALI_TEST_CHECK( viewport == expectedViewport );
1375 Vector2 newPosition(25.0f, 50.0f);
1376 task.SetViewportPosition( newPosition );
1378 // Update (viewport is a property)
1379 application.SendNotification();
1380 application.Render();
1382 DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1384 // Set by Property test
1385 Vector2 newPosition2(32.0f, 32.0f);
1386 task.SetProperty( RenderTask::Property::VIEWPORT_POSITION, newPosition2 );
1389 application.SendNotification();
1390 application.Render();
1392 DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition2, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1394 Vector2 newPosition3(64.0f, 0.0f);
1395 Animation animation = Animation::New(1.0f);
1396 animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_POSITION ), newPosition3, AlphaFunction::LINEAR );
1399 // Perform 1000ms worth of updates at which point animation should have completed.
1400 Wait(application, 1000);
1401 DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1405 int UtcDaliRenderTaskSetViewportSize(void)
1407 TestApplication application;
1409 tet_infoline("Testing RenderTask::SetViewportSize()");
1411 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1413 RenderTask task = taskList.GetTask( 0u );
1415 Viewport viewport = task.GetViewport();
1417 // By default the viewport should match the stage width/height
1419 Vector2 stageSize = Stage::GetCurrent().GetSize();
1420 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1421 DALI_TEST_CHECK( viewport == expectedViewport );
1423 Vector2 newSize(128.0f, 64.0f);
1424 task.SetViewportSize( newSize );
1426 // Update (viewport is a property)
1427 application.SendNotification();
1428 application.Render();
1430 DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1432 // Set by Property test
1433 Vector2 newSize2(50.0f, 50.0f);
1434 task.SetProperty( RenderTask::Property::VIEWPORT_SIZE, newSize2 );
1437 application.SendNotification();
1438 application.Render();
1440 DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize2, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1442 Vector2 newSize3(10.0f, 10.0f);
1443 Animation animation = Animation::New(1.0f);
1444 animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_SIZE ), newSize3, AlphaFunction::LINEAR );
1447 // Perform 1000ms worth of updates at which point animation should have completed.
1448 Wait(application, 1000);
1449 DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1454 int UtcDaliRenderTaskSetClearColorP(void)
1456 TestApplication application;
1458 tet_infoline("Testing RenderTask::SetClearColor()");
1460 Vector4 testColor( 1.0f, 2.0f, 3.0f, 4.0f );
1461 Vector4 testColor2( 5.0f, 6.0f, 7.0f, 8.0f );
1463 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1465 RenderTask task = taskList.GetTask( 0u );
1466 DALI_TEST_CHECK( task.GetClearColor() != testColor );
1468 task.SetClearColor( testColor );
1473 DALI_TEST_EQUALS( task.GetClearColor(), testColor, TEST_LOCATION );
1475 task.SetProperty( RenderTask::Property::CLEAR_COLOR, testColor2 );
1480 DALI_TEST_EQUALS( task.GetClearColor(), testColor2, TEST_LOCATION );
1484 int UtcDaliRenderTaskSetClearColorN(void)
1486 TestApplication application;
1488 tet_infoline("Testing RenderTask::SetClearColor() on empty handle");
1493 task.SetClearColor( Vector4::ZERO );
1495 catch (Dali::DaliException(e))
1497 DALI_TEST_PRINT_ASSERT( e );
1498 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1503 int UtcDaliRenderTaskGetClearColorP(void)
1505 TestApplication application;
1507 tet_infoline("Testing RenderTask::GetClearColor()");
1509 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1510 RenderTask task = taskList.GetTask( 0u );
1511 DALI_TEST_EQUALS( task.GetClearColor(), RenderTask::DEFAULT_CLEAR_COLOR, TEST_LOCATION );
1515 int UtcDaliRenderTaskGetClearColorN(void)
1517 TestApplication application;
1519 tet_infoline("Testing RenderTask::GetClearColor()");
1524 Vector4 color = task.GetClearColor();
1527 catch (Dali::DaliException(e))
1529 DALI_TEST_PRINT_ASSERT( e );
1530 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1535 int UtcDaliRenderTaskSetClearEnabledP(void)
1537 TestApplication application;
1539 tet_infoline("Testing RenderTask::SetClearEnabled()");
1541 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1543 RenderTask task = taskList.GetTask( 0u );
1544 DALI_TEST_CHECK( !task.GetClearEnabled() ); // defaults to false
1546 task.SetClearEnabled( true );
1547 DALI_TEST_EQUALS( task.GetClearEnabled(), true, TEST_LOCATION );
1549 task.SetClearEnabled( false );
1550 DALI_TEST_EQUALS( task.GetClearEnabled(), false, TEST_LOCATION );
1554 int UtcDaliRenderTaskSetClearEnabledN(void)
1556 TestApplication application;
1558 tet_infoline("Testing RenderTask::SetClearEnabled() with empty handle");
1563 task.SetClearEnabled(true);
1565 catch (Dali::DaliException(e))
1567 DALI_TEST_PRINT_ASSERT( e );
1568 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1573 int UtcDaliRenderTaskGetClearEnabledP(void)
1575 TestApplication application;
1577 tet_infoline("Testing RenderTask::GetClearEnabled()");
1579 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1581 RenderTask task = taskList.GetTask( 0u );
1582 DALI_TEST_CHECK( !task.GetClearEnabled() ); // defaults to false
1587 int UtcDaliRenderTaskGetClearEnabledN(void)
1589 TestApplication application;
1591 tet_infoline("Testing RenderTask::GetClearEnabled() with empty handle");
1596 bool x = task.GetClearEnabled();
1599 catch (Dali::DaliException(e))
1601 DALI_TEST_PRINT_ASSERT( e );
1602 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1607 int UtcDaliRenderTaskSetCullModeP(void)
1609 TestApplication application;
1611 tet_infoline("Testing RenderTask::SetCullMode()");
1613 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1614 RenderTask task = taskList.GetTask( 0u );
1615 DALI_TEST_EQUALS( task.GetCullMode(), true, TEST_LOCATION );
1617 task.SetCullMode( false );
1619 DALI_TEST_EQUALS( task.GetCullMode(), false, TEST_LOCATION );
1624 int UtcDaliRenderTaskSetCullModeN(void)
1626 TestApplication application;
1628 tet_infoline("Testing RenderTask::SetCullMode() on empty handle");
1633 task.SetCullMode( false );
1635 catch (Dali::DaliException(e))
1637 DALI_TEST_PRINT_ASSERT( e );
1638 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1643 int UtcDaliRenderTaskGetCullModeP(void)
1645 TestApplication application;
1647 tet_infoline("Testing RenderTask::GetCullMode()");
1649 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1650 RenderTask task = taskList.GetTask( 0u );
1651 DALI_TEST_EQUALS( task.GetCullMode(), true, TEST_LOCATION );
1655 int UtcDaliRenderTaskGetCullModeN(void)
1657 TestApplication application;
1659 tet_infoline("Testing RenderTask::GetCullMode() with empty handle");
1664 bool x = task.GetCullMode();
1667 catch (Dali::DaliException(e))
1669 DALI_TEST_PRINT_ASSERT( e );
1670 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1676 int UtcDaliRenderTaskSetRefreshRate(void)
1678 TestApplication application;
1680 tet_infoline("Testing RenderTask::SetRefreshRate()");
1682 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1684 // By default tasks will be processed every frame
1685 RenderTask task = taskList.GetTask( 0u );
1686 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1688 task.SetRefreshRate( 2u ); // every-other frame
1689 DALI_TEST_CHECK( 2u == task.GetRefreshRate() );
1691 task.SetRefreshRate( RenderTask::REFRESH_ALWAYS );
1692 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1696 int UtcDaliRenderTaskGetRefreshRate(void)
1698 TestApplication application;
1700 tet_infoline("Testing RenderTask::GetRefreshRate()");
1702 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1704 // By default tasks will be processed every frame
1705 RenderTask task = taskList.GetTask( 0u );
1706 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1708 RenderTask newTask = taskList.CreateTask();
1709 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == newTask.GetRefreshRate() );
1713 int UtcDaliRenderTaskSignalFinished(void)
1715 TestApplication application;
1717 tet_infoline("Testing RenderTask::SignalFinished()");
1719 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1720 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
1722 CameraActor offscreenCameraActor = CameraActor::New();
1724 Stage::GetCurrent().Add( offscreenCameraActor );
1726 BufferImage image = BufferImage::New( 10, 10 );
1727 ImageActor rootActor = ImageActor::New( image );
1728 rootActor.SetSize( 10, 10 );
1729 Stage::GetCurrent().Add( rootActor );
1731 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1732 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
1733 FrameBufferImage frameBufferImage = FrameBufferImage::New( *testNativeImagePtr.Get() );
1735 // Flush all outstanding messages
1736 application.SendNotification();
1737 application.Render();
1739 RenderTask newTask = taskList.CreateTask();
1740 newTask.SetCameraActor( offscreenCameraActor );
1741 newTask.SetSourceActor( rootActor );
1742 newTask.SetInputEnabled( false );
1743 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
1744 newTask.SetClearEnabled( true );
1745 newTask.SetExclusive( true );
1746 newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
1747 newTask.SetTargetFrameBuffer( frameBufferImage );
1749 // Framebuffer doesn't actually get created until Connected, i.e. by previous line
1751 bool finished = false;
1752 RenderTaskFinished renderTaskFinished( finished );
1753 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1755 // Flush the queue and render.
1756 application.SendNotification();
1758 // 1 render to process render task, then wait for sync before finished msg is sent
1759 // from update to the event thread.
1761 application.Render();
1762 application.SendNotification();
1763 DALI_TEST_CHECK( !finished );
1765 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
1766 DALI_TEST_CHECK( lastSyncObj != NULL );
1768 application.Render();
1769 DALI_TEST_EQUALS( (application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
1770 application.SendNotification();
1771 DALI_TEST_CHECK( !finished );
1773 application.Render();
1774 DALI_TEST_EQUALS( (application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
1775 application.SendNotification();
1776 DALI_TEST_CHECK( ! finished );
1778 sync.SetObjectSynced( lastSyncObj, true );
1780 application.Render();
1781 application.SendNotification();
1782 DALI_TEST_CHECK( !finished );
1784 application.Render();
1785 application.SendNotification();
1786 DALI_TEST_CHECK( finished );
1789 application.Render(); // Double check no more finished signal
1790 application.SendNotification();
1791 DALI_TEST_CHECK( ! finished );
1796 int UtcDaliRenderTaskContinuous01(void)
1798 TestApplication application;
1800 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not staged)\nPOST:continuous renders, no Finished signal");
1802 // SETUP AN OFFSCREEN RENDER TASK
1803 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1804 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1805 drawTrace.Enable(true);
1807 Actor rootActor = Actor::New();
1808 Stage::GetCurrent().Add( rootActor );
1810 CameraActor offscreenCameraActor = CameraActor::New();
1811 Stage::GetCurrent().Add( offscreenCameraActor );
1813 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1814 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1815 Integration::ResourceId imageRequestId = imageRequest->GetId();
1816 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1818 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1819 bool finished = false;
1820 RenderTaskFinished renderTaskFinished( finished );
1821 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1822 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1823 application.SendNotification();
1825 // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating
1826 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false ) );
1827 application.GetPlatform().ClearReadyResources();
1829 // ADD SOURCE ACTOR TO STAGE - expect continuous renders to start, no finished signal
1830 Stage::GetCurrent().Add(secondRootActor);
1831 application.SendNotification();
1833 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1834 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
1839 int UtcDaliRenderTaskContinuous02(void)
1841 TestApplication application;
1843 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not visible)\nPOST:continuous renders, no Finished signal");
1845 // SETUP AN OFFSCREEN RENDER TASK
1846 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1847 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1848 drawTrace.Enable(true);
1850 Actor rootActor = Actor::New();
1851 Stage::GetCurrent().Add( rootActor );
1853 CameraActor offscreenCameraActor = CameraActor::New();
1854 Stage::GetCurrent().Add( offscreenCameraActor );
1856 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1857 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1858 Integration::ResourceId imageRequestId = imageRequest->GetId();
1859 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1860 Stage::GetCurrent().Add(secondRootActor);
1861 secondRootActor.SetVisible(false);
1863 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1864 bool finished = false;
1865 RenderTaskFinished renderTaskFinished( finished );
1866 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1867 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1868 application.SendNotification();
1870 // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating
1871 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false ) );
1872 application.GetPlatform().ClearReadyResources();
1874 // MAKE SOURCE ACTOR VISIBLE - expect continuous renders to start, no finished signal
1875 secondRootActor.SetVisible(true);
1876 application.SendNotification();
1878 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1879 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
1883 int UtcDaliRenderTaskContinuous03(void)
1885 TestApplication application;
1887 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (camera actor not staged)\nPOST:continuous renders, no Finished signal");
1889 // SETUP AN OFFSCREEN RENDER TASK
1890 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1891 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1892 drawTrace.Enable(true);
1894 Actor rootActor = Actor::New();
1895 Stage::GetCurrent().Add( rootActor );
1897 CameraActor offscreenCameraActor = CameraActor::New();
1898 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1899 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1900 Integration::ResourceId imageRequestId = imageRequest->GetId();
1901 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1902 Stage::GetCurrent().Add(secondRootActor);
1904 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1905 bool finished = false;
1906 RenderTaskFinished renderTaskFinished( finished );
1907 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1908 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1909 application.SendNotification();
1911 // START PROCESS/RENDER Input, Expected Input, Expected
1912 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false ) );
1913 application.GetPlatform().ClearReadyResources();
1915 // ADD CAMERA ACTOR TO STAGE - expect continuous renders to start, no finished signal
1916 Stage::GetCurrent().Add( offscreenCameraActor );
1917 application.SendNotification();
1919 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1920 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
1925 int UtcDaliRenderTaskContinuous04(void)
1927 TestApplication application;
1929 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: Resource not ready\nPOST:continuous renders, no Finished signal");
1931 // SETUP AN OFFSCREEN RENDER TASK
1932 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1933 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1934 drawTrace.Enable(true);
1936 Actor rootActor = Actor::New();
1937 Stage::GetCurrent().Add( rootActor );
1939 CameraActor offscreenCameraActor = CameraActor::New();
1940 Stage::GetCurrent().Add( offscreenCameraActor );
1941 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1942 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1943 Integration::ResourceId imageRequestId = imageRequest->GetId();
1944 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1945 Stage::GetCurrent().Add(secondRootActor);
1947 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1948 bool finished = false;
1949 RenderTaskFinished renderTaskFinished( finished );
1950 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1951 application.SendNotification();
1953 // START PROCESS/RENDER Input, Expected Input, Expected
1954 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
1955 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
1957 // FINISH RESOURCE LOADING - expect 'continuous' renders to start, no finished signal
1958 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1959 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
1964 int UtcDaliRenderTaskOnce01(void)
1966 TestApplication application;
1968 tet_infoline("Testing RenderTask Render Once GlSync, using loading image\nPRE: Resources not ready, Source not visible\nPOST: Finished signal sent once only");
1970 // SETUP AN OFFSCREEN RENDER TASK
1971 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1972 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
1973 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1974 drawTrace.Enable(true);
1976 Actor rootActor = Actor::New();
1977 Stage::GetCurrent().Add( rootActor );
1979 CameraActor offscreenCameraActor = CameraActor::New();
1980 Stage::GetCurrent().Add( offscreenCameraActor );
1981 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1982 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1983 Integration::ResourceId imageRequestId = imageRequest->GetId();
1984 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1986 Stage::GetCurrent().Add(secondRootActor);
1988 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
1989 bool finished = false;
1990 RenderTaskFinished renderTaskFinished( finished );
1991 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1992 application.SendNotification();
1994 // START PROCESS/RENDER Input, Expected Input, Expected
1995 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
1996 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
1998 // MAKE SOURCE VISIBLE
1999 secondRootActor.SetVisible(true);
2000 application.SendNotification();
2001 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2002 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2004 // FINISH RESOURCE LOADING - expect no rendering yet
2005 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2006 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2007 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2008 DALI_TEST_CHECK( lastSyncObj != NULL );
2010 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2011 application.GetPlatform().ClearReadyResources();
2012 sync.SetObjectSynced( lastSyncObj, true );
2013 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2014 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2018 int UtcDaliRenderTaskOnce02(void)
2020 TestApplication application;
2022 tet_infoline("Testing RenderTask Render Once GlSync, using loading image. Switch from render always after ready to render once\n"
2023 "PRE: Render task ready, Image not loaded\n"
2024 "POST: Finished signal sent only once");
2026 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2027 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2028 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2029 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2030 drawTrace.Enable(true);
2032 Actor rootActor = Actor::New();
2033 Stage::GetCurrent().Add( rootActor );
2035 CameraActor offscreenCameraActor = CameraActor::New();
2036 Stage::GetCurrent().Add( offscreenCameraActor );
2037 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2038 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2039 Integration::ResourceId imageRequestId = imageRequest->GetId();
2040 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2041 Stage::GetCurrent().Add(secondRootActor);
2043 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2044 bool finished = false;
2045 RenderTaskFinished renderTaskFinished( finished );
2046 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2047 application.SendNotification();
2049 // START PROCESS/RENDER Input, Expected Input, Expected
2050 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2051 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2053 // FINISH RESOURCE LOADING
2054 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2055 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
2056 application.GetPlatform().ClearReadyResources();
2057 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
2059 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2060 application.SendNotification(); // Input, Expected Input, Expected
2061 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2062 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2063 DALI_TEST_CHECK( lastSyncObj != NULL );
2065 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2066 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2067 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2068 sync.SetObjectSynced( lastSyncObj, true );
2069 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2070 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2076 int UtcDaliRenderTaskOnce03(void)
2078 TestApplication application;
2080 tet_infoline("Testing RenderTask Render Once GlSync\n"
2081 "Switch from Render always after ready to render once with resources unready\n"
2082 "PRE: Everything ready to render\n"
2083 "POST: Finished signal sent once");
2085 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2086 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2087 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2088 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2089 drawTrace.Enable(true);
2091 Actor rootActor = Actor::New();
2092 Stage::GetCurrent().Add( rootActor );
2094 CameraActor offscreenCameraActor = CameraActor::New();
2095 Stage::GetCurrent().Add( offscreenCameraActor );
2096 ImageActor secondRootActor = 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 Stage::GetCurrent().Add(secondRootActor);
2102 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2103 bool finished = false;
2104 RenderTaskFinished renderTaskFinished( finished );
2105 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2106 application.SendNotification();
2108 // START PROCESS/RENDER Input, Expected Input, Expected
2109 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2110 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2112 // CHANGE TO RENDER ONCE
2113 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2114 application.SendNotification(); // Input, Expected Input, Expected
2115 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2116 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2118 // FINISH RESOURCE LOADING
2119 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2120 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2121 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2122 DALI_TEST_CHECK( lastSyncObj != NULL );
2123 application.GetPlatform().ClearReadyResources();
2125 sync.SetObjectSynced( lastSyncObj, true );
2127 // Expect: No draw - we've just drawn our render task once, above. No finished signal -
2128 // we won't read the gl sync until the next frame. Continue rendering - we're waiting for
2130 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2132 // Expect: 1 final draw - this Update doesn't update the scene, hence render instructions
2133 // from last frame but 1 are still present.
2134 // Finished signal should be true - we've just done the sync.
2135 // Should now stop rendering and updating - nothing left to do.
2136 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, true, false ) );
2142 //int UtcDaliRenderTaskOnce04(void)
2144 TestApplication application;
2146 tet_infoline("Testing RenderTask Render Once GlSync\n"
2147 "During RenderOnce, make ready resources unready before sending first finished signal\n"
2148 "PRE: Everything ready.\n"
2149 "POST: Finished signal sent only once");
2151 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2152 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2153 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2154 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2155 drawTrace.Enable(true);
2157 Actor rootActor = Actor::New();
2158 Stage::GetCurrent().Add( rootActor );
2160 CameraActor offscreenCameraActor = CameraActor::New();
2161 Stage::GetCurrent().Add( offscreenCameraActor );
2162 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2163 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2164 Integration::ResourceId imageRequestId = imageRequest->GetId();
2165 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2166 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2167 application.Render();
2169 Stage::GetCurrent().Add(secondRootActor);
2170 application.GetPlatform().ClearReadyResources();
2172 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2173 bool finished = false;
2174 RenderTaskFinished renderTaskFinished( finished );
2175 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2176 application.SendNotification();
2178 // START PROCESS/RENDER Input, Expected Input, Expected
2179 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2180 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2182 // CHANGE TO RENDER ONCE, RESOURCES BECOME NOT READY
2183 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2186 ReloadImage(application, secondRootActor.GetImage());
2187 application.SendNotification(); // Input, Expected Input, Expected
2189 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2190 DALI_TEST_EQUALS( secondRootActor.GetImage().GetLoadingState(), Dali::ResourceLoading, TEST_LOCATION);
2191 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2193 // FINISH RESOURCE LOADING
2194 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2195 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2196 application.GetPlatform().ClearReadyResources();
2197 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2198 DALI_TEST_CHECK( lastSyncObj != NULL );
2200 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2201 sync.SetObjectSynced( lastSyncObj, true );
2202 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2203 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, true ) );
2205 // Finished rendering - expect no more renders, no more signals:
2206 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2207 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2208 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2209 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2210 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2211 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2216 int UtcDaliRenderTaskOnce05(void)
2218 TestApplication application;
2220 tet_infoline("Testing RenderTask Render Once GLSync\n"
2221 "Render once, Second call to SetRefreshRate(ONCE) triggers only one more finished signal\n"
2222 "PRE: Everything ready\n"
2223 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
2225 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2226 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2227 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2228 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2229 drawTrace.Enable(true);
2231 Actor rootActor = Actor::New();
2232 Stage::GetCurrent().Add( rootActor );
2234 CameraActor offscreenCameraActor = CameraActor::New();
2235 Stage::GetCurrent().Add( offscreenCameraActor );
2236 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2237 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2238 Integration::ResourceId imageRequestId = imageRequest->GetId();
2239 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2240 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2241 application.Render();
2242 application.GetPlatform().ClearReadyResources();
2244 Stage::GetCurrent().Add(secondRootActor);
2246 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2247 bool finished = false;
2248 RenderTaskFinished renderTaskFinished( finished );
2249 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2250 application.SendNotification();
2252 // START PROCESS/RENDER Input, Expected Input, Expected
2253 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
2255 // CHANGE TO RENDER ONCE,
2256 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2257 application.SendNotification();
2258 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2259 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2260 DALI_TEST_CHECK( lastSyncObj != NULL );
2262 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2263 sync.SetObjectSynced( lastSyncObj, true );
2264 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2265 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2267 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2268 application.SendNotification();
2269 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2270 lastSyncObj = sync.GetLastSyncObject();
2271 DALI_TEST_CHECK( lastSyncObj != NULL );
2273 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2274 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2275 sync.SetObjectSynced( lastSyncObj, true );
2276 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2277 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2281 int UtcDaliRenderTaskOnce06(void)
2283 TestApplication application;
2285 tet_infoline("Testing RenderTask Render Once GLSync\n"
2286 "Render once, Call to SetRefreshRate(ONCE) in Finished signal callback triggers "
2287 "another render & another finished signal\n"
2288 "PRE: Everything ready\n"
2289 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
2292 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2293 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2294 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2295 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2296 drawTrace.Enable(true);
2298 Actor rootActor = Actor::New();
2299 Stage::GetCurrent().Add( rootActor );
2301 CameraActor offscreenCameraActor = CameraActor::New();
2302 Stage::GetCurrent().Add( offscreenCameraActor );
2303 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2304 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2305 Integration::ResourceId imageRequestId = imageRequest->GetId();
2306 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2307 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2308 application.Render();
2309 application.GetPlatform().ClearReadyResources();
2311 Stage::GetCurrent().Add(secondRootActor);
2313 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2314 bool finished = false;
2316 ConnectionTracker connectionTracker;
2317 RenderTaskFinishedRenderAgain renderTaskFinishedRenderAgain( finished );
2318 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinishedRenderAgain );
2320 application.SendNotification();
2322 // START PROCESS/RENDER Input, Expected Input, Expected
2323 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
2324 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2325 DALI_TEST_CHECK( lastSyncObj == NULL );
2327 // CHANGE TO RENDER ONCE,
2328 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2329 application.SendNotification();
2330 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2331 lastSyncObj = sync.GetLastSyncObject();
2332 DALI_TEST_CHECK( lastSyncObj != NULL );
2334 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2335 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2337 sync.SetObjectSynced( lastSyncObj, true );
2338 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2339 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2340 application.SendNotification();
2342 // Expect SetRefreshRate to have been called again
2343 // Prevent next finished signal calling refresh once again
2344 RenderTaskFinished renderTaskFinished( finished );
2345 connectionTracker.DisconnectAll();
2346 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinished );
2347 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2348 lastSyncObj = sync.GetLastSyncObject();
2349 DALI_TEST_CHECK( lastSyncObj != NULL );
2351 sync.SetObjectSynced( lastSyncObj, true );
2352 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2353 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2358 int UtcDaliRenderTaskOnce07(void)
2360 TestApplication application;
2362 tet_infoline("Testing RenderTask Render Once GlSync\n"
2363 "SetRefreshRate(ONCE) again before first finished signal has been sent.\n"
2364 "PRE: resources ready\n"
2365 "POST: Only 1 finished signal sent.");
2367 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2368 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2369 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2370 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2371 drawTrace.Enable(true);
2373 Actor rootActor = Actor::New();
2374 Stage::GetCurrent().Add( rootActor );
2376 CameraActor offscreenCameraActor = CameraActor::New();
2377 Stage::GetCurrent().Add( offscreenCameraActor );
2378 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2379 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2380 Integration::ResourceId imageRequestId = imageRequest->GetId();
2381 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2382 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2383 application.Render();
2384 application.GetPlatform().ClearReadyResources();
2386 Stage::GetCurrent().Add(secondRootActor);
2388 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2389 bool finished = false;
2390 RenderTaskFinished renderTaskFinished( finished );
2391 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2392 application.SendNotification();
2394 // START PROCESS/RENDER Input, Expected Input, Expected
2395 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
2397 // CHANGE TO RENDER ONCE,
2398 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2399 application.SendNotification();
2400 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2401 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2402 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2404 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2405 application.SendNotification();
2406 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2407 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2408 DALI_TEST_CHECK( lastSyncObj != NULL );
2410 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2411 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2412 sync.SetObjectSynced( lastSyncObj, true );
2413 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2414 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2421 int UtcDaliRenderTaskOnce08(void)
2423 TestApplication application;
2425 tet_infoline("Testing RenderTask Render Once GlSync\n"
2426 "SetRefreshRate(ONCE), resource load failed completes render task.\n"
2427 "PRE: resources not ready\n"
2428 "POST: Only 1 finished signal sent.");
2430 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2431 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2432 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2433 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2434 drawTrace.Enable(true);
2436 Actor rootActor = Actor::New();
2437 Stage::GetCurrent().Add( rootActor );
2439 CameraActor offscreenCameraActor = CameraActor::New();
2440 Stage::GetCurrent().Add( offscreenCameraActor );
2441 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2442 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2443 Integration::ResourceId imageRequestId = imageRequest->GetId();
2444 Stage::GetCurrent().Add(secondRootActor);
2446 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2447 bool finished = false;
2448 RenderTaskFinished renderTaskFinished( finished );
2449 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2450 application.SendNotification();
2452 // START PROCESS/RENDER Input, Expected Input, Expected
2453 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2454 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2456 // CHANGE TO RENDER ONCE,
2457 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2458 application.SendNotification();
2459 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2460 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2461 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2463 tet_printf(" FailImageLoad\n");
2465 FailImageLoad(application, imageRequestId); // Need to run Update again for this to complete
2467 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) ); // nothing to draw
2468 application.SendNotification();
2470 // Drawing empty framebuffer, so will still get a GL sync
2471 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2472 DALI_TEST_CHECK( lastSyncObj != NULL );
2474 sync.SetObjectSynced( lastSyncObj, true );
2476 // Expect finished signal, as all resources are complete
2477 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2478 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2485 int UtcDaliRenderTaskOnceNoSync01(void)
2487 TestApplication application;
2489 tet_infoline("Testing RenderTask Render Once, using loading image\nPRE: Resources not ready, Source not visible\nPOST: Finished signal sent once only");
2491 // SETUP AN OFFSCREEN RENDER TASK
2492 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2493 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2494 drawTrace.Enable(true);
2496 Actor rootActor = Actor::New();
2497 Stage::GetCurrent().Add( rootActor );
2499 CameraActor offscreenCameraActor = CameraActor::New();
2500 Stage::GetCurrent().Add( offscreenCameraActor );
2501 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2502 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2503 Integration::ResourceId imageRequestId = imageRequest->GetId();
2504 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2506 Stage::GetCurrent().Add(secondRootActor);
2508 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2509 bool finished = false;
2510 RenderTaskFinished renderTaskFinished( finished );
2511 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2512 application.SendNotification();
2514 // START PROCESS/RENDER Input, Expected Input, Expected
2515 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2516 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2518 // FINISH RESOURCE LOADING - expect immediate rendering yet
2519 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2520 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2521 application.GetPlatform().ClearReadyResources();
2522 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2526 int UtcDaliRenderTaskOnceNoSync02(void)
2528 TestApplication application;
2530 tet_infoline("Testing RenderTask Render Once, using loading image. Switch from render always after ready to render once\n"
2531 "PRE: Render task ready, Image not loaded\n"
2532 "POST: Finished signal sent only once");
2534 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2535 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2536 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2537 drawTrace.Enable(true);
2539 Actor rootActor = Actor::New();
2540 Stage::GetCurrent().Add( rootActor );
2542 CameraActor offscreenCameraActor = CameraActor::New();
2543 Stage::GetCurrent().Add( offscreenCameraActor );
2544 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2545 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2546 Integration::ResourceId imageRequestId = imageRequest->GetId();
2547 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2548 Stage::GetCurrent().Add(secondRootActor);
2550 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2551 bool finished = false;
2552 RenderTaskFinished renderTaskFinished( finished );
2553 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2554 application.SendNotification();
2556 // START PROCESS/RENDER Input, Expected Input, Expected
2557 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2558 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2560 // FINISH RESOURCE LOADING
2561 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2562 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
2563 application.GetPlatform().ClearReadyResources();
2565 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2566 application.SendNotification(); // Input, Expected Input, Expected
2567 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2568 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2573 int UtcDaliRenderTaskOnceNoSync03(void)
2575 TestApplication application;
2577 tet_infoline("Testing RenderTask Render Once\n"
2578 "Switch from Render always after ready to render once with resources unready\n"
2579 "PRE: Everything ready to render\n"
2580 "POST: Finished signal sent once");
2582 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2583 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2584 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2585 drawTrace.Enable(true);
2587 Actor rootActor = Actor::New();
2588 Stage::GetCurrent().Add( rootActor );
2590 CameraActor offscreenCameraActor = CameraActor::New();
2591 Stage::GetCurrent().Add( offscreenCameraActor );
2592 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2593 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2594 Integration::ResourceId imageRequestId = imageRequest->GetId();
2595 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2596 Stage::GetCurrent().Add(secondRootActor);
2598 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2599 bool finished = false;
2600 RenderTaskFinished renderTaskFinished( finished );
2601 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2602 application.SendNotification();
2604 // START PROCESS/RENDER Input, Expected Input, Expected
2605 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2606 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2608 // CHANGE TO RENDER ONCE
2609 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2610 application.SendNotification(); // Input, Expected Input, Expected
2611 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2612 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2614 // FINISH RESOURCE LOADING
2615 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2616 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2617 application.GetPlatform().ClearReadyResources();
2618 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2623 //int UtcDaliRenderTaskOnceNoSync04(void)
2625 TestApplication application;
2627 tet_infoline("Testing RenderTask Render Once\n"
2628 "During RenderOnce, make ready resources unready before sending first finished signal\n"
2629 "PRE: Everything ready.\n"
2630 "POST: Finished signal sent only once");
2632 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2633 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2634 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2635 drawTrace.Enable(true);
2637 Actor rootActor = Actor::New();
2638 Stage::GetCurrent().Add( rootActor );
2640 CameraActor offscreenCameraActor = CameraActor::New();
2641 Stage::GetCurrent().Add( offscreenCameraActor );
2642 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2643 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2644 Integration::ResourceId imageRequestId = imageRequest->GetId();
2645 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2646 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2647 application.Render();
2648 application.GetPlatform().ClearReadyResources();
2650 Stage::GetCurrent().Add(secondRootActor);
2652 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2653 bool finished = false;
2654 RenderTaskFinished renderTaskFinished( finished );
2655 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2656 application.SendNotification();
2658 // START PROCESS/RENDER Input, Expected Input, Expected
2659 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2660 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
2662 // CHANGE TO RENDER ONCE, RESOURCES BECOME NOT READY
2663 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2666 ReloadImage(application, secondRootActor.GetImage());
2667 application.SendNotification(); // Input, Expected Input, Expected
2669 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2670 DALI_TEST_EQUALS( secondRootActor.GetImage().GetLoadingState(), Dali::ResourceLoading, TEST_LOCATION);
2671 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2673 // FINISH RESOURCE LOADING
2674 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2675 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, true, true ) );
2676 application.GetPlatform().ClearReadyResources();
2677 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2678 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2679 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2680 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2685 int UtcDaliRenderTaskOnceNoSync05(void)
2687 TestApplication application;
2689 tet_infoline("Testing RenderTask Render Once\n"
2690 "Render once, Second call to SetRefreshRate(ONCE) triggers only one more finished signal\n"
2691 "PRE: Everything ready\n"
2692 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
2694 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2695 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2696 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2697 drawTrace.Enable(true);
2699 Actor rootActor = Actor::New();
2700 Stage::GetCurrent().Add( rootActor );
2702 CameraActor offscreenCameraActor = CameraActor::New();
2703 Stage::GetCurrent().Add( offscreenCameraActor );
2704 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2705 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2706 Integration::ResourceId imageRequestId = imageRequest->GetId();
2707 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2708 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2709 application.Render();
2710 application.GetPlatform().ClearReadyResources();
2712 Stage::GetCurrent().Add(secondRootActor);
2714 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2715 bool finished = false;
2716 RenderTaskFinished renderTaskFinished( finished );
2717 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2718 application.SendNotification();
2720 // START PROCESS/RENDER Input, Expected Input, Expected
2721 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
2723 // CHANGE TO RENDER ONCE,
2724 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2725 application.SendNotification();
2726 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2727 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2729 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2730 application.SendNotification();
2731 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2732 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2736 int UtcDaliRenderTaskOnceNoSync06(void)
2738 TestApplication application;
2740 tet_infoline("Testing RenderTask Render Once\n"
2741 "Render once, Call to SetRefreshRate(ONCE) in Finished signal callback triggers\n"
2742 "another render & another finished signal\n"
2743 "PRE: Everything ready\n"
2744 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
2747 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2748 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2749 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2750 drawTrace.Enable(true);
2752 Actor rootActor = Actor::New();
2753 Stage::GetCurrent().Add( rootActor );
2755 CameraActor offscreenCameraActor = CameraActor::New();
2756 Stage::GetCurrent().Add( offscreenCameraActor );
2757 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2758 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2759 Integration::ResourceId imageRequestId = imageRequest->GetId();
2760 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2761 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2762 application.Render();
2763 application.GetPlatform().ClearReadyResources();
2765 Stage::GetCurrent().Add(secondRootActor);
2767 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2768 bool finished = false;
2770 ConnectionTracker connectionTracker;
2771 RenderTaskFinishedRenderAgain renderTaskFinishedRenderAgain( finished );
2772 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinishedRenderAgain );
2774 application.SendNotification();
2776 // START PROCESS/RENDER Input, Expected Input, Expected
2777 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
2779 // CHANGE TO RENDER ONCE,
2780 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2781 application.SendNotification();
2782 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2783 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2785 // Expect SetRefreshRate to have been called again
2786 // Prevent next finished signal calling refresh once again
2787 RenderTaskFinished renderTaskFinished( finished );
2788 connectionTracker.DisconnectAll();
2789 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinished );
2791 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2792 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2797 int UtcDaliRenderTaskOnceNoSync07(void)
2799 TestApplication application;
2801 tet_infoline("Testing RenderTask Render Once\n"
2802 "SetRefreshRate(ONCE) again before first finished signal has been sent.\n"
2803 "PRE: resources ready\n"
2804 "POST: Only 1 finished signal sent.");
2806 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2807 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2808 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2809 drawTrace.Enable(true);
2811 Actor rootActor = Actor::New();
2812 Stage::GetCurrent().Add( rootActor );
2814 CameraActor offscreenCameraActor = CameraActor::New();
2815 Stage::GetCurrent().Add( offscreenCameraActor );
2816 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2817 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2818 Integration::ResourceId imageRequestId = imageRequest->GetId();
2819 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2820 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2821 application.Render();
2822 application.GetPlatform().ClearReadyResources();
2824 Stage::GetCurrent().Add(secondRootActor);
2826 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2827 bool finished = false;
2828 RenderTaskFinished renderTaskFinished( finished );
2829 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2830 application.SendNotification();
2832 // START PROCESS/RENDER Input, Expected Input, Expected
2833 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false ) );
2835 // CHANGE TO RENDER ONCE,
2836 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2837 application.SendNotification();
2838 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2839 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2841 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2842 application.SendNotification();
2843 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
2844 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2848 int UtcDaliRenderTaskOnceNoSync08(void)
2850 TestApplication application;
2852 tet_infoline("Testing RenderTask Render Once\n"
2853 "SetRefreshRate(ONCE), resource load failed, completes render task.\n"
2854 "PRE: resources not ready\n"
2855 "POST: Only 1 finished signal sent.");
2857 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2858 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2859 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2860 drawTrace.Enable(true);
2862 Actor rootActor = Actor::New();
2863 Stage::GetCurrent().Add( rootActor );
2865 CameraActor offscreenCameraActor = CameraActor::New();
2866 Stage::GetCurrent().Add( offscreenCameraActor );
2867 ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2868 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2869 Integration::ResourceId imageRequestId = imageRequest->GetId();
2870 Stage::GetCurrent().Add(secondRootActor);
2872 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2873 bool finished = false;
2874 RenderTaskFinished renderTaskFinished( finished );
2875 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2876 application.SendNotification();
2878 // START PROCESS/RENDER Input, Expected Input, Expected
2879 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2880 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2882 // CHANGE TO RENDER ONCE,
2883 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2884 application.SendNotification();
2885 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2886 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2887 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
2889 FailImageLoad(application, imageRequestId); // Need to run Update again for this to complete
2890 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) ); // nothing to draw
2891 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false ) );
2898 int UtcDaliRenderTaskOnceChain01(void)
2900 TestApplication application;
2902 tet_infoline("Testing RenderTask Render Once Chained render tasks\n"
2903 "SetRefreshRate(ONCE), resource load completes, both render tasks render.\n"
2904 "PRE: resources not ready\n"
2905 "POST: 2 finished signals sent.");
2907 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2908 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2909 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2910 drawTrace.Enable(true);
2912 Actor defaultRootActor = Actor::New(); // Root for default RT
2913 Stage::GetCurrent().Add( defaultRootActor );
2915 CameraActor offscreenCameraActor = CameraActor::New();
2916 Stage::GetCurrent().Add( offscreenCameraActor );
2917 ImageActor firstRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2918 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2919 Integration::ResourceId imageRequestId = imageRequest->GetId();
2920 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2921 Stage::GetCurrent().Add(firstRootActor);
2923 // first render task
2924 RenderTask firstTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, firstRootActor, RenderTask::REFRESH_ONCE, false);
2925 bool firstFinished = false;
2926 RenderTaskFinished renderTask1Finished( firstFinished );
2927 firstTask.FinishedSignal().Connect( &application, renderTask1Finished );
2929 // Second render task
2930 FrameBufferImage fbo = firstTask.GetTargetFrameBuffer();
2931 ImageActor secondRootActor = ImageActor::New( fbo );
2932 Stage::GetCurrent().Add(secondRootActor);
2933 RenderTask secondTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2934 bool secondFinished = false;
2935 RenderTaskFinished renderTask2Finished( secondFinished );
2936 secondTask.FinishedSignal().Connect( &application, renderTask2Finished );
2938 application.SendNotification();
2940 // START PROCESS/RENDER Input, Expected Input, Expected
2941 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true ) );
2942 DALI_TEST_CHECK( secondFinished == false );
2943 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true ) );
2944 DALI_TEST_CHECK( secondFinished == false );
2946 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2947 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true ) );
2948 DALI_TEST_CHECK( secondFinished == false );
2949 application.GetPlatform().ClearReadyResources();
2951 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, firstFinished, true, false ) );
2952 DALI_TEST_CHECK( secondFinished == true );
2957 int UtcDaliRenderTaskProperties(void)
2959 TestApplication application;
2961 RenderTask task = Stage::GetCurrent().GetRenderTaskList().CreateTask();
2963 Property::IndexContainer indices;
2964 task.GetPropertyIndices( indices );
2965 DALI_TEST_CHECK( ! indices.empty() );
2966 DALI_TEST_EQUALS( indices.size(), task.GetPropertyCount(), TEST_LOCATION );
2970 int UtcDaliRenderTaskSetScreenToFrameBufferMappingActor(void)
2972 TestApplication application;
2973 tet_infoline("Testing RenderTask::SetScreenToFrameBufferMappingActor ");
2975 Stage stage = Stage::GetCurrent();
2976 Size stageSize = stage.GetSize();
2977 Actor mappingActor = Actor::New();
2978 Vector2 scale( 0.6f, 0.75f);
2979 Vector2 offset( stageSize.x*0.1f, stageSize.y*0.15f);
2980 mappingActor.SetSize( stageSize * scale );
2981 mappingActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2982 mappingActor.SetPosition( offset.x, offset.y );
2983 stage.Add( mappingActor );
2985 Actor offscreenActor = Actor::New();
2986 offscreenActor.SetSize( stageSize );
2987 offscreenActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2988 stage.Add( offscreenActor );
2990 RenderTaskList taskList = stage.GetRenderTaskList();
2991 RenderTask renderTask = taskList.CreateTask();
2992 FrameBufferImage frameBufferImage = FrameBufferImage::New(stageSize.width*scale.x, stageSize.height*scale.y, Pixel::A8, Image::NEVER);
2993 renderTask.SetSourceActor( offscreenActor );
2994 renderTask.SetExclusive( true );
2995 renderTask.SetInputEnabled( true );
2996 renderTask.SetTargetFrameBuffer( frameBufferImage );
2997 renderTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
2998 renderTask.SetScreenToFrameBufferMappingActor( mappingActor );
2999 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3001 // Render and notify
3002 application.SendNotification();
3003 application.Render();
3004 application.Render();
3005 application.SendNotification();
3007 Vector2 screenCoordinates( stageSize.x * 0.05f, stageSize.y * 0.05f );
3008 Dali::HitTestAlgorithm::Results results;
3009 DALI_TEST_CHECK( !results.actor );
3010 DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
3011 // miss expected, results not changed
3012 DALI_TEST_CHECK( false == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3013 DALI_TEST_CHECK( !results.actor );
3014 DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
3016 screenCoordinates.x = stageSize.x * 0.265f;
3017 screenCoordinates.y = stageSize.y * 0.33f;
3018 results.actor = Actor();
3019 results.actorCoordinates = Vector2::ZERO;
3020 // hit expected, results changed
3021 DALI_TEST_CHECK( true == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3022 DALI_TEST_CHECK( results.actor == offscreenActor );
3023 DALI_TEST_EQUALS( (screenCoordinates-offset)/scale , results.actorCoordinates, 0.1f, TEST_LOCATION );
3025 screenCoordinates.x = stageSize.x * 0.435f;
3026 screenCoordinates.y = stageSize.y * 0.52f;
3027 // hit expected, results changed
3028 DALI_TEST_CHECK( true == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3029 DALI_TEST_CHECK( results.actor == offscreenActor );
3030 const Vector2 expectedCoordinates = (screenCoordinates-offset)/scale;
3031 DALI_TEST_EQUALS( expectedCoordinates , results.actorCoordinates, 0.1f, TEST_LOCATION );
3033 screenCoordinates.x = stageSize.x * 0.65f;
3034 screenCoordinates.y = stageSize.y * 0.95f;
3035 // miss expected, results not changed
3036 DALI_TEST_CHECK( false == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3037 DALI_TEST_CHECK( results.actor == offscreenActor );
3038 DALI_TEST_EQUALS( expectedCoordinates , results.actorCoordinates, 0.1f, TEST_LOCATION );
3042 int UtcDaliRenderTaskFinishInvisibleSourceActor(void)
3044 TestApplication application;
3046 tet_infoline("Testing RenderTask::SignalFinished()");
3048 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3049 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
3051 CameraActor offscreenCameraActor = CameraActor::New();
3053 Stage::GetCurrent().Add( offscreenCameraActor );
3055 BufferImage image = BufferImage::New( 10, 10 );
3056 ImageActor rootActor = ImageActor::New( image );
3057 rootActor.SetSize( 10, 10 );
3058 rootActor.SetVisible(false);
3059 Stage::GetCurrent().Add( rootActor );
3061 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3062 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
3063 FrameBufferImage frameBufferImage = FrameBufferImage::New( *testNativeImagePtr.Get() );
3065 // Flush all outstanding messages
3066 application.SendNotification();
3067 application.Render();
3069 RenderTask newTask = taskList.CreateTask();
3070 newTask.SetCameraActor( offscreenCameraActor );
3071 newTask.SetSourceActor( rootActor );
3072 newTask.SetInputEnabled( false );
3073 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
3074 newTask.SetClearEnabled( true );
3075 newTask.SetExclusive( true );
3076 newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
3077 newTask.SetTargetFrameBuffer( frameBufferImage );
3079 // Framebuffer doesn't actually get created until Connected, i.e. by previous line
3081 bool finished = false;
3082 RenderTaskFinished renderTaskFinished( finished );
3083 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3085 // Flush the queue and render.
3086 application.SendNotification();
3088 // 1 render to process render task, then wait for sync before finished msg is sent
3089 // from update to the event thread.
3091 application.Render();
3092 application.SendNotification();
3093 DALI_TEST_CHECK( !finished );
3095 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
3096 DALI_TEST_CHECK( lastSyncObj != NULL );
3098 application.Render();
3099 DALI_TEST_EQUALS( (application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
3100 application.SendNotification();
3101 DALI_TEST_CHECK( !finished );
3103 application.Render();
3104 DALI_TEST_EQUALS( (application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
3105 application.SendNotification();
3106 DALI_TEST_CHECK( ! finished );
3108 sync.SetObjectSynced( lastSyncObj, true );
3110 application.Render();
3111 application.SendNotification();
3112 DALI_TEST_CHECK( !finished );
3114 application.Render();
3115 application.SendNotification();
3116 DALI_TEST_CHECK( finished );
3119 application.Render(); // Double check no more finished signal
3120 application.SendNotification();
3121 DALI_TEST_CHECK( ! finished );