2 * Copyright (c) 2020 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.
18 #include <dali-test-suite-utils.h>
19 #include <dali/devel-api/events/hit-test-algorithm.h>
20 #include <dali/integration-api/debug.h>
21 #include <dali/public-api/dali-core.h>
22 #include <mesh-builder.h>
24 #include <test-native-image.h>
28 #define BOOLSTR(x) ((x) ? "T" : "F")
30 //& set: DaliRenderTask
34 void utc_dali_render_task_startup(void)
36 test_return_value = TET_UNDEF;
39 void utc_dali_render_task_cleanup(void)
41 test_return_value = TET_PASS;
47 * Constructor, Destructor, DownCast, New, copy constructor, assignment operator
49 * SetSourceActor 2+ve, 1-ve
50 * GetSourceActor 1+ve, 1-ve
51 * SetExclusive 2+ve, 0-ve
52 * IsExclusive 2+ve, 0-ve
53 * SetInputEnabled 1+ve, 0-ve
54 * GetInputEnabled 1+ve, 0-ve
55 * SetCameraActor 1+ve, 1-ve
56 * GetCameraActor 1+ve, 1-ve
57 * SetTargetFrameBuffer 1+ve, 1-ve
58 * GetTargetFrameBuffer 1+ve, 1-ve
59 * SetScreenToFrameBufferFunction 1+ve, 1-ve
60 * GetScreenToFrameBufferFunction 1+ve, 1-ve
61 * SetScreenToFrameBufferMappingActor 1+ve, 1-ve
62 * GetScreenToFrameBufferMappingActor 1+ve, 1-ve
63 * SetViewportPosition 1+ve
64 * GetCurrentViewportPosition 1+ve
65 * SetViewportSize 1+ve
66 * GetCurrentViewportSize 1+ve
67 * SetViewport 2+ve, 1-ve
68 * GetViewport 2+ve, 1-ve
69 * SetClearColor 1+ve, 1-ve
70 * GetClearColor 1+ve, 1-ve
71 * SetClearEnabled 1+ve, 1-ve
72 * GetClearEnabled 1+ve, 1-ve
80 namespace // unnamed namespace
82 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
85 * Simulate time passed by.
87 * @note this will always process at least 1 frame (1/60 sec)
89 * @param application Test application instance
90 * @param duration Time to pass in milliseconds.
91 * @return The actual time passed in milliseconds
93 int Wait(TestApplication& application, int duration = 0)
97 for(int i = 0; i <= (duration / RENDER_FRAME_INTERVAL); i++)
99 application.SendNotification();
100 application.Render(RENDER_FRAME_INTERVAL);
101 time += RENDER_FRAME_INTERVAL;
107 struct RenderTaskFinished
109 RenderTaskFinished(bool& finished)
114 void operator()(RenderTask& renderTask)
122 struct RenderTaskFinishedRemoveSource
124 RenderTaskFinishedRemoveSource(bool& finished)
125 : finished(finished),
130 void operator()(RenderTask& renderTask)
132 DALI_TEST_CHECK(finishedOnce == false);
135 Actor srcActor = renderTask.GetSourceActor();
136 UnparentAndReset(srcActor);
143 struct RenderTaskFinishedRenderAgain
145 RenderTaskFinishedRenderAgain(bool& finished)
146 : finished(finished),
151 void operator()(RenderTask& renderTask)
153 DALI_TEST_CHECK(finishedOnce == false);
156 renderTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
163 bool TestScreenToFrameBufferFunction(Vector2& coordinates)
165 coordinates = coordinates + Vector2(1, 2);
170 Actor CreateRenderableActorSuccess(TestApplication& application, std::string filename)
172 Actor actor = CreateRenderableActor();
173 actor.SetProperty(Actor::Property::SIZE, Vector2(80.0f, 80.0f));
177 Texture CreateTexture()
179 return Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 80u, 80u);
182 RenderTask CreateRenderTask(TestApplication& application,
183 CameraActor offscreenCamera,
184 Actor rootActor, // Reset default render task to point at this actor
185 Actor secondRootActor, // Source actor
186 unsigned int refreshRate,
189 // Change main render task to use a different root
190 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
191 taskList.GetTask(0u).SetSourceActor(rootActor);
193 FrameBuffer frameBuffer = FrameBuffer::New(10, 10);
196 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
197 Texture texture = Texture::New(*testNativeImagePtr);
198 frameBuffer.AttachColorTexture(texture);
201 // Don't draw output framebuffer // '
203 RenderTask newTask = taskList.CreateTask();
204 newTask.SetCameraActor(offscreenCamera);
205 newTask.SetSourceActor(secondRootActor);
206 newTask.SetInputEnabled(false);
207 newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
208 newTask.SetClearEnabled(true);
209 newTask.SetExclusive(true);
210 newTask.SetRefreshRate(refreshRate);
211 newTask.SetFrameBuffer(frameBuffer);
212 newTask.SetProperty(RenderTask::Property::REQUIRES_SYNC, glSync);
216 bool UpdateRender(TestApplication& application, TraceCallStack& callStack, bool testDrawn, bool& finishedSig, bool testFinished, bool testKeepUpdating, int lineNumber)
221 tet_printf("TestApplication::UpdateRender().\n");
223 application.Render(16);
224 application.SendNotification();
226 bool sigPassed = false;
229 sigPassed = finishedSig;
233 sigPassed = !finishedSig;
236 bool drawResult = callStack.FindMethod("DrawElements") || callStack.FindMethod("DrawArrays");
238 bool drawPassed = false;
241 drawPassed = drawResult;
245 drawPassed = !drawResult;
248 bool keepUpdating = (application.GetUpdateStatus() != 0);
249 bool keepUpdatingPassed = false;
252 keepUpdatingPassed = keepUpdating;
256 keepUpdatingPassed = !keepUpdating;
259 bool result = (sigPassed && drawPassed && keepUpdatingPassed);
261 tet_printf("UpdateRender: Expected: Draw:%s Signal:%s KeepUpdating: %s Actual: Draw:%s Signal:%s KeepUpdating: %s %s, line %d\n",
263 BOOLSTR(testFinished),
264 BOOLSTR(testKeepUpdating),
266 BOOLSTR(finishedSig),
267 BOOLSTR(keepUpdating),
268 result ? "Passed" : "Failed",
274 } // unnamed namespace
276 /****************************************************************************************************/
277 /****************************************************************************************************/
278 /******************************** TEST CASES BELOW **********************************************/
279 /****************************************************************************************************/
280 /****************************************************************************************************/
282 int UtcDaliRenderTaskDownCast01(void)
284 TestApplication application;
286 tet_infoline("Testing RenderTask::DownCast()");
288 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
290 BaseHandle base = taskList.GetTask(0u);
291 DALI_TEST_CHECK(base);
293 RenderTask task = RenderTask::DownCast(base);
294 DALI_TEST_CHECK(task);
296 // Try calling a method
297 DALI_TEST_CHECK(task.GetSourceActor());
301 int UtcDaliRenderTaskDownCast02(void)
303 TestApplication application;
305 tet_infoline("Testing RenderTask::DownCast()");
307 Actor actor = Actor::New();
309 RenderTask task = RenderTask::DownCast(actor);
310 DALI_TEST_CHECK(!task);
315 int UtcDaliRenderTaskSetSourceActorN(void)
317 TestApplication application;
318 tet_infoline("Testing RenderTask::SetSourceActor() Negative - try with empty actor handle");
319 Integration::Scene stage = application.GetScene();
323 RenderTaskList taskList = stage.GetRenderTaskList();
324 RenderTask renderTask = taskList.CreateTask();
325 renderTask.SetSourceActor(srcActor);
327 application.SendNotification();
328 application.Render();
330 DALI_TEST_CHECK(!renderTask.GetSourceActor());
334 int UtcDaliRenderTaskSetSourceActorP01(void)
336 TestApplication application;
338 tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that setting a non-renderable actor stops existing source actor being rendered ");
340 Integration::Scene stage = application.GetScene();
341 RenderTaskList taskList = stage.GetRenderTaskList();
342 RenderTask task = taskList.GetTask(0u);
344 Actor actor = task.GetSourceActor();
345 DALI_TEST_CHECK(actor);
347 Texture img = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
348 Actor newActor = CreateRenderableActor(img);
349 newActor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
352 Actor nonRenderableActor = Actor::New();
353 stage.Add(nonRenderableActor);
355 // Stop the newActor from being rendered by changing the source actor
356 DALI_TEST_CHECK(nonRenderableActor);
357 task.SetSourceActor(nonRenderableActor);
358 DALI_TEST_CHECK(task.GetSourceActor() != actor);
359 DALI_TEST_CHECK(task.GetSourceActor() == nonRenderableActor);
361 TestGlAbstraction& gl = application.GetGlAbstraction();
362 TraceCallStack& drawTrace = gl.GetDrawTrace();
363 drawTrace.Enable(true);
365 // Update & Render nothing!
366 application.GetGlAbstraction().ClearBoundTextures();
367 application.SendNotification();
368 application.Render();
370 // Check that nothing was rendered
371 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
376 int UtcDaliRenderTaskSetSourceActorP02(void)
378 TestApplication application;
380 tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that switching source from a non-renderable to a renderable actor causes the texture to be drawn");
382 Integration::Scene stage = application.GetScene();
384 RenderTaskList taskList = stage.GetRenderTaskList();
386 RenderTask task = taskList.GetTask(0u);
388 Actor actor = task.GetSourceActor();
389 DALI_TEST_CHECK(actor);
391 Texture img = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
392 Actor newActor = CreateRenderableActor(img);
393 newActor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
396 Actor nonRenderableActor = Actor::New();
397 stage.Add(nonRenderableActor);
399 TestGlAbstraction& gl = application.GetGlAbstraction();
400 TraceCallStack& drawTrace = gl.GetDrawTrace();
401 drawTrace.Enable(true);
403 // Stop the newActor from being rendered by changing the source actor
404 DALI_TEST_CHECK(nonRenderableActor);
405 task.SetSourceActor(nonRenderableActor);
406 DALI_TEST_CHECK(task.GetSourceActor() != actor);
407 DALI_TEST_CHECK(task.GetSourceActor() == nonRenderableActor);
409 // Update & Render nothing!
410 application.GetGlAbstraction().ClearBoundTextures();
411 application.SendNotification();
412 application.Render();
414 // Check that nothing was rendered
415 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
418 // Set newActor as the new source Actor
419 task.SetSourceActor(newActor);
420 DALI_TEST_CHECK(task.GetSourceActor() != actor);
421 DALI_TEST_CHECK(task.GetSourceActor() == newActor);
423 // Update & Render the newActor
424 application.GetGlAbstraction().ClearBoundTextures();
425 application.SendNotification();
426 application.Render();
428 // Check that the newActor was rendered
429 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
433 int UtcDaliRenderTaskSetSourceActorOffScene(void)
435 TestApplication application;
437 tet_infoline("Testing RenderTask::SetSourceActor (on/off stage testing)");
439 Integration::Scene stage = application.GetScene();
440 RenderTaskList taskList = stage.GetRenderTaskList();
441 RenderTask task = taskList.GetTask(0u);
443 Actor actor = task.GetSourceActor();
444 DALI_TEST_CHECK(actor);
446 TestGlAbstraction& gl = application.GetGlAbstraction();
447 TraceCallStack& drawTrace = gl.GetDrawTrace();
448 drawTrace.Enable(true);
450 Texture img = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
451 Actor newActor = CreateRenderableActor(img);
452 newActor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
453 task.SetSourceActor(newActor);
454 // Don't add newActor to stage yet //'
456 // Update & Render with the actor initially off-stage
457 application.SendNotification();
458 application.Render();
460 // Check that nothing was rendered
461 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
466 // Update & Render with the actor on-stage
467 application.GetGlAbstraction().ClearBoundTextures();
468 application.SendNotification();
469 application.Render();
471 // Check that the newActor was rendered
472 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
475 // Now remove from stage
476 stage.Remove(newActor);
478 // Update & Render with the actor off-stage
479 application.SendNotification();
480 application.Render();
481 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
486 int UtcDaliRenderTaskSetSourceActorEmpty(void)
488 TestApplication application;
490 tet_infoline("Testing RenderTask::SetSourceActor (empty handle case)");
492 Integration::Scene stage = application.GetScene();
493 RenderTaskList taskList = stage.GetRenderTaskList();
494 RenderTask task = taskList.GetTask(0u);
496 Actor actor = task.GetSourceActor();
497 DALI_TEST_CHECK(actor);
499 Texture img = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
500 Actor newActor = CreateRenderableActor(img);
501 newActor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
504 Actor nonRenderableActor = Actor::New();
505 stage.Add(nonRenderableActor);
507 // Set with empty handle
508 task.SetSourceActor(Actor());
509 DALI_TEST_CHECK(!task.GetSourceActor());
511 TestGlAbstraction& gl = application.GetGlAbstraction();
512 TraceCallStack& drawTrace = gl.GetDrawTrace();
513 drawTrace.Enable(true);
515 // Update & Render nothing!
516 application.SendNotification();
517 application.Render();
519 // Check that nothing was rendered
520 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
522 // Set with non-empty handle
523 task.SetSourceActor(newActor);
524 DALI_TEST_CHECK(task.GetSourceActor() == newActor);
526 // Update & Render the newActor
527 application.GetGlAbstraction().ClearBoundTextures();
528 application.SendNotification();
529 application.Render();
531 // Check that the newActor was rendered
532 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
536 int UtcDaliRenderTaskSetSourceActorDestroyed(void)
538 TestApplication application;
540 tet_infoline("Testing RenderTask::SetSourceActor - Set a source actor and destroy the source actor");
542 Integration::Scene stage = application.GetScene();
543 RenderTaskList taskList = stage.GetRenderTaskList();
544 RenderTask task = taskList.GetTask(0u);
546 Actor actor = task.GetSourceActor();
547 DALI_TEST_CHECK(actor);
549 Texture img = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
551 Actor newActor = CreateRenderableActor(img);
552 newActor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
555 task.SetSourceActor(newActor);
557 DALI_TEST_CHECK(task.GetSourceActor() != actor);
558 DALI_TEST_CHECK(task.GetSourceActor() == newActor);
560 application.SendNotification();
561 application.Render();
563 // Destroy the source actor
564 stage.Remove(newActor);
567 DALI_TEST_CHECK(!task.GetSourceActor()); // The source actor should be an empty handle.
572 int UtcDaliRenderTaskGetSourceActorP01(void)
574 TestApplication application;
576 tet_infoline("Testing RenderTask::GetSourceActor() Check the default render task has a valid source actor");
578 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
580 RenderTask task = taskList.GetTask(0u);
582 Actor actor = task.GetSourceActor();
583 DALI_TEST_CHECK(actor);
585 // By default the entire scene should be rendered
586 Actor root = application.GetScene().GetLayer(0);
587 DALI_TEST_CHECK(root == actor);
591 int UtcDaliRenderTaskGetSourceActorP02(void)
593 TestApplication application;
595 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.");
597 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
598 RenderTask task = taskList.CreateTask();
599 Actor actor = Actor::New();
600 application.GetScene().Add(actor);
601 task.SetSourceActor(actor);
603 DALI_TEST_EQUALS(actor, task.GetSourceActor(), TEST_LOCATION);
608 int UtcDaliRenderTaskGetSourceActorN(void)
610 TestApplication application;
612 tet_infoline("Testing RenderTask::GetSourceActor() Try with empty handle");
617 Actor actor = task.GetSourceActor();
619 catch(Dali::DaliException& e)
621 DALI_TEST_PRINT_ASSERT(e);
622 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
628 int UtcDaliRenderTaskSetExclusive(void)
630 TestApplication application;
632 tet_infoline("Testing RenderTask::SetExclusive() Check that exclusion works");
634 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
636 // Manipulate the GenTextures behaviour, to identify different actors
638 std::vector<GLuint> ids;
639 ids.push_back(8); // 8 = actor1
640 ids.push_back(9); // 9 = actor2
641 ids.push_back(10); // 10 = actor3
642 application.GetGlAbstraction().SetNextTextureIds(ids);
644 Texture img1 = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
645 Actor actor1 = CreateRenderableActor(img1);
646 actor1.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
647 application.GetScene().Add(actor1);
649 // Update & Render actor1
650 application.SendNotification();
651 application.Render();
653 // Check that the actor1 was rendered
654 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures(GL_TEXTURE0);
655 DALI_TEST_GREATER(boundTextures.size(), static_cast<std::vector<GLuint>::size_type>(0), TEST_LOCATION);
657 if(boundTextures.size())
660 DALI_TEST_EQUALS(boundTextures[c++], 8u /*unique to actor1*/, TEST_LOCATION);
661 if(boundTextures.size() > 1)
663 DALI_TEST_EQUALS(boundTextures[c++], 8u /*unique to actor1*/, TEST_LOCATION);
667 Texture img2 = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
669 Actor actor2 = CreateRenderableActor(img2);
670 actor2.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
672 // Force actor2 to be rendered before actor1
673 Layer layer = Layer::New();
674 application.GetScene().Add(layer);
676 layer.LowerToBottom();
679 application.GetGlAbstraction().ClearBoundTextures();
680 application.SendNotification();
681 application.Render();
683 // Check that the actors were rendered
684 DALI_TEST_GREATER(boundTextures.size(), static_cast<std::vector<GLuint>::size_type>(1), TEST_LOCATION);
686 if(boundTextures.size())
689 DALI_TEST_EQUALS(boundTextures[c++], 9u /*unique to actor2*/, TEST_LOCATION);
690 if(boundTextures.size() > 2)
692 DALI_TEST_EQUALS(boundTextures[c++], 9u /*unique to actor1*/, TEST_LOCATION);
694 DALI_TEST_EQUALS(boundTextures[c++], 8u /*unique to actor1*/, TEST_LOCATION);
697 Texture img3 = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
698 Actor actor3 = CreateRenderableActor(img3);
699 actor3.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
701 // Force actor3 to be rendered before actor2
702 layer = Layer::New();
703 application.GetScene().Add(layer);
705 layer.LowerToBottom();
707 // Update & Render all actors
708 application.GetGlAbstraction().ClearBoundTextures();
709 application.SendNotification();
710 application.Render();
712 // Check that the actors were rendered
713 DALI_TEST_GREATER(boundTextures.size(), static_cast<std::vector<GLuint>::size_type>(2), TEST_LOCATION);
715 if(boundTextures.size())
718 DALI_TEST_EQUALS(boundTextures[c++], 10u /*unique to actor3*/, TEST_LOCATION);
719 if(boundTextures.size() > 3)
721 DALI_TEST_EQUALS(boundTextures[c++], 10u /*unique to actor2*/, TEST_LOCATION);
723 DALI_TEST_EQUALS(boundTextures[c++], 9u /*unique to actor2*/, TEST_LOCATION);
724 DALI_TEST_EQUALS(boundTextures[c++], 8u /*unique to actor1*/, TEST_LOCATION);
727 // Both actors are now connected to the root node
728 // Setup 2 render-tasks - the first will render from the root-node, and the second from actor2
730 // Not exclusive is the default
731 RenderTask task1 = taskList.GetTask(0u);
732 DALI_TEST_CHECK(false == task1.IsExclusive());
734 RenderTask task2 = taskList.CreateTask();
735 DALI_TEST_CHECK(false == task2.IsExclusive());
736 task2.SetSourceActor(actor2);
738 // Task1 should render all actors, and task 2 should render only actor2
740 application.GetGlAbstraction().ClearBoundTextures();
741 application.SendNotification();
742 application.Render();
744 DALI_TEST_EQUALS(boundTextures.size(), 4u, TEST_LOCATION);
746 if(boundTextures.size() == 4)
748 // Test that task 1 renders actor3, then actor2 & then actor1
749 DALI_TEST_CHECK(boundTextures[0] == 10u);
750 DALI_TEST_CHECK(boundTextures[1] == 9u);
751 DALI_TEST_CHECK(boundTextures[2] == 8u);
753 // Test that task 2 renders actor2
754 DALI_TEST_EQUALS(boundTextures[3], 9u, TEST_LOCATION);
757 // Make actor2 exclusive to task2
759 task2.SetExclusive(true);
760 DALI_TEST_CHECK(true == task2.IsExclusive());
762 // Task1 should render only actor1, and task 2 should render only actor2
764 application.GetGlAbstraction().ClearBoundTextures();
765 application.SendNotification();
766 application.Render();
768 DALI_TEST_EQUALS(boundTextures.size(), 3u, TEST_LOCATION);
769 if(boundTextures.size() == 3)
771 // Test that task 1 renders actor3 & actor1
772 DALI_TEST_CHECK(boundTextures[0] == 10u);
773 DALI_TEST_CHECK(boundTextures[1] == 8u);
775 // Test that task 2 renders actor2
776 DALI_TEST_CHECK(boundTextures[2] == 9u);
779 // Create a renderable actor and replace the source actor in task2
780 auto actor4 = CreateRenderableActor();
781 task2.SetSourceActor(actor3);
782 DALI_TEST_EQUALS(actor3, task2.GetSourceActor(), TEST_LOCATION);
787 int UtcDaliRenderTaskSetExclusive02(void)
789 TestApplication application;
791 tet_infoline("Testing RenderTask::SetExclusive() Check that changing from exclusive to not-exclusive works");
793 std::vector<GLuint> ids;
794 ids.push_back(8); // 8 = actor1
795 application.GetGlAbstraction().SetNextTextureIds(ids);
797 Texture img1 = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
798 Actor actor1 = CreateRenderableActor(img1);
799 actor1.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
800 application.GetScene().Add(actor1);
802 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
803 RenderTask task = taskList.CreateTask();
805 task.SetSourceActor(actor1);
806 task.SetExclusive(true); // Actor should only render once
808 TestGlAbstraction& gl = application.GetGlAbstraction();
809 TraceCallStack& drawTrace = gl.GetDrawTrace();
810 drawTrace.Enable(true);
812 // Update & Render actor1
813 application.SendNotification();
814 application.Render();
816 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
818 // Set task to non-exclusive - actor1 should render twice:
820 task.SetExclusive(false);
821 application.SendNotification();
822 application.Render();
824 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 2, TEST_LOCATION);
829 int UtcDaliRenderTaskSetExclusiveN(void)
831 TestApplication application;
833 tet_infoline("Testing RenderTask::SetExclusive() on empty handle");
838 task.SetExclusive(true);
840 catch(Dali::DaliException& e)
842 DALI_TEST_PRINT_ASSERT(e);
843 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
848 int UtcDaliRenderTaskIsExclusive01(void)
850 TestApplication application;
852 tet_infoline("Testing RenderTask::IsExclusive() Check default values are non-exclusive");
854 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
856 // Not exclusive is the default
857 RenderTask task = taskList.GetTask(0u);
858 DALI_TEST_CHECK(false == task.IsExclusive());
860 RenderTask newTask = taskList.CreateTask();
861 DALI_TEST_CHECK(false == newTask.IsExclusive());
866 int UtcDaliRenderTaskIsExclusive02(void)
868 TestApplication application;
870 tet_infoline("Testing RenderTask::IsExclusive() Check the getter returns set values");
872 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
874 // Not exclusive is the default
875 RenderTask newTask = taskList.CreateTask();
876 DALI_TEST_EQUALS(newTask.IsExclusive(), false, TEST_LOCATION);
878 newTask.SetExclusive(true);
879 DALI_TEST_EQUALS(newTask.IsExclusive(), true, TEST_LOCATION);
883 int UtcDaliRenderTaskIsExclusiveN(void)
885 TestApplication application;
887 tet_infoline("Testing RenderTask::IsExclusive() on empty handle");
892 bool x = task.IsExclusive();
895 catch(Dali::DaliException& e)
897 DALI_TEST_PRINT_ASSERT(e);
898 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
903 int UtcDaliRenderTaskSetInputEnabled(void)
905 TestApplication application;
907 tet_infoline("Testing RenderTask::SetInputEnabled()");
909 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
911 // Input is enabled by default
912 RenderTask task = taskList.GetTask(0u);
913 DALI_TEST_CHECK(true == task.GetInputEnabled());
915 task.SetInputEnabled(false);
916 DALI_TEST_CHECK(false == task.GetInputEnabled());
918 task.SetInputEnabled(true);
919 DALI_TEST_CHECK(true == task.GetInputEnabled());
923 int UtcDaliRenderTaskGetInputEnabled(void)
925 TestApplication application;
927 tet_infoline("Testing RenderTask::GetInputEnabled()");
929 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
931 // Input is enabled by default
932 RenderTask task = taskList.GetTask(0u);
933 DALI_TEST_EQUALS(true, task.GetInputEnabled(), TEST_LOCATION);
935 RenderTask newTask = taskList.CreateTask();
936 DALI_TEST_EQUALS(true, newTask.GetInputEnabled(), TEST_LOCATION);
938 newTask.SetInputEnabled(false);
939 DALI_TEST_EQUALS(false, newTask.GetInputEnabled(), TEST_LOCATION);
944 int UtcDaliRenderTaskSetCameraActorP(void)
946 TestApplication application;
948 tet_infoline("Testing RenderTask::SetCameraActor()");
950 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
952 RenderTask task = taskList.GetTask(0u);
954 Actor defaultCameraActor = task.GetCameraActor();
955 DALI_TEST_CHECK(defaultCameraActor);
957 CameraActor newCameraActor = CameraActor::New();
958 DALI_TEST_CHECK(newCameraActor);
960 task.SetCameraActor(newCameraActor);
961 DALI_TEST_CHECK(task.GetCameraActor() != defaultCameraActor);
962 DALI_TEST_EQUALS(task.GetCameraActor(), newCameraActor, TEST_LOCATION);
966 int UtcDaliRenderTaskSetCameraActorN(void)
968 TestApplication application;
970 tet_infoline("Testing RenderTask::SetCameraActor() with empty actor handle");
972 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
974 RenderTask task = taskList.GetTask(0u);
976 Actor actor = task.GetCameraActor();
977 DALI_TEST_CHECK(actor);
979 CameraActor cameraActor;
981 task.SetCameraActor(cameraActor);
982 DALI_TEST_EQUALS((bool)task.GetCameraActor(), false, TEST_LOCATION);
983 DALI_TEST_EQUALS(task.GetCameraActor(), cameraActor, TEST_LOCATION);
987 int UtcDaliRenderTaskSetCameraActorDestroyed(void)
989 TestApplication application;
991 tet_infoline("Testing RenderTask::SetCameraActor - Set a camera actor and destroy the camera actor");
993 Integration::Scene stage = application.GetScene();
994 RenderTaskList taskList = stage.GetRenderTaskList();
995 RenderTask task = taskList.GetTask(0u);
997 CameraActor newCameraActor = CameraActor::New();
998 task.SetCameraActor(newCameraActor);
1000 DALI_TEST_EQUALS(task.GetCameraActor(), newCameraActor, TEST_LOCATION);
1002 // Destroy the camera actor
1003 newCameraActor.Reset();
1005 CameraActor camera = task.GetCameraActor();
1006 DALI_TEST_CHECK(!camera); // The camera actor should be an empty handle.
1011 int UtcDaliRenderTaskGetCameraActorP(void)
1013 TestApplication application;
1015 tet_infoline("Testing RenderTask::GetCameraActor()");
1017 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1019 RenderTask task = taskList.GetTask(0u);
1021 CameraActor actor = task.GetCameraActor();
1022 DALI_TEST_CHECK(actor);
1023 DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION);
1024 DALI_TEST_GREATER(actor.GetFieldOfView(), 0.0f, TEST_LOCATION);
1028 int UtcDaliRenderTaskGetCameraActorN(void)
1030 TestApplication application;
1032 tet_infoline("Testing RenderTask::GetCameraActor() with empty handle");
1037 Actor actor = task.GetCameraActor();
1039 catch(Dali::DaliException& e)
1041 DALI_TEST_PRINT_ASSERT(e);
1042 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1048 int UtcDaliRenderTaskSetFrameBufferP(void)
1050 TestApplication application;
1052 tet_infoline("Testing RenderTask::SetFrameBuffer()");
1054 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1056 RenderTask task = taskList.GetTask(0u);
1058 FrameBuffer newFrameBuffer = FrameBuffer::New(128u, 128u, FrameBuffer::Attachment::NONE);
1059 task.SetFrameBuffer(newFrameBuffer);
1060 DALI_TEST_CHECK(task.GetFrameBuffer() == newFrameBuffer);
1064 int UtcDaliRenderTaskSetFrameBufferN(void)
1066 TestApplication application;
1068 tet_infoline("Testing RenderTask::SetFrameBuffer()");
1070 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1072 RenderTask task = taskList.GetTask(0u);
1073 FrameBuffer newFrameBuffer; // Empty handle
1074 task.SetFrameBuffer(newFrameBuffer);
1075 DALI_TEST_EQUALS((bool)task.GetFrameBuffer(), false, TEST_LOCATION);
1079 int UtcDaliRenderTaskGetFrameBufferP(void)
1081 TestApplication application;
1083 tet_infoline("Testing RenderTask::GetFrameBuffer()");
1085 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1087 RenderTask task = taskList.GetTask(0u);
1089 FrameBuffer newFrameBuffer = FrameBuffer::New(1u, 1u, FrameBuffer::Attachment::NONE);
1090 task.SetFrameBuffer(newFrameBuffer);
1091 DALI_TEST_CHECK(task.GetFrameBuffer() == newFrameBuffer);
1095 int UtcDaliRenderTaskGetFrameBufferN(void)
1097 TestApplication application;
1099 tet_infoline("Testing RenderTask::GetFrameBuffer()");
1101 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1103 RenderTask task = taskList.GetTask(0u);
1105 // By default render-tasks do not render off-screen
1106 FrameBuffer frameBuffer = task.GetFrameBuffer();
1107 DALI_TEST_CHECK(!frameBuffer);
1112 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionP(void)
1114 TestApplication application;
1116 tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1118 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1120 RenderTask task = taskList.GetTask(0u);
1122 task.SetScreenToFrameBufferFunction(TestScreenToFrameBufferFunction);
1124 Vector2 coordinates(5, 10);
1125 Vector2 convertedCoordinates(6, 12); // + Vector(1, 2)
1127 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1128 DALI_TEST_CHECK(func(coordinates));
1129 DALI_TEST_CHECK(coordinates == convertedCoordinates);
1131 task.SetScreenToFrameBufferFunction(RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION);
1132 func = task.GetScreenToFrameBufferFunction();
1133 DALI_TEST_CHECK(func(coordinates));
1135 task.SetScreenToFrameBufferFunction(RenderTask::DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION);
1136 func = task.GetScreenToFrameBufferFunction();
1137 DALI_TEST_CHECK(!func(coordinates));
1141 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionN(void)
1143 TestApplication application;
1145 tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1147 RenderTask task; // Empty handle
1150 task.SetScreenToFrameBufferFunction(TestScreenToFrameBufferFunction);
1152 catch(Dali::DaliException& e)
1154 DALI_TEST_PRINT_ASSERT(e);
1155 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1160 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionP(void)
1162 TestApplication application;
1164 tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction()");
1166 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1168 RenderTask task = taskList.GetTask(0u);
1170 Vector2 originalCoordinates(5, 10);
1171 Vector2 coordinates(5, 10);
1173 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1174 DALI_TEST_CHECK(!func(coordinates)); // conversion should fail by default
1175 DALI_TEST_CHECK(coordinates == originalCoordinates); // coordinates should not be modified
1179 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionN(void)
1181 TestApplication application;
1183 tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction() on empty handle");
1188 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1191 catch(Dali::DaliException& e)
1193 DALI_TEST_PRINT_ASSERT(e);
1194 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1199 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorP(void)
1201 TestApplication application;
1202 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor ");
1204 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1205 RenderTask renderTask = taskList.CreateTask();
1206 Actor mappingActor = Actor::New();
1207 renderTask.SetScreenToFrameBufferMappingActor(mappingActor);
1209 DALI_TEST_EQUALS(mappingActor, renderTask.GetScreenToFrameBufferMappingActor(), TEST_LOCATION);
1213 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorN(void)
1215 TestApplication application;
1216 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1222 task.SetScreenToFrameBufferMappingActor(mappingActor);
1224 catch(Dali::DaliException& e)
1226 DALI_TEST_PRINT_ASSERT(e);
1227 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1232 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActor02N(void)
1234 TestApplication application;
1235 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1237 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1238 RenderTask renderTask = taskList.CreateTask();
1240 renderTask.SetScreenToFrameBufferMappingActor(actor);
1242 DALI_TEST_EQUALS((bool)renderTask.GetScreenToFrameBufferMappingActor(), false, TEST_LOCATION);
1246 int UtcDaliRenderTaskGetViewportP01(void)
1248 TestApplication application;
1250 tet_infoline("Testing RenderTask::GetViewport() on default task");
1252 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1253 RenderTask task = taskList.GetTask(0u);
1254 Viewport viewport = task.GetViewport();
1256 // By default the viewport should match the stage width/height
1257 Vector2 stageSize = application.GetScene().GetSize();
1258 Viewport expectedViewport(0, 0, stageSize.width, stageSize.height);
1259 DALI_TEST_CHECK(viewport == expectedViewport);
1263 int UtcDaliRenderTaskGetViewportP02(void)
1265 TestApplication application;
1267 tet_infoline("Testing RenderTask::GetViewport() on new task");
1269 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1270 RenderTask task = taskList.CreateTask();
1271 Viewport viewport = task.GetViewport();
1273 // By default the viewport should match the stage width/height
1274 Vector2 stageSize = application.GetScene().GetSize();
1275 Viewport expectedViewport(0, 0, stageSize.width, stageSize.height);
1276 DALI_TEST_CHECK(viewport == expectedViewport);
1280 int UtcDaliRenderTaskGetViewportN(void)
1282 TestApplication application;
1284 tet_infoline("Testing RenderTask::GetViewport() on empty handle");
1289 Viewport viewport = task.GetViewport();
1292 catch(Dali::DaliException& e)
1294 DALI_TEST_PRINT_ASSERT(e);
1295 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1300 int UtcDaliRenderTaskSetViewportP(void)
1302 TestApplication application;
1304 tet_infoline("Testing RenderTask::SetViewport()");
1306 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1308 RenderTask task = taskList.GetTask(0u);
1309 Vector2 stageSize = application.GetScene().GetSize();
1310 Viewport newViewport(0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f);
1311 task.SetViewport(newViewport);
1313 // Update (viewport is a property)
1314 application.SendNotification();
1315 application.Render();
1317 DALI_TEST_CHECK(task.GetViewport() == newViewport);
1321 int UtcDaliRenderTaskSetViewportN(void)
1323 TestApplication application;
1325 tet_infoline("Testing RenderTask::SetViewport()");
1327 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1332 Vector2 stageSize = application.GetScene().GetSize();
1333 Viewport newViewport(0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f);
1334 task.SetViewport(newViewport);
1336 catch(Dali::DaliException& e)
1338 DALI_TEST_PRINT_ASSERT(e);
1339 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1345 int UtcDaliRenderTaskSetViewportPosition(void)
1347 TestApplication application;
1349 tet_infoline("Testing RenderTask::SetViewportPosition()");
1351 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1353 RenderTask task = taskList.GetTask(0u);
1355 Viewport viewport = task.GetViewport();
1357 // By default the viewport should match the stage width/height
1359 Vector2 stageSize = application.GetScene().GetSize();
1360 Viewport expectedViewport(0, 0, stageSize.width, stageSize.height);
1361 DALI_TEST_CHECK(viewport == expectedViewport);
1364 Vector2 newPosition(25.0f, 50.0f);
1365 task.SetViewportPosition(newPosition);
1367 // Update (viewport is a property)
1368 application.SendNotification();
1369 application.Render();
1371 DALI_TEST_EQUALS(task.GetCurrentViewportPosition(), newPosition, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1373 // Set by Property test
1374 Vector2 newPosition2(32.0f, 32.0f);
1375 task.SetProperty(RenderTask::Property::VIEWPORT_POSITION, newPosition2);
1376 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition2, TEST_LOCATION);
1377 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition, TEST_LOCATION); // still the old position
1380 application.SendNotification();
1381 application.Render();
1383 DALI_TEST_EQUALS(task.GetCurrentViewportPosition(), newPosition2, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1384 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition2, TEST_LOCATION);
1385 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition2, TEST_LOCATION);
1387 Vector2 newPosition3(64.0f, 0.0f);
1388 Animation animation = Animation::New(1.0f);
1389 animation.AnimateTo(Property(task, RenderTask::Property::VIEWPORT_POSITION), newPosition3, AlphaFunction::LINEAR);
1392 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1393 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition2, TEST_LOCATION);
1395 // Perform 1000ms worth of updates at which point animation should have completed.
1396 Wait(application, 1000);
1397 DALI_TEST_EQUALS(task.GetCurrentViewportPosition(), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1398 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1399 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1401 // Create another animation which animates by a certain value
1402 const Vector2 newPosition4(75.0f, 45.0f);
1403 const Vector2 relativePosition(newPosition4 - newPosition3);
1404 animation = Animation::New(1.0f);
1405 animation.AnimateBy(Property(task, RenderTask::Property::VIEWPORT_POSITION), relativePosition);
1408 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1409 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition3, TEST_LOCATION);
1411 // Perform 1000ms worth of updates at which point animation should have completed.
1412 Wait(application, 1000);
1413 DALI_TEST_EQUALS(task.GetCurrentViewportPosition(), newPosition4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1414 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1415 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1420 int UtcDaliRenderTaskSetViewportSize(void)
1422 TestApplication application;
1424 tet_infoline("Testing RenderTask::SetViewportSize()");
1426 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1428 RenderTask task = taskList.GetTask(0u);
1430 Viewport viewport = task.GetViewport();
1432 // By default the viewport should match the stage width/height
1434 Vector2 stageSize = application.GetScene().GetSize();
1435 Viewport expectedViewport(0, 0, stageSize.width, stageSize.height);
1436 DALI_TEST_CHECK(viewport == expectedViewport);
1438 Vector2 newSize(128.0f, 64.0f);
1439 task.SetViewportSize(newSize);
1441 // Update (viewport is a property)
1442 application.SendNotification();
1443 application.Render();
1445 DALI_TEST_EQUALS(task.GetCurrentViewportSize(), newSize, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1447 // Set by Property test
1448 Vector2 newSize2(50.0f, 50.0f);
1449 task.SetProperty(RenderTask::Property::VIEWPORT_SIZE, newSize2);
1450 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize2, TEST_LOCATION);
1451 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize, TEST_LOCATION); // still the old position
1454 application.SendNotification();
1455 application.Render();
1457 DALI_TEST_EQUALS(task.GetCurrentViewportSize(), newSize2, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1458 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize2, TEST_LOCATION);
1459 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize2, 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 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1467 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize2, TEST_LOCATION);
1469 // Perform 1000ms worth of updates at which point animation should have completed.
1470 Wait(application, 1000);
1471 DALI_TEST_EQUALS(task.GetCurrentViewportSize(), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1472 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1473 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1475 // Create another animation which animates by a certain value
1476 const Vector2 newSize4(75.0f, 45.0f);
1477 const Vector2 relativeSize(newSize4 - newSize3);
1478 animation = Animation::New(1.0f);
1479 animation.AnimateBy(Property(task, RenderTask::Property::VIEWPORT_SIZE), relativeSize);
1482 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1483 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize3, TEST_LOCATION);
1485 // Perform 1000ms worth of updates at which point animation should have completed.
1486 Wait(application, 1000);
1487 DALI_TEST_EQUALS(task.GetCurrentViewportSize(), newSize4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1488 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1489 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1494 int UtcDaliRenderTaskSetClearColorP(void)
1496 TestApplication application;
1498 tet_infoline("Testing RenderTask::SetClearColor()");
1500 Vector4 testColor(1.0f, 2.0f, 3.0f, 4.0f);
1501 Vector4 testColor2(5.0f, 6.0f, 7.0f, 8.0f);
1503 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1505 RenderTask task = taskList.GetTask(0u);
1506 DALI_TEST_CHECK(task.GetClearColor() != testColor);
1508 task.SetClearColor(testColor);
1513 DALI_TEST_EQUALS(task.GetClearColor(), testColor, TEST_LOCATION);
1515 task.SetProperty(RenderTask::Property::CLEAR_COLOR, testColor2);
1516 DALI_TEST_EQUALS(task.GetProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), testColor2, TEST_LOCATION);
1517 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), testColor, TEST_LOCATION); // still the old color
1522 DALI_TEST_EQUALS(task.GetClearColor(), testColor2, TEST_LOCATION);
1523 DALI_TEST_EQUALS(task.GetProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), testColor2, TEST_LOCATION);
1524 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), testColor2, TEST_LOCATION);
1526 Vector4 newColor3(10.0f, 10.0f, 20.0f, 30.0f);
1527 Animation animation = Animation::New(1.0f);
1528 animation.AnimateTo(Property(task, RenderTask::Property::CLEAR_COLOR), newColor3, AlphaFunction::LINEAR);
1531 DALI_TEST_EQUALS(task.GetProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1532 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), testColor2, TEST_LOCATION);
1534 // Perform 1000ms worth of updates at which point animation should have completed.
1535 Wait(application, 1000);
1536 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1537 DALI_TEST_EQUALS(task.GetProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1539 // Create another animation which animates by a certain value
1540 const Vector4 newColor4(0.45f, 0.35f, 0.25f, 0.1f);
1541 const Vector4 relativeColor(newColor4 - newColor3);
1542 animation = Animation::New(1.0f);
1543 animation.AnimateBy(Property(task, RenderTask::Property::CLEAR_COLOR), relativeColor);
1546 DALI_TEST_EQUALS(task.GetProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor4, Math::MACHINE_EPSILON_10, TEST_LOCATION);
1547 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor3, Math::MACHINE_EPSILON_10, TEST_LOCATION);
1549 // Perform 1000ms worth of updates at which point animation should have completed.
1550 Wait(application, 1000);
1551 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor4, Math::MACHINE_EPSILON_10, TEST_LOCATION);
1552 DALI_TEST_EQUALS(task.GetProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor4, Math::MACHINE_EPSILON_10, TEST_LOCATION);
1557 int UtcDaliRenderTaskSetClearColorN(void)
1559 TestApplication application;
1561 tet_infoline("Testing RenderTask::SetClearColor() on empty handle");
1566 task.SetClearColor(Vector4::ZERO);
1568 catch(Dali::DaliException& e)
1570 DALI_TEST_PRINT_ASSERT(e);
1571 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1576 int UtcDaliRenderTaskGetClearColorP(void)
1578 TestApplication application;
1580 tet_infoline("Testing RenderTask::GetClearColor()");
1582 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1583 RenderTask task = taskList.GetTask(0u);
1584 DALI_TEST_EQUALS(task.GetClearColor(), RenderTask::DEFAULT_CLEAR_COLOR, TEST_LOCATION);
1588 int UtcDaliRenderTaskGetClearColorN(void)
1590 TestApplication application;
1592 tet_infoline("Testing RenderTask::GetClearColor()");
1597 Vector4 color = task.GetClearColor();
1600 catch(Dali::DaliException& e)
1602 DALI_TEST_PRINT_ASSERT(e);
1603 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1608 int UtcDaliRenderTaskSetClearEnabledP(void)
1610 TestApplication application;
1612 tet_infoline("Testing RenderTask::SetClearEnabled()");
1614 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1616 RenderTask task = taskList.GetTask(0u);
1617 DALI_TEST_CHECK(task.GetClearEnabled()); // defaults to true
1619 task.SetClearEnabled(false);
1620 DALI_TEST_EQUALS(task.GetClearEnabled(), false, TEST_LOCATION);
1622 task.SetClearEnabled(true);
1623 DALI_TEST_EQUALS(task.GetClearEnabled(), true, TEST_LOCATION);
1627 int UtcDaliRenderTaskSetClearEnabledN(void)
1629 TestApplication application;
1631 tet_infoline("Testing RenderTask::SetClearEnabled() with empty handle");
1636 task.SetClearEnabled(true);
1638 catch(Dali::DaliException& e)
1640 DALI_TEST_PRINT_ASSERT(e);
1641 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1646 int UtcDaliRenderTaskGetClearEnabledP(void)
1648 TestApplication application;
1650 tet_infoline("Testing RenderTask::GetClearEnabled()");
1652 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1654 RenderTask task = taskList.GetTask(0u);
1655 DALI_TEST_CHECK(task.GetClearEnabled()); // defaults to true
1659 int UtcDaliRenderTaskGetClearEnabledN(void)
1661 TestApplication application;
1663 tet_infoline("Testing RenderTask::GetClearEnabled() with empty handle");
1668 bool x = task.GetClearEnabled();
1671 catch(Dali::DaliException& e)
1673 DALI_TEST_PRINT_ASSERT(e);
1674 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1679 int UtcDaliRenderTaskSetCullModeP(void)
1681 TestApplication application;
1683 tet_infoline("Testing RenderTask::SetCullMode()");
1685 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1686 RenderTask task = taskList.GetTask(0u);
1687 DALI_TEST_EQUALS(task.GetCullMode(), true, TEST_LOCATION);
1689 task.SetCullMode(false);
1691 DALI_TEST_EQUALS(task.GetCullMode(), false, TEST_LOCATION);
1696 int UtcDaliRenderTaskSetCullModeN(void)
1698 TestApplication application;
1700 tet_infoline("Testing RenderTask::SetCullMode() on empty handle");
1705 task.SetCullMode(false);
1707 catch(Dali::DaliException& e)
1709 DALI_TEST_PRINT_ASSERT(e);
1710 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1715 int UtcDaliRenderTaskGetCullModeP(void)
1717 TestApplication application;
1719 tet_infoline("Testing RenderTask::GetCullMode()");
1721 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1722 RenderTask task = taskList.GetTask(0u);
1723 DALI_TEST_EQUALS(task.GetCullMode(), true, TEST_LOCATION);
1727 int UtcDaliRenderTaskGetCullModeN(void)
1729 TestApplication application;
1731 tet_infoline("Testing RenderTask::GetCullMode() with empty handle");
1736 bool x = task.GetCullMode();
1739 catch(Dali::DaliException& e)
1741 DALI_TEST_PRINT_ASSERT(e);
1742 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1747 int UtcDaliRenderTaskSetRefreshRate(void)
1749 TestApplication application;
1751 tet_infoline("Testing RenderTask::SetRefreshRate()");
1753 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1755 // By default tasks will be processed every frame
1756 RenderTask task = taskList.GetTask(0u);
1757 DALI_TEST_CHECK(RenderTask::REFRESH_ALWAYS == task.GetRefreshRate());
1759 task.SetRefreshRate(2u); // every-other frame
1760 DALI_TEST_CHECK(2u == task.GetRefreshRate());
1762 task.SetRefreshRate(RenderTask::REFRESH_ALWAYS);
1763 DALI_TEST_CHECK(RenderTask::REFRESH_ALWAYS == task.GetRefreshRate());
1767 int UtcDaliRenderTaskGetRefreshRate(void)
1769 TestApplication application;
1771 tet_infoline("Testing RenderTask::GetRefreshRate()");
1773 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1775 // By default tasks will be processed every frame
1776 RenderTask task = taskList.GetTask(0u);
1777 DALI_TEST_CHECK(RenderTask::REFRESH_ALWAYS == task.GetRefreshRate());
1779 RenderTask newTask = taskList.CreateTask();
1780 DALI_TEST_CHECK(RenderTask::REFRESH_ALWAYS == newTask.GetRefreshRate());
1784 int UtcDaliRenderTaskSignalFinished(void)
1786 TestApplication application;
1788 tet_infoline("Testing RenderTask::SignalFinished()");
1790 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1791 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
1793 CameraActor offscreenCameraActor = CameraActor::New();
1795 application.GetScene().Add(offscreenCameraActor);
1797 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 10, 10);
1798 Actor rootActor = CreateRenderableActor(image);
1799 rootActor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1800 application.GetScene().Add(rootActor);
1802 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1803 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
1804 Texture frameBufferTexture = Texture::New(*testNativeImagePtr);
1805 FrameBuffer frameBuffer = FrameBuffer::New(frameBufferTexture.GetWidth(), frameBufferTexture.GetHeight());
1806 frameBuffer.AttachColorTexture(frameBufferTexture);
1808 RenderTask newTask = taskList.CreateTask();
1809 newTask.SetCameraActor(offscreenCameraActor);
1810 newTask.SetSourceActor(rootActor);
1811 newTask.SetInputEnabled(false);
1812 newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
1813 newTask.SetClearEnabled(true);
1814 newTask.SetExclusive(true);
1815 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
1816 newTask.SetFrameBuffer(frameBuffer);
1817 newTask.SetProperty(RenderTask::Property::REQUIRES_SYNC, true);
1819 bool finished = false;
1820 RenderTaskFinished renderTaskFinished(finished);
1821 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
1823 // Flush the queue and render.
1824 application.SendNotification();
1826 // 1 render to process render task, then wait for sync before finished msg is sent
1827 // from update to the event thread.
1829 application.Render();
1830 application.SendNotification();
1831 DALI_TEST_CHECK(!finished);
1833 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
1834 DALI_TEST_CHECK(lastSyncObj != NULL);
1836 application.Render();
1837 DALI_TEST_EQUALS((Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION);
1838 application.SendNotification();
1839 DALI_TEST_CHECK(!finished);
1841 application.Render();
1842 DALI_TEST_EQUALS((Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION);
1843 application.SendNotification();
1844 DALI_TEST_CHECK(!finished);
1846 sync.SetObjectSynced(lastSyncObj, true);
1848 application.Render();
1849 application.SendNotification();
1850 DALI_TEST_CHECK(!finished);
1852 application.Render();
1853 application.SendNotification();
1854 DALI_TEST_CHECK(finished);
1856 DALI_TEST_EQUALS(application.GetUpdateStatus(), 0, TEST_LOCATION);
1860 int UtcDaliRenderTaskContinuous01(void)
1862 TestApplication application;
1864 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not staged)\nPOST:continuous renders, no Finished signal");
1866 // SETUP AN OFFSCREEN RENDER TASK
1867 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1868 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1869 drawTrace.Enable(true);
1871 Actor rootActor = Actor::New();
1872 application.GetScene().Add(rootActor);
1874 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
1875 application.GetScene().Add(offscreenCameraActor);
1877 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
1879 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1880 bool finished = false;
1881 RenderTaskFinished renderTaskFinished(finished);
1882 application.SendNotification();
1884 // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating
1885 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, false, __LINE__));
1886 application.GetPlatform().ClearReadyResources();
1888 // ADD SOURCE ACTOR TO STAGE - expect continuous renders to start, no finished signal
1889 application.GetScene().Add(secondRootActor);
1890 application.SendNotification();
1892 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1893 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
1897 int UtcDaliRenderTaskContinuous02(void)
1899 TestApplication application;
1901 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not visible)\nPOST:continuous renders, no Finished signal");
1903 // SETUP AN OFFSCREEN RENDER TASK
1904 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1905 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1906 drawTrace.Enable(true);
1908 Actor rootActor = Actor::New();
1909 application.GetScene().Add(rootActor);
1911 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
1912 application.GetScene().Add(offscreenCameraActor);
1914 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
1915 application.GetScene().Add(secondRootActor);
1916 secondRootActor.SetProperty(Actor::Property::VISIBLE, false);
1918 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1919 bool finished = false;
1920 RenderTaskFinished renderTaskFinished(finished);
1921 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
1922 application.SendNotification();
1924 // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating
1925 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, false, __LINE__));
1926 application.GetPlatform().ClearReadyResources();
1928 // MAKE SOURCE ACTOR VISIBLE - expect continuous renders to start, no finished signal
1929 secondRootActor.SetProperty(Actor::Property::VISIBLE, true);
1930 application.SendNotification();
1932 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1933 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
1937 int UtcDaliRenderTaskContinuous03(void)
1939 TestApplication application;
1941 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (camera actor not staged)\nPOST:continuous renders, no Finished signal");
1943 // SETUP AN OFFSCREEN RENDER TASK
1944 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1945 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1946 drawTrace.Enable(true);
1948 Actor rootActor = Actor::New();
1949 application.GetScene().Add(rootActor);
1951 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
1952 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
1953 application.GetScene().Add(secondRootActor);
1955 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1956 bool finished = false;
1957 RenderTaskFinished renderTaskFinished(finished);
1958 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
1959 application.SendNotification();
1961 // START PROCESS/RENDER Input, Expected Input, Expected
1962 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, false, __LINE__));
1963 application.GetPlatform().ClearReadyResources();
1965 // ADD CAMERA ACTOR TO STAGE - expect continuous renders to start, no finished signal
1966 application.GetScene().Add(offscreenCameraActor);
1967 application.SendNotification();
1969 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1970 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
1974 int UtcDaliRenderTaskContinuous04(void)
1976 TestApplication application;
1978 tet_infoline("Testing RenderTask Render Continuous using loaded image");
1980 // SETUP AN OFFSCREEN RENDER TASK
1981 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1982 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1983 drawTrace.Enable(true);
1985 Actor rootActor = Actor::New();
1986 application.GetScene().Add(rootActor);
1988 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
1989 application.GetScene().Add(offscreenCameraActor);
1990 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
1991 application.GetScene().Add(secondRootActor);
1993 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1994 bool finished = false;
1995 RenderTaskFinished renderTaskFinished(finished);
1996 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
1997 application.SendNotification();
1999 // START PROCESS/RENDER Input, Expected Input, Expected
2000 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2004 int UtcDaliRenderTaskOnce01(void)
2006 TestApplication application;
2008 tet_infoline("Testing RenderTask Render Once GlSync, using loaded image");
2010 // SETUP AN OFFSCREEN RENDER TASK
2011 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2012 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2013 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2014 drawTrace.Enable(true);
2016 Actor rootActor = Actor::New();
2017 application.GetScene().Add(rootActor);
2019 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2020 application.GetScene().Add(offscreenCameraActor);
2021 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2023 application.GetScene().Add(secondRootActor);
2025 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
2026 bool finished = false;
2027 RenderTaskFinished renderTaskFinished(finished);
2028 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2029 application.SendNotification();
2031 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2033 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2034 DALI_TEST_CHECK(lastSyncObj != NULL);
2035 sync.SetObjectSynced(lastSyncObj, true);
2037 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, true, __LINE__));
2038 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2042 int UtcDaliRenderTaskOnce02(void)
2044 TestApplication application;
2046 tet_infoline("Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loaded image.\n");
2048 // SETUP AN OFFSCREEN RENDER TASK
2049 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2050 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2051 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2052 drawTrace.Enable(true);
2054 Actor rootActor = Actor::New();
2055 application.GetScene().Add(rootActor);
2057 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2058 application.GetScene().Add(offscreenCameraActor);
2060 Shader shader = CreateShader();
2061 Texture image = CreateTexture();
2062 TextureSet textureSet = CreateTextureSet(image);
2064 Geometry geometry = CreateQuadGeometry();
2065 Renderer renderer = Renderer::New(geometry, shader);
2066 renderer.SetTextures(textureSet);
2067 Actor secondRootActor = Actor::New();
2068 secondRootActor.AddRenderer(renderer);
2069 secondRootActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2070 application.GetScene().Add(secondRootActor);
2072 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
2073 bool finished = false;
2074 RenderTaskFinished renderTaskFinished(finished);
2075 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2076 application.SendNotification();
2078 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2080 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2081 DALI_TEST_CHECK(lastSyncObj != NULL);
2082 sync.SetObjectSynced(lastSyncObj, true);
2084 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, true, __LINE__));
2085 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2090 int UtcDaliRenderTaskOnce03(void)
2092 TestApplication application;
2094 tet_infoline("Testing RenderTask Render Once GlSync, using loaded image. Switch from render always after ready to render once\n");
2096 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2097 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2098 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2099 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2100 drawTrace.Enable(true);
2102 Actor rootActor = Actor::New();
2103 application.GetScene().Add(rootActor);
2105 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2106 application.GetScene().Add(offscreenCameraActor);
2107 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2108 application.GetScene().Add(secondRootActor);
2110 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2111 bool finished = false;
2112 RenderTaskFinished renderTaskFinished(finished);
2113 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2114 application.SendNotification();
2116 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2118 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2119 application.SendNotification();
2121 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2123 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2124 DALI_TEST_CHECK(lastSyncObj != NULL);
2125 sync.SetObjectSynced(lastSyncObj, true);
2127 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, true, __LINE__));
2128 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2133 int UtcDaliRenderTaskOnce04(void)
2135 TestApplication application;
2137 "Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loaded image.\n"
2138 "Switch from render always after ready to render once\n");
2140 // SETUP AN OFFSCREEN RENDER TASK
2141 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2142 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2143 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2144 drawTrace.Enable(true);
2146 Actor rootActor = Actor::New();
2147 application.GetScene().Add(rootActor);
2149 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2150 application.GetScene().Add(offscreenCameraActor);
2152 Shader shader = CreateShader();
2153 Texture image = CreateTexture();
2154 TextureSet textureSet = CreateTextureSet(image);
2156 Geometry geometry = CreateQuadGeometry();
2157 Renderer renderer = Renderer::New(geometry, shader);
2158 renderer.SetTextures(textureSet);
2159 Actor secondRootActor = Actor::New();
2160 secondRootActor.AddRenderer(renderer);
2161 secondRootActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2162 application.GetScene().Add(secondRootActor);
2164 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2165 bool finished = false;
2166 RenderTaskFinished renderTaskFinished(finished);
2167 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2168 application.SendNotification();
2170 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2172 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2173 application.SendNotification();
2175 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2177 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2178 DALI_TEST_CHECK(lastSyncObj != NULL);
2179 sync.SetObjectSynced(lastSyncObj, true);
2181 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, true, __LINE__));
2182 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2187 int UtcDaliRenderTaskOnceNoSync01(void)
2189 TestApplication application;
2191 tet_infoline("Testing RenderTask Render Once, \nPRE: Resources ready\nPOST: Finished signal sent once only");
2193 // SETUP AN OFFSCREEN RENDER TASK
2194 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2195 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2196 drawTrace.Enable(true);
2198 Actor rootActor = Actor::New();
2199 application.GetScene().Add(rootActor);
2201 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2202 application.GetScene().Add(offscreenCameraActor);
2203 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2204 application.GetScene().Add(secondRootActor);
2206 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2207 bool finished = false;
2208 RenderTaskFinished renderTaskFinished(finished);
2209 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2210 application.SendNotification();
2212 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2213 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2217 int UtcDaliRenderTaskOnceNoSync02(void)
2219 TestApplication application;
2222 "Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loaded image.\n"
2223 "PRE: Resources ready\nPOST: Finished signal sent once only");
2224 // SETUP AN OFFSCREEN RENDER TASK
2225 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2226 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2227 drawTrace.Enable(true);
2229 Actor rootActor = Actor::New();
2230 application.GetScene().Add(rootActor);
2232 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2233 application.GetScene().Add(offscreenCameraActor);
2235 Shader shader = CreateShader();
2236 Texture image = CreateTexture();
2237 TextureSet textureSet = CreateTextureSet(image);
2239 Geometry geometry = CreateQuadGeometry();
2240 Renderer renderer = Renderer::New(geometry, shader);
2241 renderer.SetTextures(textureSet);
2242 Actor secondRootActor = Actor::New();
2243 secondRootActor.AddRenderer(renderer);
2244 secondRootActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2245 application.GetScene().Add(secondRootActor);
2247 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2248 bool finished = false;
2249 RenderTaskFinished renderTaskFinished(finished);
2250 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2251 application.SendNotification();
2253 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2254 application.GetPlatform().ClearReadyResources();
2255 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2260 int UtcDaliRenderTaskOnceNoSync03(void)
2262 TestApplication application;
2265 "Testing RenderTask Render Once, using loaded image. Switch from render always after ready to render once\n"
2266 "PRE: Render task ready, Image loaded\n"
2267 "POST: Finished signal sent only once");
2269 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2270 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2271 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2272 drawTrace.Enable(true);
2274 Actor rootActor = Actor::New();
2275 application.GetScene().Add(rootActor);
2277 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2278 application.GetScene().Add(offscreenCameraActor);
2279 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2280 application.GetScene().Add(secondRootActor);
2282 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2283 bool finished = false;
2284 RenderTaskFinished renderTaskFinished(finished);
2285 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2286 application.SendNotification();
2288 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2290 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2291 application.SendNotification(); // Input, Expected Input, Expected
2292 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2293 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2297 int UtcDaliRenderTaskOnceNoSync04(void)
2299 TestApplication application;
2302 "Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loading image.\n"
2303 "Switch from render always after ready to render once\n"
2304 "PRE: Render task ready, Image not loaded\n"
2305 "POST: Finished signal sent only once");
2307 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2308 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2309 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2310 drawTrace.Enable(true);
2312 Actor rootActor = Actor::New();
2313 application.GetScene().Add(rootActor);
2315 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2316 application.GetScene().Add(offscreenCameraActor);
2318 Shader shader = CreateShader();
2319 Texture image = CreateTexture();
2320 TextureSet textureSet = CreateTextureSet(image);
2322 Geometry geometry = CreateQuadGeometry();
2323 Renderer renderer = Renderer::New(geometry, shader);
2324 renderer.SetTextures(textureSet);
2325 Actor secondRootActor = Actor::New();
2326 secondRootActor.AddRenderer(renderer);
2327 secondRootActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2328 application.GetScene().Add(secondRootActor);
2330 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2331 bool finished = false;
2332 RenderTaskFinished renderTaskFinished(finished);
2333 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2334 application.SendNotification();
2336 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2337 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2338 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2339 DALI_TEST_CHECK(lastSyncObj == NULL);
2341 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2342 application.SendNotification(); // Input, Expected Input, Expected
2343 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2344 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2346 lastSyncObj = sync.GetLastSyncObject();
2347 DALI_TEST_CHECK(lastSyncObj == NULL);
2352 int UtcDaliRenderTaskOnceNoSync05(void)
2354 TestApplication application;
2357 "Testing RenderTask Render Once\n"
2358 "SetRefreshRate(ONCE), resource load failed, completes render task.\n"
2359 "PRE: resources failed to load\n"
2360 "POST: No finished signal sent.");
2362 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2363 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2364 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2365 drawTrace.Enable(true);
2367 Actor rootActor = Actor::New();
2368 application.GetScene().Add(rootActor);
2370 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2371 application.GetScene().Add(offscreenCameraActor);
2372 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2373 application.GetScene().Add(secondRootActor);
2375 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2376 bool finished = false;
2377 RenderTaskFinished renderTaskFinished(finished);
2378 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2379 application.SendNotification();
2381 // START PROCESS/RENDER Input, Expected Input, Expected
2382 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2384 // CHANGE TO RENDER ONCE,
2385 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2386 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2391 int UtcDaliRenderTaskOnceChain01(void)
2393 TestApplication application;
2396 "Testing RenderTask Render Once Chained render tasks\n"
2397 "SetRefreshRate(ONCE), resource load completes, both render tasks render.\n"
2398 "PRE: resources ready\n"
2399 "POST: 2 finished signals sent.");
2401 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2402 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2403 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2404 drawTrace.Enable(true);
2406 Actor defaultRootActor = Actor::New(); // Root for default RT
2407 application.GetScene().Add(defaultRootActor);
2409 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2410 application.GetScene().Add(offscreenCameraActor);
2411 Actor firstRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2412 application.GetScene().Add(firstRootActor);
2414 // first render task
2415 RenderTask firstTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, firstRootActor, RenderTask::REFRESH_ONCE, false);
2416 bool firstFinished = false;
2417 RenderTaskFinished renderTask1Finished(firstFinished);
2418 firstTask.FinishedSignal().Connect(&application, renderTask1Finished);
2420 // Second render task
2421 FrameBuffer fbo = firstTask.GetFrameBuffer();
2422 Actor secondRootActor = CreateRenderableActor(fbo.GetColorTexture());
2423 application.GetScene().Add(secondRootActor);
2424 RenderTask secondTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2425 bool secondFinished = false;
2426 RenderTaskFinished renderTask2Finished(secondFinished);
2427 secondTask.FinishedSignal().Connect(&application, renderTask2Finished);
2429 application.SendNotification();
2431 //Both render tasks are executed.
2432 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__));
2433 DALI_TEST_CHECK(firstFinished == false);
2434 DALI_TEST_CHECK(secondFinished == false);
2436 //Nothing else to render and both render task should have finished now
2437 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, firstFinished, true, false, __LINE__));
2438 DALI_TEST_CHECK(firstFinished == true);
2439 DALI_TEST_CHECK(secondFinished == true);
2444 int UtcDaliRenderTaskProperties(void)
2446 TestApplication application;
2448 RenderTask task = application.GetScene().GetRenderTaskList().CreateTask();
2450 Property::IndexContainer indices;
2451 task.GetPropertyIndices(indices);
2452 DALI_TEST_CHECK(indices.Size());
2453 DALI_TEST_EQUALS(indices.Size(), task.GetPropertyCount(), TEST_LOCATION);
2457 int UtcDaliRenderTaskFinishInvisibleSourceActor(void)
2459 TestApplication application;
2461 tet_infoline("Testing RenderTask::FinishInvisibleSourceActor()");
2463 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2464 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2466 CameraActor offscreenCameraActor = CameraActor::New();
2468 application.GetScene().Add(offscreenCameraActor);
2470 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 10, 10);
2471 Actor rootActor = CreateRenderableActor(image);
2472 rootActor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
2473 rootActor.SetProperty(Actor::Property::VISIBLE, false);
2474 application.GetScene().Add(rootActor);
2476 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2477 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
2478 Texture frameBufferTexture = Texture::New(*testNativeImagePtr);
2479 FrameBuffer frameBuffer = FrameBuffer::New(frameBufferTexture.GetWidth(), frameBufferTexture.GetHeight());
2480 frameBuffer.AttachColorTexture(frameBufferTexture);
2482 // Flush all outstanding messages
2483 application.SendNotification();
2484 application.Render();
2486 RenderTask newTask = taskList.CreateTask();
2487 newTask.SetCameraActor(offscreenCameraActor);
2488 newTask.SetSourceActor(rootActor);
2489 newTask.SetInputEnabled(false);
2490 newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
2491 newTask.SetClearEnabled(true);
2492 newTask.SetExclusive(true);
2493 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2494 newTask.SetFrameBuffer(frameBuffer);
2495 newTask.SetProperty(RenderTask::Property::REQUIRES_SYNC, true);
2497 // Framebuffer doesn't actually get created until Connected, i.e. by previous line
2499 bool finished = false;
2500 RenderTaskFinished renderTaskFinished(finished);
2501 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2503 // Flush the queue and render.
2504 application.SendNotification();
2506 // 1 render to process render task, then wait for sync before finished msg is sent
2507 // from update to the event thread.
2509 application.Render();
2510 application.SendNotification();
2511 DALI_TEST_CHECK(!finished);
2513 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2514 DALI_TEST_CHECK(lastSyncObj != NULL);
2516 application.Render();
2517 DALI_TEST_EQUALS((Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION);
2518 application.SendNotification();
2519 DALI_TEST_CHECK(!finished);
2521 application.Render();
2522 DALI_TEST_EQUALS((Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION);
2523 application.SendNotification();
2524 DALI_TEST_CHECK(!finished);
2526 sync.SetObjectSynced(lastSyncObj, true);
2528 application.Render();
2529 application.SendNotification();
2530 DALI_TEST_CHECK(!finished);
2532 application.Render();
2533 application.SendNotification();
2534 DALI_TEST_CHECK(finished);
2537 application.Render(); // Double check no more finished signal
2538 application.SendNotification();
2539 DALI_TEST_CHECK(!finished);
2544 int UtcDaliRenderTaskFinishMissingImage(void)
2546 TestApplication application;
2548 // Previously we had bugs where not having a resource ID would cause render-tasks to wait forever
2549 tet_infoline("Testing RenderTask::SignalFinished() when an Actor has no Image set");
2551 Integration::Scene stage = application.GetScene();
2553 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 10, 10);
2554 Actor rootActor = CreateRenderableActor(image);
2555 rootActor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
2556 stage.Add(rootActor);
2558 Actor actorWithMissingImage = CreateRenderableActor(Texture());
2559 actorWithMissingImage.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
2560 stage.Add(actorWithMissingImage);
2562 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2563 RenderTask newTask = taskList.CreateTask();
2564 newTask.SetInputEnabled(false);
2565 newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
2566 newTask.SetClearEnabled(true);
2567 newTask.SetExclusive(true);
2568 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2570 bool finished = false;
2571 RenderTaskFinished renderTaskFinished(finished);
2572 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2574 // 1 render to process render task, then 1 before finished msg is sent from update to the event thread.
2575 application.SendNotification();
2576 application.Render();
2577 application.Render();
2579 application.SendNotification();
2580 DALI_TEST_CHECK(finished);
2585 int UtcDaliRenderTaskWorldToViewport(void)
2587 TestApplication application(400u, 400u); // square surface
2589 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2591 Actor actor = Actor::New();
2592 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2593 actor.SetProperty(Actor::Property::POSITION, Vector3(0.0, 0.0, 0.0));
2595 actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.5, 0.5, 0.5));
2596 actor.SetProperty(Actor::Property::ANCHOR_POINT, Vector3(0.5, 0.5, 0.5));
2598 application.GetScene().Add(actor);
2600 application.SendNotification();
2601 application.Render();
2602 application.SendNotification();
2604 RenderTask task = taskList.GetTask(0u);
2606 CameraActor camera = task.GetCameraActor();
2608 Vector2 screenSize = task.GetCurrentViewportSize();
2610 float screenX = 0.0;
2611 float screenY = 0.0;
2613 bool ok = task.WorldToViewport(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), screenX, screenY);
2614 DALI_TEST_CHECK(ok == true);
2616 DALI_TEST_EQUALS(screenX, screenSize.x / 2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
2617 DALI_TEST_EQUALS(screenY, screenSize.y / 2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
2619 Actor actor2 = Actor::New();
2620 float actor2Size = 100.f;
2621 actor2.SetProperty(Actor::Property::SIZE, Vector2(actor2Size, actor2Size));
2622 actor2.SetProperty(Actor::Property::POSITION, Vector3(0.0, 0.0, 0.0));
2623 actor2.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.5, 0.5, 0.0));
2624 actor2.SetProperty(Actor::Property::ANCHOR_POINT, Vector3(0.5, 0.5, 0.0));
2625 application.GetScene().Add(actor2);
2627 actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0, 0, 0));
2629 application.SendNotification();
2630 application.Render();
2631 application.SendNotification();
2633 ok = task.WorldToViewport(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), screenX, screenY);
2634 DALI_TEST_CHECK(ok == true);
2636 DALI_TEST_EQUALS(screenX, screenSize.x / 2 - actor2Size / 2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
2637 DALI_TEST_EQUALS(screenY, screenSize.y / 2 - actor2Size / 2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
2642 int UtcDaliRenderTaskViewportToLocal(void)
2644 TestApplication application;
2645 Actor actor = Actor::New();
2646 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2647 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2648 actor.SetProperty(Actor::Property::POSITION, Vector2(10.0f, 10.0f));
2649 application.GetScene().Add(actor);
2651 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2652 RenderTask task = taskList.GetTask(0u);
2654 // flush the queue and render once
2655 application.SendNotification();
2656 application.Render();
2657 application.SendNotification();
2658 application.Render();
2666 float screenX = 50.0f;
2667 float screenY = 50.0f;
2669 DALI_TEST_CHECK(actor.ScreenToLocal(localX, localY, screenX, screenY));
2671 DALI_TEST_CHECK(task.ViewportToLocal(actor, screenX, screenY, rtLocalX, rtLocalY));
2673 DALI_TEST_EQUALS(localX, rtLocalX, 0.01f, TEST_LOCATION);
2674 DALI_TEST_EQUALS(localY, rtLocalY, 0.01f, TEST_LOCATION);
2679 int UtcDaliRenderTaskOffscreenViewportToLocal(void)
2681 TestApplication application;
2682 Actor actor = Actor::New();
2683 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2684 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2685 actor.SetProperty(Actor::Property::POSITION, Vector2(10.0f, 10.0f));
2686 application.GetScene().Add(actor);
2688 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2689 RenderTask task = taskList.CreateTask();
2691 FrameBuffer newFrameBuffer = FrameBuffer::New(10, 10);
2692 task.SetFrameBuffer(newFrameBuffer);
2693 task.SetSourceActor(actor);
2694 task.SetScreenToFrameBufferMappingActor(actor);
2696 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2697 application.GetScene().Add(offscreenCameraActor);
2698 task.SetCameraActor(offscreenCameraActor);
2700 // flush the queue and render once
2701 application.SendNotification();
2702 application.Render();
2703 application.SendNotification();
2704 application.Render();
2712 float screenX = 50.0f;
2713 float screenY = 50.0f;
2715 DALI_TEST_CHECK(actor.ScreenToLocal(localX, localY, screenX, screenY));
2717 DALI_TEST_CHECK(task.ViewportToLocal(actor, screenX, screenY, rtLocalX, rtLocalY));
2719 DALI_TEST_EQUALS(localX, rtLocalX, 0.01f, TEST_LOCATION);
2720 DALI_TEST_EQUALS(localY, rtLocalY, 0.01f, TEST_LOCATION);
2725 int UtcDaliRenderTaskRequiresSync(void)
2727 TestApplication application;
2728 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2730 RenderTask newTask = taskList.CreateTask();
2731 newTask.SetProperty(RenderTask::Property::REQUIRES_SYNC, false);
2733 DALI_TEST_EQUALS(newTask.GetProperty<bool>(RenderTask::Property::REQUIRES_SYNC), false, TEST_LOCATION);
2734 DALI_TEST_EQUALS(newTask.GetCurrentProperty<bool>(RenderTask::Property::REQUIRES_SYNC), false, TEST_LOCATION);
2736 newTask.SetProperty(RenderTask::Property::REQUIRES_SYNC, true);
2738 DALI_TEST_EQUALS(newTask.GetProperty<bool>(RenderTask::Property::REQUIRES_SYNC), true, TEST_LOCATION);
2739 DALI_TEST_EQUALS(newTask.GetCurrentProperty<bool>(RenderTask::Property::REQUIRES_SYNC), true, TEST_LOCATION);
2744 int UtcDaliRenderTaskSetClearEnabled(void)
2746 TestApplication application;
2748 tet_infoline("UtcDaliRenderTaskSetClearEnabled");
2750 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2751 TestGlAbstraction& gl = application.GetGlAbstraction();
2753 Actor renderableActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2754 application.GetScene().Add(renderableActor);
2756 Actor rootActor = Actor::New();
2757 application.GetScene().Add(rootActor);
2759 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2760 application.GetScene().Add(offscreenCameraActor);
2762 Actor sourceActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2763 application.GetScene().Add(sourceActor);
2765 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, sourceActor, RenderTask::REFRESH_ALWAYS, false);
2767 DALI_TEST_EQUALS(gl.GetClearCountCalled(), 0, TEST_LOCATION);
2769 application.SendNotification();
2770 application.Render();
2772 // glClear should be called twice - default task and the new task.
2773 DALI_TEST_EQUALS(gl.GetClearCountCalled(), 2, TEST_LOCATION);
2775 newTask.SetClearEnabled(false);
2777 application.SendNotification();
2778 application.Render();
2780 // The count should increase by 1 - default task only.
2781 DALI_TEST_EQUALS(gl.GetClearCountCalled(), 3, TEST_LOCATION);
2786 int UtcDaliRenderTaskMoveConstrctor(void)
2788 TestApplication application;
2790 Vector4 testColor(1.0f, 2.0f, 3.0f, 4.0f);
2792 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2793 RenderTask task = taskList.GetTask(0u);
2794 DALI_TEST_CHECK(task);
2795 DALI_TEST_EQUALS(2, task.GetBaseObject().ReferenceCount(), TEST_LOCATION);
2796 DALI_TEST_CHECK(task.GetClearColor() != testColor);
2798 task.SetClearColor(testColor);
2803 DALI_TEST_EQUALS(task.GetClearColor(), testColor, TEST_LOCATION);
2805 RenderTask move = std::move(task);
2806 DALI_TEST_CHECK(move);
2807 DALI_TEST_EQUALS(2, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
2808 DALI_TEST_EQUALS(move.GetClearColor(), testColor, TEST_LOCATION);
2809 DALI_TEST_CHECK(!task);
2814 int UtcDaliRenderTaskMoveAssignment(void)
2816 TestApplication application;
2818 Vector4 testColor(1.0f, 2.0f, 3.0f, 4.0f);
2820 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2821 RenderTask task = taskList.GetTask(0u);
2822 DALI_TEST_CHECK(task);
2823 DALI_TEST_EQUALS(2, task.GetBaseObject().ReferenceCount(), TEST_LOCATION);
2824 DALI_TEST_CHECK(task.GetClearColor() != testColor);
2826 task.SetClearColor(testColor);
2831 DALI_TEST_EQUALS(task.GetClearColor(), testColor, TEST_LOCATION);
2834 move = std::move(task);
2835 DALI_TEST_CHECK(move);
2836 DALI_TEST_EQUALS(2, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
2837 DALI_TEST_EQUALS(move.GetClearColor(), testColor, TEST_LOCATION);
2838 DALI_TEST_CHECK(!task);
2843 int UtcDaliRenderTaskSetCullModeNegative(void)
2845 TestApplication application;
2846 Dali::RenderTask instance;
2850 instance.SetCullMode(arg1);
2851 DALI_TEST_CHECK(false); // Should not get here
2855 DALI_TEST_CHECK(true); // We expect an assert
2860 int UtcDaliRenderTaskSetViewportNegative(void)
2862 TestApplication application;
2863 Dali::RenderTask instance;
2866 Dali::Rect<int> arg1;
2867 instance.SetViewport(arg1);
2868 DALI_TEST_CHECK(false); // Should not get here
2872 DALI_TEST_CHECK(true); // We expect an assert
2877 int UtcDaliRenderTaskSetExclusiveNegative(void)
2879 TestApplication application;
2880 Dali::RenderTask instance;
2884 instance.SetExclusive(arg1);
2885 DALI_TEST_CHECK(false); // Should not get here
2889 DALI_TEST_CHECK(true); // We expect an assert
2894 int UtcDaliRenderTaskSetClearColorNegative(void)
2896 TestApplication application;
2897 Dali::RenderTask instance;
2901 instance.SetClearColor(arg1);
2902 DALI_TEST_CHECK(false); // Should not get here
2906 DALI_TEST_CHECK(true); // We expect an assert
2911 int UtcDaliRenderTaskFinishedSignalNegative(void)
2913 TestApplication application;
2914 Dali::RenderTask instance;
2917 instance.FinishedSignal();
2918 DALI_TEST_CHECK(false); // Should not get here
2922 DALI_TEST_CHECK(true); // We expect an assert
2927 int UtcDaliRenderTaskSetCameraActorNegative(void)
2929 TestApplication application;
2930 Dali::RenderTask instance;
2933 Dali::CameraActor arg1;
2934 instance.SetCameraActor(arg1);
2935 DALI_TEST_CHECK(false); // Should not get here
2939 DALI_TEST_CHECK(true); // We expect an assert
2944 int UtcDaliRenderTaskSetFrameBufferNegative(void)
2946 TestApplication application;
2947 Dali::RenderTask instance;
2950 Dali::FrameBuffer arg1;
2951 instance.SetFrameBuffer(arg1);
2952 DALI_TEST_CHECK(false); // Should not get here
2956 DALI_TEST_CHECK(true); // We expect an assert
2961 int UtcDaliRenderTaskSetRefreshRateNegative(void)
2963 TestApplication application;
2964 Dali::RenderTask instance;
2967 unsigned int arg1(0u);
2968 instance.SetRefreshRate(arg1);
2969 DALI_TEST_CHECK(false); // Should not get here
2973 DALI_TEST_CHECK(true); // We expect an assert
2978 int UtcDaliRenderTaskSetSourceActorNegative(void)
2980 TestApplication application;
2981 Dali::RenderTask instance;
2985 instance.SetSourceActor(arg1);
2986 DALI_TEST_CHECK(false); // Should not get here
2990 DALI_TEST_CHECK(true); // We expect an assert
2995 int UtcDaliRenderTaskSetClearEnabledNegative(void)
2997 TestApplication application;
2998 Dali::RenderTask instance;
3002 instance.SetClearEnabled(arg1);
3003 DALI_TEST_CHECK(false); // Should not get here
3007 DALI_TEST_CHECK(true); // We expect an assert
3012 int UtcDaliRenderTaskSetInputEnabledNegative(void)
3014 TestApplication application;
3015 Dali::RenderTask instance;
3019 instance.SetInputEnabled(arg1);
3020 DALI_TEST_CHECK(false); // Should not get here
3024 DALI_TEST_CHECK(true); // We expect an assert
3029 int UtcDaliRenderTaskSetViewportSizeNegative(void)
3031 TestApplication application;
3032 Dali::RenderTask instance;
3036 instance.SetViewportSize(arg1);
3037 DALI_TEST_CHECK(false); // Should not get here
3041 DALI_TEST_CHECK(true); // We expect an assert
3046 int UtcDaliRenderTaskSetViewportPositionNegative(void)
3048 TestApplication application;
3049 Dali::RenderTask instance;
3053 instance.SetViewportPosition(arg1);
3054 DALI_TEST_CHECK(false); // Should not get here
3058 DALI_TEST_CHECK(true); // We expect an assert
3063 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionNegative(void)
3065 TestApplication application;
3066 Dali::RenderTask instance;
3069 RenderTask::ScreenToFrameBufferFunction arg1(nullptr);
3070 instance.SetScreenToFrameBufferFunction(arg1);
3071 DALI_TEST_CHECK(false); // Should not get here
3075 DALI_TEST_CHECK(true); // We expect an assert
3080 int UtcDaliRenderTaskSetScreenToFrameBufferMappingActorNegative(void)
3082 TestApplication application;
3083 Dali::RenderTask instance;
3087 instance.SetScreenToFrameBufferMappingActor(arg1);
3088 DALI_TEST_CHECK(false); // Should not get here
3092 DALI_TEST_CHECK(true); // We expect an assert
3097 int UtcDaliRenderTaskGetCullModeNegative(void)
3099 TestApplication application;
3100 Dali::RenderTask instance;
3103 instance.GetCullMode();
3104 DALI_TEST_CHECK(false); // Should not get here
3108 DALI_TEST_CHECK(true); // We expect an assert
3113 int UtcDaliRenderTaskGetViewportNegative(void)
3115 TestApplication application;
3116 Dali::RenderTask instance;
3119 instance.GetViewport();
3120 DALI_TEST_CHECK(false); // Should not get here
3124 DALI_TEST_CHECK(true); // We expect an assert
3129 int UtcDaliRenderTaskIsExclusiveNegative(void)
3131 TestApplication application;
3132 Dali::RenderTask instance;
3135 instance.IsExclusive();
3136 DALI_TEST_CHECK(false); // Should not get here
3140 DALI_TEST_CHECK(true); // We expect an assert
3145 int UtcDaliRenderTaskGetClearColorNegative(void)
3147 TestApplication application;
3148 Dali::RenderTask instance;
3151 instance.GetClearColor();
3152 DALI_TEST_CHECK(false); // Should not get here
3156 DALI_TEST_CHECK(true); // We expect an assert
3161 int UtcDaliRenderTaskGetCameraActorNegative(void)
3163 TestApplication application;
3164 Dali::RenderTask instance;
3167 instance.GetCameraActor();
3168 DALI_TEST_CHECK(false); // Should not get here
3172 DALI_TEST_CHECK(true); // We expect an assert
3177 int UtcDaliRenderTaskGetFrameBufferNegative(void)
3179 TestApplication application;
3180 Dali::RenderTask instance;
3183 instance.GetFrameBuffer();
3184 DALI_TEST_CHECK(false); // Should not get here
3188 DALI_TEST_CHECK(true); // We expect an assert
3193 int UtcDaliRenderTaskGetRefreshRateNegative(void)
3195 TestApplication application;
3196 Dali::RenderTask instance;
3199 instance.GetRefreshRate();
3200 DALI_TEST_CHECK(false); // Should not get here
3204 DALI_TEST_CHECK(true); // We expect an assert
3209 int UtcDaliRenderTaskGetSourceActorNegative(void)
3211 TestApplication application;
3212 Dali::RenderTask instance;
3215 instance.GetSourceActor();
3216 DALI_TEST_CHECK(false); // Should not get here
3220 DALI_TEST_CHECK(true); // We expect an assert
3225 int UtcDaliRenderTaskGetClearEnabledNegative(void)
3227 TestApplication application;
3228 Dali::RenderTask instance;
3231 instance.GetClearEnabled();
3232 DALI_TEST_CHECK(false); // Should not get here
3236 DALI_TEST_CHECK(true); // We expect an assert
3241 int UtcDaliRenderTaskGetInputEnabledNegative(void)
3243 TestApplication application;
3244 Dali::RenderTask instance;
3247 instance.GetInputEnabled();
3248 DALI_TEST_CHECK(false); // Should not get here
3252 DALI_TEST_CHECK(true); // We expect an assert
3257 int UtcDaliRenderTaskViewportToLocalNegative(void)
3259 TestApplication application;
3260 Dali::RenderTask instance;
3263 Dali::Actor arg1(Actor::New());
3268 instance.ViewportToLocal(arg1, arg2, arg3, arg4, arg5);
3269 DALI_TEST_CHECK(false); // Should not get here
3273 DALI_TEST_CHECK(true); // We expect an assert
3278 int UtcDaliRenderTaskWorldToViewportNegative(void)
3280 TestApplication application;
3281 Dali::RenderTask instance;
3287 instance.WorldToViewport(arg1, arg2, arg3);
3288 DALI_TEST_CHECK(false); // Should not get here
3292 DALI_TEST_CHECK(true); // We expect an assert
3297 int UtcDaliRenderTaskGetCurrentViewportSizeNegative(void)
3299 TestApplication application;
3300 Dali::RenderTask instance;
3303 instance.GetCurrentViewportSize();
3304 DALI_TEST_CHECK(false); // Should not get here
3308 DALI_TEST_CHECK(true); // We expect an assert
3313 int UtcDaliRenderTaskGetCurrentViewportPositionNegative(void)
3315 TestApplication application;
3316 Dali::RenderTask instance;
3319 instance.GetCurrentViewportPosition();
3320 DALI_TEST_CHECK(false); // Should not get here
3324 DALI_TEST_CHECK(true); // We expect an assert
3329 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionNegative(void)
3331 TestApplication application;
3332 Dali::RenderTask instance;
3335 instance.GetScreenToFrameBufferFunction();
3336 DALI_TEST_CHECK(false); // Should not get here
3340 DALI_TEST_CHECK(true); // We expect an assert
3345 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorNegative(void)
3347 TestApplication application;
3348 Dali::RenderTask instance;
3351 instance.GetScreenToFrameBufferMappingActor();
3352 DALI_TEST_CHECK(false); // Should not get here
3356 DALI_TEST_CHECK(true); // We expect an assert