2 * Copyright (c) 2021 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-actor-utils.h>
25 #include <test-native-image.h>
29 #define BOOLSTR(x) ((x) ? "T" : "F")
31 //& set: DaliRenderTask
35 void utc_dali_render_task_startup(void)
37 test_return_value = TET_UNDEF;
40 void utc_dali_render_task_cleanup(void)
42 test_return_value = TET_PASS;
48 * Constructor, Destructor, DownCast, New, copy constructor, assignment operator
50 * SetSourceActor 2+ve, 1-ve
51 * GetSourceActor 1+ve, 1-ve
52 * SetExclusive 2+ve, 0-ve
53 * IsExclusive 2+ve, 0-ve
54 * SetInputEnabled 1+ve, 0-ve
55 * GetInputEnabled 1+ve, 0-ve
56 * SetCameraActor 1+ve, 1-ve
57 * GetCameraActor 1+ve, 1-ve
58 * SetTargetFrameBuffer 1+ve, 1-ve
59 * GetTargetFrameBuffer 1+ve, 1-ve
60 * SetScreenToFrameBufferFunction 1+ve, 1-ve
61 * GetScreenToFrameBufferFunction 1+ve, 1-ve
62 * SetScreenToFrameBufferMappingActor 1+ve, 1-ve
63 * GetScreenToFrameBufferMappingActor 1+ve, 1-ve
64 * SetViewportPosition 1+ve
65 * GetCurrentViewportPosition 1+ve
66 * SetViewportSize 1+ve
67 * GetCurrentViewportSize 1+ve
68 * SetViewport 2+ve, 1-ve
69 * GetViewport 2+ve, 1-ve
70 * SetClearColor 1+ve, 1-ve
71 * GetClearColor 1+ve, 1-ve
72 * SetClearEnabled 1+ve, 1-ve
73 * GetClearEnabled 1+ve, 1-ve
81 namespace // unnamed namespace
83 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
86 * Simulate time passed by.
88 * @note this will always process at least 1 frame (1/60 sec)
90 * @param application Test application instance
91 * @param duration Time to pass in milliseconds.
92 * @return The actual time passed in milliseconds
94 int Wait(TestApplication& application, int duration = 0)
98 for(int i = 0; i <= (duration / RENDER_FRAME_INTERVAL); i++)
100 application.SendNotification();
101 application.Render(RENDER_FRAME_INTERVAL);
102 time += RENDER_FRAME_INTERVAL;
108 struct RenderTaskFinished
110 RenderTaskFinished(bool& finished)
115 void operator()(RenderTask& renderTask)
123 struct RenderTaskFinishedRemoveSource
125 RenderTaskFinishedRemoveSource(bool& finished)
126 : finished(finished),
131 void operator()(RenderTask& renderTask)
133 DALI_TEST_CHECK(finishedOnce == false);
136 Actor srcActor = renderTask.GetSourceActor();
137 UnparentAndReset(srcActor);
144 struct RenderTaskFinishedRenderAgain
146 RenderTaskFinishedRenderAgain(bool& finished)
147 : finished(finished),
152 void operator()(RenderTask& renderTask)
154 DALI_TEST_CHECK(finishedOnce == false);
157 renderTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
164 bool TestScreenToFrameBufferFunction(Vector2& coordinates)
166 coordinates = coordinates + Vector2(1, 2);
171 Actor CreateRenderableActorSuccess(TestApplication& application, std::string filename)
173 Actor actor = CreateRenderableActor();
174 actor.SetProperty(Actor::Property::SIZE, Vector2(80.0f, 80.0f));
178 Texture CreateTexture(void)
180 return Dali::CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 80, 80);
183 RenderTask CreateRenderTask(TestApplication& application,
184 CameraActor offscreenCamera,
185 Actor rootActor, // Reset default render task to point at this actor
186 Actor secondRootActor, // Source actor
187 unsigned int refreshRate,
189 uint32_t frameBufferWidth = 10,
190 uint32_t frameBufferHeight = 10)
192 // Change main render task to use a different root
193 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
194 taskList.GetTask(0u).SetSourceActor(rootActor);
196 FrameBuffer frameBuffer = FrameBuffer::New(frameBufferWidth, frameBufferHeight);
199 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(frameBufferWidth, frameBufferHeight);
200 Texture texture = Texture::New(*testNativeImagePtr);
201 frameBuffer.AttachColorTexture(texture);
204 // Don't draw output framebuffer // '
206 RenderTask newTask = taskList.CreateTask();
207 newTask.SetCameraActor(offscreenCamera);
208 newTask.SetSourceActor(secondRootActor);
209 newTask.SetInputEnabled(false);
210 newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
211 newTask.SetClearEnabled(true);
212 newTask.SetExclusive(true);
213 newTask.SetRefreshRate(refreshRate);
214 newTask.SetFrameBuffer(frameBuffer);
215 newTask.SetProperty(RenderTask::Property::REQUIRES_SYNC, glSync);
219 bool UpdateRender(TestApplication& application, TraceCallStack& callStack, bool testDrawn, bool& finishedSig, bool testFinished, bool testKeepUpdating, int lineNumber)
224 tet_printf("TestApplication::UpdateRender().\n");
226 application.Render(16);
227 application.SendNotification();
229 bool sigPassed = false;
232 sigPassed = finishedSig;
236 sigPassed = !finishedSig;
239 bool drawResult = callStack.FindMethod("DrawElements") || callStack.FindMethod("DrawArrays");
241 bool drawPassed = false;
244 drawPassed = drawResult;
248 drawPassed = !drawResult;
251 bool keepUpdating = (application.GetUpdateStatus() != 0);
252 bool keepUpdatingPassed = false;
255 keepUpdatingPassed = keepUpdating;
259 keepUpdatingPassed = !keepUpdating;
262 bool result = (sigPassed && drawPassed && keepUpdatingPassed);
264 tet_printf("UpdateRender: Expected: Draw:%s Signal:%s KeepUpdating: %s Actual: Draw:%s Signal:%s KeepUpdating: %s %s, line %d\n",
266 BOOLSTR(testFinished),
267 BOOLSTR(testKeepUpdating),
269 BOOLSTR(finishedSig),
270 BOOLSTR(keepUpdating),
271 result ? "Passed" : "Failed",
277 } // unnamed namespace
279 /****************************************************************************************************/
280 /****************************************************************************************************/
281 /******************************** TEST CASES BELOW **********************************************/
282 /****************************************************************************************************/
283 /****************************************************************************************************/
285 int UtcDaliRenderTaskDownCast01(void)
287 TestApplication application;
289 tet_infoline("Testing RenderTask::DownCast()");
291 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
293 BaseHandle base = taskList.GetTask(0u);
294 DALI_TEST_CHECK(base);
296 RenderTask task = RenderTask::DownCast(base);
297 DALI_TEST_CHECK(task);
299 // Try calling a method
300 DALI_TEST_CHECK(task.GetSourceActor());
304 int UtcDaliRenderTaskDownCast02(void)
306 TestApplication application;
308 tet_infoline("Testing RenderTask::DownCast()");
310 Actor actor = Actor::New();
312 RenderTask task = RenderTask::DownCast(actor);
313 DALI_TEST_CHECK(!task);
318 int UtcDaliRenderTaskSetSourceActorN(void)
320 TestApplication application;
321 tet_infoline("Testing RenderTask::SetSourceActor() Negative - try with empty actor handle");
322 Integration::Scene stage = application.GetScene();
326 RenderTaskList taskList = stage.GetRenderTaskList();
327 RenderTask renderTask = taskList.CreateTask();
328 renderTask.SetSourceActor(srcActor);
330 application.SendNotification();
331 application.Render();
333 DALI_TEST_CHECK(!renderTask.GetSourceActor());
337 int UtcDaliRenderTaskSetSourceActorP01(void)
339 TestApplication application;
341 tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that setting a non-renderable actor stops existing source actor being rendered ");
343 Integration::Scene stage = application.GetScene();
344 RenderTaskList taskList = stage.GetRenderTaskList();
345 RenderTask task = taskList.GetTask(0u);
347 Actor actor = task.GetSourceActor();
348 DALI_TEST_CHECK(actor);
350 Texture img = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
351 Actor newActor = CreateRenderableActor(img);
352 newActor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
355 Actor nonRenderableActor = Actor::New();
356 stage.Add(nonRenderableActor);
358 // Stop the newActor from being rendered by changing the source actor
359 DALI_TEST_CHECK(nonRenderableActor);
360 task.SetSourceActor(nonRenderableActor);
361 DALI_TEST_CHECK(task.GetSourceActor() != actor);
362 DALI_TEST_CHECK(task.GetSourceActor() == nonRenderableActor);
364 TestGlAbstraction& gl = application.GetGlAbstraction();
365 TraceCallStack& drawTrace = gl.GetDrawTrace();
366 drawTrace.Enable(true);
368 // Update & Render nothing!
369 application.GetGlAbstraction().ClearBoundTextures();
370 application.SendNotification();
371 application.Render();
373 // Check that nothing was rendered
374 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
379 int UtcDaliRenderTaskSetSourceActorP02(void)
381 TestApplication application;
383 tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that switching source from a non-renderable to a renderable actor causes the texture to be drawn");
385 Integration::Scene stage = application.GetScene();
387 RenderTaskList taskList = stage.GetRenderTaskList();
389 RenderTask task = taskList.GetTask(0u);
391 Actor actor = task.GetSourceActor();
392 DALI_TEST_CHECK(actor);
394 Texture img = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
395 Actor newActor = CreateRenderableActor(img);
396 newActor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
399 Actor nonRenderableActor = Actor::New();
400 stage.Add(nonRenderableActor);
402 TestGlAbstraction& gl = application.GetGlAbstraction();
403 TraceCallStack& drawTrace = gl.GetDrawTrace();
404 drawTrace.Enable(true);
406 // Stop the newActor from being rendered by changing the source actor
407 DALI_TEST_CHECK(nonRenderableActor);
408 task.SetSourceActor(nonRenderableActor);
409 DALI_TEST_CHECK(task.GetSourceActor() != actor);
410 DALI_TEST_CHECK(task.GetSourceActor() == nonRenderableActor);
412 // Update & Render nothing!
413 application.GetGlAbstraction().ClearBoundTextures();
414 application.SendNotification();
415 application.Render();
417 // Check that nothing was rendered
418 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
421 // Set newActor as the new source Actor
422 task.SetSourceActor(newActor);
423 DALI_TEST_CHECK(task.GetSourceActor() != actor);
424 DALI_TEST_CHECK(task.GetSourceActor() == newActor);
426 // Update & Render the newActor
427 application.GetGlAbstraction().ClearBoundTextures();
428 application.SendNotification();
429 application.Render();
431 // Check that the newActor was rendered
432 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
436 int UtcDaliRenderTaskSetSourceActorOffScene(void)
438 TestApplication application;
440 tet_infoline("Testing RenderTask::SetSourceActor (on/off stage testing)");
442 Integration::Scene stage = application.GetScene();
443 RenderTaskList taskList = stage.GetRenderTaskList();
444 RenderTask task = taskList.GetTask(0u);
446 Actor actor = task.GetSourceActor();
447 DALI_TEST_CHECK(actor);
449 TestGlAbstraction& gl = application.GetGlAbstraction();
450 TraceCallStack& drawTrace = gl.GetDrawTrace();
451 drawTrace.Enable(true);
453 Texture img = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
454 Actor newActor = CreateRenderableActor(img);
455 newActor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
456 task.SetSourceActor(newActor);
457 // Don't add newActor to stage yet //'
459 // Update & Render with the actor initially off-stage
460 application.SendNotification();
461 application.Render();
463 // Check that nothing was rendered
464 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
469 // Update & Render with the actor on-stage
470 application.GetGlAbstraction().ClearBoundTextures();
471 application.SendNotification();
472 application.Render();
474 // Check that the newActor was rendered
475 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
478 // Now remove from stage
479 stage.Remove(newActor);
481 // Update & Render with the actor off-stage
482 application.SendNotification();
483 application.Render();
484 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
489 int UtcDaliRenderTaskSetSourceActorEmpty(void)
491 TestApplication application;
493 tet_infoline("Testing RenderTask::SetSourceActor (empty handle case)");
495 Integration::Scene stage = application.GetScene();
496 RenderTaskList taskList = stage.GetRenderTaskList();
497 RenderTask task = taskList.GetTask(0u);
499 Actor actor = task.GetSourceActor();
500 DALI_TEST_CHECK(actor);
502 Texture img = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
503 Actor newActor = CreateRenderableActor(img);
504 newActor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
507 Actor nonRenderableActor = Actor::New();
508 stage.Add(nonRenderableActor);
510 // Set with empty handle
511 task.SetSourceActor(Actor());
512 DALI_TEST_CHECK(!task.GetSourceActor());
514 TestGlAbstraction& gl = application.GetGlAbstraction();
515 TraceCallStack& drawTrace = gl.GetDrawTrace();
516 drawTrace.Enable(true);
518 // Update & Render nothing!
519 application.SendNotification();
520 application.Render();
522 // Check that nothing was rendered
523 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
525 // Set with non-empty handle
526 task.SetSourceActor(newActor);
527 DALI_TEST_CHECK(task.GetSourceActor() == newActor);
529 // Update & Render the newActor
530 application.GetGlAbstraction().ClearBoundTextures();
531 application.SendNotification();
532 application.Render();
534 // Check that the newActor was rendered
535 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
539 int UtcDaliRenderTaskSetSourceActorDestroyed(void)
541 TestApplication application;
543 tet_infoline("Testing RenderTask::SetSourceActor - Set a source actor and destroy the source actor");
545 Integration::Scene stage = application.GetScene();
546 RenderTaskList taskList = stage.GetRenderTaskList();
547 RenderTask task = taskList.GetTask(0u);
549 Actor actor = task.GetSourceActor();
550 DALI_TEST_CHECK(actor);
552 Texture img = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
554 Actor newActor = CreateRenderableActor(img);
555 newActor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
558 task.SetSourceActor(newActor);
560 DALI_TEST_CHECK(task.GetSourceActor() != actor);
561 DALI_TEST_CHECK(task.GetSourceActor() == newActor);
563 application.SendNotification();
564 application.Render();
566 // Destroy the source actor
567 stage.Remove(newActor);
570 DALI_TEST_CHECK(!task.GetSourceActor()); // The source actor should be an empty handle.
575 int UtcDaliRenderTaskGetSourceActorP01(void)
577 TestApplication application;
579 tet_infoline("Testing RenderTask::GetSourceActor() Check the default render task has a valid source actor");
581 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
583 RenderTask task = taskList.GetTask(0u);
585 Actor actor = task.GetSourceActor();
586 DALI_TEST_CHECK(actor);
588 // By default the entire scene should be rendered
589 Actor root = application.GetScene().GetLayer(0);
590 DALI_TEST_CHECK(root == actor);
594 int UtcDaliRenderTaskGetSourceActorP02(void)
596 TestApplication application;
598 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.");
600 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
601 RenderTask task = taskList.CreateTask();
602 Actor actor = Actor::New();
603 application.GetScene().Add(actor);
604 task.SetSourceActor(actor);
606 DALI_TEST_EQUALS(actor, task.GetSourceActor(), TEST_LOCATION);
611 int UtcDaliRenderTaskGetSourceActorN(void)
613 TestApplication application;
615 tet_infoline("Testing RenderTask::GetSourceActor() Try with empty handle");
620 Actor actor = task.GetSourceActor();
622 catch(Dali::DaliException& e)
624 DALI_TEST_PRINT_ASSERT(e);
625 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
631 int UtcDaliRenderTaskSetExclusive(void)
633 TestApplication application;
635 tet_infoline("Testing RenderTask::SetExclusive() Check that exclusion works");
637 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
641 // Actor1 Layer Layer
644 // Task 1 is the default render task, should render from Root, incl Actor2
645 // Task 2 uses Actor2 as a source actor (texture id 9)
647 // Manipulate the GenTextures behaviour, to identify different actors
649 std::vector<GLuint> ids;
650 ids.push_back(8); // 8 = actor1
651 ids.push_back(9); // 9 = actor2
652 ids.push_back(10); // 10 = actor3
653 application.GetGlAbstraction().SetNextTextureIds(ids);
655 Texture img1 = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
656 Actor actor1 = CreateRenderableActor(img1);
657 actor1.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
658 application.GetScene().Add(actor1);
660 // Update & Render actor1
661 application.SendNotification();
662 application.Render();
664 // Check that the actor1 was rendered
665 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures(GL_TEXTURE0);
666 DALI_TEST_GREATER(boundTextures.size(), static_cast<std::vector<GLuint>::size_type>(0), TEST_LOCATION);
668 if(boundTextures.size())
670 int a = boundTextures.size() - 1;
671 DALI_TEST_EQUALS(boundTextures[a], 8u /*unique to actor1*/, TEST_LOCATION);
674 Texture img2 = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
676 Actor actor2 = CreateRenderableActor(img2);
677 actor2.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
679 // Force actor2 to be rendered before actor1
680 Layer layer = Layer::New();
681 application.GetScene().Add(layer);
683 layer.LowerToBottom();
686 application.GetGlAbstraction().ClearBoundTextures();
687 application.SendNotification();
688 application.Render();
690 // Check that the actors were rendered
691 DALI_TEST_GREATER(boundTextures.size(), static_cast<std::vector<GLuint>::size_type>(1), TEST_LOCATION);
693 if(boundTextures.size() >= 2)
695 int a = boundTextures.size() - 2;
696 int b = boundTextures.size() - 1;
697 DALI_TEST_EQUALS(boundTextures[a], 9u /*unique to actor2*/, TEST_LOCATION);
698 DALI_TEST_EQUALS(boundTextures[b], 8u /*unique to actor1*/, TEST_LOCATION);
701 Texture img3 = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
702 Actor actor3 = CreateRenderableActor(img3);
703 actor3.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
705 // Force actor3 to be rendered before actor2
706 layer = Layer::New();
707 application.GetScene().Add(layer);
709 layer.LowerToBottom();
711 // Update & Render all actors
712 application.GetGlAbstraction().ClearBoundTextures();
713 application.SendNotification();
714 application.Render();
716 // Check that the actors were rendered
717 DALI_TEST_GREATER(boundTextures.size(), static_cast<std::vector<GLuint>::size_type>(2), TEST_LOCATION);
719 if(boundTextures.size() >= 3)
721 int a = boundTextures.size() - 3;
722 int b = boundTextures.size() - 2;
723 int c = boundTextures.size() - 1;
724 DALI_TEST_EQUALS(boundTextures[a], 10u /*unique to actor3*/, TEST_LOCATION);
725 DALI_TEST_EQUALS(boundTextures[b], 9u /*unique to actor2*/, TEST_LOCATION);
726 DALI_TEST_EQUALS(boundTextures[c], 8u /*unique to actor1*/, TEST_LOCATION);
729 // Both actors are now connected to the root node
730 // Setup 2 render-tasks - the first will render from the root-node, and the second from actor2
732 // Not exclusive is the default
733 RenderTask task1 = taskList.GetTask(0u);
734 DALI_TEST_CHECK(false == task1.IsExclusive());
736 RenderTask task2 = taskList.CreateTask();
737 DALI_TEST_CHECK(false == task2.IsExclusive());
738 task2.SetSourceActor(actor2);
740 // Task1 should render all actors, and task 2 should render only actor2
742 application.GetGlAbstraction().ClearBoundTextures();
743 application.SendNotification();
744 application.Render();
746 if(boundTextures.size() >= 4)
748 // Test that task 1 renders actor3, then actor2 & then actor1
749 int a = boundTextures.size() - 4;
750 int b = boundTextures.size() - 3;
751 int c = boundTextures.size() - 2;
752 int d = boundTextures.size() - 1;
753 DALI_TEST_EQUALS(boundTextures[a], 10u /*unique to actor3*/, TEST_LOCATION);
754 DALI_TEST_EQUALS(boundTextures[b], 9u /*unique to actor2*/, TEST_LOCATION);
755 DALI_TEST_EQUALS(boundTextures[c], 8u /*unique to actor1*/, TEST_LOCATION);
757 // Test that task 2 renders actor2
758 DALI_TEST_EQUALS(boundTextures[d], 9u, TEST_LOCATION);
761 // Make actor2 exclusive to task2
763 task2.SetExclusive(true);
764 DALI_TEST_CHECK(true == task2.IsExclusive());
766 // Task1 should render only actor1, and task 2 should render only actor2
768 application.GetGlAbstraction().ClearBoundTextures();
769 application.SendNotification();
770 application.Render();
772 DALI_TEST_EQUALS(boundTextures.size(), 3u, TEST_LOCATION);
773 if(boundTextures.size() == 3)
775 // Test that task 1 renders actor3 & actor1
776 DALI_TEST_CHECK(boundTextures[0] == 10u);
777 DALI_TEST_CHECK(boundTextures[1] == 8u);
779 // Test that task 2 renders actor2
780 DALI_TEST_CHECK(boundTextures[2] == 9u);
783 // Create a renderable actor and replace the source actor in task2
784 auto actor4 = CreateRenderableActor();
785 task2.SetSourceActor(actor3);
786 DALI_TEST_EQUALS(actor3, task2.GetSourceActor(), TEST_LOCATION);
791 int UtcDaliRenderTaskSetExclusive02(void)
793 TestApplication application;
795 tet_infoline("Testing RenderTask::SetExclusive() Check that changing from exclusive to not-exclusive works");
797 std::vector<GLuint> ids;
798 ids.push_back(8); // 8 = actor1
799 application.GetGlAbstraction().SetNextTextureIds(ids);
801 Texture img1 = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
802 Actor actor1 = CreateRenderableActor(img1);
803 actor1.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
804 application.GetScene().Add(actor1);
806 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
807 RenderTask task = taskList.CreateTask();
809 task.SetSourceActor(actor1);
810 task.SetExclusive(true); // Actor should only render once
812 TestGlAbstraction& gl = application.GetGlAbstraction();
813 TraceCallStack& drawTrace = gl.GetDrawTrace();
814 drawTrace.Enable(true);
816 // Update & Render actor1
817 application.SendNotification();
818 application.Render();
820 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
822 // Set task to non-exclusive - actor1 should render twice:
824 task.SetExclusive(false);
825 application.SendNotification();
826 application.Render();
828 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 2, TEST_LOCATION);
833 int UtcDaliRenderTaskSetExclusiveN(void)
835 TestApplication application;
837 tet_infoline("Testing RenderTask::SetExclusive() on empty handle");
842 task.SetExclusive(true);
844 catch(Dali::DaliException& e)
846 DALI_TEST_PRINT_ASSERT(e);
847 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
852 int UtcDaliRenderTaskIsExclusive01(void)
854 TestApplication application;
856 tet_infoline("Testing RenderTask::IsExclusive() Check default values are non-exclusive");
858 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
860 // Not exclusive is the default
861 RenderTask task = taskList.GetTask(0u);
862 DALI_TEST_CHECK(false == task.IsExclusive());
864 RenderTask newTask = taskList.CreateTask();
865 DALI_TEST_CHECK(false == newTask.IsExclusive());
870 int UtcDaliRenderTaskIsExclusive02(void)
872 TestApplication application;
874 tet_infoline("Testing RenderTask::IsExclusive() Check the getter returns set values");
876 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
878 // Not exclusive is the default
879 RenderTask newTask = taskList.CreateTask();
880 DALI_TEST_EQUALS(newTask.IsExclusive(), false, TEST_LOCATION);
882 newTask.SetExclusive(true);
883 DALI_TEST_EQUALS(newTask.IsExclusive(), true, TEST_LOCATION);
887 int UtcDaliRenderTaskIsExclusiveN(void)
889 TestApplication application;
891 tet_infoline("Testing RenderTask::IsExclusive() on empty handle");
896 bool x = task.IsExclusive();
899 catch(Dali::DaliException& e)
901 DALI_TEST_PRINT_ASSERT(e);
902 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
907 int UtcDaliRenderTaskSetInputEnabled(void)
909 TestApplication application;
911 tet_infoline("Testing RenderTask::SetInputEnabled()");
913 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
915 // Input is enabled by default
916 RenderTask task = taskList.GetTask(0u);
917 DALI_TEST_CHECK(true == task.GetInputEnabled());
919 task.SetInputEnabled(false);
920 DALI_TEST_CHECK(false == task.GetInputEnabled());
922 task.SetInputEnabled(true);
923 DALI_TEST_CHECK(true == task.GetInputEnabled());
927 int UtcDaliRenderTaskGetInputEnabled(void)
929 TestApplication application;
931 tet_infoline("Testing RenderTask::GetInputEnabled()");
933 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
935 // Input is enabled by default
936 RenderTask task = taskList.GetTask(0u);
937 DALI_TEST_EQUALS(true, task.GetInputEnabled(), TEST_LOCATION);
939 RenderTask newTask = taskList.CreateTask();
940 DALI_TEST_EQUALS(true, newTask.GetInputEnabled(), TEST_LOCATION);
942 newTask.SetInputEnabled(false);
943 DALI_TEST_EQUALS(false, newTask.GetInputEnabled(), TEST_LOCATION);
948 int UtcDaliRenderTaskSetCameraActorP(void)
950 TestApplication application;
952 tet_infoline("Testing RenderTask::SetCameraActor()");
954 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
956 RenderTask task = taskList.GetTask(0u);
958 Actor defaultCameraActor = task.GetCameraActor();
959 DALI_TEST_CHECK(defaultCameraActor);
961 CameraActor newCameraActor = CameraActor::New();
962 DALI_TEST_CHECK(newCameraActor);
964 task.SetCameraActor(newCameraActor);
965 DALI_TEST_CHECK(task.GetCameraActor() != defaultCameraActor);
966 DALI_TEST_EQUALS(task.GetCameraActor(), newCameraActor, TEST_LOCATION);
970 int UtcDaliRenderTaskSetCameraActorN(void)
972 TestApplication application;
974 tet_infoline("Testing RenderTask::SetCameraActor() with empty actor handle");
976 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
978 RenderTask task = taskList.GetTask(0u);
980 Actor actor = task.GetCameraActor();
981 DALI_TEST_CHECK(actor);
983 CameraActor cameraActor;
985 task.SetCameraActor(cameraActor);
986 DALI_TEST_EQUALS((bool)task.GetCameraActor(), false, TEST_LOCATION);
987 DALI_TEST_EQUALS(task.GetCameraActor(), cameraActor, TEST_LOCATION);
991 int UtcDaliRenderTaskSetCameraActorDestroyed(void)
993 TestApplication application;
995 tet_infoline("Testing RenderTask::SetCameraActor - Set a camera actor and destroy the camera actor");
997 Integration::Scene stage = application.GetScene();
998 RenderTaskList taskList = stage.GetRenderTaskList();
999 RenderTask task = taskList.GetTask(0u);
1001 CameraActor newCameraActor = CameraActor::New();
1002 task.SetCameraActor(newCameraActor);
1004 DALI_TEST_EQUALS(task.GetCameraActor(), newCameraActor, TEST_LOCATION);
1006 // Destroy the camera actor
1007 newCameraActor.Reset();
1009 CameraActor camera = task.GetCameraActor();
1010 DALI_TEST_CHECK(!camera); // The camera actor should be an empty handle.
1015 int UtcDaliRenderTaskGetCameraActorP(void)
1017 TestApplication application;
1019 tet_infoline("Testing RenderTask::GetCameraActor()");
1021 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1023 RenderTask task = taskList.GetTask(0u);
1025 CameraActor actor = task.GetCameraActor();
1026 DALI_TEST_CHECK(actor);
1027 DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION);
1028 DALI_TEST_GREATER(actor.GetFieldOfView(), 0.0f, TEST_LOCATION);
1032 int UtcDaliRenderTaskGetCameraActorN(void)
1034 TestApplication application;
1036 tet_infoline("Testing RenderTask::GetCameraActor() with empty handle");
1041 Actor actor = task.GetCameraActor();
1043 catch(Dali::DaliException& e)
1045 DALI_TEST_PRINT_ASSERT(e);
1046 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1052 int UtcDaliRenderTaskSetFrameBufferP(void)
1054 TestApplication application;
1056 tet_infoline("Testing RenderTask::SetFrameBuffer()");
1058 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1060 RenderTask task = taskList.GetTask(0u);
1062 FrameBuffer newFrameBuffer = FrameBuffer::New(128u, 128u, FrameBuffer::Attachment::NONE);
1063 task.SetFrameBuffer(newFrameBuffer);
1064 DALI_TEST_CHECK(task.GetFrameBuffer() == newFrameBuffer);
1068 int UtcDaliRenderTaskSetFrameBufferN(void)
1070 TestApplication application;
1072 tet_infoline("Testing RenderTask::SetFrameBuffer()");
1074 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1076 RenderTask task = taskList.GetTask(0u);
1077 FrameBuffer newFrameBuffer; // Empty handle
1078 task.SetFrameBuffer(newFrameBuffer);
1079 DALI_TEST_EQUALS((bool)task.GetFrameBuffer(), false, TEST_LOCATION);
1083 int UtcDaliRenderTaskGetFrameBufferP(void)
1085 TestApplication application;
1087 tet_infoline("Testing RenderTask::GetFrameBuffer()");
1089 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1091 RenderTask task = taskList.GetTask(0u);
1093 FrameBuffer newFrameBuffer = FrameBuffer::New(1u, 1u, FrameBuffer::Attachment::NONE);
1094 task.SetFrameBuffer(newFrameBuffer);
1095 DALI_TEST_CHECK(task.GetFrameBuffer() == newFrameBuffer);
1099 int UtcDaliRenderTaskGetFrameBufferN(void)
1101 TestApplication application;
1103 tet_infoline("Testing RenderTask::GetFrameBuffer()");
1105 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1107 RenderTask task = taskList.GetTask(0u);
1109 // By default render-tasks do not render off-screen
1110 FrameBuffer frameBuffer = task.GetFrameBuffer();
1111 DALI_TEST_CHECK(!frameBuffer);
1116 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionP(void)
1118 TestApplication application;
1120 tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1122 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1124 RenderTask task = taskList.GetTask(0u);
1126 task.SetScreenToFrameBufferFunction(TestScreenToFrameBufferFunction);
1128 Vector2 coordinates(5, 10);
1129 Vector2 convertedCoordinates(6, 12); // + Vector(1, 2)
1131 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1132 DALI_TEST_CHECK(func(coordinates));
1133 DALI_TEST_CHECK(coordinates == convertedCoordinates);
1135 task.SetScreenToFrameBufferFunction(RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION);
1136 func = task.GetScreenToFrameBufferFunction();
1137 DALI_TEST_CHECK(func(coordinates));
1139 task.SetScreenToFrameBufferFunction(RenderTask::DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION);
1140 func = task.GetScreenToFrameBufferFunction();
1141 DALI_TEST_CHECK(!func(coordinates));
1145 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionN(void)
1147 TestApplication application;
1149 tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1151 RenderTask task; // Empty handle
1154 task.SetScreenToFrameBufferFunction(TestScreenToFrameBufferFunction);
1156 catch(Dali::DaliException& e)
1158 DALI_TEST_PRINT_ASSERT(e);
1159 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1164 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionP(void)
1166 TestApplication application;
1168 tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction()");
1170 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1172 RenderTask task = taskList.GetTask(0u);
1174 Vector2 originalCoordinates(5, 10);
1175 Vector2 coordinates(5, 10);
1177 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1178 DALI_TEST_CHECK(!func(coordinates)); // conversion should fail by default
1179 DALI_TEST_CHECK(coordinates == originalCoordinates); // coordinates should not be modified
1183 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionN(void)
1185 TestApplication application;
1187 tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction() on empty handle");
1192 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1195 catch(Dali::DaliException& e)
1197 DALI_TEST_PRINT_ASSERT(e);
1198 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1203 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorP(void)
1205 TestApplication application;
1206 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor ");
1208 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1209 RenderTask renderTask = taskList.CreateTask();
1210 Actor mappingActor = Actor::New();
1211 renderTask.SetScreenToFrameBufferMappingActor(mappingActor);
1213 DALI_TEST_EQUALS(mappingActor, renderTask.GetScreenToFrameBufferMappingActor(), TEST_LOCATION);
1217 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorN(void)
1219 TestApplication application;
1220 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1226 task.SetScreenToFrameBufferMappingActor(mappingActor);
1228 catch(Dali::DaliException& e)
1230 DALI_TEST_PRINT_ASSERT(e);
1231 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1236 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActor02N(void)
1238 TestApplication application;
1239 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1241 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1242 RenderTask renderTask = taskList.CreateTask();
1244 renderTask.SetScreenToFrameBufferMappingActor(actor);
1246 DALI_TEST_EQUALS((bool)renderTask.GetScreenToFrameBufferMappingActor(), false, TEST_LOCATION);
1250 int UtcDaliRenderTaskGetViewportP01(void)
1252 TestApplication application;
1254 tet_infoline("Testing RenderTask::GetViewport() on default task");
1256 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1257 RenderTask task = taskList.GetTask(0u);
1258 Viewport viewport = task.GetViewport();
1260 // By default the viewport should match the stage width/height
1261 Vector2 stageSize = application.GetScene().GetSize();
1262 Viewport expectedViewport(0, 0, stageSize.width, stageSize.height);
1263 DALI_TEST_CHECK(viewport == expectedViewport);
1267 int UtcDaliRenderTaskGetViewportP02(void)
1269 TestApplication application;
1271 tet_infoline("Testing RenderTask::GetViewport() on new task");
1273 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1274 RenderTask task = taskList.CreateTask();
1275 Viewport viewport = task.GetViewport();
1277 // By default the viewport should match the stage width/height
1278 Vector2 stageSize = application.GetScene().GetSize();
1279 Viewport expectedViewport(0, 0, stageSize.width, stageSize.height);
1280 DALI_TEST_CHECK(viewport == expectedViewport);
1284 int UtcDaliRenderTaskGetViewportN(void)
1286 TestApplication application;
1288 tet_infoline("Testing RenderTask::GetViewport() on empty handle");
1293 Viewport viewport = task.GetViewport();
1296 catch(Dali::DaliException& e)
1298 DALI_TEST_PRINT_ASSERT(e);
1299 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1304 int UtcDaliRenderTaskSetViewportP(void)
1306 TestApplication application;
1308 tet_infoline("Testing RenderTask::SetViewport()");
1310 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1312 RenderTask task = taskList.GetTask(0u);
1313 Vector2 stageSize = application.GetScene().GetSize();
1314 Viewport newViewport(0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f);
1315 task.SetViewport(newViewport);
1317 // Update (viewport is a property)
1318 application.SendNotification();
1319 application.Render();
1321 DALI_TEST_CHECK(task.GetViewport() == newViewport);
1325 int UtcDaliRenderTaskSetViewportN(void)
1327 TestApplication application;
1329 tet_infoline("Testing RenderTask::SetViewport()");
1331 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1336 Vector2 stageSize = application.GetScene().GetSize();
1337 Viewport newViewport(0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f);
1338 task.SetViewport(newViewport);
1340 catch(Dali::DaliException& e)
1342 DALI_TEST_PRINT_ASSERT(e);
1343 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1349 int UtcDaliRenderTaskSetViewportPosition(void)
1351 TestApplication application;
1353 tet_infoline("Testing RenderTask::SetViewportPosition()");
1355 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1357 RenderTask task = taskList.GetTask(0u);
1359 Viewport viewport = task.GetViewport();
1361 // By default the viewport should match the stage width/height
1363 Vector2 stageSize = application.GetScene().GetSize();
1364 Viewport expectedViewport(0, 0, stageSize.width, stageSize.height);
1365 DALI_TEST_CHECK(viewport == expectedViewport);
1368 Vector2 newPosition(25.0f, 50.0f);
1369 task.SetViewportPosition(newPosition);
1371 // Update (viewport is a property)
1372 application.SendNotification();
1373 application.Render();
1375 DALI_TEST_EQUALS(task.GetCurrentViewportPosition(), newPosition, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1377 // Set by Property test
1378 Vector2 newPosition2(32.0f, 32.0f);
1379 task.SetProperty(RenderTask::Property::VIEWPORT_POSITION, newPosition2);
1380 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition2, TEST_LOCATION);
1381 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition, TEST_LOCATION); // still the old position
1384 application.SendNotification();
1385 application.Render();
1387 DALI_TEST_EQUALS(task.GetCurrentViewportPosition(), newPosition2, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1388 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition2, TEST_LOCATION);
1389 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition2, TEST_LOCATION);
1391 Vector2 newPosition3(64.0f, 0.0f);
1392 Animation animation = Animation::New(1.0f);
1393 animation.AnimateTo(Property(task, RenderTask::Property::VIEWPORT_POSITION), newPosition3, AlphaFunction::LINEAR);
1396 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1397 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition2, TEST_LOCATION);
1399 // Perform 1000ms worth of updates at which point animation should have completed.
1400 Wait(application, 1000);
1401 DALI_TEST_EQUALS(task.GetCurrentViewportPosition(), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1402 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1403 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1405 // Create another animation which animates by a certain value
1406 const Vector2 newPosition4(75.0f, 45.0f);
1407 const Vector2 relativePosition(newPosition4 - newPosition3);
1408 animation = Animation::New(1.0f);
1409 animation.AnimateBy(Property(task, RenderTask::Property::VIEWPORT_POSITION), relativePosition);
1412 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1413 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition3, TEST_LOCATION);
1415 // Perform 1000ms worth of updates at which point animation should have completed.
1416 Wait(application, 1000);
1417 DALI_TEST_EQUALS(task.GetCurrentViewportPosition(), newPosition4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1418 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1419 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1424 int UtcDaliRenderTaskSetViewportSize(void)
1426 TestApplication application;
1428 tet_infoline("Testing RenderTask::SetViewportSize()");
1430 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1432 RenderTask task = taskList.GetTask(0u);
1434 Viewport viewport = task.GetViewport();
1436 // By default the viewport should match the stage width/height
1438 Vector2 stageSize = application.GetScene().GetSize();
1439 Viewport expectedViewport(0, 0, stageSize.width, stageSize.height);
1440 DALI_TEST_CHECK(viewport == expectedViewport);
1442 Vector2 newSize(128.0f, 64.0f);
1443 task.SetViewportSize(newSize);
1445 // Update (viewport is a property)
1446 application.SendNotification();
1447 application.Render();
1449 DALI_TEST_EQUALS(task.GetCurrentViewportSize(), newSize, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1451 // Set by Property test
1452 Vector2 newSize2(50.0f, 50.0f);
1453 task.SetProperty(RenderTask::Property::VIEWPORT_SIZE, newSize2);
1454 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize2, TEST_LOCATION);
1455 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize, TEST_LOCATION); // still the old position
1458 application.SendNotification();
1459 application.Render();
1461 DALI_TEST_EQUALS(task.GetCurrentViewportSize(), newSize2, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1462 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize2, TEST_LOCATION);
1463 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize2, TEST_LOCATION);
1465 Vector2 newSize3(10.0f, 10.0f);
1466 Animation animation = Animation::New(1.0f);
1467 animation.AnimateTo(Property(task, RenderTask::Property::VIEWPORT_SIZE), newSize3, AlphaFunction::LINEAR);
1470 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1471 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize2, TEST_LOCATION);
1473 // Perform 1000ms worth of updates at which point animation should have completed.
1474 Wait(application, 1000);
1475 DALI_TEST_EQUALS(task.GetCurrentViewportSize(), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1476 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1477 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1479 // Create another animation which animates by a certain value
1480 const Vector2 newSize4(75.0f, 45.0f);
1481 const Vector2 relativeSize(newSize4 - newSize3);
1482 animation = Animation::New(1.0f);
1483 animation.AnimateBy(Property(task, RenderTask::Property::VIEWPORT_SIZE), relativeSize);
1486 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1487 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize3, TEST_LOCATION);
1489 // Perform 1000ms worth of updates at which point animation should have completed.
1490 Wait(application, 1000);
1491 DALI_TEST_EQUALS(task.GetCurrentViewportSize(), newSize4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1492 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1493 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1498 int UtcDaliRenderTaskSetClearColorP(void)
1500 TestApplication application;
1502 tet_infoline("Testing RenderTask::SetClearColor()");
1504 Vector4 testColor(1.0f, 2.0f, 3.0f, 4.0f);
1505 Vector4 testColor2(5.0f, 6.0f, 7.0f, 8.0f);
1507 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1509 RenderTask task = taskList.GetTask(0u);
1510 DALI_TEST_CHECK(task.GetClearColor() != testColor);
1512 task.SetClearColor(testColor);
1517 DALI_TEST_EQUALS(task.GetClearColor(), testColor, TEST_LOCATION);
1519 task.SetProperty(RenderTask::Property::CLEAR_COLOR, testColor2);
1520 DALI_TEST_EQUALS(task.GetProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), testColor2, TEST_LOCATION);
1521 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), testColor, TEST_LOCATION); // still the old color
1526 DALI_TEST_EQUALS(task.GetClearColor(), testColor2, TEST_LOCATION);
1527 DALI_TEST_EQUALS(task.GetProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), testColor2, TEST_LOCATION);
1528 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), testColor2, TEST_LOCATION);
1530 Vector4 newColor3(10.0f, 10.0f, 20.0f, 30.0f);
1531 Animation animation = Animation::New(1.0f);
1532 animation.AnimateTo(Property(task, RenderTask::Property::CLEAR_COLOR), newColor3, AlphaFunction::LINEAR);
1535 DALI_TEST_EQUALS(task.GetProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1536 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), testColor2, TEST_LOCATION);
1538 // Perform 1000ms worth of updates at which point animation should have completed.
1539 Wait(application, 1000);
1540 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1541 DALI_TEST_EQUALS(task.GetProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1543 // Create another animation which animates by a certain value
1544 const Vector4 newColor4(0.45f, 0.35f, 0.25f, 0.1f);
1545 const Vector4 relativeColor(newColor4 - newColor3);
1546 animation = Animation::New(1.0f);
1547 animation.AnimateBy(Property(task, RenderTask::Property::CLEAR_COLOR), relativeColor);
1550 DALI_TEST_EQUALS(task.GetProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor4, Math::MACHINE_EPSILON_10, TEST_LOCATION);
1551 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor3, Math::MACHINE_EPSILON_10, TEST_LOCATION);
1553 // Perform 1000ms worth of updates at which point animation should have completed.
1554 Wait(application, 1000);
1555 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor4, Math::MACHINE_EPSILON_10, TEST_LOCATION);
1556 DALI_TEST_EQUALS(task.GetProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor4, Math::MACHINE_EPSILON_10, TEST_LOCATION);
1561 int UtcDaliRenderTaskSetClearColorN(void)
1563 TestApplication application;
1565 tet_infoline("Testing RenderTask::SetClearColor() on empty handle");
1570 task.SetClearColor(Vector4::ZERO);
1572 catch(Dali::DaliException& e)
1574 DALI_TEST_PRINT_ASSERT(e);
1575 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1580 int UtcDaliRenderTaskGetClearColorP(void)
1582 TestApplication application;
1584 tet_infoline("Testing RenderTask::GetClearColor()");
1586 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1587 RenderTask task = taskList.GetTask(0u);
1588 DALI_TEST_EQUALS(task.GetClearColor(), RenderTask::DEFAULT_CLEAR_COLOR, TEST_LOCATION);
1592 int UtcDaliRenderTaskGetClearColorN(void)
1594 TestApplication application;
1596 tet_infoline("Testing RenderTask::GetClearColor()");
1601 Vector4 color = task.GetClearColor();
1604 catch(Dali::DaliException& e)
1606 DALI_TEST_PRINT_ASSERT(e);
1607 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1612 int UtcDaliRenderTaskSetClearEnabledP(void)
1614 TestApplication application;
1616 tet_infoline("Testing RenderTask::SetClearEnabled()");
1618 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1620 RenderTask task = taskList.GetTask(0u);
1621 DALI_TEST_CHECK(task.GetClearEnabled()); // defaults to true
1623 task.SetClearEnabled(false);
1624 DALI_TEST_EQUALS(task.GetClearEnabled(), false, TEST_LOCATION);
1626 task.SetClearEnabled(true);
1627 DALI_TEST_EQUALS(task.GetClearEnabled(), true, TEST_LOCATION);
1631 int UtcDaliRenderTaskSetClearEnabledN(void)
1633 TestApplication application;
1635 tet_infoline("Testing RenderTask::SetClearEnabled() with empty handle");
1640 task.SetClearEnabled(true);
1642 catch(Dali::DaliException& e)
1644 DALI_TEST_PRINT_ASSERT(e);
1645 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1650 int UtcDaliRenderTaskGetClearEnabledP(void)
1652 TestApplication application;
1654 tet_infoline("Testing RenderTask::GetClearEnabled()");
1656 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1658 RenderTask task = taskList.GetTask(0u);
1659 DALI_TEST_CHECK(task.GetClearEnabled()); // defaults to true
1663 int UtcDaliRenderTaskGetClearEnabledN(void)
1665 TestApplication application;
1667 tet_infoline("Testing RenderTask::GetClearEnabled() with empty handle");
1672 bool x = task.GetClearEnabled();
1675 catch(Dali::DaliException& e)
1677 DALI_TEST_PRINT_ASSERT(e);
1678 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1683 int UtcDaliRenderTaskSetCullModeP(void)
1685 TestApplication application;
1687 tet_infoline("Testing RenderTask::SetCullMode()");
1689 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1690 RenderTask task = taskList.GetTask(0u);
1691 DALI_TEST_EQUALS(task.GetCullMode(), true, TEST_LOCATION);
1693 task.SetCullMode(false);
1695 DALI_TEST_EQUALS(task.GetCullMode(), false, TEST_LOCATION);
1700 int UtcDaliRenderTaskSetCullModeN(void)
1702 TestApplication application;
1704 tet_infoline("Testing RenderTask::SetCullMode() on empty handle");
1709 task.SetCullMode(false);
1711 catch(Dali::DaliException& e)
1713 DALI_TEST_PRINT_ASSERT(e);
1714 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1719 int UtcDaliRenderTaskGetCullModeP(void)
1721 TestApplication application;
1723 tet_infoline("Testing RenderTask::GetCullMode()");
1725 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1726 RenderTask task = taskList.GetTask(0u);
1727 DALI_TEST_EQUALS(task.GetCullMode(), true, TEST_LOCATION);
1731 int UtcDaliRenderTaskGetCullModeN(void)
1733 TestApplication application;
1735 tet_infoline("Testing RenderTask::GetCullMode() with empty handle");
1740 bool x = task.GetCullMode();
1743 catch(Dali::DaliException& e)
1745 DALI_TEST_PRINT_ASSERT(e);
1746 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1751 int UtcDaliRenderTaskSetRefreshRate(void)
1753 TestApplication application;
1755 tet_infoline("Testing RenderTask::SetRefreshRate()");
1757 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1759 // By default tasks will be processed every frame
1760 RenderTask task = taskList.GetTask(0u);
1761 DALI_TEST_CHECK(RenderTask::REFRESH_ALWAYS == task.GetRefreshRate());
1763 task.SetRefreshRate(2u); // every-other frame
1764 DALI_TEST_CHECK(2u == task.GetRefreshRate());
1766 task.SetRefreshRate(RenderTask::REFRESH_ALWAYS);
1767 DALI_TEST_CHECK(RenderTask::REFRESH_ALWAYS == task.GetRefreshRate());
1771 int UtcDaliRenderTaskGetRefreshRate(void)
1773 TestApplication application;
1775 tet_infoline("Testing RenderTask::GetRefreshRate()");
1777 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1779 // By default tasks will be processed every frame
1780 RenderTask task = taskList.GetTask(0u);
1781 DALI_TEST_CHECK(RenderTask::REFRESH_ALWAYS == task.GetRefreshRate());
1783 RenderTask newTask = taskList.CreateTask();
1784 DALI_TEST_CHECK(RenderTask::REFRESH_ALWAYS == newTask.GetRefreshRate());
1788 int UtcDaliRenderTaskSignalFinished(void)
1790 TestApplication application;
1792 tet_infoline("Testing RenderTask::SignalFinished()");
1794 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1795 auto& sync = application.GetGraphicsSyncImpl();
1797 CameraActor offscreenCameraActor = CameraActor::New();
1799 application.GetScene().Add(offscreenCameraActor);
1801 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 10, 10);
1802 Actor rootActor = CreateRenderableActor(image);
1803 rootActor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1804 application.GetScene().Add(rootActor);
1806 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1807 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
1808 Texture frameBufferTexture = Texture::New(*testNativeImagePtr);
1809 FrameBuffer frameBuffer = FrameBuffer::New(frameBufferTexture.GetWidth(), frameBufferTexture.GetHeight());
1810 frameBuffer.AttachColorTexture(frameBufferTexture);
1812 RenderTask newTask = taskList.CreateTask();
1813 newTask.SetCameraActor(offscreenCameraActor);
1814 newTask.SetSourceActor(rootActor);
1815 newTask.SetInputEnabled(false);
1816 newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
1817 newTask.SetClearEnabled(true);
1818 newTask.SetExclusive(true);
1819 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
1820 newTask.SetFrameBuffer(frameBuffer);
1821 newTask.SetProperty(RenderTask::Property::REQUIRES_SYNC, true);
1823 bool finished = false;
1824 RenderTaskFinished renderTaskFinished(finished);
1825 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
1827 // Flush the queue and render.
1828 application.SendNotification();
1830 // 1 render to process render task, then wait for sync before finished msg is sent
1831 // from update to the event thread.
1833 application.Render();
1834 application.SendNotification();
1835 DALI_TEST_CHECK(!finished);
1837 Integration::GraphicsSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
1838 DALI_TEST_CHECK(lastSyncObj != NULL);
1840 application.Render();
1841 DALI_TEST_EQUALS((Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION);
1842 application.SendNotification();
1843 DALI_TEST_CHECK(!finished);
1845 application.Render();
1846 DALI_TEST_EQUALS((Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION);
1847 application.SendNotification();
1848 DALI_TEST_CHECK(!finished);
1850 sync.SetObjectSynced(lastSyncObj, true);
1852 application.Render();
1853 application.SendNotification();
1854 DALI_TEST_CHECK(!finished);
1856 application.Render();
1857 application.SendNotification();
1858 DALI_TEST_CHECK(finished);
1860 DALI_TEST_EQUALS(application.GetUpdateStatus(), 0, TEST_LOCATION);
1864 int UtcDaliRenderTaskContinuous01(void)
1866 TestApplication application;
1868 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not staged)\nPOST:continuous renders, no Finished signal");
1870 // SETUP AN OFFSCREEN RENDER TASK
1871 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1872 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1873 drawTrace.Enable(true);
1875 Actor rootActor = Actor::New();
1876 application.GetScene().Add(rootActor);
1878 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
1879 application.GetScene().Add(offscreenCameraActor);
1881 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
1883 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1884 bool finished = false;
1885 RenderTaskFinished renderTaskFinished(finished);
1886 application.SendNotification();
1888 // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating
1889 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, false, __LINE__));
1890 application.GetPlatform().ClearReadyResources();
1892 // ADD SOURCE ACTOR TO STAGE - expect continuous renders to start, no finished signal
1893 application.GetScene().Add(secondRootActor);
1894 application.SendNotification();
1896 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1897 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
1901 int UtcDaliRenderTaskContinuous02(void)
1903 TestApplication application;
1905 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not visible)\nPOST:continuous renders, no Finished signal");
1907 // SETUP AN OFFSCREEN RENDER TASK
1908 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1909 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1910 drawTrace.Enable(true);
1912 Actor rootActor = Actor::New();
1913 application.GetScene().Add(rootActor);
1915 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
1916 application.GetScene().Add(offscreenCameraActor);
1918 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
1919 application.GetScene().Add(secondRootActor);
1920 secondRootActor.SetProperty(Actor::Property::VISIBLE, false);
1922 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1923 bool finished = false;
1924 RenderTaskFinished renderTaskFinished(finished);
1925 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
1926 application.SendNotification();
1928 // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating
1929 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, false, __LINE__));
1930 application.GetPlatform().ClearReadyResources();
1932 // MAKE SOURCE ACTOR VISIBLE - expect continuous renders to start, no finished signal
1933 secondRootActor.SetProperty(Actor::Property::VISIBLE, true);
1934 application.SendNotification();
1936 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1937 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
1941 int UtcDaliRenderTaskContinuous03(void)
1943 TestApplication application;
1945 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (camera actor not staged)\nPOST:continuous renders, no Finished signal");
1947 // SETUP AN OFFSCREEN RENDER TASK
1948 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1949 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1950 drawTrace.Enable(true);
1952 Actor rootActor = Actor::New();
1953 application.GetScene().Add(rootActor);
1955 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
1956 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
1957 application.GetScene().Add(secondRootActor);
1959 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1960 bool finished = false;
1961 RenderTaskFinished renderTaskFinished(finished);
1962 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
1963 application.SendNotification();
1965 // START PROCESS/RENDER Input, Expected Input, Expected
1966 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, false, __LINE__));
1967 application.GetPlatform().ClearReadyResources();
1969 // ADD CAMERA ACTOR TO STAGE - expect continuous renders to start, no finished signal
1970 application.GetScene().Add(offscreenCameraActor);
1971 application.SendNotification();
1973 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1974 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
1978 int UtcDaliRenderTaskContinuous04(void)
1980 TestApplication application;
1982 tet_infoline("Testing RenderTask Render Continuous using loaded image");
1984 // SETUP AN OFFSCREEN RENDER TASK
1985 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1986 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1987 drawTrace.Enable(true);
1989 Actor rootActor = Actor::New();
1990 application.GetScene().Add(rootActor);
1992 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
1993 application.GetScene().Add(offscreenCameraActor);
1994 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
1995 application.GetScene().Add(secondRootActor);
1997 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1998 bool finished = false;
1999 RenderTaskFinished renderTaskFinished(finished);
2000 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2001 application.SendNotification();
2003 // START PROCESS/RENDER Input, Expected Input, Expected
2004 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2008 int UtcDaliRenderTaskOnce01(void)
2010 TestApplication application;
2012 tet_infoline("Testing RenderTask Render Once GlSync, using loaded image");
2014 // SETUP AN OFFSCREEN RENDER TASK
2015 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2016 auto& sync = application.GetGraphicsSyncImpl();
2017 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2018 drawTrace.Enable(true);
2020 Actor rootActor = Actor::New();
2021 application.GetScene().Add(rootActor);
2023 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2024 application.GetScene().Add(offscreenCameraActor);
2025 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2027 application.GetScene().Add(secondRootActor);
2029 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
2030 bool finished = false;
2031 RenderTaskFinished renderTaskFinished(finished);
2032 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2033 application.SendNotification();
2035 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2037 Integration::GraphicsSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2038 DALI_TEST_CHECK(lastSyncObj != NULL);
2039 sync.SetObjectSynced(lastSyncObj, true);
2041 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, true, __LINE__));
2042 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2046 int UtcDaliRenderTaskOnce02(void)
2048 TestApplication application;
2050 tet_infoline("Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loaded image.\n");
2052 // SETUP AN OFFSCREEN RENDER TASK
2053 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2054 auto& sync = application.GetGraphicsSyncImpl();
2055 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2056 drawTrace.Enable(true);
2058 Actor rootActor = Actor::New();
2059 application.GetScene().Add(rootActor);
2061 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2062 application.GetScene().Add(offscreenCameraActor);
2064 Shader shader = CreateShader();
2065 Texture image = CreateTexture();
2066 TextureSet textureSet = CreateTextureSet(image);
2068 Geometry geometry = CreateQuadGeometry();
2069 Renderer renderer = Renderer::New(geometry, shader);
2070 renderer.SetTextures(textureSet);
2071 Actor secondRootActor = Actor::New();
2072 secondRootActor.AddRenderer(renderer);
2073 secondRootActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2074 application.GetScene().Add(secondRootActor);
2076 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
2077 bool finished = false;
2078 RenderTaskFinished renderTaskFinished(finished);
2079 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2080 application.SendNotification();
2082 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2084 Integration::GraphicsSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2085 DALI_TEST_CHECK(lastSyncObj != NULL);
2086 sync.SetObjectSynced(lastSyncObj, true);
2088 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, true, __LINE__));
2089 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2094 int UtcDaliRenderTaskOnce03(void)
2096 TestApplication application;
2098 tet_infoline("Testing RenderTask Render Once GlSync, using loaded image. Switch from render always after ready to render once\n");
2100 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2101 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2102 auto& sync = application.GetGraphicsSyncImpl();
2103 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2104 drawTrace.Enable(true);
2106 Actor rootActor = Actor::New();
2107 application.GetScene().Add(rootActor);
2109 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2110 application.GetScene().Add(offscreenCameraActor);
2111 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2112 application.GetScene().Add(secondRootActor);
2114 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2115 bool finished = false;
2116 RenderTaskFinished renderTaskFinished(finished);
2117 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2118 application.SendNotification();
2120 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2122 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2123 application.SendNotification();
2124 // drawn sig finished Keep updating
2125 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2127 Integration::GraphicsSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2128 DALI_TEST_CHECK(lastSyncObj != NULL);
2129 sync.SetObjectSynced(lastSyncObj, true);
2131 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, true, __LINE__));
2132 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2137 int UtcDaliRenderTaskOnce04(void)
2139 TestApplication application;
2141 "Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loaded image.\n"
2142 "Switch from render always after ready to render once\n");
2144 // SETUP AN OFFSCREEN RENDER TASK
2145 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2146 auto& sync = application.GetGraphicsSyncImpl();
2147 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2148 drawTrace.Enable(true);
2150 Actor rootActor = Actor::New();
2151 application.GetScene().Add(rootActor);
2153 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2154 application.GetScene().Add(offscreenCameraActor);
2156 Shader shader = CreateShader();
2157 Texture image = CreateTexture();
2158 TextureSet textureSet = CreateTextureSet(image);
2160 Geometry geometry = CreateQuadGeometry();
2161 Renderer renderer = Renderer::New(geometry, shader);
2162 renderer.SetTextures(textureSet);
2163 Actor secondRootActor = Actor::New();
2164 secondRootActor.AddRenderer(renderer);
2165 secondRootActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2166 application.GetScene().Add(secondRootActor);
2168 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2169 bool finished = false;
2170 RenderTaskFinished renderTaskFinished(finished);
2171 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2172 application.SendNotification();
2174 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2176 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2177 application.SendNotification();
2178 // FAILS drawn sig finished Keep updating
2179 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2181 Integration::GraphicsSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2182 DALI_TEST_CHECK(lastSyncObj != NULL);
2183 sync.SetObjectSynced(lastSyncObj, true);
2185 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, true, __LINE__));
2186 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2191 int UtcDaliRenderTaskOnceNoSync01(void)
2193 TestApplication application;
2195 tet_infoline("Testing RenderTask Render Once, \nPRE: Resources ready\nPOST: Finished signal sent once only");
2197 // SETUP AN OFFSCREEN RENDER TASK
2198 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2199 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2200 drawTrace.Enable(true);
2202 Actor rootActor = Actor::New();
2203 application.GetScene().Add(rootActor);
2205 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2206 application.GetScene().Add(offscreenCameraActor);
2207 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2208 application.GetScene().Add(secondRootActor);
2210 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2211 bool finished = false;
2212 RenderTaskFinished renderTaskFinished(finished);
2213 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2214 application.SendNotification();
2216 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2217 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2221 int UtcDaliRenderTaskOnceNoSync02(void)
2223 TestApplication application;
2226 "Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loaded image.\n"
2227 "PRE: Resources ready\nPOST: Finished signal sent once only");
2228 // SETUP AN OFFSCREEN RENDER TASK
2229 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2230 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2231 drawTrace.Enable(true);
2233 Actor rootActor = Actor::New();
2234 application.GetScene().Add(rootActor);
2236 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2237 application.GetScene().Add(offscreenCameraActor);
2239 Shader shader = CreateShader();
2240 Texture image = CreateTexture();
2241 TextureSet textureSet = CreateTextureSet(image);
2243 Geometry geometry = CreateQuadGeometry();
2244 Renderer renderer = Renderer::New(geometry, shader);
2245 renderer.SetTextures(textureSet);
2246 Actor secondRootActor = Actor::New();
2247 secondRootActor.AddRenderer(renderer);
2248 secondRootActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2249 application.GetScene().Add(secondRootActor);
2251 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2252 bool finished = false;
2253 RenderTaskFinished renderTaskFinished(finished);
2254 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2255 application.SendNotification();
2257 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2258 application.GetPlatform().ClearReadyResources();
2259 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2264 int UtcDaliRenderTaskOnceNoSync03(void)
2266 TestApplication application;
2269 "Testing RenderTask Render Once, using loaded image. Switch from render always after ready to render once\n"
2270 "PRE: Render task ready, Image loaded\n"
2271 "POST: Finished signal sent only once");
2273 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2274 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2275 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2276 drawTrace.Enable(true);
2278 Actor rootActor = Actor::New();
2279 application.GetScene().Add(rootActor);
2281 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2282 application.GetScene().Add(offscreenCameraActor);
2283 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2284 application.GetScene().Add(secondRootActor);
2286 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2287 bool finished = false;
2288 RenderTaskFinished renderTaskFinished(finished);
2289 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2290 application.SendNotification();
2292 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2294 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2295 application.SendNotification(); // Input, Expected Input, Expected
2296 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2297 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2301 int UtcDaliRenderTaskOnceNoSync04(void)
2303 TestApplication application;
2306 "Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loading image.\n"
2307 "Switch from render always after ready to render once\n"
2308 "PRE: Render task ready, Image not loaded\n"
2309 "POST: Finished signal sent only once");
2311 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2312 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2313 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2314 drawTrace.Enable(true);
2316 Actor rootActor = Actor::New();
2317 application.GetScene().Add(rootActor);
2319 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2320 application.GetScene().Add(offscreenCameraActor);
2322 Shader shader = CreateShader();
2323 Texture image = CreateTexture();
2324 TextureSet textureSet = CreateTextureSet(image);
2326 Geometry geometry = CreateQuadGeometry();
2327 Renderer renderer = Renderer::New(geometry, shader);
2328 renderer.SetTextures(textureSet);
2329 Actor secondRootActor = Actor::New();
2330 secondRootActor.AddRenderer(renderer);
2331 secondRootActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2332 application.GetScene().Add(secondRootActor);
2334 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2335 bool finished = false;
2336 RenderTaskFinished renderTaskFinished(finished);
2337 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2338 application.SendNotification();
2340 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2341 auto& sync = application.GetGraphicsSyncImpl();
2342 Integration::GraphicsSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2343 DALI_TEST_CHECK(lastSyncObj == NULL);
2345 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2346 application.SendNotification(); // Input, Expected Input, Expected
2347 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2348 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2350 lastSyncObj = sync.GetLastSyncObject();
2351 DALI_TEST_CHECK(lastSyncObj == NULL);
2356 int UtcDaliRenderTaskOnceNoSync05(void)
2358 TestApplication application;
2361 "Testing RenderTask Render Once\n"
2362 "SetRefreshRate(ONCE), resource load failed, completes render task.\n"
2363 "PRE: resources failed to load\n"
2364 "POST: No finished signal sent.");
2366 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2367 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2368 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2369 drawTrace.Enable(true);
2371 Actor rootActor = Actor::New();
2372 application.GetScene().Add(rootActor);
2374 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2375 application.GetScene().Add(offscreenCameraActor);
2376 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2377 application.GetScene().Add(secondRootActor);
2379 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2380 bool finished = false;
2381 RenderTaskFinished renderTaskFinished(finished);
2382 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2383 application.SendNotification();
2385 // START PROCESS/RENDER Input, Expected Input, Expected
2386 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2388 // CHANGE TO RENDER ONCE,
2389 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2390 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2395 int UtcDaliRenderTaskOnceChain01(void)
2397 TestApplication application;
2400 "Testing RenderTask Render Once Chained render tasks\n"
2401 "SetRefreshRate(ONCE), resource load completes, both render tasks render.\n"
2402 "PRE: resources ready\n"
2403 "POST: 2 finished signals sent.");
2405 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2406 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2407 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2408 drawTrace.Enable(true);
2410 Actor defaultRootActor = Actor::New(); // Root for default RT
2411 application.GetScene().Add(defaultRootActor);
2413 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2414 application.GetScene().Add(offscreenCameraActor);
2415 Actor firstRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2416 application.GetScene().Add(firstRootActor);
2418 // first render task
2419 RenderTask firstTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, firstRootActor, RenderTask::REFRESH_ONCE, false);
2420 bool firstFinished = false;
2421 RenderTaskFinished renderTask1Finished(firstFinished);
2422 firstTask.FinishedSignal().Connect(&application, renderTask1Finished);
2424 // Second render task
2425 FrameBuffer fbo = firstTask.GetFrameBuffer();
2426 Actor secondRootActor = CreateRenderableActor(fbo.GetColorTexture());
2427 application.GetScene().Add(secondRootActor);
2428 RenderTask secondTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2429 bool secondFinished = false;
2430 RenderTaskFinished renderTask2Finished(secondFinished);
2431 secondTask.FinishedSignal().Connect(&application, renderTask2Finished);
2433 application.SendNotification();
2435 //Both render tasks are executed.
2436 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__));
2437 DALI_TEST_CHECK(firstFinished == false);
2438 DALI_TEST_CHECK(secondFinished == false);
2440 //Nothing else to render and both render task should have finished now
2441 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, firstFinished, true, false, __LINE__));
2442 DALI_TEST_CHECK(firstFinished == true);
2443 DALI_TEST_CHECK(secondFinished == true);
2448 int UtcDaliRenderTaskProperties(void)
2450 TestApplication application;
2452 RenderTask task = application.GetScene().GetRenderTaskList().CreateTask();
2454 Property::IndexContainer indices;
2455 task.GetPropertyIndices(indices);
2456 DALI_TEST_CHECK(indices.Size());
2457 DALI_TEST_EQUALS(indices.Size(), task.GetPropertyCount(), TEST_LOCATION);
2461 int UtcDaliRenderTaskFinishInvisibleSourceActor(void)
2463 TestApplication application;
2465 tet_infoline("Testing RenderTask::FinishInvisibleSourceActor()");
2467 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2468 auto& sync = application.GetGraphicsSyncImpl();
2470 CameraActor offscreenCameraActor = CameraActor::New();
2472 application.GetScene().Add(offscreenCameraActor);
2474 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 10, 10);
2475 Actor rootActor = CreateRenderableActor(image);
2476 rootActor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
2477 rootActor.SetProperty(Actor::Property::VISIBLE, false);
2478 application.GetScene().Add(rootActor);
2480 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2481 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
2482 Texture frameBufferTexture = Texture::New(*testNativeImagePtr);
2483 FrameBuffer frameBuffer = FrameBuffer::New(frameBufferTexture.GetWidth(), frameBufferTexture.GetHeight());
2484 frameBuffer.AttachColorTexture(frameBufferTexture);
2486 // Flush all outstanding messages
2487 application.SendNotification();
2488 application.Render();
2490 RenderTask newTask = taskList.CreateTask();
2491 newTask.SetCameraActor(offscreenCameraActor);
2492 newTask.SetSourceActor(rootActor);
2493 newTask.SetInputEnabled(false);
2494 newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
2495 newTask.SetClearEnabled(true);
2496 newTask.SetExclusive(true);
2497 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2498 newTask.SetFrameBuffer(frameBuffer);
2499 newTask.SetProperty(RenderTask::Property::REQUIRES_SYNC, true);
2501 // Framebuffer doesn't actually get created until Connected, i.e. by previous line
2503 bool finished = false;
2504 RenderTaskFinished renderTaskFinished(finished);
2505 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2507 // Flush the queue and render.
2508 application.SendNotification();
2510 // 1 render to process render task, then wait for sync before finished msg is sent
2511 // from update to the event thread.
2513 application.Render();
2514 application.SendNotification();
2515 DALI_TEST_CHECK(!finished);
2517 Integration::GraphicsSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2518 DALI_TEST_CHECK(lastSyncObj != NULL);
2520 application.Render();
2521 DALI_TEST_EQUALS((Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION);
2522 application.SendNotification();
2523 DALI_TEST_CHECK(!finished);
2525 application.Render();
2526 DALI_TEST_EQUALS((Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION);
2527 application.SendNotification();
2528 DALI_TEST_CHECK(!finished);
2530 sync.SetObjectSynced(lastSyncObj, true);
2532 application.Render();
2533 application.SendNotification();
2534 DALI_TEST_CHECK(!finished);
2536 application.Render();
2537 application.SendNotification();
2538 DALI_TEST_CHECK(finished);
2541 application.Render(); // Double check no more finished signal
2542 application.SendNotification();
2543 DALI_TEST_CHECK(!finished);
2548 int UtcDaliRenderTaskFinishMissingImage(void)
2550 TestApplication application;
2552 // Previously we had bugs where not having a resource ID would cause render-tasks to wait forever
2553 tet_infoline("Testing RenderTask::SignalFinished() when an Actor has no Image set");
2555 Integration::Scene stage = application.GetScene();
2557 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 10, 10);
2558 Actor rootActor = CreateRenderableActor(image);
2559 rootActor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
2560 stage.Add(rootActor);
2562 Actor actorWithMissingImage = CreateRenderableActor(Texture());
2563 actorWithMissingImage.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
2564 stage.Add(actorWithMissingImage);
2566 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2567 RenderTask newTask = taskList.CreateTask();
2568 newTask.SetInputEnabled(false);
2569 newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
2570 newTask.SetClearEnabled(true);
2571 newTask.SetExclusive(true);
2572 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2574 bool finished = false;
2575 RenderTaskFinished renderTaskFinished(finished);
2576 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2578 // 1 render to process render task, then 1 before finished msg is sent from update to the event thread.
2579 application.SendNotification();
2580 application.Render();
2581 application.Render();
2583 application.SendNotification();
2584 DALI_TEST_CHECK(finished);
2589 int UtcDaliRenderTaskWorldToViewport(void)
2591 TestApplication application(400u, 400u); // square surface
2593 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2595 Actor actor = Actor::New();
2596 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2597 actor.SetProperty(Actor::Property::POSITION, Vector3(0.0, 0.0, 0.0));
2599 actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.5, 0.5, 0.5));
2600 actor.SetProperty(Actor::Property::ANCHOR_POINT, Vector3(0.5, 0.5, 0.5));
2602 application.GetScene().Add(actor);
2604 application.SendNotification();
2605 application.Render();
2606 application.SendNotification();
2608 RenderTask task = taskList.GetTask(0u);
2610 CameraActor camera = task.GetCameraActor();
2612 Vector2 screenSize = task.GetCurrentViewportSize();
2614 float screenX = 0.0;
2615 float screenY = 0.0;
2617 bool ok = task.WorldToViewport(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), screenX, screenY);
2618 DALI_TEST_CHECK(ok == true);
2620 DALI_TEST_EQUALS(screenX, screenSize.x / 2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
2621 DALI_TEST_EQUALS(screenY, screenSize.y / 2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
2623 Actor actor2 = Actor::New();
2624 float actor2Size = 100.f;
2625 actor2.SetProperty(Actor::Property::SIZE, Vector2(actor2Size, actor2Size));
2626 actor2.SetProperty(Actor::Property::POSITION, Vector3(0.0, 0.0, 0.0));
2627 actor2.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.5, 0.5, 0.0));
2628 actor2.SetProperty(Actor::Property::ANCHOR_POINT, Vector3(0.5, 0.5, 0.0));
2629 application.GetScene().Add(actor2);
2631 actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0, 0, 0));
2633 application.SendNotification();
2634 application.Render();
2635 application.SendNotification();
2637 ok = task.WorldToViewport(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), screenX, screenY);
2638 DALI_TEST_CHECK(ok == true);
2640 DALI_TEST_EQUALS(screenX, screenSize.x / 2 - actor2Size / 2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
2641 DALI_TEST_EQUALS(screenY, screenSize.y / 2 - actor2Size / 2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
2646 int UtcDaliRenderTaskViewportToLocal(void)
2648 TestApplication application;
2649 Actor actor = Actor::New();
2650 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2651 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2652 actor.SetProperty(Actor::Property::POSITION, Vector2(10.0f, 10.0f));
2653 application.GetScene().Add(actor);
2655 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2656 RenderTask task = taskList.GetTask(0u);
2658 // flush the queue and render once
2659 application.SendNotification();
2660 application.Render();
2661 application.SendNotification();
2662 application.Render();
2670 float screenX = 50.0f;
2671 float screenY = 50.0f;
2673 DALI_TEST_CHECK(actor.ScreenToLocal(localX, localY, screenX, screenY));
2675 DALI_TEST_CHECK(task.ViewportToLocal(actor, screenX, screenY, rtLocalX, rtLocalY));
2677 DALI_TEST_EQUALS(localX, rtLocalX, 0.01f, TEST_LOCATION);
2678 DALI_TEST_EQUALS(localY, rtLocalY, 0.01f, TEST_LOCATION);
2683 int UtcDaliRenderTaskOffscreenViewportToLocal(void)
2685 TestApplication application;
2686 Actor actor = Actor::New();
2687 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2688 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2689 actor.SetProperty(Actor::Property::POSITION, Vector2(10.0f, 10.0f));
2690 application.GetScene().Add(actor);
2692 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2693 RenderTask task = taskList.CreateTask();
2695 FrameBuffer newFrameBuffer = FrameBuffer::New(10, 10);
2696 task.SetFrameBuffer(newFrameBuffer);
2697 task.SetSourceActor(actor);
2698 task.SetScreenToFrameBufferMappingActor(actor);
2700 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2701 application.GetScene().Add(offscreenCameraActor);
2702 task.SetCameraActor(offscreenCameraActor);
2704 // flush the queue and render once
2705 application.SendNotification();
2706 application.Render();
2707 application.SendNotification();
2708 application.Render();
2716 float screenX = 50.0f;
2717 float screenY = 50.0f;
2719 DALI_TEST_CHECK(actor.ScreenToLocal(localX, localY, screenX, screenY));
2721 DALI_TEST_CHECK(task.ViewportToLocal(actor, screenX, screenY, rtLocalX, rtLocalY));
2723 DALI_TEST_EQUALS(localX, rtLocalX, 0.01f, TEST_LOCATION);
2724 DALI_TEST_EQUALS(localY, rtLocalY, 0.01f, TEST_LOCATION);
2729 int UtcDaliRenderTaskRequiresSync(void)
2731 TestApplication application;
2732 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2734 RenderTask newTask = taskList.CreateTask();
2735 newTask.SetProperty(RenderTask::Property::REQUIRES_SYNC, false);
2737 DALI_TEST_EQUALS(newTask.GetProperty<bool>(RenderTask::Property::REQUIRES_SYNC), false, TEST_LOCATION);
2738 DALI_TEST_EQUALS(newTask.GetCurrentProperty<bool>(RenderTask::Property::REQUIRES_SYNC), false, TEST_LOCATION);
2740 newTask.SetProperty(RenderTask::Property::REQUIRES_SYNC, true);
2742 DALI_TEST_EQUALS(newTask.GetProperty<bool>(RenderTask::Property::REQUIRES_SYNC), true, TEST_LOCATION);
2743 DALI_TEST_EQUALS(newTask.GetCurrentProperty<bool>(RenderTask::Property::REQUIRES_SYNC), true, TEST_LOCATION);
2748 int UtcDaliRenderTaskSetClearEnabled(void)
2750 TestApplication application;
2752 tet_infoline("UtcDaliRenderTaskSetClearEnabled");
2754 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2755 TestGlAbstraction& gl = application.GetGlAbstraction();
2757 Actor renderableActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2758 application.GetScene().Add(renderableActor);
2760 Actor rootActor = Actor::New();
2761 application.GetScene().Add(rootActor);
2763 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2764 application.GetScene().Add(offscreenCameraActor);
2766 Actor sourceActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2767 application.GetScene().Add(sourceActor);
2769 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, sourceActor, RenderTask::REFRESH_ALWAYS, false);
2771 DALI_TEST_EQUALS(gl.GetClearCountCalled(), 0, TEST_LOCATION);
2773 application.SendNotification();
2774 application.Render();
2776 // glClear should be called twice - default task and the new task.
2777 DALI_TEST_EQUALS(gl.GetClearCountCalled(), 2, TEST_LOCATION);
2779 newTask.SetClearEnabled(false);
2781 application.SendNotification();
2782 application.Render();
2784 // The count should increase by 1 - default task only.
2785 DALI_TEST_EQUALS(gl.GetClearCountCalled(), 3, TEST_LOCATION);
2790 int UtcDaliRenderTaskMoveConstrctor(void)
2792 TestApplication application;
2794 Vector4 testColor(1.0f, 2.0f, 3.0f, 4.0f);
2796 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2797 RenderTask task = taskList.GetTask(0u);
2798 DALI_TEST_CHECK(task);
2799 DALI_TEST_EQUALS(2, task.GetBaseObject().ReferenceCount(), TEST_LOCATION);
2800 DALI_TEST_CHECK(task.GetClearColor() != testColor);
2802 task.SetClearColor(testColor);
2807 DALI_TEST_EQUALS(task.GetClearColor(), testColor, TEST_LOCATION);
2809 RenderTask move = std::move(task);
2810 DALI_TEST_CHECK(move);
2811 DALI_TEST_EQUALS(2, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
2812 DALI_TEST_EQUALS(move.GetClearColor(), testColor, TEST_LOCATION);
2813 DALI_TEST_CHECK(!task);
2818 int UtcDaliRenderTaskMoveAssignment(void)
2820 TestApplication application;
2822 Vector4 testColor(1.0f, 2.0f, 3.0f, 4.0f);
2824 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2825 RenderTask task = taskList.GetTask(0u);
2826 DALI_TEST_CHECK(task);
2827 DALI_TEST_EQUALS(2, task.GetBaseObject().ReferenceCount(), TEST_LOCATION);
2828 DALI_TEST_CHECK(task.GetClearColor() != testColor);
2830 task.SetClearColor(testColor);
2835 DALI_TEST_EQUALS(task.GetClearColor(), testColor, TEST_LOCATION);
2838 move = std::move(task);
2839 DALI_TEST_CHECK(move);
2840 DALI_TEST_EQUALS(2, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
2841 DALI_TEST_EQUALS(move.GetClearColor(), testColor, TEST_LOCATION);
2842 DALI_TEST_CHECK(!task);
2847 int UtcDaliRenderTaskSetCullModeNegative(void)
2849 TestApplication application;
2850 Dali::RenderTask instance;
2854 instance.SetCullMode(arg1);
2855 DALI_TEST_CHECK(false); // Should not get here
2859 DALI_TEST_CHECK(true); // We expect an assert
2864 int UtcDaliRenderTaskSetViewportNegative(void)
2866 TestApplication application;
2867 Dali::RenderTask instance;
2870 Dali::Rect<int> arg1;
2871 instance.SetViewport(arg1);
2872 DALI_TEST_CHECK(false); // Should not get here
2876 DALI_TEST_CHECK(true); // We expect an assert
2881 int UtcDaliRenderTaskSetExclusiveNegative(void)
2883 TestApplication application;
2884 Dali::RenderTask instance;
2888 instance.SetExclusive(arg1);
2889 DALI_TEST_CHECK(false); // Should not get here
2893 DALI_TEST_CHECK(true); // We expect an assert
2898 int UtcDaliRenderTaskSetClearColorNegative(void)
2900 TestApplication application;
2901 Dali::RenderTask instance;
2905 instance.SetClearColor(arg1);
2906 DALI_TEST_CHECK(false); // Should not get here
2910 DALI_TEST_CHECK(true); // We expect an assert
2915 int UtcDaliRenderTaskFinishedSignalNegative(void)
2917 TestApplication application;
2918 Dali::RenderTask instance;
2921 instance.FinishedSignal();
2922 DALI_TEST_CHECK(false); // Should not get here
2926 DALI_TEST_CHECK(true); // We expect an assert
2931 int UtcDaliRenderTaskSetCameraActorNegative(void)
2933 TestApplication application;
2934 Dali::RenderTask instance;
2937 Dali::CameraActor arg1;
2938 instance.SetCameraActor(arg1);
2939 DALI_TEST_CHECK(false); // Should not get here
2943 DALI_TEST_CHECK(true); // We expect an assert
2948 int UtcDaliRenderTaskSetFrameBufferNegative(void)
2950 TestApplication application;
2951 Dali::RenderTask instance;
2954 Dali::FrameBuffer arg1;
2955 instance.SetFrameBuffer(arg1);
2956 DALI_TEST_CHECK(false); // Should not get here
2960 DALI_TEST_CHECK(true); // We expect an assert
2965 int UtcDaliRenderTaskSetRefreshRateNegative(void)
2967 TestApplication application;
2968 Dali::RenderTask instance;
2971 unsigned int arg1(0u);
2972 instance.SetRefreshRate(arg1);
2973 DALI_TEST_CHECK(false); // Should not get here
2977 DALI_TEST_CHECK(true); // We expect an assert
2982 int UtcDaliRenderTaskSetSourceActorNegative(void)
2984 TestApplication application;
2985 Dali::RenderTask instance;
2989 instance.SetSourceActor(arg1);
2990 DALI_TEST_CHECK(false); // Should not get here
2994 DALI_TEST_CHECK(true); // We expect an assert
2999 int UtcDaliRenderTaskSetClearEnabledNegative(void)
3001 TestApplication application;
3002 Dali::RenderTask instance;
3006 instance.SetClearEnabled(arg1);
3007 DALI_TEST_CHECK(false); // Should not get here
3011 DALI_TEST_CHECK(true); // We expect an assert
3016 int UtcDaliRenderTaskSetInputEnabledNegative(void)
3018 TestApplication application;
3019 Dali::RenderTask instance;
3023 instance.SetInputEnabled(arg1);
3024 DALI_TEST_CHECK(false); // Should not get here
3028 DALI_TEST_CHECK(true); // We expect an assert
3033 int UtcDaliRenderTaskSetViewportSizeNegative(void)
3035 TestApplication application;
3036 Dali::RenderTask instance;
3040 instance.SetViewportSize(arg1);
3041 DALI_TEST_CHECK(false); // Should not get here
3045 DALI_TEST_CHECK(true); // We expect an assert
3050 int UtcDaliRenderTaskSetViewportPositionNegative(void)
3052 TestApplication application;
3053 Dali::RenderTask instance;
3057 instance.SetViewportPosition(arg1);
3058 DALI_TEST_CHECK(false); // Should not get here
3062 DALI_TEST_CHECK(true); // We expect an assert
3067 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionNegative(void)
3069 TestApplication application;
3070 Dali::RenderTask instance;
3073 RenderTask::ScreenToFrameBufferFunction arg1(nullptr);
3074 instance.SetScreenToFrameBufferFunction(arg1);
3075 DALI_TEST_CHECK(false); // Should not get here
3079 DALI_TEST_CHECK(true); // We expect an assert
3084 int UtcDaliRenderTaskSetScreenToFrameBufferMappingActorNegative(void)
3086 TestApplication application;
3087 Dali::RenderTask instance;
3091 instance.SetScreenToFrameBufferMappingActor(arg1);
3092 DALI_TEST_CHECK(false); // Should not get here
3096 DALI_TEST_CHECK(true); // We expect an assert
3101 int UtcDaliRenderTaskGetCullModeNegative(void)
3103 TestApplication application;
3104 Dali::RenderTask instance;
3107 instance.GetCullMode();
3108 DALI_TEST_CHECK(false); // Should not get here
3112 DALI_TEST_CHECK(true); // We expect an assert
3117 int UtcDaliRenderTaskGetViewportNegative(void)
3119 TestApplication application;
3120 Dali::RenderTask instance;
3123 instance.GetViewport();
3124 DALI_TEST_CHECK(false); // Should not get here
3128 DALI_TEST_CHECK(true); // We expect an assert
3133 int UtcDaliRenderTaskIsExclusiveNegative(void)
3135 TestApplication application;
3136 Dali::RenderTask instance;
3139 instance.IsExclusive();
3140 DALI_TEST_CHECK(false); // Should not get here
3144 DALI_TEST_CHECK(true); // We expect an assert
3149 int UtcDaliRenderTaskGetClearColorNegative(void)
3151 TestApplication application;
3152 Dali::RenderTask instance;
3155 instance.GetClearColor();
3156 DALI_TEST_CHECK(false); // Should not get here
3160 DALI_TEST_CHECK(true); // We expect an assert
3165 int UtcDaliRenderTaskGetCameraActorNegative(void)
3167 TestApplication application;
3168 Dali::RenderTask instance;
3171 instance.GetCameraActor();
3172 DALI_TEST_CHECK(false); // Should not get here
3176 DALI_TEST_CHECK(true); // We expect an assert
3181 int UtcDaliRenderTaskGetFrameBufferNegative(void)
3183 TestApplication application;
3184 Dali::RenderTask instance;
3187 instance.GetFrameBuffer();
3188 DALI_TEST_CHECK(false); // Should not get here
3192 DALI_TEST_CHECK(true); // We expect an assert
3197 int UtcDaliRenderTaskGetRefreshRateNegative(void)
3199 TestApplication application;
3200 Dali::RenderTask instance;
3203 instance.GetRefreshRate();
3204 DALI_TEST_CHECK(false); // Should not get here
3208 DALI_TEST_CHECK(true); // We expect an assert
3213 int UtcDaliRenderTaskGetSourceActorNegative(void)
3215 TestApplication application;
3216 Dali::RenderTask instance;
3219 instance.GetSourceActor();
3220 DALI_TEST_CHECK(false); // Should not get here
3224 DALI_TEST_CHECK(true); // We expect an assert
3229 int UtcDaliRenderTaskGetClearEnabledNegative(void)
3231 TestApplication application;
3232 Dali::RenderTask instance;
3235 instance.GetClearEnabled();
3236 DALI_TEST_CHECK(false); // Should not get here
3240 DALI_TEST_CHECK(true); // We expect an assert
3245 int UtcDaliRenderTaskGetInputEnabledNegative(void)
3247 TestApplication application;
3248 Dali::RenderTask instance;
3251 instance.GetInputEnabled();
3252 DALI_TEST_CHECK(false); // Should not get here
3256 DALI_TEST_CHECK(true); // We expect an assert
3261 int UtcDaliRenderTaskViewportToLocalNegative(void)
3263 TestApplication application;
3264 Dali::RenderTask instance;
3267 Dali::Actor arg1(Actor::New());
3272 instance.ViewportToLocal(arg1, arg2, arg3, arg4, arg5);
3273 DALI_TEST_CHECK(false); // Should not get here
3277 DALI_TEST_CHECK(true); // We expect an assert
3282 int UtcDaliRenderTaskWorldToViewportNegative(void)
3284 TestApplication application;
3285 Dali::RenderTask instance;
3291 instance.WorldToViewport(arg1, arg2, arg3);
3292 DALI_TEST_CHECK(false); // Should not get here
3296 DALI_TEST_CHECK(true); // We expect an assert
3301 int UtcDaliRenderTaskGetCurrentViewportSizeNegative(void)
3303 TestApplication application;
3304 Dali::RenderTask instance;
3307 instance.GetCurrentViewportSize();
3308 DALI_TEST_CHECK(false); // Should not get here
3312 DALI_TEST_CHECK(true); // We expect an assert
3317 int UtcDaliRenderTaskGetCurrentViewportPositionNegative(void)
3319 TestApplication application;
3320 Dali::RenderTask instance;
3323 instance.GetCurrentViewportPosition();
3324 DALI_TEST_CHECK(false); // Should not get here
3328 DALI_TEST_CHECK(true); // We expect an assert
3333 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionNegative(void)
3335 TestApplication application;
3336 Dali::RenderTask instance;
3339 instance.GetScreenToFrameBufferFunction();
3340 DALI_TEST_CHECK(false); // Should not get here
3344 DALI_TEST_CHECK(true); // We expect an assert
3349 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorNegative(void)
3351 TestApplication application;
3352 Dali::RenderTask instance;
3355 instance.GetScreenToFrameBufferMappingActor();
3356 DALI_TEST_CHECK(false); // Should not get here
3360 DALI_TEST_CHECK(true); // We expect an assert
3365 int UtcDaliRenderTaskClippingMode01(void)
3367 TestApplication application;
3369 tet_infoline("Testing clipping mode: CLIP_TO_BOUNDING_BOX.\n");
3371 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3372 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3373 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
3375 enabledDisableTrace.Enable(true);
3376 scissorTrace.Enable(true);
3378 // SETUP AN OFFSCREEN RENDER TASK
3379 Actor rootActor = Actor::New();
3380 application.GetScene().Add(rootActor);
3382 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
3383 offscreenCameraActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3384 offscreenCameraActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3385 application.GetScene().Add(offscreenCameraActor);
3387 Shader shader = CreateShader();
3388 Texture image = CreateTexture();
3389 TextureSet textureSet = CreateTextureSet(image);
3391 Geometry geometry = CreateQuadGeometry();
3392 Renderer renderer = Renderer::New(geometry, shader);
3393 renderer.SetTextures(textureSet);
3395 Vector2 position(100.0f, 100.0f);
3396 Vector2 size(200.0f, 200.0f);
3397 Actor secondRootActor = Actor::New();
3398 secondRootActor.AddRenderer(renderer);
3399 secondRootActor.SetProperty(Actor::Property::POSITION, position);
3400 secondRootActor.SetProperty(Actor::Property::SIZE, size);
3401 secondRootActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3402 secondRootActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3403 secondRootActor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
3404 application.GetScene().Add(secondRootActor);
3406 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
3408 application.SendNotification();
3409 application.Render();
3411 std::ostringstream scissor;
3412 scissor << std::hex << GL_SCISSOR_TEST;
3413 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
3415 // Check the scissor was set, and the coordinates are correct.
3416 Vector4 expectResults(position.x, TestApplication::DEFAULT_SURFACE_HEIGHT - size.height - position.y, size.width, size.height); // (100, 500, 200, 200)
3417 std::stringstream compareParametersString;
3418 compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
3419 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with the expected result
3424 int UtcDaliRenderTaskClippingMode02(void)
3426 TestApplication application;
3428 tet_infoline("Testing clipping mode with the inverted camera: CLIP_TO_BOUNDING_BOX.\n");
3430 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3431 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3432 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
3434 enabledDisableTrace.Enable(true);
3435 scissorTrace.Enable(true);
3437 // SETUP AN OFFSCREEN RENDER TASK
3438 Actor rootActor = Actor::New();
3439 application.GetScene().Add(rootActor);
3441 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
3442 offscreenCameraActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3443 offscreenCameraActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3444 offscreenCameraActor.SetInvertYAxis(true);
3445 application.GetScene().Add(offscreenCameraActor);
3447 Shader shader = CreateShader();
3448 Texture image = CreateTexture();
3449 TextureSet textureSet = CreateTextureSet(image);
3451 Geometry geometry = CreateQuadGeometry();
3452 Renderer renderer = Renderer::New(geometry, shader);
3453 renderer.SetTextures(textureSet);
3455 Vector2 position(100.0f, 100.0f);
3456 Vector2 size(200.0f, 200.0f);
3457 Actor secondRootActor = Actor::New();
3458 secondRootActor.AddRenderer(renderer);
3459 secondRootActor.SetProperty(Actor::Property::POSITION, position);
3460 secondRootActor.SetProperty(Actor::Property::SIZE, size);
3461 secondRootActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3462 secondRootActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3463 secondRootActor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
3464 application.GetScene().Add(secondRootActor);
3466 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
3468 application.SendNotification();
3469 application.Render();
3471 std::ostringstream scissor;
3472 scissor << std::hex << GL_SCISSOR_TEST;
3473 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
3475 // Check the scissor was set, and the coordinates are correct.
3476 Vector4 expectResults(position.x, position.y, size.width, size.height); // (100, 100, 200, 200)
3477 std::stringstream compareParametersString;
3478 compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
3479 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with the expected result