2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali/public-api/dali-core.h>
22 #include <dali/devel-api/events/hit-test-algorithm.h>
23 #include <dali-test-suite-utils.h>
24 #include <dali/integration-api/debug.h>
25 #include <test-native-image.h>
27 #include <mesh-builder.h>
29 #define BOOLSTR(x) ((x)?"T":"F")
31 //& set: DaliRenderTask
35 void utc_dali_render_task_startup(void)
37 test_return_value = TET_UNDEF;
40 void utc_dali_render_task_cleanup(void)
42 test_return_value = TET_PASS;
48 * Constructor, Destructor, DownCast, New, copy constructor, assignment operator
50 * SetSourceActor 2+ve, 1-ve
51 * GetSourceActor 1+ve, 1-ve
52 * SetExclusive 2+ve, 0-ve
53 * IsExclusive 2+ve, 0-ve
54 * SetInputEnabled 1+ve, 0-ve
55 * GetInputEnabled 1+ve, 0-ve
56 * SetCameraActor 1+ve, 1-ve
57 * GetCameraActor 1+ve, 1-ve
58 * SetTargetFrameBuffer 1+ve, 1-ve
59 * GetTargetFrameBuffer 1+ve, 1-ve
60 * SetScreenToFrameBufferFunction 1+ve, 1-ve
61 * GetScreenToFrameBufferFunction 1+ve, 1-ve
62 * SetScreenToFrameBufferMappingActor 1+ve, 1-ve
63 * GetScreenToFrameBufferMappingActor 1+ve, 1-ve
64 * SetViewportPosition 1+ve
65 * GetCurrentViewportPosition 1+ve
66 * SetViewportSize 1+ve
67 * GetCurrentViewportSize 1+ve
68 * SetViewport 2+ve, 1-ve
69 * GetViewport 2+ve, 1-ve
70 * SetClearColor 1+ve, 1-ve
71 * GetClearColor 1+ve, 1-ve
72 * SetClearEnabled 1+ve, 1-ve
73 * GetClearEnabled 1+ve, 1-ve
81 namespace // unnamed namespace
84 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
87 * Simulate time passed by.
89 * @note this will always process at least 1 frame (1/60 sec)
91 * @param application Test application instance
92 * @param duration Time to pass in milliseconds.
93 * @return The actual time passed in milliseconds
95 int Wait(TestApplication& application, int duration = 0)
99 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
101 application.SendNotification();
102 application.Render(RENDER_FRAME_INTERVAL);
103 time += RENDER_FRAME_INTERVAL;
109 struct RenderTaskFinished
111 RenderTaskFinished( bool& finished )
112 : finished( finished )
116 void operator()( RenderTask& renderTask )
124 struct RenderTaskFinishedRemoveSource
126 RenderTaskFinishedRemoveSource( bool& finished )
127 : finished( finished ),
132 void operator()( RenderTask& renderTask )
134 DALI_TEST_CHECK(finishedOnce == false);
137 Actor srcActor = renderTask.GetSourceActor();
138 UnparentAndReset(srcActor);
145 struct RenderTaskFinishedRenderAgain
147 RenderTaskFinishedRenderAgain( bool& finished )
148 : finished( finished ),
153 void operator()( RenderTask& renderTask )
155 DALI_TEST_CHECK(finishedOnce == false);
158 renderTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
166 bool TestScreenToFrameBufferFunction( Vector2& coordinates )
168 coordinates = coordinates + Vector2( 1, 2 );
173 ImageActor CreateLoadingImageActor(TestApplication& application, std::string filename, ResourceImage::LoadPolicy loadPolicy, Image::ReleasePolicy releasePolicy)
175 Image image = ResourceImage::New(filename, loadPolicy, releasePolicy);
176 DALI_TEST_CHECK( image );
177 application.SendNotification();
178 application.Render(16);
179 DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
180 ImageActor actor = ImageActor::New(image);
181 actor.SetSize( 80, 80 );
182 application.SendNotification();
183 application.Render(16);
187 Image CreateLoadingImage(TestApplication& application, std::string filename, ResourceImage::LoadPolicy loadPolicy, Image::ReleasePolicy releasePolicy)
189 Image image = ResourceImage::New(filename, loadPolicy, releasePolicy);
190 DALI_TEST_CHECK( image );
191 application.SendNotification();
192 application.Render(16);
193 DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
198 void CompleteImageLoad(TestApplication& application, Integration::ResourceId resourceId, Integration::ResourceTypeId requestType)
200 std::vector<GLuint> ids;
202 application.GetGlAbstraction().SetNextTextureIds( ids );
204 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
205 Integration::ResourcePointer resource(bitmap);
206 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80);
208 application.GetPlatform().SetResourceLoaded(resourceId, requestType, resource);
211 void FailImageLoad(TestApplication& application, Integration::ResourceId resourceId )
213 application.GetPlatform().SetResourceLoadFailed(resourceId, Integration::FailureUnknown);
216 void ReloadImage(TestApplication& application, ResourceImage image)
218 application.GetPlatform().ClearReadyResources();
219 application.GetPlatform().DiscardRequest();
220 application.GetPlatform().ResetTrace();
221 application.GetPlatform().SetClosestImageSize(Vector2(80.0f, 80.0f)); // Ensure reload is called.
225 RenderTask CreateRenderTask(TestApplication& application,
226 CameraActor offscreenCamera,
227 Actor rootActor, // Reset default render task to point at this actor
228 Actor secondRootActor, // Source actor
229 unsigned int refreshRate,
232 // Change main render task to use a different root
233 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
234 taskList.GetTask(0u).SetSourceActor( rootActor );
236 FrameBufferImage frameBufferImage;
239 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
240 frameBufferImage= FrameBufferImage::New( *(testNativeImagePtr.Get()) );
244 frameBufferImage = FrameBufferImage::New( 10, 10 );
247 // Don't draw output framebuffer // '
249 RenderTask newTask = taskList.CreateTask();
250 newTask.SetCameraActor( offscreenCamera );
251 newTask.SetSourceActor( secondRootActor );
252 newTask.SetInputEnabled( false );
253 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
254 newTask.SetClearEnabled( true );
255 newTask.SetExclusive( true );
256 newTask.SetRefreshRate( refreshRate );
257 newTask.SetTargetFrameBuffer( frameBufferImage );
258 newTask.SetProperty( RenderTask::Property::REQUIRES_SYNC, glSync );
262 bool UpdateRender(TestApplication& application, TraceCallStack& callStack, bool testDrawn, bool& finishedSig, bool testFinished, bool testKeepUpdating, int lineNumber )
267 tet_printf("TestApplication::UpdateRender().\n");
269 application.Render(16);
270 application.SendNotification();
272 bool sigPassed = false;
275 sigPassed = finishedSig;
279 sigPassed = ! finishedSig;
282 bool drawResult = callStack.FindMethod("DrawElements") || callStack.FindMethod("DrawArrays");
284 bool drawPassed = false;
287 drawPassed = drawResult;
291 drawPassed = !drawResult;
294 bool keepUpdating = (application.GetUpdateStatus() != 0);
295 bool keepUpdatingPassed = false;
296 if( testKeepUpdating )
298 keepUpdatingPassed = keepUpdating;
302 keepUpdatingPassed = !keepUpdating;
305 bool result = (sigPassed && drawPassed && keepUpdatingPassed);
307 tet_printf("UpdateRender: Expected: Draw:%s Signal:%s KeepUpdating: %s Actual: Draw:%s Signal:%s KeepUpdating: %s %s, line %d\n",
308 BOOLSTR(testDrawn), BOOLSTR(testFinished), BOOLSTR(testKeepUpdating),
309 BOOLSTR(drawResult), BOOLSTR(finishedSig), BOOLSTR(keepUpdating),
310 result ? "Passed":"Failed",
316 // The functor to be used in the hit-test algorithm to check whether the actor is hittable.
317 bool IsActorHittableFunction(Actor actor, Dali::HitTestAlgorithm::TraverseType type)
319 bool hittable = false;
323 case Dali::HitTestAlgorithm::CHECK_ACTOR:
325 // Check whether the actor is visible and not fully transparent.
326 if( actor.IsVisible()
327 && actor.GetCurrentWorldColor().a > 0.01f) // not FULLY_TRANSPARENT
334 case Dali::HitTestAlgorithm::DESCEND_ACTOR_TREE:
336 if( actor.IsVisible() ) // Actor is visible, if not visible then none of its children are visible.
351 } // unnamed namespace
354 /****************************************************************************************************/
355 /****************************************************************************************************/
356 /******************************** TEST CASES BELOW **********************************************/
357 /****************************************************************************************************/
358 /****************************************************************************************************/
360 int UtcDaliRenderTaskDownCast01(void)
362 TestApplication application;
364 tet_infoline("Testing RenderTask::DownCast()");
366 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
368 BaseHandle base = taskList.GetTask( 0u );
369 DALI_TEST_CHECK( base );
371 RenderTask task = RenderTask::DownCast( base );
372 DALI_TEST_CHECK( task );
374 // Try calling a method
375 DALI_TEST_CHECK( task.GetSourceActor() );
379 int UtcDaliRenderTaskDownCast02(void)
381 TestApplication application;
383 tet_infoline("Testing RenderTask::DownCast()");
385 Actor actor = Actor::New();
387 RenderTask task = RenderTask::DownCast( actor );
388 DALI_TEST_CHECK( ! task );
393 int UtcDaliRenderTaskSetSourceActorN(void)
395 TestApplication application;
396 tet_infoline("Testing RenderTask::SetSourceActor() Negative - try with empty actor handle");
397 Stage stage = Stage::GetCurrent();
401 RenderTaskList taskList = stage.GetRenderTaskList();
402 RenderTask renderTask = taskList.CreateTask();
403 renderTask.SetSourceActor(srcActor);
405 application.SendNotification();
406 application.Render();
408 DALI_TEST_CHECK( ! renderTask.GetSourceActor() );
413 int UtcDaliRenderTaskSetSourceActorP01(void)
415 TestApplication application;
417 tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that setting a non-renderable actor stops existing source actor being rendered ");
419 Stage stage = Stage::GetCurrent();
421 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
423 RenderTaskList taskList = stage.GetRenderTaskList();
425 RenderTask task = taskList.GetTask( 0u );
427 Actor actor = task.GetSourceActor();
428 DALI_TEST_CHECK( actor );
430 std::vector<GLuint> ids;
432 application.GetGlAbstraction().SetNextTextureIds( ids );
434 BufferImage img = BufferImage::New( 1,1 );
435 ImageActor newActor = ImageActor::New( img );
436 newActor.SetSize(1,1);
437 stage.Add( newActor );
439 Actor nonRenderableActor = Actor::New();
440 stage.Add( nonRenderableActor );
442 // Stop the newActor from being rendered by changing the source actor
443 DALI_TEST_CHECK( nonRenderableActor );
444 task.SetSourceActor( nonRenderableActor );
445 DALI_TEST_CHECK( task.GetSourceActor() != actor );
446 DALI_TEST_CHECK( task.GetSourceActor() == nonRenderableActor );
448 // Update & Render nothing!
449 application.GetGlAbstraction().ClearBoundTextures();
450 application.SendNotification();
451 application.Render();
453 // Check that nothing was rendered
454 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
460 int UtcDaliRenderTaskSetSourceActorP02(void)
462 TestApplication application;
464 tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that switching source from a non-renderable to a renderable actor causes the texture to be drawn");
466 Stage stage = Stage::GetCurrent();
468 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
470 RenderTaskList taskList = stage.GetRenderTaskList();
472 RenderTask task = taskList.GetTask( 0u );
474 Actor actor = task.GetSourceActor();
475 DALI_TEST_CHECK( actor );
477 std::vector<GLuint> ids;
479 application.GetGlAbstraction().SetNextTextureIds( ids );
481 BufferImage img = BufferImage::New( 1,1 );
482 ImageActor newActor = ImageActor::New( img );
483 newActor.SetSize(1,1);
484 stage.Add( newActor );
486 Actor nonRenderableActor = Actor::New();
487 stage.Add( nonRenderableActor );
489 // Stop the newActor from being rendered by changing the source actor
490 DALI_TEST_CHECK( nonRenderableActor );
491 task.SetSourceActor( nonRenderableActor );
492 DALI_TEST_CHECK( task.GetSourceActor() != actor );
493 DALI_TEST_CHECK( task.GetSourceActor() == nonRenderableActor );
495 // Update & Render nothing!
496 application.GetGlAbstraction().ClearBoundTextures();
497 application.SendNotification();
498 application.Render();
500 // Check that nothing was rendered
501 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
503 // Set newActor as the new source Actor
504 task.SetSourceActor( newActor );
505 DALI_TEST_CHECK( task.GetSourceActor() != actor );
506 DALI_TEST_CHECK( task.GetSourceActor() == newActor );
508 // Update & Render the newActor
509 application.GetGlAbstraction().ClearBoundTextures();
510 application.SendNotification();
511 application.Render();
513 // Check that the newActor was rendered
514 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
515 if ( boundTextures.size() )
517 DALI_TEST_EQUALS( boundTextures[0], 7u, TEST_LOCATION );
522 int UtcDaliRenderTaskSetSourceActorOffStage(void)
524 TestApplication application;
526 tet_infoline("Testing RenderTask::SetSourceActor (on/off stage testing)");
528 Stage stage = Stage::GetCurrent();
530 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
532 RenderTaskList taskList = stage.GetRenderTaskList();
534 RenderTask task = taskList.GetTask( 0u );
536 Actor actor = task.GetSourceActor();
537 DALI_TEST_CHECK( actor );
539 std::vector<GLuint> ids;
540 GLuint expectedTextureId( 3 );
541 ids.push_back( expectedTextureId );
542 application.GetGlAbstraction().SetNextTextureIds( ids );
544 BufferImage img = BufferImage::New( 1,1 );
545 ImageActor newActor = ImageActor::New( img );
546 newActor.SetSize(1,1);
547 task.SetSourceActor( newActor );
548 // Don't add newActor to stage yet //'
550 // Update & Render with the actor initially off-stage
551 application.GetGlAbstraction().ClearBoundTextures();
552 application.SendNotification();
553 application.Render();
555 // Check that nothing was rendered
556 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
559 stage.Add( newActor );
561 // Update & Render with the actor on-stage
562 application.GetGlAbstraction().ClearBoundTextures();
563 application.SendNotification();
564 application.Render();
566 // Check that the newActor was rendered
567 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
568 if ( boundTextures.size() )
570 DALI_TEST_EQUALS( boundTextures[0], expectedTextureId, TEST_LOCATION );
573 // Now remove from stage
574 stage.Remove( newActor );
576 // Update & Render with the actor off-stage
577 application.GetGlAbstraction().ClearBoundTextures();
578 application.SendNotification();
579 application.Render();
583 int UtcDaliRenderTaskSetSourceActorEmpty(void)
585 TestApplication application;
587 tet_infoline("Testing RenderTask::SetSourceActor (empty handle case)");
589 Stage stage = Stage::GetCurrent();
591 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
593 RenderTaskList taskList = stage.GetRenderTaskList();
595 RenderTask task = taskList.GetTask( 0u );
597 Actor actor = task.GetSourceActor();
598 DALI_TEST_CHECK( actor );
600 std::vector<GLuint> ids;
601 GLuint expectedTextureId( 5 );
602 ids.push_back( expectedTextureId );
603 application.GetGlAbstraction().SetNextTextureIds( ids );
605 BufferImage img = BufferImage::New( 1,1 );
606 ImageActor newActor = ImageActor::New( img );
607 newActor.SetSize(1,1);
608 stage.Add( newActor );
610 Actor nonRenderableActor = Actor::New();
611 stage.Add( nonRenderableActor );
613 // Set with empty handle
614 task.SetSourceActor( Actor() );
615 DALI_TEST_CHECK( ! task.GetSourceActor() );
617 // Update & Render nothing!
618 application.GetGlAbstraction().ClearBoundTextures();
619 application.SendNotification();
620 application.Render();
622 // Check that nothing was rendered
623 DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
625 // Set with non-empty handle
626 task.SetSourceActor( newActor );
627 DALI_TEST_CHECK( task.GetSourceActor() == newActor );
629 // Update & Render the newActor
630 application.GetGlAbstraction().ClearBoundTextures();
631 application.SendNotification();
632 application.Render();
634 // Check that the newActor was rendered
635 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
636 if ( boundTextures.size() )
638 DALI_TEST_EQUALS( boundTextures[0], expectedTextureId, TEST_LOCATION );
643 int UtcDaliRenderTaskGetSourceActorP01(void)
645 TestApplication application;
647 tet_infoline("Testing RenderTask::GetSourceActor() Check the default render task has a valid source actor");
649 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
651 RenderTask task = taskList.GetTask( 0u );
653 Actor actor = task.GetSourceActor();
654 DALI_TEST_CHECK( actor );
656 // By default the entire scene should be rendered
657 Actor root = Stage::GetCurrent().GetLayer( 0 );
658 DALI_TEST_CHECK( root == actor );
662 int UtcDaliRenderTaskGetSourceActorP02(void)
664 TestApplication application;
666 tet_infoline("Testing RenderTask::GetSourceActor() Create a new render task, Add a new actor to the stage and set it as the source of the new render task. Get its source actor and check that it is equivalent to what was set.");
668 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
669 RenderTask task = taskList.CreateTask();
670 Actor actor = Actor::New();
671 Stage::GetCurrent().Add(actor);
672 task.SetSourceActor( actor );
674 DALI_TEST_EQUALS( actor, task.GetSourceActor(), TEST_LOCATION );
679 int UtcDaliRenderTaskGetSourceActorN(void)
681 TestApplication application;
683 tet_infoline("Testing RenderTask::GetSourceActor() Try with empty handle");
688 Actor actor = task.GetSourceActor();
690 catch (Dali::DaliException(e))
692 DALI_TEST_PRINT_ASSERT( e );
693 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
699 int UtcDaliRenderTaskSetExclusive(void)
701 TestApplication application;
703 tet_infoline("Testing RenderTask::SetExclusive() Check that exclusion works");
705 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
707 // Manipulate the GenTextures behaviour, to identify different ImageActors
709 std::vector<GLuint> ids;
710 ids.push_back( 8 ); // 8 = actor1
711 ids.push_back( 9 ); // 9 = actor2
712 ids.push_back( 10 ); // 10 = actor3
713 application.GetGlAbstraction().SetNextTextureIds( ids );
715 BufferImage img1 = BufferImage::New( 1,1 );
716 ImageActor actor1 = ImageActor::New( img1 );
718 Stage::GetCurrent().Add( actor1 );
720 // Update & Render actor1
721 application.SendNotification();
722 application.Render();
724 // Check that the actor1 was rendered
725 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
726 DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
728 if ( boundTextures.size() )
730 DALI_TEST_EQUALS( boundTextures[0], 8u/*unique to actor1*/, TEST_LOCATION );
733 BufferImage img2 = BufferImage::New( 1,1 );
734 ImageActor actor2 = ImageActor::New( img2 );
737 // Force actor2 to be rendered before actor1
738 Layer layer = Layer::New();
739 Stage::GetCurrent().Add( layer );
741 layer.LowerToBottom();
744 application.GetGlAbstraction().ClearBoundTextures();
745 application.SendNotification();
746 application.Render();
748 // Check that the actors were rendered
749 DALI_TEST_EQUALS( boundTextures.size(), 2u, TEST_LOCATION );
751 if ( boundTextures.size() )
753 DALI_TEST_EQUALS( boundTextures[0], 9u/*unique to actor2*/, TEST_LOCATION );
754 DALI_TEST_EQUALS( boundTextures[1], 8u/*unique to actor1*/, TEST_LOCATION );
757 BufferImage img3 = BufferImage::New( 1,1 );
758 ImageActor actor3 = ImageActor::New( img3 );
761 // Force actor3 to be rendered before actor2
762 layer = Layer::New();
763 Stage::GetCurrent().Add( layer );
765 layer.LowerToBottom();
767 // Update & Render all actors
768 application.GetGlAbstraction().ClearBoundTextures();
769 application.SendNotification();
770 application.Render();
772 // Check that the actors were rendered
773 DALI_TEST_EQUALS( boundTextures.size(), 3u, TEST_LOCATION );
775 if ( boundTextures.size() )
777 DALI_TEST_EQUALS( boundTextures[0], 10u/*unique to actor3*/, TEST_LOCATION );
778 DALI_TEST_EQUALS( boundTextures[1], 9u/*unique to actor2*/, TEST_LOCATION );
779 DALI_TEST_EQUALS( boundTextures[2], 8u/*unique to actor1*/, TEST_LOCATION );
782 // Both actors are now connected to the root node
783 // Setup 2 render-tasks - the first will render from the root-node, and the second from actor2
785 // Not exclusive is the default
786 RenderTask task1 = taskList.GetTask( 0u );
787 DALI_TEST_CHECK( false == task1.IsExclusive() );
789 RenderTask task2 = taskList.CreateTask();
790 DALI_TEST_CHECK( false == task2.IsExclusive() );
791 task2.SetSourceActor( actor2 );
793 // Task1 should render all actors, and task 2 should render only actor2
795 application.GetGlAbstraction().ClearBoundTextures();
796 application.SendNotification();
797 application.Render();
799 DALI_TEST_EQUALS( boundTextures.size(), 4u, TEST_LOCATION );
801 if ( boundTextures.size() == 4 )
803 // Test that task 1 renders actor3, then actor2 & then actor1
804 DALI_TEST_CHECK( boundTextures[0] == 10u );
805 DALI_TEST_CHECK( boundTextures[1] == 9u );
806 DALI_TEST_CHECK( boundTextures[2] == 8u );
808 // Test that task 2 renders actor2
809 DALI_TEST_EQUALS( boundTextures[3], 9u, TEST_LOCATION );
812 // Make actor2 exclusive to task2
814 task2.SetExclusive( true );
815 DALI_TEST_CHECK( true == task2.IsExclusive() );
817 // Task1 should render only actor1, and task 2 should render only actor2
819 application.GetGlAbstraction().ClearBoundTextures();
820 application.SendNotification();
821 application.Render();
823 DALI_TEST_EQUALS( boundTextures.size(), 3u, TEST_LOCATION );
824 if ( boundTextures.size() == 3 )
826 // Test that task 1 renders actor3 & actor1
827 DALI_TEST_CHECK( boundTextures[0] == 10u );
828 DALI_TEST_CHECK( boundTextures[1] == 8u );
830 // Test that task 2 renders actor2
831 DALI_TEST_CHECK( boundTextures[2] == 9u );
836 int UtcDaliRenderTaskSetExclusive02(void)
838 TestApplication application;
840 tet_infoline("Testing RenderTask::SetExclusive() Check that changing from exclusive to not-exclusive works");
842 std::vector<GLuint> ids;
843 ids.push_back( 8 ); // 8 = actor1
844 application.GetGlAbstraction().SetNextTextureIds( ids );
846 BufferImage img1 = BufferImage::New( 1,1 );
847 ImageActor actor1 = ImageActor::New( img1 );
849 Stage::GetCurrent().Add( actor1 );
851 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
852 RenderTask task = taskList.CreateTask();
854 task.SetSourceActor( actor1 );
855 task.SetExclusive(true); // Actor should only render once
857 TestGlAbstraction& gl = application.GetGlAbstraction();
858 TraceCallStack& drawTrace = gl.GetDrawTrace();
859 drawTrace.Enable(true);
861 // Update & Render actor1
862 application.SendNotification();
863 application.Render();
865 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION );
867 // Set task to non-exclusive - actor1 should render twice:
869 task.SetExclusive(false);
870 application.SendNotification();
871 application.Render();
873 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 2, TEST_LOCATION );
878 int UtcDaliRenderTaskSetExclusiveN(void)
880 TestApplication application;
882 tet_infoline("Testing RenderTask::SetExclusive() on empty handle");
887 task.SetExclusive(true);
889 catch (Dali::DaliException(e))
891 DALI_TEST_PRINT_ASSERT( e );
892 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
897 int UtcDaliRenderTaskIsExclusive01(void)
899 TestApplication application;
901 tet_infoline("Testing RenderTask::IsExclusive() Check default values are non-exclusive");
903 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
905 // Not exclusive is the default
906 RenderTask task = taskList.GetTask( 0u );
907 DALI_TEST_CHECK( false == task.IsExclusive() );
909 RenderTask newTask = taskList.CreateTask();
910 DALI_TEST_CHECK( false == newTask.IsExclusive() );
915 int UtcDaliRenderTaskIsExclusive02(void)
917 TestApplication application;
919 tet_infoline("Testing RenderTask::IsExclusive() Check the getter returns set values");
921 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
923 // Not exclusive is the default
924 RenderTask newTask = taskList.CreateTask();
925 DALI_TEST_EQUALS( newTask.IsExclusive(), false, TEST_LOCATION );
927 newTask.SetExclusive(true);
928 DALI_TEST_EQUALS( newTask.IsExclusive(), true, TEST_LOCATION );
932 int UtcDaliRenderTaskIsExclusiveN(void)
934 TestApplication application;
936 tet_infoline("Testing RenderTask::IsExclusive() on empty handle");
941 bool x = task.IsExclusive();
944 catch (Dali::DaliException(e))
946 DALI_TEST_PRINT_ASSERT( e );
947 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
952 int UtcDaliRenderTaskSetInputEnabled(void)
954 TestApplication application;
956 tet_infoline("Testing RenderTask::SetInputEnabled()");
958 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
960 // Input is enabled by default
961 RenderTask task = taskList.GetTask( 0u );
962 DALI_TEST_CHECK( true == task.GetInputEnabled() );
964 task.SetInputEnabled( false );
965 DALI_TEST_CHECK( false == task.GetInputEnabled() );
967 task.SetInputEnabled( true );
968 DALI_TEST_CHECK( true == task.GetInputEnabled() );
972 int UtcDaliRenderTaskGetInputEnabled(void)
974 TestApplication application;
976 tet_infoline("Testing RenderTask::GetInputEnabled()");
978 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
980 // Input is enabled by default
981 RenderTask task = taskList.GetTask( 0u );
982 DALI_TEST_EQUALS( true, task.GetInputEnabled(), TEST_LOCATION );
984 RenderTask newTask = taskList.CreateTask();
985 DALI_TEST_EQUALS( true, newTask.GetInputEnabled(), TEST_LOCATION );
987 newTask.SetInputEnabled(false);
988 DALI_TEST_EQUALS( false, newTask.GetInputEnabled(), TEST_LOCATION );
993 int UtcDaliRenderTaskSetCameraActorP(void)
995 TestApplication application;
997 tet_infoline("Testing RenderTask::SetCameraActor()");
999 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1001 RenderTask task = taskList.GetTask( 0u );
1003 Actor defaultCameraActor = task.GetCameraActor();
1004 DALI_TEST_CHECK( defaultCameraActor );
1006 CameraActor newCameraActor = CameraActor::New();
1007 DALI_TEST_CHECK( newCameraActor );
1009 task.SetCameraActor( newCameraActor );
1010 DALI_TEST_CHECK( task.GetCameraActor() != defaultCameraActor );
1011 DALI_TEST_EQUALS( task.GetCameraActor(), newCameraActor, TEST_LOCATION );
1016 int UtcDaliRenderTaskSetCameraActorN(void)
1018 TestApplication application;
1020 tet_infoline("Testing RenderTask::SetCameraActor() with empty actor handle");
1022 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1024 RenderTask task = taskList.GetTask( 0u );
1026 Actor actor = task.GetCameraActor();
1027 DALI_TEST_CHECK( actor );
1029 CameraActor cameraActor;
1031 task.SetCameraActor( cameraActor );
1032 DALI_TEST_EQUALS( (bool)task.GetCameraActor(), false, TEST_LOCATION );
1033 DALI_TEST_EQUALS( task.GetCameraActor(), cameraActor, TEST_LOCATION );
1038 int UtcDaliRenderTaskGetCameraActorP(void)
1040 TestApplication application;
1042 tet_infoline("Testing RenderTask::GetCameraActor()");
1044 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1046 RenderTask task = taskList.GetTask( 0u );
1048 CameraActor actor = task.GetCameraActor();
1049 DALI_TEST_CHECK( actor );
1050 DALI_TEST_EQUALS( actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION );
1051 DALI_TEST_GREATER( actor.GetFieldOfView(), 0.0f, TEST_LOCATION );
1055 int UtcDaliRenderTaskGetCameraActorN(void)
1057 TestApplication application;
1059 tet_infoline("Testing RenderTask::GetCameraActor() with empty handle");
1064 Actor actor = task.GetCameraActor();
1066 catch (Dali::DaliException(e))
1068 DALI_TEST_PRINT_ASSERT( e );
1069 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1075 int UtcDaliRenderTaskSetTargetFrameBufferP(void)
1077 TestApplication application;
1079 tet_infoline("Testing RenderTask::SetTargetFrameBuffer()");
1081 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1083 RenderTask task = taskList.GetTask( 0u );
1085 FrameBufferImage newImage = FrameBufferImage::New();
1086 task.SetTargetFrameBuffer( newImage );
1087 DALI_TEST_CHECK( task.GetTargetFrameBuffer() == newImage );
1091 int UtcDaliRenderTaskSetTargetFrameBufferN(void)
1093 TestApplication application;
1095 tet_infoline("Testing RenderTask::SetTargetFrameBuffer()");
1097 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1099 RenderTask task = taskList.GetTask( 0u );
1100 FrameBufferImage newImage; // Empty handle
1101 task.SetTargetFrameBuffer( newImage );
1102 DALI_TEST_EQUALS( (bool)task.GetTargetFrameBuffer(), false, TEST_LOCATION );
1106 int UtcDaliRenderTaskGetTargetFrameBufferP(void)
1108 TestApplication application;
1110 tet_infoline("Testing RenderTask::GetTargetFrameBuffer()");
1112 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1114 RenderTask newTask = taskList.CreateTask();
1115 FrameBufferImage fb = FrameBufferImage::New(128, 128, Pixel::RGBA8888);
1116 newTask.SetTargetFrameBuffer( fb );
1117 DALI_TEST_EQUALS( newTask.GetTargetFrameBuffer(), fb, TEST_LOCATION );
1121 int UtcDaliRenderTaskGetTargetFrameBufferN(void)
1123 TestApplication application;
1125 tet_infoline("Testing RenderTask::GetTargetFrameBuffer()");
1127 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1129 RenderTask task = taskList.GetTask( 0u );
1131 // By default render-tasks do not render off-screen
1132 FrameBufferImage image = task.GetTargetFrameBuffer();
1133 DALI_TEST_CHECK( !image );
1138 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionP(void)
1140 TestApplication application;
1142 tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1144 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1146 RenderTask task = taskList.GetTask( 0u );
1148 task.SetScreenToFrameBufferFunction( TestScreenToFrameBufferFunction );
1150 Vector2 coordinates( 5, 10 );
1151 Vector2 convertedCoordinates( 6, 12 ); // + Vector(1, 2)
1153 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1154 DALI_TEST_CHECK( func( coordinates ) );
1155 DALI_TEST_CHECK( coordinates == convertedCoordinates );
1157 task.SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
1158 func = task.GetScreenToFrameBufferFunction();
1159 DALI_TEST_CHECK( func( coordinates ) );
1161 task.SetScreenToFrameBufferFunction( RenderTask::DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION );
1162 func = task.GetScreenToFrameBufferFunction();
1163 DALI_TEST_CHECK( ! func( coordinates ) );
1167 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionN(void)
1169 TestApplication application;
1171 tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1173 RenderTask task; // Empty handle
1176 task.SetScreenToFrameBufferFunction( TestScreenToFrameBufferFunction );
1178 catch (Dali::DaliException(e))
1180 DALI_TEST_PRINT_ASSERT( e );
1181 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1186 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionP(void)
1188 TestApplication application;
1190 tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction()");
1192 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1194 RenderTask task = taskList.GetTask( 0u );
1196 Vector2 originalCoordinates( 5, 10 );
1197 Vector2 coordinates( 5, 10 );
1199 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1200 DALI_TEST_CHECK( !func( coordinates ) ); // conversion should fail by default
1201 DALI_TEST_CHECK( coordinates == originalCoordinates ); // coordinates should not be modified
1205 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionN(void)
1207 TestApplication application;
1209 tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction() on empty handle");
1214 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1217 catch (Dali::DaliException(e))
1219 DALI_TEST_PRINT_ASSERT( e );
1220 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1226 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorP(void)
1228 TestApplication application;
1229 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor ");
1231 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1232 RenderTask renderTask = taskList.CreateTask();
1233 Actor mappingActor = Actor::New();
1234 renderTask.SetScreenToFrameBufferMappingActor(mappingActor);
1236 DALI_TEST_EQUALS( mappingActor, renderTask.GetScreenToFrameBufferMappingActor(), TEST_LOCATION );
1241 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorN(void)
1243 TestApplication application;
1244 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1250 task.SetScreenToFrameBufferMappingActor(mappingActor);
1252 catch (Dali::DaliException(e))
1254 DALI_TEST_PRINT_ASSERT( e );
1255 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1260 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActor02N(void)
1262 TestApplication application;
1263 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1265 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1266 RenderTask renderTask = taskList.CreateTask();
1268 renderTask.SetScreenToFrameBufferMappingActor(actor);
1270 DALI_TEST_EQUALS( (bool)renderTask.GetScreenToFrameBufferMappingActor(), false, TEST_LOCATION);
1274 int UtcDaliRenderTaskGetViewportP01(void)
1276 TestApplication application;
1278 tet_infoline("Testing RenderTask::GetViewport() on default task");
1280 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1281 RenderTask task = taskList.GetTask( 0u );
1282 Viewport viewport = task.GetViewport();
1284 // By default the viewport should match the stage width/height
1285 Vector2 stageSize = Stage::GetCurrent().GetSize();
1286 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1287 DALI_TEST_CHECK( viewport == expectedViewport );
1291 int UtcDaliRenderTaskGetViewportP02(void)
1293 TestApplication application;
1295 tet_infoline("Testing RenderTask::GetViewport() on new task");
1297 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1298 RenderTask task = taskList.CreateTask();
1299 Viewport viewport = task.GetViewport();
1301 // By default the viewport should match the stage width/height
1302 Vector2 stageSize = Stage::GetCurrent().GetSize();
1303 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1304 DALI_TEST_CHECK( viewport == expectedViewport );
1308 int UtcDaliRenderTaskGetViewportN(void)
1310 TestApplication application;
1312 tet_infoline("Testing RenderTask::GetViewport() on empty handle");
1317 Viewport viewport = task.GetViewport();
1318 viewport = viewport;
1320 catch (Dali::DaliException(e))
1322 DALI_TEST_PRINT_ASSERT( e );
1323 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1329 int UtcDaliRenderTaskSetViewportP(void)
1331 TestApplication application;
1333 tet_infoline("Testing RenderTask::SetViewport()");
1335 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1337 RenderTask task = taskList.GetTask( 0u );
1338 Vector2 stageSize = Stage::GetCurrent().GetSize();
1339 Viewport newViewport( 0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f );
1340 task.SetViewport( newViewport );
1342 // Update (viewport is a property)
1343 application.SendNotification();
1344 application.Render();
1346 DALI_TEST_CHECK( task.GetViewport() == newViewport );
1350 int UtcDaliRenderTaskSetViewportN(void)
1352 TestApplication application;
1354 tet_infoline("Testing RenderTask::SetViewport()");
1356 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1361 Vector2 stageSize = Stage::GetCurrent().GetSize();
1362 Viewport newViewport( 0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f );
1363 task.SetViewport( newViewport );
1365 catch (Dali::DaliException(e))
1367 DALI_TEST_PRINT_ASSERT( e );
1368 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1375 int UtcDaliRenderTaskSetViewportPosition(void)
1377 TestApplication application;
1379 tet_infoline("Testing RenderTask::SetViewportPosition()");
1381 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1383 RenderTask task = taskList.GetTask( 0u );
1385 Viewport viewport = task.GetViewport();
1387 // By default the viewport should match the stage width/height
1389 Vector2 stageSize = Stage::GetCurrent().GetSize();
1390 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1391 DALI_TEST_CHECK( viewport == expectedViewport );
1394 Vector2 newPosition(25.0f, 50.0f);
1395 task.SetViewportPosition( newPosition );
1397 // Update (viewport is a property)
1398 application.SendNotification();
1399 application.Render();
1401 DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1403 // Set by Property test
1404 Vector2 newPosition2(32.0f, 32.0f);
1405 task.SetProperty( RenderTask::Property::VIEWPORT_POSITION, newPosition2 );
1408 application.SendNotification();
1409 application.Render();
1411 DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition2, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1413 Vector2 newPosition3(64.0f, 0.0f);
1414 Animation animation = Animation::New(1.0f);
1415 animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_POSITION ), newPosition3, AlphaFunction::LINEAR );
1418 // Perform 1000ms worth of updates at which point animation should have completed.
1419 Wait(application, 1000);
1420 DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1424 int UtcDaliRenderTaskSetViewportSize(void)
1426 TestApplication application;
1428 tet_infoline("Testing RenderTask::SetViewportSize()");
1430 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1432 RenderTask task = taskList.GetTask( 0u );
1434 Viewport viewport = task.GetViewport();
1436 // By default the viewport should match the stage width/height
1438 Vector2 stageSize = Stage::GetCurrent().GetSize();
1439 Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1440 DALI_TEST_CHECK( viewport == expectedViewport );
1442 Vector2 newSize(128.0f, 64.0f);
1443 task.SetViewportSize( newSize );
1445 // Update (viewport is a property)
1446 application.SendNotification();
1447 application.Render();
1449 DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1451 // Set by Property test
1452 Vector2 newSize2(50.0f, 50.0f);
1453 task.SetProperty( RenderTask::Property::VIEWPORT_SIZE, newSize2 );
1456 application.SendNotification();
1457 application.Render();
1459 DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize2, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1461 Vector2 newSize3(10.0f, 10.0f);
1462 Animation animation = Animation::New(1.0f);
1463 animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_SIZE ), newSize3, AlphaFunction::LINEAR );
1466 // Perform 1000ms worth of updates at which point animation should have completed.
1467 Wait(application, 1000);
1468 DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1473 int UtcDaliRenderTaskSetClearColorP(void)
1475 TestApplication application;
1477 tet_infoline("Testing RenderTask::SetClearColor()");
1479 Vector4 testColor( 1.0f, 2.0f, 3.0f, 4.0f );
1480 Vector4 testColor2( 5.0f, 6.0f, 7.0f, 8.0f );
1482 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1484 RenderTask task = taskList.GetTask( 0u );
1485 DALI_TEST_CHECK( task.GetClearColor() != testColor );
1487 task.SetClearColor( testColor );
1492 DALI_TEST_EQUALS( task.GetClearColor(), testColor, TEST_LOCATION );
1494 task.SetProperty( RenderTask::Property::CLEAR_COLOR, testColor2 );
1499 DALI_TEST_EQUALS( task.GetClearColor(), testColor2, TEST_LOCATION );
1503 int UtcDaliRenderTaskSetClearColorN(void)
1505 TestApplication application;
1507 tet_infoline("Testing RenderTask::SetClearColor() on empty handle");
1512 task.SetClearColor( Vector4::ZERO );
1514 catch (Dali::DaliException(e))
1516 DALI_TEST_PRINT_ASSERT( e );
1517 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1522 int UtcDaliRenderTaskGetClearColorP(void)
1524 TestApplication application;
1526 tet_infoline("Testing RenderTask::GetClearColor()");
1528 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1529 RenderTask task = taskList.GetTask( 0u );
1530 DALI_TEST_EQUALS( task.GetClearColor(), RenderTask::DEFAULT_CLEAR_COLOR, TEST_LOCATION );
1534 int UtcDaliRenderTaskGetClearColorN(void)
1536 TestApplication application;
1538 tet_infoline("Testing RenderTask::GetClearColor()");
1543 Vector4 color = task.GetClearColor();
1546 catch (Dali::DaliException(e))
1548 DALI_TEST_PRINT_ASSERT( e );
1549 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1554 int UtcDaliRenderTaskSetClearEnabledP(void)
1556 TestApplication application;
1558 tet_infoline("Testing RenderTask::SetClearEnabled()");
1560 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1562 RenderTask task = taskList.GetTask( 0u );
1563 DALI_TEST_CHECK( !task.GetClearEnabled() ); // defaults to false
1565 task.SetClearEnabled( true );
1566 DALI_TEST_EQUALS( task.GetClearEnabled(), true, TEST_LOCATION );
1568 task.SetClearEnabled( false );
1569 DALI_TEST_EQUALS( task.GetClearEnabled(), false, TEST_LOCATION );
1573 int UtcDaliRenderTaskSetClearEnabledN(void)
1575 TestApplication application;
1577 tet_infoline("Testing RenderTask::SetClearEnabled() with empty handle");
1582 task.SetClearEnabled(true);
1584 catch (Dali::DaliException(e))
1586 DALI_TEST_PRINT_ASSERT( e );
1587 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1592 int UtcDaliRenderTaskGetClearEnabledP(void)
1594 TestApplication application;
1596 tet_infoline("Testing RenderTask::GetClearEnabled()");
1598 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1600 RenderTask task = taskList.GetTask( 0u );
1601 DALI_TEST_CHECK( !task.GetClearEnabled() ); // defaults to false
1606 int UtcDaliRenderTaskGetClearEnabledN(void)
1608 TestApplication application;
1610 tet_infoline("Testing RenderTask::GetClearEnabled() with empty handle");
1615 bool x = task.GetClearEnabled();
1618 catch (Dali::DaliException(e))
1620 DALI_TEST_PRINT_ASSERT( e );
1621 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1626 int UtcDaliRenderTaskSetCullModeP(void)
1628 TestApplication application;
1630 tet_infoline("Testing RenderTask::SetCullMode()");
1632 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1633 RenderTask task = taskList.GetTask( 0u );
1634 DALI_TEST_EQUALS( task.GetCullMode(), true, TEST_LOCATION );
1636 task.SetCullMode( false );
1638 DALI_TEST_EQUALS( task.GetCullMode(), false, TEST_LOCATION );
1643 int UtcDaliRenderTaskSetCullModeN(void)
1645 TestApplication application;
1647 tet_infoline("Testing RenderTask::SetCullMode() on empty handle");
1652 task.SetCullMode( false );
1654 catch (Dali::DaliException(e))
1656 DALI_TEST_PRINT_ASSERT( e );
1657 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1662 int UtcDaliRenderTaskGetCullModeP(void)
1664 TestApplication application;
1666 tet_infoline("Testing RenderTask::GetCullMode()");
1668 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1669 RenderTask task = taskList.GetTask( 0u );
1670 DALI_TEST_EQUALS( task.GetCullMode(), true, TEST_LOCATION );
1674 int UtcDaliRenderTaskGetCullModeN(void)
1676 TestApplication application;
1678 tet_infoline("Testing RenderTask::GetCullMode() with empty handle");
1683 bool x = task.GetCullMode();
1686 catch (Dali::DaliException(e))
1688 DALI_TEST_PRINT_ASSERT( e );
1689 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1695 int UtcDaliRenderTaskSetRefreshRate(void)
1697 TestApplication application;
1699 tet_infoline("Testing RenderTask::SetRefreshRate()");
1701 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1703 // By default tasks will be processed every frame
1704 RenderTask task = taskList.GetTask( 0u );
1705 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1707 task.SetRefreshRate( 2u ); // every-other frame
1708 DALI_TEST_CHECK( 2u == task.GetRefreshRate() );
1710 task.SetRefreshRate( RenderTask::REFRESH_ALWAYS );
1711 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1715 int UtcDaliRenderTaskGetRefreshRate(void)
1717 TestApplication application;
1719 tet_infoline("Testing RenderTask::GetRefreshRate()");
1721 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1723 // By default tasks will be processed every frame
1724 RenderTask task = taskList.GetTask( 0u );
1725 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1727 RenderTask newTask = taskList.CreateTask();
1728 DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == newTask.GetRefreshRate() );
1732 int UtcDaliRenderTaskSignalFinished(void)
1734 TestApplication application;
1736 tet_infoline("Testing RenderTask::SignalFinished()");
1738 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1739 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
1741 CameraActor offscreenCameraActor = CameraActor::New();
1743 Stage::GetCurrent().Add( offscreenCameraActor );
1745 BufferImage image = BufferImage::New( 10, 10 );
1747 ImageActor rootActor = ImageActor::New( image );
1748 rootActor.SetSize( 10, 10 );
1749 Stage::GetCurrent().Add( rootActor );
1751 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1752 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
1753 FrameBufferImage frameBufferImage = FrameBufferImage::New( *testNativeImagePtr.Get() );
1755 RenderTask newTask = taskList.CreateTask();
1756 newTask.SetCameraActor( offscreenCameraActor );
1757 newTask.SetSourceActor( rootActor );
1758 newTask.SetInputEnabled( false );
1759 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
1760 newTask.SetClearEnabled( true );
1761 newTask.SetExclusive( true );
1762 newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
1763 newTask.SetTargetFrameBuffer( frameBufferImage );
1764 newTask.SetProperty( RenderTask::Property::REQUIRES_SYNC, true );
1766 bool finished = false;
1767 RenderTaskFinished renderTaskFinished( finished );
1768 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1770 // Flush the queue and render.
1771 application.SendNotification();
1773 // 1 render to process render task, then wait for sync before finished msg is sent
1774 // from update to the event thread.
1776 application.Render();
1777 application.SendNotification();
1778 DALI_TEST_CHECK( !finished );
1780 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
1781 DALI_TEST_CHECK( lastSyncObj != NULL );
1783 application.Render();
1784 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
1785 application.SendNotification();
1786 DALI_TEST_CHECK( !finished );
1788 application.Render();
1789 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
1790 application.SendNotification();
1791 DALI_TEST_CHECK( ! finished );
1793 sync.SetObjectSynced( lastSyncObj, true );
1795 application.Render();
1796 application.SendNotification();
1797 DALI_TEST_CHECK( !finished );
1799 application.Render();
1800 application.SendNotification();
1801 DALI_TEST_CHECK( finished );
1804 DALI_TEST_EQUALS( application.GetUpdateStatus(), 0, TEST_LOCATION );
1809 int UtcDaliRenderTaskContinuous01(void)
1811 TestApplication application;
1813 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not staged)\nPOST:continuous renders, no Finished signal");
1815 // SETUP AN OFFSCREEN RENDER TASK
1816 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1817 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1818 drawTrace.Enable(true);
1820 Actor rootActor = Actor::New();
1821 Stage::GetCurrent().Add( rootActor );
1823 CameraActor offscreenCameraActor = CameraActor::New();
1824 Stage::GetCurrent().Add( offscreenCameraActor );
1826 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1827 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1828 Integration::ResourceId imageRequestId = imageRequest->GetId();
1829 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1831 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1832 bool finished = false;
1833 RenderTaskFinished renderTaskFinished( finished );
1834 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1835 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1836 application.SendNotification();
1838 // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating
1839 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false, __LINE__ ) );
1840 application.GetPlatform().ClearReadyResources();
1842 // ADD SOURCE ACTOR TO STAGE - expect continuous renders to start, no finished signal
1843 Stage::GetCurrent().Add(secondRootActor);
1844 application.SendNotification();
1846 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1847 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
1852 int UtcDaliRenderTaskContinuous02(void)
1854 TestApplication application;
1856 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not visible)\nPOST:continuous renders, no Finished signal");
1858 // SETUP AN OFFSCREEN RENDER TASK
1859 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1860 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1861 drawTrace.Enable(true);
1863 Actor rootActor = Actor::New();
1864 Stage::GetCurrent().Add( rootActor );
1866 CameraActor offscreenCameraActor = CameraActor::New();
1867 Stage::GetCurrent().Add( offscreenCameraActor );
1869 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1870 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1871 Integration::ResourceId imageRequestId = imageRequest->GetId();
1872 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1873 Stage::GetCurrent().Add(secondRootActor);
1874 secondRootActor.SetVisible(false);
1876 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1877 bool finished = false;
1878 RenderTaskFinished renderTaskFinished( finished );
1879 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1880 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1881 application.SendNotification();
1883 // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating
1884 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false, __LINE__ ) );
1885 application.GetPlatform().ClearReadyResources();
1887 // MAKE SOURCE ACTOR VISIBLE - expect continuous renders to start, no finished signal
1888 secondRootActor.SetVisible(true);
1889 application.SendNotification();
1891 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1892 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
1896 int UtcDaliRenderTaskContinuous03(void)
1898 TestApplication application;
1900 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (camera actor not staged)\nPOST:continuous renders, no Finished signal");
1902 // SETUP AN OFFSCREEN RENDER TASK
1903 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1904 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1905 drawTrace.Enable(true);
1907 Actor rootActor = Actor::New();
1908 Stage::GetCurrent().Add( rootActor );
1910 CameraActor offscreenCameraActor = CameraActor::New();
1911 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1912 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1913 Integration::ResourceId imageRequestId = imageRequest->GetId();
1914 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1915 Stage::GetCurrent().Add(secondRootActor);
1917 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1918 bool finished = false;
1919 RenderTaskFinished renderTaskFinished( finished );
1920 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1921 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1922 application.SendNotification();
1924 // START PROCESS/RENDER Input, Expected Input, Expected
1925 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, false, __LINE__ ) );
1926 application.GetPlatform().ClearReadyResources();
1928 // ADD CAMERA ACTOR TO STAGE - expect continuous renders to start, no finished signal
1929 Stage::GetCurrent().Add( offscreenCameraActor );
1930 application.SendNotification();
1932 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1933 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
1938 int UtcDaliRenderTaskContinuous04(void)
1940 TestApplication application;
1942 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: Resource not ready\nPOST:continuous renders, no Finished signal");
1944 // SETUP AN OFFSCREEN RENDER TASK
1945 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1946 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1947 drawTrace.Enable(true);
1949 Actor rootActor = Actor::New();
1950 Stage::GetCurrent().Add( rootActor );
1952 CameraActor offscreenCameraActor = CameraActor::New();
1953 Stage::GetCurrent().Add( offscreenCameraActor );
1954 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1955 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1956 Integration::ResourceId imageRequestId = imageRequest->GetId();
1957 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1958 Stage::GetCurrent().Add(secondRootActor);
1960 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1961 bool finished = false;
1962 RenderTaskFinished renderTaskFinished( finished );
1963 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1964 application.SendNotification();
1966 // START PROCESS/RENDER Input, Expected Input, Expected
1967 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
1968 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
1970 // FINISH RESOURCE LOADING - expect 'continuous' renders to start, no finished signal
1971 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
1972 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
1976 int UtcDaliRenderTaskContinous05(void)
1978 TestApplication application;
1980 tet_infoline("Testing RenderTask Render Continuous using Mesh which accesses texture through sampler with loading image\n"
1981 "PRE: Resource not ready\nPOST:continuous renders, no Finished signal");
1983 // SETUP AN OFFSCREEN RENDER TASK
1984 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1985 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1986 drawTrace.Enable(true);
1988 Actor rootActor = Actor::New();
1989 Stage::GetCurrent().Add( rootActor );
1991 CameraActor offscreenCameraActor = CameraActor::New();
1992 Stage::GetCurrent().Add( offscreenCameraActor );
1994 Material material = CreateMaterial();
1995 Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
1996 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
1997 Integration::ResourceId imageRequestId = imageRequest->GetId();
1998 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
1999 material.AddTexture( image, "sTexture" );
2001 Geometry geometry = CreateQuadGeometry();
2002 Renderer renderer = Renderer::New(geometry, material);
2003 Actor secondRootActor = Actor::New();
2004 secondRootActor.AddRenderer(renderer);
2005 secondRootActor.SetSize(100, 100);
2006 Stage::GetCurrent().Add(secondRootActor);
2008 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2009 bool finished = false;
2010 RenderTaskFinished renderTaskFinished( finished );
2011 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2012 application.SendNotification();
2014 // START PROCESS/RENDER Input, Expected Input, Expected
2015 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2016 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2018 // FINISH RESOURCE LOADING - expect 'continuous' renders to start, no finished signal
2019 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2020 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2026 int UtcDaliRenderTaskOnce01(void)
2028 TestApplication application;
2030 tet_infoline("Testing RenderTask Render Once GlSync, using loading image\nPRE: Resources not ready, Source not visible\nPOST: Finished signal sent once only");
2032 // SETUP AN OFFSCREEN RENDER TASK
2033 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2034 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2035 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2036 drawTrace.Enable(true);
2038 Actor rootActor = Actor::New();
2039 Stage::GetCurrent().Add( rootActor );
2041 CameraActor offscreenCameraActor = CameraActor::New();
2042 Stage::GetCurrent().Add( offscreenCameraActor );
2043 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2044 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2045 Integration::ResourceId imageRequestId = imageRequest->GetId();
2046 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2048 Stage::GetCurrent().Add(secondRootActor);
2050 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
2051 bool finished = false;
2052 RenderTaskFinished renderTaskFinished( finished );
2053 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2054 application.SendNotification();
2056 // START PROCESS/RENDER Input, Expected Input, Expected
2057 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2058 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2060 // MAKE SOURCE VISIBLE
2061 secondRootActor.SetVisible(true);
2062 application.SendNotification();
2063 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2064 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2066 // FINISH RESOURCE LOADING - expect no rendering yet
2067 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2068 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2069 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2070 DALI_TEST_CHECK( lastSyncObj != NULL );
2072 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2073 application.GetPlatform().ClearReadyResources();
2074 sync.SetObjectSynced( lastSyncObj, true );
2075 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2076 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2080 int UtcDaliRenderTaskOnce02(void)
2082 TestApplication application;
2084 tet_infoline("Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loading image.\n"
2085 "PRE: Resources not ready\nPOST: Finished signal sent once only");
2087 // SETUP AN OFFSCREEN RENDER TASK
2088 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2089 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2090 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2091 drawTrace.Enable(true);
2093 Actor rootActor = Actor::New();
2094 Stage::GetCurrent().Add( rootActor );
2096 CameraActor offscreenCameraActor = CameraActor::New();
2097 Stage::GetCurrent().Add( offscreenCameraActor );
2099 Material material = CreateMaterial();
2100 Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2101 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2102 Integration::ResourceId imageRequestId = imageRequest->GetId();
2103 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2104 material.AddTexture( image, "sTexture");
2106 Geometry geometry = CreateQuadGeometry();
2107 Renderer renderer = Renderer::New(geometry, material);
2108 Actor secondRootActor = Actor::New();
2109 secondRootActor.AddRenderer(renderer);
2110 secondRootActor.SetSize(100, 100);
2111 Stage::GetCurrent().Add(secondRootActor);
2113 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
2114 bool finished = false;
2115 RenderTaskFinished renderTaskFinished( finished );
2116 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2117 application.SendNotification();
2119 // START PROCESS/RENDER Input, Expected Input, Expected
2120 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2121 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2123 // FINISH RESOURCE LOADING - expect no rendering yet
2124 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2125 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2126 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2127 DALI_TEST_CHECK( lastSyncObj != NULL );
2129 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2130 application.GetPlatform().ClearReadyResources();
2131 sync.SetObjectSynced( lastSyncObj, true );
2132 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2133 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2138 int UtcDaliRenderTaskOnce03(void)
2140 TestApplication application;
2142 tet_infoline("Testing RenderTask Render Once GlSync, using loading image. Switch from render always after ready to render once\n"
2143 "PRE: Render task ready, Image not loaded\n"
2144 "POST: Finished signal sent only once");
2146 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2147 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2148 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2149 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2150 drawTrace.Enable(true);
2152 Actor rootActor = Actor::New();
2153 Stage::GetCurrent().Add( rootActor );
2155 CameraActor offscreenCameraActor = CameraActor::New();
2156 Stage::GetCurrent().Add( offscreenCameraActor );
2157 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2158 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2159 Integration::ResourceId imageRequestId = imageRequest->GetId();
2160 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2161 Stage::GetCurrent().Add(secondRootActor);
2163 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2164 bool finished = false;
2165 RenderTaskFinished renderTaskFinished( finished );
2166 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2167 application.SendNotification();
2169 // START PROCESS/RENDER Input, Expected Input, Expected
2170 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2171 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2173 // FINISH RESOURCE LOADING
2174 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2175 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2176 application.GetPlatform().ClearReadyResources();
2177 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2179 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2180 application.SendNotification(); // Input, Expected Input, Expected
2181 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2182 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2183 DALI_TEST_CHECK( lastSyncObj != NULL );
2185 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2186 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2187 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2188 sync.SetObjectSynced( lastSyncObj, true );
2189 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2190 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2196 int UtcDaliRenderTaskOnce04(void)
2198 TestApplication application;
2199 tet_infoline("Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loading image.\n"
2200 "Switch from render always after ready to render once\n"
2201 "PRE: Render task ready, Image not loaded\n"
2202 "POST: Finished signal sent only once");
2204 // SETUP AN OFFSCREEN RENDER TASK
2205 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2206 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2207 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2208 drawTrace.Enable(true);
2210 Actor rootActor = Actor::New();
2211 Stage::GetCurrent().Add( rootActor );
2213 CameraActor offscreenCameraActor = CameraActor::New();
2214 Stage::GetCurrent().Add( offscreenCameraActor );
2216 Material material = CreateMaterial();
2217 Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2218 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2219 Integration::ResourceId imageRequestId = imageRequest->GetId();
2220 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2221 material.AddTexture( image, "sTexture" );
2223 Geometry geometry = CreateQuadGeometry();
2224 Renderer renderer = Renderer::New(geometry, material);
2225 Actor secondRootActor = Actor::New();
2226 secondRootActor.AddRenderer(renderer);
2227 secondRootActor.SetSize(100, 100);
2228 Stage::GetCurrent().Add(secondRootActor);
2230 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2231 bool finished = false;
2232 RenderTaskFinished renderTaskFinished( finished );
2233 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2234 application.SendNotification();
2236 // START PROCESS/RENDER Input, Expected Input, Expected
2237 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2238 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2240 // FINISH RESOURCE LOADING
2241 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2242 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2243 application.GetPlatform().ClearReadyResources();
2244 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2246 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2247 application.SendNotification(); // Input, Expected Input, Expected
2248 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2249 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2250 DALI_TEST_CHECK( lastSyncObj != NULL );
2252 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2253 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2254 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2255 sync.SetObjectSynced( lastSyncObj, true );
2256 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2257 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2262 int UtcDaliRenderTaskOnce05(void)
2264 TestApplication application;
2266 tet_infoline("Testing RenderTask Render Once GlSync\n"
2267 "Switch from Render always after ready to render once with resources unready\n"
2268 "PRE: Everything ready to render\n"
2269 "POST: Finished signal sent once");
2271 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2272 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2273 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2274 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2275 drawTrace.Enable(true);
2277 Actor rootActor = Actor::New();
2278 Stage::GetCurrent().Add( rootActor );
2280 CameraActor offscreenCameraActor = CameraActor::New();
2281 Stage::GetCurrent().Add( offscreenCameraActor );
2282 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2283 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2284 Integration::ResourceId imageRequestId = imageRequest->GetId();
2285 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2286 Stage::GetCurrent().Add(secondRootActor);
2288 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2289 bool finished = false;
2290 RenderTaskFinished renderTaskFinished( finished );
2291 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2292 application.SendNotification();
2294 // START PROCESS/RENDER Input, Expected Input, Expected
2295 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2296 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2298 // CHANGE TO RENDER ONCE
2299 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2300 application.SendNotification(); // Input, Expected Input, Expected
2301 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2302 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2304 // FINISH RESOURCE LOADING
2305 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2306 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2307 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2308 DALI_TEST_CHECK( lastSyncObj != NULL );
2309 application.GetPlatform().ClearReadyResources();
2311 sync.SetObjectSynced( lastSyncObj, true );
2313 // Expect: No draw - we've just drawn our render task once, above. No finished signal -
2314 // we won't read the gl sync until the next frame. Continue rendering - we're waiting for
2316 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2318 // Expect: 1 final draw - this Update doesn't update the scene, hence render instructions
2319 // from last frame but 1 are still present.
2320 // Finished signal should be true - we've just done the sync.
2321 // Should now stop rendering and updating - nothing left to do.
2322 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, true, false, __LINE__ ) );
2328 //int UtcDaliRenderTaskOnce06(void)
2330 TestApplication application;
2332 tet_infoline("Testing RenderTask Render Once GlSync\n"
2333 "During RenderOnce, make ready resources unready before sending first finished signal\n"
2334 "PRE: Everything ready.\n"
2335 "POST: Finished signal sent only once");
2337 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2338 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2339 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2340 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2341 drawTrace.Enable(true);
2343 Actor rootActor = Actor::New();
2344 Stage::GetCurrent().Add( rootActor );
2346 CameraActor offscreenCameraActor = CameraActor::New();
2347 Stage::GetCurrent().Add( offscreenCameraActor );
2348 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2349 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2350 Integration::ResourceId imageRequestId = imageRequest->GetId();
2351 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2352 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2353 application.Render();
2355 Stage::GetCurrent().Add(secondRootActor);
2356 application.GetPlatform().ClearReadyResources();
2358 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2359 bool finished = false;
2360 RenderTaskFinished renderTaskFinished( finished );
2361 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2362 application.SendNotification();
2364 // START PROCESS/RENDER Input, Expected Input, Expected
2365 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2366 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2368 // CHANGE TO RENDER ONCE, RESOURCES BECOME NOT READY
2369 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2372 ReloadImage(application, secondRootActor.GetImage());
2373 application.SendNotification(); // Input, Expected Input, Expected
2375 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2376 DALI_TEST_EQUALS( secondRootActor.GetImage().GetLoadingState(), Dali::ResourceLoading, TEST_LOCATION);
2377 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2379 // FINISH RESOURCE LOADING
2380 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2381 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2382 application.GetPlatform().ClearReadyResources();
2383 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2384 DALI_TEST_CHECK( lastSyncObj != NULL );
2386 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2387 sync.SetObjectSynced( lastSyncObj, true );
2388 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2389 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, true, __LINE__ ) );
2391 // Finished rendering - expect no more renders, no more signals:
2392 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2393 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2394 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2395 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2396 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2397 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2402 int UtcDaliRenderTaskOnce07(void)
2404 TestApplication application;
2406 tet_infoline("Testing RenderTask Render Once GLSync\n"
2407 "Render once, Second call to SetRefreshRate(ONCE) triggers only one more finished signal\n"
2408 "PRE: Everything ready\n"
2409 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
2411 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2412 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2413 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2414 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2415 drawTrace.Enable(true);
2417 Actor rootActor = Actor::New();
2418 Stage::GetCurrent().Add( rootActor );
2420 CameraActor offscreenCameraActor = CameraActor::New();
2421 Stage::GetCurrent().Add( offscreenCameraActor );
2422 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2423 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2424 Integration::ResourceId imageRequestId = imageRequest->GetId();
2425 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2426 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2427 application.Render();
2428 application.GetPlatform().ClearReadyResources();
2430 Stage::GetCurrent().Add(secondRootActor);
2432 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2433 bool finished = false;
2434 RenderTaskFinished renderTaskFinished( finished );
2435 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2436 application.SendNotification();
2438 // START PROCESS/RENDER Input, Expected Input, Expected
2439 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2441 // CHANGE TO RENDER ONCE,
2442 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2443 application.SendNotification();
2444 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2445 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2446 DALI_TEST_CHECK( lastSyncObj != NULL );
2448 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2449 sync.SetObjectSynced( lastSyncObj, true );
2450 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2451 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2453 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2454 application.SendNotification();
2455 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2456 lastSyncObj = sync.GetLastSyncObject();
2457 DALI_TEST_CHECK( lastSyncObj != NULL );
2459 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2460 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2461 sync.SetObjectSynced( lastSyncObj, true );
2462 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2463 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2467 int UtcDaliRenderTaskOnce08(void)
2469 TestApplication application;
2471 tet_infoline("Testing RenderTask Render Once GLSync\n"
2472 "Render once, Call to SetRefreshRate(ONCE) in Finished signal callback triggers "
2473 "another render & another finished signal\n"
2474 "PRE: Everything ready\n"
2475 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
2478 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2479 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2480 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2481 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2482 sync.GetTrace().Enable(true);
2483 drawTrace.Enable(true);
2485 Actor rootActor = Actor::New();
2486 Stage::GetCurrent().Add( rootActor );
2488 CameraActor offscreenCameraActor = CameraActor::New();
2489 Stage::GetCurrent().Add( offscreenCameraActor );
2490 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2491 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2492 Integration::ResourceId imageRequestId = imageRequest->GetId();
2493 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2494 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2495 application.Render();
2496 application.GetPlatform().ClearReadyResources();
2498 Stage::GetCurrent().Add(secondRootActor);
2500 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, /*GL-SYNC*/ true);
2501 bool finished = false;
2503 ConnectionTracker connectionTracker;
2504 RenderTaskFinishedRenderAgain renderTaskFinishedRenderAgain( finished );
2505 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinishedRenderAgain );
2507 application.SendNotification();
2509 // START PROCESS/RENDER Input, Expected Input, Expected
2510 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2511 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2512 DALI_TEST_CHECK( lastSyncObj == NULL );
2513 DALI_TEST_EQUALS( sync.GetTrace().CountMethod( "CreateSyncObject" ), 0, TEST_LOCATION );
2516 // CHANGE TO RENDER ONCE,
2517 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2518 application.SendNotification();
2519 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2520 lastSyncObj = sync.GetLastSyncObject();
2521 DALI_TEST_CHECK( lastSyncObj != NULL );
2522 DALI_TEST_EQUALS( sync.GetNumberOfSyncObjects(), 1, TEST_LOCATION );
2523 DALI_TEST_EQUALS( sync.GetTrace().CountMethod( "CreateSyncObject" ), 1, TEST_LOCATION );
2525 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2528 DALI_TEST_EQUALS( sync.GetNumberOfSyncObjects(), 1, TEST_LOCATION );
2529 DALI_TEST_EQUALS( sync.GetTrace().CountMethod( "CreateSyncObject" ), 1, TEST_LOCATION );
2531 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2533 DALI_TEST_EQUALS( sync.GetNumberOfSyncObjects(), 1, TEST_LOCATION );
2534 DALI_TEST_EQUALS( sync.GetTrace().CountMethod( "CreateSyncObject" ), 1, TEST_LOCATION );
2536 sync.SetObjectSynced( lastSyncObj, true );
2537 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2538 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2539 application.SendNotification();
2541 // Expect SetRefreshRate to have been called again
2542 // Prevent next finished signal calling refresh once again
2543 RenderTaskFinished renderTaskFinished( finished );
2544 connectionTracker.DisconnectAll();
2545 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinished );
2546 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2547 lastSyncObj = sync.GetLastSyncObject();
2548 DALI_TEST_CHECK( lastSyncObj != NULL );
2550 sync.SetObjectSynced( lastSyncObj, true );
2551 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2552 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2557 int UtcDaliRenderTaskOnce09(void)
2559 TestApplication application;
2561 tet_infoline("Testing RenderTask Render Once GlSync\n"
2562 "SetRefreshRate(ONCE) again before first finished signal has been sent.\n"
2563 "PRE: resources ready\n"
2564 "POST: Only 1 finished signal sent.");
2566 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2567 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2568 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2569 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2570 drawTrace.Enable(true);
2572 Actor rootActor = Actor::New();
2573 Stage::GetCurrent().Add( rootActor );
2575 CameraActor offscreenCameraActor = CameraActor::New();
2576 Stage::GetCurrent().Add( offscreenCameraActor );
2577 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2578 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2579 Integration::ResourceId imageRequestId = imageRequest->GetId();
2580 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2581 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2582 application.Render();
2583 application.GetPlatform().ClearReadyResources();
2585 Stage::GetCurrent().Add(secondRootActor);
2587 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2588 bool finished = false;
2589 RenderTaskFinished renderTaskFinished( finished );
2590 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2591 application.SendNotification();
2593 // START PROCESS/RENDER Input, Expected Input, Expected
2594 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2596 // CHANGE TO RENDER ONCE,
2597 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2598 application.SendNotification();
2599 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2600 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2601 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2603 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2604 application.SendNotification();
2605 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2606 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2607 DALI_TEST_CHECK( lastSyncObj != NULL );
2609 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2610 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2611 sync.SetObjectSynced( lastSyncObj, true );
2612 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2613 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2618 int UtcDaliRenderTaskOnce10(void)
2620 TestApplication application;
2622 tet_infoline("Testing RenderTask Render Once GlSync\n"
2623 "SetRefreshRate(ONCE), resource load failed completes render task.\n"
2624 "PRE: resources not ready\n"
2625 "POST: Only 1 finished signal sent.");
2627 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2628 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2629 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2630 drawTrace.Enable(true);
2632 Actor rootActor = Actor::New();
2633 Stage::GetCurrent().Add( rootActor );
2635 CameraActor offscreenCameraActor = CameraActor::New();
2636 Stage::GetCurrent().Add( offscreenCameraActor );
2637 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2638 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2639 Integration::ResourceId imageRequestId = imageRequest->GetId();
2640 Stage::GetCurrent().Add(secondRootActor);
2642 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2643 bool finished = false;
2644 RenderTaskFinished renderTaskFinished( finished );
2645 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2646 application.SendNotification();
2648 // START PROCESS/RENDER Input, Expected Input, Expected
2649 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2650 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2652 // CHANGE TO RENDER ONCE,
2653 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2654 application.SendNotification();
2655 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2656 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2657 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2659 tet_printf(" FailImageLoad\n");
2661 FailImageLoad(application, imageRequestId); // Need to run Update again for this to complete
2663 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); // nothing to draw
2664 application.SendNotification();
2666 // load is now failed so there's nothing more to render in the render task
2667 // Expect finished signal, as all resources are complete
2668 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2673 int UtcDaliRenderTaskOnceNoSync01(void)
2675 TestApplication application;
2677 tet_infoline("Testing RenderTask Render Once, using loading image\nPRE: Resources not ready, Source not visible\nPOST: Finished signal sent once only");
2679 // SETUP AN OFFSCREEN RENDER TASK
2680 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2681 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2682 drawTrace.Enable(true);
2684 Actor rootActor = Actor::New();
2685 Stage::GetCurrent().Add( rootActor );
2687 CameraActor offscreenCameraActor = CameraActor::New();
2688 Stage::GetCurrent().Add( offscreenCameraActor );
2689 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2690 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2691 Integration::ResourceId imageRequestId = imageRequest->GetId();
2692 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2694 Stage::GetCurrent().Add(secondRootActor);
2696 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2697 bool finished = false;
2698 RenderTaskFinished renderTaskFinished( finished );
2699 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2700 application.SendNotification();
2702 // START PROCESS/RENDER Input, Expected Input, Expected
2703 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2704 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2706 // FINISH RESOURCE LOADING - expect immediate rendering yet
2707 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2708 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2709 application.GetPlatform().ClearReadyResources();
2710 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2714 int UtcDaliRenderTaskOnceNoSync02(void)
2716 TestApplication application;
2718 tet_infoline("Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loading image.\n"
2719 "PRE: Resources not ready\nPOST: Finished signal sent once only");
2720 // SETUP AN OFFSCREEN RENDER TASK
2721 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2722 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2723 drawTrace.Enable(true);
2725 Actor rootActor = Actor::New();
2726 Stage::GetCurrent().Add( rootActor );
2728 CameraActor offscreenCameraActor = CameraActor::New();
2729 Stage::GetCurrent().Add( offscreenCameraActor );
2731 Material material = CreateMaterial();
2732 Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2733 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2734 Integration::ResourceId imageRequestId = imageRequest->GetId();
2735 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2736 material.AddTexture( image, "sTexture");
2738 Geometry geometry = CreateQuadGeometry();
2739 Renderer renderer = Renderer::New(geometry, material);
2740 Actor secondRootActor = Actor::New();
2741 secondRootActor.AddRenderer(renderer);
2742 secondRootActor.SetSize(100, 100);
2743 Stage::GetCurrent().Add(secondRootActor);
2745 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2746 bool finished = false;
2747 RenderTaskFinished renderTaskFinished( finished );
2748 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2749 application.SendNotification();
2751 // START PROCESS/RENDER Input, Expected Input, Expected
2752 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2753 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2755 // FINISH RESOURCE LOADING - expect immediate rendering yet
2756 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2757 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2758 application.GetPlatform().ClearReadyResources();
2759 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2764 int UtcDaliRenderTaskOnceNoSync03(void)
2766 TestApplication application;
2768 tet_infoline("Testing RenderTask Render Once, using loading image. Switch from render always after ready to render once\n"
2769 "PRE: Render task ready, Image not loaded\n"
2770 "POST: Finished signal sent only once");
2772 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2773 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2774 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2775 drawTrace.Enable(true);
2777 Actor rootActor = Actor::New();
2778 Stage::GetCurrent().Add( rootActor );
2780 CameraActor offscreenCameraActor = CameraActor::New();
2781 Stage::GetCurrent().Add( offscreenCameraActor );
2782 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2783 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2784 Integration::ResourceId imageRequestId = imageRequest->GetId();
2785 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2786 Stage::GetCurrent().Add(secondRootActor);
2788 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2789 bool finished = false;
2790 RenderTaskFinished renderTaskFinished( finished );
2791 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2792 application.SendNotification();
2794 // START PROCESS/RENDER Input, Expected Input, Expected
2795 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2796 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2798 // FINISH RESOURCE LOADING
2799 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2800 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2801 application.GetPlatform().ClearReadyResources();
2803 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2804 application.SendNotification(); // Input, Expected Input, Expected
2805 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2806 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2810 int UtcDaliRenderTaskOnceNoSync04(void)
2812 TestApplication application;
2814 tet_infoline("Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loading image.\n"
2815 "Switch from render always after ready to render once\n"
2816 "PRE: Render task ready, Image not loaded\n"
2817 "POST: Finished signal sent only once");
2819 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2820 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2821 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2822 drawTrace.Enable(true);
2824 Actor rootActor = Actor::New();
2825 Stage::GetCurrent().Add( rootActor );
2827 CameraActor offscreenCameraActor = CameraActor::New();
2828 Stage::GetCurrent().Add( offscreenCameraActor );
2830 Material material = CreateMaterial();
2831 Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2832 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2833 Integration::ResourceId imageRequestId = imageRequest->GetId();
2834 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2835 material.AddTexture( image, "sTexture" );
2837 Geometry geometry = CreateQuadGeometry();
2838 Renderer renderer = Renderer::New(geometry, material);
2839 Actor secondRootActor = Actor::New();
2840 secondRootActor.AddRenderer(renderer);
2841 secondRootActor.SetSize(100, 100);
2842 Stage::GetCurrent().Add(secondRootActor);
2845 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2846 bool finished = false;
2847 RenderTaskFinished renderTaskFinished( finished );
2848 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2849 application.SendNotification();
2851 // START PROCESS/RENDER Input, Expected Input, Expected
2852 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2853 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2855 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2856 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2857 DALI_TEST_CHECK( lastSyncObj == NULL );
2859 // FINISH RESOURCE LOADING
2860 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2861 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2862 application.GetPlatform().ClearReadyResources();
2864 lastSyncObj = sync.GetLastSyncObject();
2865 DALI_TEST_CHECK( lastSyncObj == NULL );
2867 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2868 application.SendNotification(); // Input, Expected Input, Expected
2869 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2870 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2872 lastSyncObj = sync.GetLastSyncObject();
2873 DALI_TEST_CHECK( lastSyncObj == NULL );
2878 int UtcDaliRenderTaskOnceNoSync05(void)
2880 TestApplication application;
2882 tet_infoline("Testing RenderTask Render Once\n"
2883 "Switch from Render always after ready to render once with resources unready\n"
2884 "PRE: Everything ready to render\n"
2885 "POST: Finished signal sent once");
2887 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2888 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2889 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2890 drawTrace.Enable(true);
2892 Actor rootActor = Actor::New();
2893 Stage::GetCurrent().Add( rootActor );
2895 CameraActor offscreenCameraActor = CameraActor::New();
2896 Stage::GetCurrent().Add( offscreenCameraActor );
2897 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2898 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2899 Integration::ResourceId imageRequestId = imageRequest->GetId();
2900 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2901 Stage::GetCurrent().Add(secondRootActor);
2903 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2904 bool finished = false;
2905 RenderTaskFinished renderTaskFinished( finished );
2906 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2907 application.SendNotification();
2909 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2910 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2911 DALI_TEST_CHECK( lastSyncObj == NULL );
2913 // START PROCESS/RENDER Input, Expected Input, Expected
2914 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2915 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2917 // CHANGE TO RENDER ONCE
2918 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2919 application.SendNotification(); // Input, Expected Input, Expected
2920 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2921 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2923 // FINISH RESOURCE LOADING
2924 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2925 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2926 application.GetPlatform().ClearReadyResources();
2927 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
2932 //int UtcDaliRenderTaskOnceNoSync06(void)
2934 TestApplication application;
2936 tet_infoline("Testing RenderTask Render Once\n"
2937 "During RenderOnce, make ready resources unready before sending first finished signal\n"
2938 "PRE: Everything ready.\n"
2939 "POST: Finished signal sent only once");
2941 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2942 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2943 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2944 drawTrace.Enable(true);
2946 Actor rootActor = Actor::New();
2947 Stage::GetCurrent().Add( rootActor );
2949 CameraActor offscreenCameraActor = CameraActor::New();
2950 Stage::GetCurrent().Add( offscreenCameraActor );
2951 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
2952 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
2953 Integration::ResourceId imageRequestId = imageRequest->GetId();
2954 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
2955 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2956 application.Render();
2957 application.GetPlatform().ClearReadyResources();
2959 Stage::GetCurrent().Add(secondRootActor);
2961 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2962 bool finished = false;
2963 RenderTaskFinished renderTaskFinished( finished );
2964 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2965 application.SendNotification();
2967 // START PROCESS/RENDER Input, Expected Input, Expected
2968 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
2969 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
2971 // CHANGE TO RENDER ONCE, RESOURCES BECOME NOT READY
2972 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2975 ReloadImage(application, secondRootActor.GetImage());
2976 application.SendNotification(); // Input, Expected Input, Expected
2978 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2979 DALI_TEST_EQUALS( secondRootActor.GetImage().GetLoadingState(), Dali::ResourceLoading, TEST_LOCATION);
2980 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2982 // FINISH RESOURCE LOADING
2983 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
2984 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, true, true, __LINE__ ) );
2985 application.GetPlatform().ClearReadyResources();
2986 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2987 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2988 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2989 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
2994 int UtcDaliRenderTaskOnceNoSync07(void)
2996 TestApplication application;
2998 tet_infoline("Testing RenderTask Render Once\n"
2999 "Render once, Second call to SetRefreshRate(ONCE) triggers only one more finished signal\n"
3000 "PRE: Everything ready\n"
3001 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
3003 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3004 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3005 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3006 drawTrace.Enable(true);
3008 Actor rootActor = Actor::New();
3009 Stage::GetCurrent().Add( rootActor );
3011 CameraActor offscreenCameraActor = CameraActor::New();
3012 Stage::GetCurrent().Add( offscreenCameraActor );
3013 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3014 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3015 Integration::ResourceId imageRequestId = imageRequest->GetId();
3016 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
3017 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
3018 application.Render();
3019 application.GetPlatform().ClearReadyResources();
3021 Stage::GetCurrent().Add(secondRootActor);
3023 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3024 bool finished = false;
3025 RenderTaskFinished renderTaskFinished( finished );
3026 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3027 application.SendNotification();
3029 // START PROCESS/RENDER Input, Expected Input, Expected
3030 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
3032 // CHANGE TO RENDER ONCE,
3033 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3034 application.SendNotification();
3035 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3036 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3038 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3039 application.SendNotification();
3040 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3041 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3045 int UtcDaliRenderTaskOnceNoSync08(void)
3047 TestApplication application;
3049 tet_infoline("Testing RenderTask Render Once\n"
3050 "Render once, Call to SetRefreshRate(ONCE) in Finished signal callback triggers\n"
3051 "another render & another finished signal\n"
3052 "PRE: Everything ready\n"
3053 "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)");
3056 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3057 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3058 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3059 drawTrace.Enable(true);
3061 Actor rootActor = Actor::New();
3062 Stage::GetCurrent().Add( rootActor );
3064 CameraActor offscreenCameraActor = CameraActor::New();
3065 Stage::GetCurrent().Add( offscreenCameraActor );
3066 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3067 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3068 Integration::ResourceId imageRequestId = imageRequest->GetId();
3069 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
3070 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
3071 application.Render();
3072 application.GetPlatform().ClearReadyResources();
3074 Stage::GetCurrent().Add(secondRootActor);
3076 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3077 bool finished = false;
3079 ConnectionTracker connectionTracker;
3080 RenderTaskFinishedRenderAgain renderTaskFinishedRenderAgain( finished );
3081 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinishedRenderAgain );
3083 application.SendNotification();
3085 // START PROCESS/RENDER Input, Expected Input, Expected
3086 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
3088 // CHANGE TO RENDER ONCE,
3089 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3090 application.SendNotification();
3091 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3092 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3094 // Expect SetRefreshRate to have been called again
3095 // Prevent next finished signal calling refresh once again
3096 RenderTaskFinished renderTaskFinished( finished );
3097 connectionTracker.DisconnectAll();
3098 newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinished );
3100 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3101 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3106 int UtcDaliRenderTaskOnceNoSync09(void)
3108 TestApplication application;
3110 tet_infoline("Testing RenderTask Render Once\n"
3111 "SetRefreshRate(ONCE) again before first finished signal has been sent.\n"
3112 "PRE: resources ready\n"
3113 "POST: Only 1 finished signal sent.");
3115 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3116 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3117 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3118 drawTrace.Enable(true);
3120 Actor rootActor = Actor::New();
3121 Stage::GetCurrent().Add( rootActor );
3123 CameraActor offscreenCameraActor = CameraActor::New();
3124 Stage::GetCurrent().Add( offscreenCameraActor );
3125 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3126 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3127 Integration::ResourceId imageRequestId = imageRequest->GetId();
3128 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
3129 CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
3130 application.Render();
3131 application.GetPlatform().ClearReadyResources();
3133 Stage::GetCurrent().Add(secondRootActor);
3135 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3136 bool finished = false;
3137 RenderTaskFinished renderTaskFinished( finished );
3138 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3139 application.SendNotification();
3141 // START PROCESS/RENDER Input, Expected Input, Expected
3142 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) );
3144 // CHANGE TO RENDER ONCE,
3145 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3146 application.SendNotification();
3147 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3148 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3150 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3151 application.SendNotification();
3152 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) );
3153 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3157 int UtcDaliRenderTaskOnceNoSync10(void)
3159 TestApplication application;
3161 tet_infoline("Testing RenderTask Render Once\n"
3162 "SetRefreshRate(ONCE), resource load failed, completes render task.\n"
3163 "PRE: resources not ready\n"
3164 "POST: Only 1 finished signal sent.");
3166 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3167 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3168 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3169 drawTrace.Enable(true);
3171 Actor rootActor = Actor::New();
3172 Stage::GetCurrent().Add( rootActor );
3174 CameraActor offscreenCameraActor = CameraActor::New();
3175 Stage::GetCurrent().Add( offscreenCameraActor );
3176 ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3177 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3178 Integration::ResourceId imageRequestId = imageRequest->GetId();
3179 Stage::GetCurrent().Add(secondRootActor);
3181 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
3182 bool finished = false;
3183 RenderTaskFinished renderTaskFinished( finished );
3184 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3185 application.SendNotification();
3187 // START PROCESS/RENDER Input, Expected Input, Expected
3188 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3189 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3191 // CHANGE TO RENDER ONCE,
3192 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
3193 application.SendNotification();
3194 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3195 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3196 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) );
3198 FailImageLoad(application, imageRequestId); // Need to run Update again for this to complete
3199 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); // nothing to draw
3200 DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) );
3207 int UtcDaliRenderTaskOnceChain01(void)
3209 TestApplication application;
3211 tet_infoline("Testing RenderTask Render Once Chained render tasks\n"
3212 "SetRefreshRate(ONCE), resource load completes, both render tasks render.\n"
3213 "PRE: resources not ready\n"
3214 "POST: 2 finished signals sent.");
3216 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
3217 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3218 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3219 drawTrace.Enable(true);
3221 Actor defaultRootActor = Actor::New(); // Root for default RT
3222 Stage::GetCurrent().Add( defaultRootActor );
3224 CameraActor offscreenCameraActor = CameraActor::New();
3225 Stage::GetCurrent().Add( offscreenCameraActor );
3226 ImageActor firstRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
3227 Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
3228 Integration::ResourceId imageRequestId = imageRequest->GetId();
3229 Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
3230 Stage::GetCurrent().Add(firstRootActor);
3232 // first render task
3233 RenderTask firstTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, firstRootActor, RenderTask::REFRESH_ONCE, false);
3234 bool firstFinished = false;
3235 RenderTaskFinished renderTask1Finished( firstFinished );
3236 firstTask.FinishedSignal().Connect( &application, renderTask1Finished );
3238 // Second render task
3239 FrameBufferImage fbo = firstTask.GetTargetFrameBuffer();
3240 ImageActor secondRootActor = ImageActor::New( fbo );
3241 Stage::GetCurrent().Add(secondRootActor);
3242 RenderTask secondTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
3243 bool secondFinished = false;
3244 RenderTaskFinished renderTask2Finished( secondFinished );
3245 secondTask.FinishedSignal().Connect( &application, renderTask2Finished );
3247 application.SendNotification();
3249 // START PROCESS/RENDER Input, Expected Input, Expected
3250 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__ ) );
3251 DALI_TEST_CHECK( firstFinished == false );
3252 DALI_TEST_CHECK( secondFinished == false );
3253 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__ ) );
3254 DALI_TEST_CHECK( firstFinished == false );
3255 DALI_TEST_CHECK( secondFinished == false );
3257 CompleteImageLoad(application, imageRequestId, imageType);
3258 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__ ) );
3259 DALI_TEST_CHECK( firstFinished == false );
3260 DALI_TEST_CHECK( secondFinished == false );
3262 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, true, true, __LINE__ ) );
3263 DALI_TEST_CHECK( firstFinished == true );
3264 DALI_TEST_CHECK( secondFinished == false );
3266 DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, secondFinished, true, false, __LINE__ ) );
3267 DALI_TEST_CHECK( secondFinished == true );
3272 int UtcDaliRenderTaskProperties(void)
3274 TestApplication application;
3276 RenderTask task = Stage::GetCurrent().GetRenderTaskList().CreateTask();
3278 Property::IndexContainer indices;
3279 task.GetPropertyIndices( indices );
3280 DALI_TEST_CHECK( indices.Size() );
3281 DALI_TEST_EQUALS( indices.Size(), task.GetPropertyCount(), TEST_LOCATION );
3285 int UtcDaliRenderTaskSetScreenToFrameBufferMappingActor(void)
3287 TestApplication application;
3288 tet_infoline("Testing RenderTask::SetScreenToFrameBufferMappingActor ");
3290 Stage stage = Stage::GetCurrent();
3291 Size stageSize = stage.GetSize();
3292 Actor mappingActor = Actor::New();
3293 Vector2 scale( 0.6f, 0.75f);
3294 Vector2 offset( stageSize.x*0.1f, stageSize.y*0.15f);
3295 mappingActor.SetSize( stageSize * scale );
3296 mappingActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
3297 mappingActor.SetPosition( offset.x, offset.y );
3298 stage.Add( mappingActor );
3300 Actor offscreenActor = Actor::New();
3301 offscreenActor.SetSize( stageSize );
3302 offscreenActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
3303 stage.Add( offscreenActor );
3305 RenderTaskList taskList = stage.GetRenderTaskList();
3306 RenderTask renderTask = taskList.CreateTask();
3307 FrameBufferImage frameBufferImage = FrameBufferImage::New(stageSize.width*scale.x, stageSize.height*scale.y, Pixel::A8, Image::NEVER);
3308 renderTask.SetSourceActor( offscreenActor );
3309 renderTask.SetExclusive( true );
3310 renderTask.SetInputEnabled( true );
3311 renderTask.SetTargetFrameBuffer( frameBufferImage );
3312 renderTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
3313 renderTask.SetScreenToFrameBufferMappingActor( mappingActor );
3314 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3316 // Render and notify
3317 application.SendNotification();
3318 application.Render();
3319 application.Render();
3320 application.SendNotification();
3322 Vector2 screenCoordinates( stageSize.x * 0.05f, stageSize.y * 0.05f );
3323 Dali::HitTestAlgorithm::Results results;
3324 DALI_TEST_CHECK( !results.actor );
3325 DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
3326 // miss expected, results not changed
3327 DALI_TEST_CHECK( false == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3328 DALI_TEST_CHECK( !results.actor );
3329 DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
3331 screenCoordinates.x = stageSize.x * 0.265f;
3332 screenCoordinates.y = stageSize.y * 0.33f;
3333 results.actor = Actor();
3334 results.actorCoordinates = Vector2::ZERO;
3335 // hit expected, results changed
3336 DALI_TEST_CHECK( true == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3337 DALI_TEST_CHECK( results.actor == offscreenActor );
3338 DALI_TEST_EQUALS( (screenCoordinates-offset)/scale , results.actorCoordinates, 0.1f, TEST_LOCATION );
3340 screenCoordinates.x = stageSize.x * 0.435f;
3341 screenCoordinates.y = stageSize.y * 0.52f;
3342 // hit expected, results changed
3343 DALI_TEST_CHECK( true == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3344 DALI_TEST_CHECK( results.actor == offscreenActor );
3345 const Vector2 expectedCoordinates = (screenCoordinates-offset)/scale;
3346 DALI_TEST_EQUALS( expectedCoordinates , results.actorCoordinates, 0.1f, TEST_LOCATION );
3348 screenCoordinates.x = stageSize.x * 0.65f;
3349 screenCoordinates.y = stageSize.y * 0.95f;
3350 // miss expected, results not changed
3351 DALI_TEST_CHECK( false == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
3352 DALI_TEST_CHECK( results.actor == offscreenActor );
3353 DALI_TEST_EQUALS( expectedCoordinates , results.actorCoordinates, 0.1f, TEST_LOCATION );
3357 int UtcDaliRenderTaskFinishInvisibleSourceActor(void)
3359 TestApplication application;
3361 tet_infoline("Testing RenderTask::FinishInvisibleSourceActor()");
3363 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3364 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
3366 CameraActor offscreenCameraActor = CameraActor::New();
3368 Stage::GetCurrent().Add( offscreenCameraActor );
3370 BufferImage image = BufferImage::New( 10, 10 );
3371 ImageActor rootActor = ImageActor::New( image );
3372 rootActor.SetSize( 10, 10 );
3373 rootActor.SetVisible(false);
3374 Stage::GetCurrent().Add( rootActor );
3376 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3377 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
3378 FrameBufferImage frameBufferImage = FrameBufferImage::New( *testNativeImagePtr.Get() );
3380 // Flush all outstanding messages
3381 application.SendNotification();
3382 application.Render();
3384 RenderTask newTask = taskList.CreateTask();
3385 newTask.SetCameraActor( offscreenCameraActor );
3386 newTask.SetSourceActor( rootActor );
3387 newTask.SetInputEnabled( false );
3388 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
3389 newTask.SetClearEnabled( true );
3390 newTask.SetExclusive( true );
3391 newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
3392 newTask.SetTargetFrameBuffer( frameBufferImage );
3393 newTask.SetProperty( RenderTask::Property::REQUIRES_SYNC, true );
3395 // Framebuffer doesn't actually get created until Connected, i.e. by previous line
3397 bool finished = false;
3398 RenderTaskFinished renderTaskFinished( finished );
3399 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3401 // Flush the queue and render.
3402 application.SendNotification();
3404 // 1 render to process render task, then wait for sync before finished msg is sent
3405 // from update to the event thread.
3407 application.Render();
3408 application.SendNotification();
3409 DALI_TEST_CHECK( !finished );
3411 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
3412 DALI_TEST_CHECK( lastSyncObj != NULL );
3414 application.Render();
3415 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
3416 application.SendNotification();
3417 DALI_TEST_CHECK( !finished );
3419 application.Render();
3420 DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
3421 application.SendNotification();
3422 DALI_TEST_CHECK( ! finished );
3424 sync.SetObjectSynced( lastSyncObj, true );
3426 application.Render();
3427 application.SendNotification();
3428 DALI_TEST_CHECK( !finished );
3430 application.Render();
3431 application.SendNotification();
3432 DALI_TEST_CHECK( finished );
3435 application.Render(); // Double check no more finished signal
3436 application.SendNotification();
3437 DALI_TEST_CHECK( ! finished );
3442 int UtcDaliRenderTaskFinishMissingImage(void)
3444 TestApplication application;
3446 // Previously we had bugs where not having a resource ID would cause render-tasks to wait forever
3447 tet_infoline("Testing RenderTask::SignalFinished() when an ImageActor has no Image set");
3449 Stage stage = Stage::GetCurrent();
3451 BufferImage image = BufferImage::New( 10, 10 );
3452 ImageActor rootActor = ImageActor::New( image );
3453 rootActor.SetSize( 10, 10 );
3454 stage.Add( rootActor );
3456 ImageActor actorWithMissingImage = ImageActor::New( Image() );
3457 actorWithMissingImage.SetSize( 10, 10 );
3458 stage.Add( actorWithMissingImage );
3460 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3461 RenderTask newTask = taskList.CreateTask();
3462 newTask.SetInputEnabled( false );
3463 newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
3464 newTask.SetClearEnabled( true );
3465 newTask.SetExclusive( true );
3466 newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
3468 bool finished = false;
3469 RenderTaskFinished renderTaskFinished( finished );
3470 newTask.FinishedSignal().Connect( &application, renderTaskFinished );
3472 // 1 render to process render task, then 1 before finished msg is sent from update to the event thread.
3473 application.SendNotification();
3474 application.Render();
3475 application.Render();
3477 application.SendNotification();
3478 DALI_TEST_CHECK( finished );
3483 int UtcDaliRenderTaskWorldToViewport(void)
3485 TestApplication application( static_cast<size_t>(400), static_cast<size_t>(400) ); // square surface
3487 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3489 Actor actor = Actor::New();
3490 actor.SetSize(100.0f, 100.0f);
3491 actor.SetPosition( Vector3(0.0, 0.0, 0.0) );
3493 actor.SetParentOrigin( Vector3(0.5, 0.5, 0.5) );
3494 actor.SetAnchorPoint( Vector3(0.5, 0.5, 0.5) );
3496 Stage::GetCurrent().Add(actor);
3498 application.SendNotification();
3499 application.Render();
3500 application.SendNotification();
3502 RenderTask task = taskList.GetTask( 0u );
3504 CameraActor camera = task.GetCameraActor();
3506 Vector2 screenSize = task.GetCurrentViewportSize();
3508 float screenX = 0.0;
3509 float screenY = 0.0;
3511 bool ok = task.WorldToViewport(actor.GetCurrentWorldPosition(), screenX, screenY);
3512 DALI_TEST_CHECK(ok == true);
3514 DALI_TEST_EQUALS(screenX, screenSize.x/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
3515 DALI_TEST_EQUALS(screenY, screenSize.y/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
3517 Actor actor2 = Actor::New();
3518 float actor2Size = 100.f;
3519 actor2.SetSize( actor2Size, actor2Size );
3520 actor2.SetPosition( Vector3(0.0, 0.0, 0.0) );
3521 actor2.SetParentOrigin( Vector3(0.5, 0.5, 0.0) );
3522 actor2.SetAnchorPoint( Vector3(0.5, 0.5, 0.0) );
3523 Stage::GetCurrent().Add( actor2 );
3525 actor.SetParentOrigin( Vector3(0,0,0) );
3527 application.SendNotification();
3528 application.Render();
3529 application.SendNotification();
3531 ok = task.WorldToViewport(actor.GetCurrentWorldPosition(), screenX, screenY);
3532 DALI_TEST_CHECK(ok == true);
3534 DALI_TEST_EQUALS(screenX, screenSize.x/2 - actor2Size/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
3535 DALI_TEST_EQUALS(screenY, screenSize.y/2 - actor2Size/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
3541 int UtcDaliRenderTaskViewportToLocal(void)
3543 TestApplication application;
3544 Actor actor = Actor::New();
3545 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
3546 actor.SetSize(100.0f, 100.0f);
3547 actor.SetPosition(10.0f, 10.0f);
3548 Stage::GetCurrent().Add(actor);
3550 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
3551 RenderTask task = taskList.GetTask( 0u );
3553 // flush the queue and render once
3554 application.SendNotification();
3555 application.Render();
3556 application.SendNotification();
3557 application.Render();
3565 float screenX = 50.0f;
3566 float screenY = 50.0f;
3568 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, screenX, screenY) );
3570 DALI_TEST_CHECK( task.ViewportToLocal(actor, screenX, screenY, rtLocalX, rtLocalY ) );
3572 DALI_TEST_EQUALS(localX, rtLocalX, 0.01f, TEST_LOCATION);
3573 DALI_TEST_EQUALS(localY, rtLocalY, 0.01f, TEST_LOCATION);