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-native-image.h>
28 #define BOOLSTR(x) ((x) ? "T" : "F")
30 //& set: DaliRenderTask
34 void utc_dali_render_task_startup(void)
36 test_return_value = TET_UNDEF;
39 void utc_dali_render_task_cleanup(void)
41 test_return_value = TET_PASS;
47 * Constructor, Destructor, DownCast, New, copy constructor, assignment operator
49 * SetSourceActor 2+ve, 1-ve
50 * GetSourceActor 1+ve, 1-ve
51 * SetExclusive 2+ve, 0-ve
52 * IsExclusive 2+ve, 0-ve
53 * SetInputEnabled 1+ve, 0-ve
54 * GetInputEnabled 1+ve, 0-ve
55 * SetCameraActor 1+ve, 1-ve
56 * GetCameraActor 1+ve, 1-ve
57 * SetTargetFrameBuffer 1+ve, 1-ve
58 * GetTargetFrameBuffer 1+ve, 1-ve
59 * SetScreenToFrameBufferFunction 1+ve, 1-ve
60 * GetScreenToFrameBufferFunction 1+ve, 1-ve
61 * SetScreenToFrameBufferMappingActor 1+ve, 1-ve
62 * GetScreenToFrameBufferMappingActor 1+ve, 1-ve
63 * SetViewportPosition 1+ve
64 * GetCurrentViewportPosition 1+ve
65 * SetViewportSize 1+ve
66 * GetCurrentViewportSize 1+ve
67 * SetViewport 2+ve, 1-ve
68 * GetViewport 2+ve, 1-ve
69 * SetClearColor 1+ve, 1-ve
70 * GetClearColor 1+ve, 1-ve
71 * SetClearEnabled 1+ve, 1-ve
72 * GetClearEnabled 1+ve, 1-ve
80 namespace // unnamed namespace
82 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
85 * Simulate time passed by.
87 * @note this will always process at least 1 frame (1/60 sec)
89 * @param application Test application instance
90 * @param duration Time to pass in milliseconds.
91 * @return The actual time passed in milliseconds
93 int Wait(TestApplication& application, int duration = 0)
97 for(int i = 0; i <= (duration / RENDER_FRAME_INTERVAL); i++)
99 application.SendNotification();
100 application.Render(RENDER_FRAME_INTERVAL);
101 time += RENDER_FRAME_INTERVAL;
107 struct RenderTaskFinished
109 RenderTaskFinished(bool& finished)
114 void operator()(RenderTask& renderTask)
122 struct RenderTaskFinishedRemoveSource
124 RenderTaskFinishedRemoveSource(bool& finished)
125 : finished(finished),
130 void operator()(RenderTask& renderTask)
132 DALI_TEST_CHECK(finishedOnce == false);
135 Actor srcActor = renderTask.GetSourceActor();
136 UnparentAndReset(srcActor);
143 struct RenderTaskFinishedRenderAgain
145 RenderTaskFinishedRenderAgain(bool& finished)
146 : finished(finished),
151 void operator()(RenderTask& renderTask)
153 DALI_TEST_CHECK(finishedOnce == false);
156 renderTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
163 bool TestScreenToFrameBufferFunction(Vector2& coordinates)
165 coordinates = coordinates + Vector2(1, 2);
170 Actor CreateRenderableActorSuccess(TestApplication& application, std::string filename)
172 Actor actor = CreateRenderableActor();
173 actor.SetProperty(Actor::Property::SIZE, Vector2(80.0f, 80.0f));
177 Texture CreateTexture(TextureType::Type type, Pixel::Format format, int width, int height)
179 Texture texture = Texture::New(type, format, width, height);
181 int bufferSize = width * height * 2;
182 uint8_t* buffer = reinterpret_cast<uint8_t*>(malloc(bufferSize));
183 PixelData pixelData = PixelData::New(buffer, bufferSize, width, height, format, PixelData::FREE);
184 texture.Upload(pixelData, 0u, 0u, 0u, 0u, width, height);
188 Texture CreateTexture()
190 return CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 80, 80);
193 RenderTask CreateRenderTask(TestApplication& application,
194 CameraActor offscreenCamera,
195 Actor rootActor, // Reset default render task to point at this actor
196 Actor secondRootActor, // Source actor
197 unsigned int refreshRate,
199 uint32_t frameBufferWidth = 10,
200 uint32_t frameBufferHeight = 10)
202 // Change main render task to use a different root
203 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
204 taskList.GetTask(0u).SetSourceActor(rootActor);
206 FrameBuffer frameBuffer = FrameBuffer::New(frameBufferWidth, frameBufferHeight);
209 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(frameBufferWidth, frameBufferHeight);
210 Texture texture = Texture::New(*testNativeImagePtr);
211 frameBuffer.AttachColorTexture(texture);
214 // Don't draw output framebuffer // '
216 RenderTask newTask = taskList.CreateTask();
217 newTask.SetCameraActor(offscreenCamera);
218 newTask.SetSourceActor(secondRootActor);
219 newTask.SetInputEnabled(false);
220 newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
221 newTask.SetClearEnabled(true);
222 newTask.SetExclusive(true);
223 newTask.SetRefreshRate(refreshRate);
224 newTask.SetFrameBuffer(frameBuffer);
225 newTask.SetProperty(RenderTask::Property::REQUIRES_SYNC, glSync);
229 bool UpdateRender(TestApplication& application, TraceCallStack& callStack, bool testDrawn, bool& finishedSig, bool testFinished, bool testKeepUpdating, int lineNumber)
234 tet_printf("TestApplication::UpdateRender().\n");
236 application.Render(16);
237 application.SendNotification();
239 bool sigPassed = false;
242 sigPassed = finishedSig;
246 sigPassed = !finishedSig;
249 bool drawResult = callStack.FindMethod("DrawElements") || callStack.FindMethod("DrawArrays");
251 bool drawPassed = false;
254 drawPassed = drawResult;
258 drawPassed = !drawResult;
261 bool keepUpdating = (application.GetUpdateStatus() != 0);
262 bool keepUpdatingPassed = false;
265 keepUpdatingPassed = keepUpdating;
269 keepUpdatingPassed = !keepUpdating;
272 bool result = (sigPassed && drawPassed && keepUpdatingPassed);
274 tet_printf("UpdateRender: Expected: Draw:%s Signal:%s KeepUpdating: %s Actual: Draw:%s Signal:%s KeepUpdating: %s %s, line %d\n",
276 BOOLSTR(testFinished),
277 BOOLSTR(testKeepUpdating),
279 BOOLSTR(finishedSig),
280 BOOLSTR(keepUpdating),
281 result ? "Passed" : "Failed",
287 } // unnamed namespace
289 /****************************************************************************************************/
290 /****************************************************************************************************/
291 /******************************** TEST CASES BELOW **********************************************/
292 /****************************************************************************************************/
293 /****************************************************************************************************/
295 int UtcDaliRenderTaskDownCast01(void)
297 TestApplication application;
299 tet_infoline("Testing RenderTask::DownCast()");
301 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
303 BaseHandle base = taskList.GetTask(0u);
304 DALI_TEST_CHECK(base);
306 RenderTask task = RenderTask::DownCast(base);
307 DALI_TEST_CHECK(task);
309 // Try calling a method
310 DALI_TEST_CHECK(task.GetSourceActor());
314 int UtcDaliRenderTaskDownCast02(void)
316 TestApplication application;
318 tet_infoline("Testing RenderTask::DownCast()");
320 Actor actor = Actor::New();
322 RenderTask task = RenderTask::DownCast(actor);
323 DALI_TEST_CHECK(!task);
328 int UtcDaliRenderTaskSetSourceActorN(void)
330 TestApplication application;
331 tet_infoline("Testing RenderTask::SetSourceActor() Negative - try with empty actor handle");
332 Integration::Scene stage = application.GetScene();
336 RenderTaskList taskList = stage.GetRenderTaskList();
337 RenderTask renderTask = taskList.CreateTask();
338 renderTask.SetSourceActor(srcActor);
340 application.SendNotification();
341 application.Render();
343 DALI_TEST_CHECK(!renderTask.GetSourceActor());
347 int UtcDaliRenderTaskSetSourceActorP01(void)
349 TestApplication application;
351 tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that setting a non-renderable actor stops existing source actor being rendered ");
353 Integration::Scene stage = application.GetScene();
354 RenderTaskList taskList = stage.GetRenderTaskList();
355 RenderTask task = taskList.GetTask(0u);
357 Actor actor = task.GetSourceActor();
358 DALI_TEST_CHECK(actor);
360 Texture img = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
361 Actor newActor = CreateRenderableActor(img);
362 newActor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
365 Actor nonRenderableActor = Actor::New();
366 stage.Add(nonRenderableActor);
368 // Stop the newActor from being rendered by changing the source actor
369 DALI_TEST_CHECK(nonRenderableActor);
370 task.SetSourceActor(nonRenderableActor);
371 DALI_TEST_CHECK(task.GetSourceActor() != actor);
372 DALI_TEST_CHECK(task.GetSourceActor() == nonRenderableActor);
374 TestGlAbstraction& gl = application.GetGlAbstraction();
375 TraceCallStack& drawTrace = gl.GetDrawTrace();
376 drawTrace.Enable(true);
378 // Update & Render nothing!
379 application.GetGlAbstraction().ClearBoundTextures();
380 application.SendNotification();
381 application.Render();
383 // Check that nothing was rendered
384 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
389 int UtcDaliRenderTaskSetSourceActorP02(void)
391 TestApplication application;
393 tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that switching source from a non-renderable to a renderable actor causes the texture to be drawn");
395 Integration::Scene stage = application.GetScene();
397 RenderTaskList taskList = stage.GetRenderTaskList();
399 RenderTask task = taskList.GetTask(0u);
401 Actor actor = task.GetSourceActor();
402 DALI_TEST_CHECK(actor);
404 Texture img = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
405 Actor newActor = CreateRenderableActor(img);
406 newActor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
409 Actor nonRenderableActor = Actor::New();
410 stage.Add(nonRenderableActor);
412 TestGlAbstraction& gl = application.GetGlAbstraction();
413 TraceCallStack& drawTrace = gl.GetDrawTrace();
414 drawTrace.Enable(true);
416 // Stop the newActor from being rendered by changing the source actor
417 DALI_TEST_CHECK(nonRenderableActor);
418 task.SetSourceActor(nonRenderableActor);
419 DALI_TEST_CHECK(task.GetSourceActor() != actor);
420 DALI_TEST_CHECK(task.GetSourceActor() == nonRenderableActor);
422 // Update & Render nothing!
423 application.GetGlAbstraction().ClearBoundTextures();
424 application.SendNotification();
425 application.Render();
427 // Check that nothing was rendered
428 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
431 // Set newActor as the new source Actor
432 task.SetSourceActor(newActor);
433 DALI_TEST_CHECK(task.GetSourceActor() != actor);
434 DALI_TEST_CHECK(task.GetSourceActor() == newActor);
436 // Update & Render the newActor
437 application.GetGlAbstraction().ClearBoundTextures();
438 application.SendNotification();
439 application.Render();
441 // Check that the newActor was rendered
442 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
446 int UtcDaliRenderTaskSetSourceActorOffScene(void)
448 TestApplication application;
450 tet_infoline("Testing RenderTask::SetSourceActor (on/off stage testing)");
452 Integration::Scene stage = application.GetScene();
453 RenderTaskList taskList = stage.GetRenderTaskList();
454 RenderTask task = taskList.GetTask(0u);
456 Actor actor = task.GetSourceActor();
457 DALI_TEST_CHECK(actor);
459 TestGlAbstraction& gl = application.GetGlAbstraction();
460 TraceCallStack& drawTrace = gl.GetDrawTrace();
461 drawTrace.Enable(true);
463 Texture img = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
464 Actor newActor = CreateRenderableActor(img);
465 newActor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
466 task.SetSourceActor(newActor);
467 // Don't add newActor to stage yet //'
469 // Update & Render with the actor initially off-stage
470 application.SendNotification();
471 application.Render();
473 // Check that nothing was rendered
474 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
479 // Update & Render with the actor on-stage
480 application.GetGlAbstraction().ClearBoundTextures();
481 application.SendNotification();
482 application.Render();
484 // Check that the newActor was rendered
485 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
488 // Now remove from stage
489 stage.Remove(newActor);
491 // Update & Render with the actor off-stage
492 application.SendNotification();
493 application.Render();
494 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
499 int UtcDaliRenderTaskSetSourceActorEmpty(void)
501 TestApplication application;
503 tet_infoline("Testing RenderTask::SetSourceActor (empty handle case)");
505 Integration::Scene stage = application.GetScene();
506 RenderTaskList taskList = stage.GetRenderTaskList();
507 RenderTask task = taskList.GetTask(0u);
509 Actor actor = task.GetSourceActor();
510 DALI_TEST_CHECK(actor);
512 Texture img = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
513 Actor newActor = CreateRenderableActor(img);
514 newActor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
517 Actor nonRenderableActor = Actor::New();
518 stage.Add(nonRenderableActor);
520 // Set with empty handle
521 task.SetSourceActor(Actor());
522 DALI_TEST_CHECK(!task.GetSourceActor());
524 TestGlAbstraction& gl = application.GetGlAbstraction();
525 TraceCallStack& drawTrace = gl.GetDrawTrace();
526 drawTrace.Enable(true);
528 // Update & Render nothing!
529 application.SendNotification();
530 application.Render();
532 // Check that nothing was rendered
533 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
535 // Set with non-empty handle
536 task.SetSourceActor(newActor);
537 DALI_TEST_CHECK(task.GetSourceActor() == newActor);
539 // Update & Render the newActor
540 application.GetGlAbstraction().ClearBoundTextures();
541 application.SendNotification();
542 application.Render();
544 // Check that the newActor was rendered
545 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
549 int UtcDaliRenderTaskSetSourceActorDestroyed(void)
551 TestApplication application;
553 tet_infoline("Testing RenderTask::SetSourceActor - Set a source actor and destroy the source actor");
555 Integration::Scene stage = application.GetScene();
556 RenderTaskList taskList = stage.GetRenderTaskList();
557 RenderTask task = taskList.GetTask(0u);
559 Actor actor = task.GetSourceActor();
560 DALI_TEST_CHECK(actor);
562 Texture img = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
564 Actor newActor = CreateRenderableActor(img);
565 newActor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
568 task.SetSourceActor(newActor);
570 DALI_TEST_CHECK(task.GetSourceActor() != actor);
571 DALI_TEST_CHECK(task.GetSourceActor() == newActor);
573 application.SendNotification();
574 application.Render();
576 // Destroy the source actor
577 stage.Remove(newActor);
580 DALI_TEST_CHECK(!task.GetSourceActor()); // The source actor should be an empty handle.
585 int UtcDaliRenderTaskGetSourceActorP01(void)
587 TestApplication application;
589 tet_infoline("Testing RenderTask::GetSourceActor() Check the default render task has a valid source actor");
591 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
593 RenderTask task = taskList.GetTask(0u);
595 Actor actor = task.GetSourceActor();
596 DALI_TEST_CHECK(actor);
598 // By default the entire scene should be rendered
599 Actor root = application.GetScene().GetLayer(0);
600 DALI_TEST_CHECK(root == actor);
604 int UtcDaliRenderTaskGetSourceActorP02(void)
606 TestApplication application;
608 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.");
610 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
611 RenderTask task = taskList.CreateTask();
612 Actor actor = Actor::New();
613 application.GetScene().Add(actor);
614 task.SetSourceActor(actor);
616 DALI_TEST_EQUALS(actor, task.GetSourceActor(), TEST_LOCATION);
621 int UtcDaliRenderTaskGetSourceActorN(void)
623 TestApplication application;
625 tet_infoline("Testing RenderTask::GetSourceActor() Try with empty handle");
630 Actor actor = task.GetSourceActor();
632 catch(Dali::DaliException& e)
634 DALI_TEST_PRINT_ASSERT(e);
635 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
641 int UtcDaliRenderTaskSetExclusive(void)
643 TestApplication application;
645 tet_infoline("Testing RenderTask::SetExclusive() Check that exclusion works");
647 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
649 // Manipulate the GenTextures behaviour, to identify different actors
651 std::vector<GLuint> ids;
652 ids.push_back(8); // 8 = actor1
653 ids.push_back(9); // 9 = actor2
654 ids.push_back(10); // 10 = actor3
655 application.GetGlAbstraction().SetNextTextureIds(ids);
657 Texture img1 = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
658 Actor actor1 = CreateRenderableActor(img1);
659 actor1.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
660 application.GetScene().Add(actor1);
662 // Update & Render actor1
663 application.SendNotification();
664 application.Render();
666 // Check that the actor1 was rendered
667 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures(GL_TEXTURE0);
668 DALI_TEST_GREATER(boundTextures.size(), static_cast<std::vector<GLuint>::size_type>(0), TEST_LOCATION);
670 if(boundTextures.size())
672 int a = boundTextures.size() - 1;
673 DALI_TEST_EQUALS(boundTextures[a], 8u /*unique to actor1*/, TEST_LOCATION);
676 Texture img2 = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
678 Actor actor2 = CreateRenderableActor(img2);
679 actor2.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
681 // Force actor2 to be rendered before actor1
682 Layer layer = Layer::New();
683 application.GetScene().Add(layer);
685 layer.LowerToBottom();
688 application.GetGlAbstraction().ClearBoundTextures();
689 application.SendNotification();
690 application.Render();
692 // Check that the actors were rendered
693 DALI_TEST_GREATER(boundTextures.size(), static_cast<std::vector<GLuint>::size_type>(1), TEST_LOCATION);
695 if(boundTextures.size() >= 2)
697 int a = boundTextures.size() - 2;
698 int b = boundTextures.size() - 1;
699 DALI_TEST_EQUALS(boundTextures[a], 9u /*unique to actor2*/, TEST_LOCATION);
700 DALI_TEST_EQUALS(boundTextures[b], 8u /*unique to actor1*/, TEST_LOCATION);
703 Texture img3 = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
704 Actor actor3 = CreateRenderableActor(img3);
705 actor3.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
707 // Force actor3 to be rendered before actor2
708 layer = Layer::New();
709 application.GetScene().Add(layer);
711 layer.LowerToBottom();
713 // Update & Render all actors
714 application.GetGlAbstraction().ClearBoundTextures();
715 application.SendNotification();
716 application.Render();
718 // Check that the actors were rendered
719 DALI_TEST_GREATER(boundTextures.size(), static_cast<std::vector<GLuint>::size_type>(2), TEST_LOCATION);
721 if(boundTextures.size() >= 3)
723 int a = boundTextures.size() - 3;
724 int b = boundTextures.size() - 2;
725 int c = boundTextures.size() - 1;
726 DALI_TEST_EQUALS(boundTextures[a], 10u /*unique to actor3*/, TEST_LOCATION);
727 DALI_TEST_EQUALS(boundTextures[b], 9u /*unique to actor2*/, TEST_LOCATION);
728 DALI_TEST_EQUALS(boundTextures[c], 8u /*unique to actor1*/, TEST_LOCATION);
731 // Both actors are now connected to the root node
732 // Setup 2 render-tasks - the first will render from the root-node, and the second from actor2
734 // Not exclusive is the default
735 RenderTask task1 = taskList.GetTask(0u);
736 DALI_TEST_CHECK(false == task1.IsExclusive());
738 RenderTask task2 = taskList.CreateTask();
739 DALI_TEST_CHECK(false == task2.IsExclusive());
740 task2.SetSourceActor(actor2);
742 // Task1 should render all actors, and task 2 should render only actor2
744 application.GetGlAbstraction().ClearBoundTextures();
745 application.SendNotification();
746 application.Render();
748 if(boundTextures.size() >= 4)
750 // Test that task 1 renders actor3, then actor2 & then actor1
751 int a = boundTextures.size() - 4;
752 int b = boundTextures.size() - 3;
753 int c = boundTextures.size() - 2;
754 int d = boundTextures.size() - 1;
755 DALI_TEST_EQUALS(boundTextures[a], 10u /*unique to actor3*/, TEST_LOCATION);
756 DALI_TEST_EQUALS(boundTextures[b], 9u /*unique to actor2*/, TEST_LOCATION);
757 DALI_TEST_EQUALS(boundTextures[c], 8u /*unique to actor1*/, TEST_LOCATION);
759 // Test that task 2 renders actor2
760 DALI_TEST_EQUALS(boundTextures[d], 9u, TEST_LOCATION);
763 // Make actor2 exclusive to task2
765 task2.SetExclusive(true);
766 DALI_TEST_CHECK(true == task2.IsExclusive());
768 // Task1 should render only actor1, and task 2 should render only actor2
770 application.GetGlAbstraction().ClearBoundTextures();
771 application.SendNotification();
772 application.Render();
774 DALI_TEST_EQUALS(boundTextures.size(), 3u, TEST_LOCATION);
775 if(boundTextures.size() == 3)
777 // Test that task 1 renders actor3 & actor1
778 DALI_TEST_CHECK(boundTextures[0] == 10u);
779 DALI_TEST_CHECK(boundTextures[1] == 8u);
781 // Test that task 2 renders actor2
782 DALI_TEST_CHECK(boundTextures[2] == 9u);
785 // Create a renderable actor and replace the source actor in task2
786 auto actor4 = CreateRenderableActor();
787 task2.SetSourceActor(actor3);
788 DALI_TEST_EQUALS(actor3, task2.GetSourceActor(), TEST_LOCATION);
793 int UtcDaliRenderTaskSetExclusive02(void)
795 TestApplication application;
797 tet_infoline("Testing RenderTask::SetExclusive() Check that changing from exclusive to not-exclusive works");
799 std::vector<GLuint> ids;
800 ids.push_back(8); // 8 = actor1
801 application.GetGlAbstraction().SetNextTextureIds(ids);
803 Texture img1 = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
804 Actor actor1 = CreateRenderableActor(img1);
805 actor1.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
806 application.GetScene().Add(actor1);
808 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
809 RenderTask task = taskList.CreateTask();
811 task.SetSourceActor(actor1);
812 task.SetExclusive(true); // Actor should only render once
814 TestGlAbstraction& gl = application.GetGlAbstraction();
815 TraceCallStack& drawTrace = gl.GetDrawTrace();
816 drawTrace.Enable(true);
818 // Update & Render actor1
819 application.SendNotification();
820 application.Render();
822 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
824 // Set task to non-exclusive - actor1 should render twice:
826 task.SetExclusive(false);
827 application.SendNotification();
828 application.Render();
830 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 2, TEST_LOCATION);
835 int UtcDaliRenderTaskSetExclusiveN(void)
837 TestApplication application;
839 tet_infoline("Testing RenderTask::SetExclusive() on empty handle");
844 task.SetExclusive(true);
846 catch(Dali::DaliException& e)
848 DALI_TEST_PRINT_ASSERT(e);
849 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
854 int UtcDaliRenderTaskIsExclusive01(void)
856 TestApplication application;
858 tet_infoline("Testing RenderTask::IsExclusive() Check default values are non-exclusive");
860 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
862 // Not exclusive is the default
863 RenderTask task = taskList.GetTask(0u);
864 DALI_TEST_CHECK(false == task.IsExclusive());
866 RenderTask newTask = taskList.CreateTask();
867 DALI_TEST_CHECK(false == newTask.IsExclusive());
872 int UtcDaliRenderTaskIsExclusive02(void)
874 TestApplication application;
876 tet_infoline("Testing RenderTask::IsExclusive() Check the getter returns set values");
878 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
880 // Not exclusive is the default
881 RenderTask newTask = taskList.CreateTask();
882 DALI_TEST_EQUALS(newTask.IsExclusive(), false, TEST_LOCATION);
884 newTask.SetExclusive(true);
885 DALI_TEST_EQUALS(newTask.IsExclusive(), true, TEST_LOCATION);
889 int UtcDaliRenderTaskIsExclusiveN(void)
891 TestApplication application;
893 tet_infoline("Testing RenderTask::IsExclusive() on empty handle");
898 bool x = task.IsExclusive();
901 catch(Dali::DaliException& e)
903 DALI_TEST_PRINT_ASSERT(e);
904 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
909 int UtcDaliRenderTaskSetInputEnabled(void)
911 TestApplication application;
913 tet_infoline("Testing RenderTask::SetInputEnabled()");
915 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
917 // Input is enabled by default
918 RenderTask task = taskList.GetTask(0u);
919 DALI_TEST_CHECK(true == task.GetInputEnabled());
921 task.SetInputEnabled(false);
922 DALI_TEST_CHECK(false == task.GetInputEnabled());
924 task.SetInputEnabled(true);
925 DALI_TEST_CHECK(true == task.GetInputEnabled());
929 int UtcDaliRenderTaskGetInputEnabled(void)
931 TestApplication application;
933 tet_infoline("Testing RenderTask::GetInputEnabled()");
935 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
937 // Input is enabled by default
938 RenderTask task = taskList.GetTask(0u);
939 DALI_TEST_EQUALS(true, task.GetInputEnabled(), TEST_LOCATION);
941 RenderTask newTask = taskList.CreateTask();
942 DALI_TEST_EQUALS(true, newTask.GetInputEnabled(), TEST_LOCATION);
944 newTask.SetInputEnabled(false);
945 DALI_TEST_EQUALS(false, newTask.GetInputEnabled(), TEST_LOCATION);
950 int UtcDaliRenderTaskSetCameraActorP(void)
952 TestApplication application;
954 tet_infoline("Testing RenderTask::SetCameraActor()");
956 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
958 RenderTask task = taskList.GetTask(0u);
960 Actor defaultCameraActor = task.GetCameraActor();
961 DALI_TEST_CHECK(defaultCameraActor);
963 CameraActor newCameraActor = CameraActor::New();
964 DALI_TEST_CHECK(newCameraActor);
966 task.SetCameraActor(newCameraActor);
967 DALI_TEST_CHECK(task.GetCameraActor() != defaultCameraActor);
968 DALI_TEST_EQUALS(task.GetCameraActor(), newCameraActor, TEST_LOCATION);
972 int UtcDaliRenderTaskSetCameraActorN(void)
974 TestApplication application;
976 tet_infoline("Testing RenderTask::SetCameraActor() with empty actor handle");
978 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
980 RenderTask task = taskList.GetTask(0u);
982 Actor actor = task.GetCameraActor();
983 DALI_TEST_CHECK(actor);
985 CameraActor cameraActor;
987 task.SetCameraActor(cameraActor);
988 DALI_TEST_EQUALS((bool)task.GetCameraActor(), false, TEST_LOCATION);
989 DALI_TEST_EQUALS(task.GetCameraActor(), cameraActor, TEST_LOCATION);
993 int UtcDaliRenderTaskSetCameraActorDestroyed(void)
995 TestApplication application;
997 tet_infoline("Testing RenderTask::SetCameraActor - Set a camera actor and destroy the camera actor");
999 Integration::Scene stage = application.GetScene();
1000 RenderTaskList taskList = stage.GetRenderTaskList();
1001 RenderTask task = taskList.GetTask(0u);
1003 CameraActor newCameraActor = CameraActor::New();
1004 task.SetCameraActor(newCameraActor);
1006 DALI_TEST_EQUALS(task.GetCameraActor(), newCameraActor, TEST_LOCATION);
1008 // Destroy the camera actor
1009 newCameraActor.Reset();
1011 CameraActor camera = task.GetCameraActor();
1012 DALI_TEST_CHECK(!camera); // The camera actor should be an empty handle.
1017 int UtcDaliRenderTaskGetCameraActorP(void)
1019 TestApplication application;
1021 tet_infoline("Testing RenderTask::GetCameraActor()");
1023 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1025 RenderTask task = taskList.GetTask(0u);
1027 CameraActor actor = task.GetCameraActor();
1028 DALI_TEST_CHECK(actor);
1029 DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION);
1030 DALI_TEST_GREATER(actor.GetFieldOfView(), 0.0f, TEST_LOCATION);
1034 int UtcDaliRenderTaskGetCameraActorN(void)
1036 TestApplication application;
1038 tet_infoline("Testing RenderTask::GetCameraActor() with empty handle");
1043 Actor actor = task.GetCameraActor();
1045 catch(Dali::DaliException& e)
1047 DALI_TEST_PRINT_ASSERT(e);
1048 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1054 int UtcDaliRenderTaskSetFrameBufferP(void)
1056 TestApplication application;
1058 tet_infoline("Testing RenderTask::SetFrameBuffer()");
1060 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1062 RenderTask task = taskList.GetTask(0u);
1064 FrameBuffer newFrameBuffer = FrameBuffer::New(128u, 128u, FrameBuffer::Attachment::NONE);
1065 task.SetFrameBuffer(newFrameBuffer);
1066 DALI_TEST_CHECK(task.GetFrameBuffer() == newFrameBuffer);
1070 int UtcDaliRenderTaskSetFrameBufferN(void)
1072 TestApplication application;
1074 tet_infoline("Testing RenderTask::SetFrameBuffer()");
1076 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1078 RenderTask task = taskList.GetTask(0u);
1079 FrameBuffer newFrameBuffer; // Empty handle
1080 task.SetFrameBuffer(newFrameBuffer);
1081 DALI_TEST_EQUALS((bool)task.GetFrameBuffer(), false, TEST_LOCATION);
1085 int UtcDaliRenderTaskGetFrameBufferP(void)
1087 TestApplication application;
1089 tet_infoline("Testing RenderTask::GetFrameBuffer()");
1091 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1093 RenderTask task = taskList.GetTask(0u);
1095 FrameBuffer newFrameBuffer = FrameBuffer::New(1u, 1u, FrameBuffer::Attachment::NONE);
1096 task.SetFrameBuffer(newFrameBuffer);
1097 DALI_TEST_CHECK(task.GetFrameBuffer() == newFrameBuffer);
1101 int UtcDaliRenderTaskGetFrameBufferN(void)
1103 TestApplication application;
1105 tet_infoline("Testing RenderTask::GetFrameBuffer()");
1107 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1109 RenderTask task = taskList.GetTask(0u);
1111 // By default render-tasks do not render off-screen
1112 FrameBuffer frameBuffer = task.GetFrameBuffer();
1113 DALI_TEST_CHECK(!frameBuffer);
1118 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionP(void)
1120 TestApplication application;
1122 tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1124 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1126 RenderTask task = taskList.GetTask(0u);
1128 task.SetScreenToFrameBufferFunction(TestScreenToFrameBufferFunction);
1130 Vector2 coordinates(5, 10);
1131 Vector2 convertedCoordinates(6, 12); // + Vector(1, 2)
1133 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1134 DALI_TEST_CHECK(func(coordinates));
1135 DALI_TEST_CHECK(coordinates == convertedCoordinates);
1137 task.SetScreenToFrameBufferFunction(RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION);
1138 func = task.GetScreenToFrameBufferFunction();
1139 DALI_TEST_CHECK(func(coordinates));
1141 task.SetScreenToFrameBufferFunction(RenderTask::DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION);
1142 func = task.GetScreenToFrameBufferFunction();
1143 DALI_TEST_CHECK(!func(coordinates));
1147 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionN(void)
1149 TestApplication application;
1151 tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1153 RenderTask task; // Empty handle
1156 task.SetScreenToFrameBufferFunction(TestScreenToFrameBufferFunction);
1158 catch(Dali::DaliException& e)
1160 DALI_TEST_PRINT_ASSERT(e);
1161 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1166 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionP(void)
1168 TestApplication application;
1170 tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction()");
1172 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1174 RenderTask task = taskList.GetTask(0u);
1176 Vector2 originalCoordinates(5, 10);
1177 Vector2 coordinates(5, 10);
1179 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1180 DALI_TEST_CHECK(!func(coordinates)); // conversion should fail by default
1181 DALI_TEST_CHECK(coordinates == originalCoordinates); // coordinates should not be modified
1185 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionN(void)
1187 TestApplication application;
1189 tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction() on empty handle");
1194 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1197 catch(Dali::DaliException& e)
1199 DALI_TEST_PRINT_ASSERT(e);
1200 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1205 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorP(void)
1207 TestApplication application;
1208 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor ");
1210 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1211 RenderTask renderTask = taskList.CreateTask();
1212 Actor mappingActor = Actor::New();
1213 renderTask.SetScreenToFrameBufferMappingActor(mappingActor);
1215 DALI_TEST_EQUALS(mappingActor, renderTask.GetScreenToFrameBufferMappingActor(), TEST_LOCATION);
1219 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorN(void)
1221 TestApplication application;
1222 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1228 task.SetScreenToFrameBufferMappingActor(mappingActor);
1230 catch(Dali::DaliException& e)
1232 DALI_TEST_PRINT_ASSERT(e);
1233 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1238 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActor02N(void)
1240 TestApplication application;
1241 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1243 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1244 RenderTask renderTask = taskList.CreateTask();
1246 renderTask.SetScreenToFrameBufferMappingActor(actor);
1248 DALI_TEST_EQUALS((bool)renderTask.GetScreenToFrameBufferMappingActor(), false, TEST_LOCATION);
1252 int UtcDaliRenderTaskGetViewportP01(void)
1254 TestApplication application;
1256 tet_infoline("Testing RenderTask::GetViewport() on default task");
1258 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1259 RenderTask task = taskList.GetTask(0u);
1260 Viewport viewport = task.GetViewport();
1262 // By default the viewport should match the stage width/height
1263 Vector2 stageSize = application.GetScene().GetSize();
1264 Viewport expectedViewport(0, 0, stageSize.width, stageSize.height);
1265 DALI_TEST_CHECK(viewport == expectedViewport);
1269 int UtcDaliRenderTaskGetViewportP02(void)
1271 TestApplication application;
1273 tet_infoline("Testing RenderTask::GetViewport() on new task");
1275 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1276 RenderTask task = taskList.CreateTask();
1277 Viewport viewport = task.GetViewport();
1279 // By default the viewport should match the stage width/height
1280 Vector2 stageSize = application.GetScene().GetSize();
1281 Viewport expectedViewport(0, 0, stageSize.width, stageSize.height);
1282 DALI_TEST_CHECK(viewport == expectedViewport);
1286 int UtcDaliRenderTaskGetViewportN(void)
1288 TestApplication application;
1290 tet_infoline("Testing RenderTask::GetViewport() on empty handle");
1295 Viewport viewport = task.GetViewport();
1298 catch(Dali::DaliException& e)
1300 DALI_TEST_PRINT_ASSERT(e);
1301 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1306 int UtcDaliRenderTaskSetViewportP(void)
1308 TestApplication application;
1310 tet_infoline("Testing RenderTask::SetViewport()");
1312 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1314 RenderTask task = taskList.GetTask(0u);
1315 Vector2 stageSize = application.GetScene().GetSize();
1316 Viewport newViewport(0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f);
1317 task.SetViewport(newViewport);
1319 // Update (viewport is a property)
1320 application.SendNotification();
1321 application.Render();
1323 DALI_TEST_CHECK(task.GetViewport() == newViewport);
1327 int UtcDaliRenderTaskSetViewportN(void)
1329 TestApplication application;
1331 tet_infoline("Testing RenderTask::SetViewport()");
1333 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1338 Vector2 stageSize = application.GetScene().GetSize();
1339 Viewport newViewport(0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f);
1340 task.SetViewport(newViewport);
1342 catch(Dali::DaliException& e)
1344 DALI_TEST_PRINT_ASSERT(e);
1345 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1351 int UtcDaliRenderTaskSetViewportPosition(void)
1353 TestApplication application;
1355 tet_infoline("Testing RenderTask::SetViewportPosition()");
1357 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1359 RenderTask task = taskList.GetTask(0u);
1361 Viewport viewport = task.GetViewport();
1363 // By default the viewport should match the stage width/height
1365 Vector2 stageSize = application.GetScene().GetSize();
1366 Viewport expectedViewport(0, 0, stageSize.width, stageSize.height);
1367 DALI_TEST_CHECK(viewport == expectedViewport);
1370 Vector2 newPosition(25.0f, 50.0f);
1371 task.SetViewportPosition(newPosition);
1373 // Update (viewport is a property)
1374 application.SendNotification();
1375 application.Render();
1377 DALI_TEST_EQUALS(task.GetCurrentViewportPosition(), newPosition, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1379 // Set by Property test
1380 Vector2 newPosition2(32.0f, 32.0f);
1381 task.SetProperty(RenderTask::Property::VIEWPORT_POSITION, newPosition2);
1382 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition2, TEST_LOCATION);
1383 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition, TEST_LOCATION); // still the old position
1386 application.SendNotification();
1387 application.Render();
1389 DALI_TEST_EQUALS(task.GetCurrentViewportPosition(), newPosition2, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1390 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition2, TEST_LOCATION);
1391 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition2, TEST_LOCATION);
1393 Vector2 newPosition3(64.0f, 0.0f);
1394 Animation animation = Animation::New(1.0f);
1395 animation.AnimateTo(Property(task, RenderTask::Property::VIEWPORT_POSITION), newPosition3, AlphaFunction::LINEAR);
1398 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1399 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition2, TEST_LOCATION);
1401 // Perform 1000ms worth of updates at which point animation should have completed.
1402 Wait(application, 1000);
1403 DALI_TEST_EQUALS(task.GetCurrentViewportPosition(), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1404 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1405 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1407 // Create another animation which animates by a certain value
1408 const Vector2 newPosition4(75.0f, 45.0f);
1409 const Vector2 relativePosition(newPosition4 - newPosition3);
1410 animation = Animation::New(1.0f);
1411 animation.AnimateBy(Property(task, RenderTask::Property::VIEWPORT_POSITION), relativePosition);
1414 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1415 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition3, TEST_LOCATION);
1417 // Perform 1000ms worth of updates at which point animation should have completed.
1418 Wait(application, 1000);
1419 DALI_TEST_EQUALS(task.GetCurrentViewportPosition(), newPosition4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1420 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1421 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1426 int UtcDaliRenderTaskSetViewportSize(void)
1428 TestApplication application;
1430 tet_infoline("Testing RenderTask::SetViewportSize()");
1432 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1434 RenderTask task = taskList.GetTask(0u);
1436 Viewport viewport = task.GetViewport();
1438 // By default the viewport should match the stage width/height
1440 Vector2 stageSize = application.GetScene().GetSize();
1441 Viewport expectedViewport(0, 0, stageSize.width, stageSize.height);
1442 DALI_TEST_CHECK(viewport == expectedViewport);
1444 Vector2 newSize(128.0f, 64.0f);
1445 task.SetViewportSize(newSize);
1447 // Update (viewport is a property)
1448 application.SendNotification();
1449 application.Render();
1451 DALI_TEST_EQUALS(task.GetCurrentViewportSize(), newSize, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1453 // Set by Property test
1454 Vector2 newSize2(50.0f, 50.0f);
1455 task.SetProperty(RenderTask::Property::VIEWPORT_SIZE, newSize2);
1456 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize2, TEST_LOCATION);
1457 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize, TEST_LOCATION); // still the old position
1460 application.SendNotification();
1461 application.Render();
1463 DALI_TEST_EQUALS(task.GetCurrentViewportSize(), newSize2, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1464 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize2, TEST_LOCATION);
1465 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize2, TEST_LOCATION);
1467 Vector2 newSize3(10.0f, 10.0f);
1468 Animation animation = Animation::New(1.0f);
1469 animation.AnimateTo(Property(task, RenderTask::Property::VIEWPORT_SIZE), newSize3, AlphaFunction::LINEAR);
1472 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1473 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize2, TEST_LOCATION);
1475 // Perform 1000ms worth of updates at which point animation should have completed.
1476 Wait(application, 1000);
1477 DALI_TEST_EQUALS(task.GetCurrentViewportSize(), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1478 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1479 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1481 // Create another animation which animates by a certain value
1482 const Vector2 newSize4(75.0f, 45.0f);
1483 const Vector2 relativeSize(newSize4 - newSize3);
1484 animation = Animation::New(1.0f);
1485 animation.AnimateBy(Property(task, RenderTask::Property::VIEWPORT_SIZE), relativeSize);
1488 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1489 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize3, TEST_LOCATION);
1491 // Perform 1000ms worth of updates at which point animation should have completed.
1492 Wait(application, 1000);
1493 DALI_TEST_EQUALS(task.GetCurrentViewportSize(), newSize4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1494 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1495 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1500 int UtcDaliRenderTaskSetClearColorP(void)
1502 TestApplication application;
1504 tet_infoline("Testing RenderTask::SetClearColor()");
1506 Vector4 testColor(1.0f, 2.0f, 3.0f, 4.0f);
1507 Vector4 testColor2(5.0f, 6.0f, 7.0f, 8.0f);
1509 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1511 RenderTask task = taskList.GetTask(0u);
1512 DALI_TEST_CHECK(task.GetClearColor() != testColor);
1514 task.SetClearColor(testColor);
1519 DALI_TEST_EQUALS(task.GetClearColor(), testColor, TEST_LOCATION);
1521 task.SetProperty(RenderTask::Property::CLEAR_COLOR, testColor2);
1522 DALI_TEST_EQUALS(task.GetProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), testColor2, TEST_LOCATION);
1523 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), testColor, TEST_LOCATION); // still the old color
1528 DALI_TEST_EQUALS(task.GetClearColor(), testColor2, TEST_LOCATION);
1529 DALI_TEST_EQUALS(task.GetProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), testColor2, TEST_LOCATION);
1530 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), testColor2, TEST_LOCATION);
1532 Vector4 newColor3(10.0f, 10.0f, 20.0f, 30.0f);
1533 Animation animation = Animation::New(1.0f);
1534 animation.AnimateTo(Property(task, RenderTask::Property::CLEAR_COLOR), newColor3, AlphaFunction::LINEAR);
1537 DALI_TEST_EQUALS(task.GetProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1538 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), testColor2, TEST_LOCATION);
1540 // Perform 1000ms worth of updates at which point animation should have completed.
1541 Wait(application, 1000);
1542 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1543 DALI_TEST_EQUALS(task.GetProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1545 // Create another animation which animates by a certain value
1546 const Vector4 newColor4(0.45f, 0.35f, 0.25f, 0.1f);
1547 const Vector4 relativeColor(newColor4 - newColor3);
1548 animation = Animation::New(1.0f);
1549 animation.AnimateBy(Property(task, RenderTask::Property::CLEAR_COLOR), relativeColor);
1552 DALI_TEST_EQUALS(task.GetProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor4, Math::MACHINE_EPSILON_10, TEST_LOCATION);
1553 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor3, Math::MACHINE_EPSILON_10, TEST_LOCATION);
1555 // Perform 1000ms worth of updates at which point animation should have completed.
1556 Wait(application, 1000);
1557 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor4, Math::MACHINE_EPSILON_10, TEST_LOCATION);
1558 DALI_TEST_EQUALS(task.GetProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor4, Math::MACHINE_EPSILON_10, TEST_LOCATION);
1563 int UtcDaliRenderTaskSetClearColorN(void)
1565 TestApplication application;
1567 tet_infoline("Testing RenderTask::SetClearColor() on empty handle");
1572 task.SetClearColor(Vector4::ZERO);
1574 catch(Dali::DaliException& e)
1576 DALI_TEST_PRINT_ASSERT(e);
1577 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1582 int UtcDaliRenderTaskGetClearColorP(void)
1584 TestApplication application;
1586 tet_infoline("Testing RenderTask::GetClearColor()");
1588 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1589 RenderTask task = taskList.GetTask(0u);
1590 DALI_TEST_EQUALS(task.GetClearColor(), RenderTask::DEFAULT_CLEAR_COLOR, TEST_LOCATION);
1594 int UtcDaliRenderTaskGetClearColorN(void)
1596 TestApplication application;
1598 tet_infoline("Testing RenderTask::GetClearColor()");
1603 Vector4 color = task.GetClearColor();
1606 catch(Dali::DaliException& e)
1608 DALI_TEST_PRINT_ASSERT(e);
1609 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1614 int UtcDaliRenderTaskSetClearEnabledP(void)
1616 TestApplication application;
1618 tet_infoline("Testing RenderTask::SetClearEnabled()");
1620 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1622 RenderTask task = taskList.GetTask(0u);
1623 DALI_TEST_CHECK(task.GetClearEnabled()); // defaults to true
1625 task.SetClearEnabled(false);
1626 DALI_TEST_EQUALS(task.GetClearEnabled(), false, TEST_LOCATION);
1628 task.SetClearEnabled(true);
1629 DALI_TEST_EQUALS(task.GetClearEnabled(), true, TEST_LOCATION);
1633 int UtcDaliRenderTaskSetClearEnabledN(void)
1635 TestApplication application;
1637 tet_infoline("Testing RenderTask::SetClearEnabled() with empty handle");
1642 task.SetClearEnabled(true);
1644 catch(Dali::DaliException& e)
1646 DALI_TEST_PRINT_ASSERT(e);
1647 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1652 int UtcDaliRenderTaskGetClearEnabledP(void)
1654 TestApplication application;
1656 tet_infoline("Testing RenderTask::GetClearEnabled()");
1658 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1660 RenderTask task = taskList.GetTask(0u);
1661 DALI_TEST_CHECK(task.GetClearEnabled()); // defaults to true
1665 int UtcDaliRenderTaskGetClearEnabledN(void)
1667 TestApplication application;
1669 tet_infoline("Testing RenderTask::GetClearEnabled() with empty handle");
1674 bool x = task.GetClearEnabled();
1677 catch(Dali::DaliException& e)
1679 DALI_TEST_PRINT_ASSERT(e);
1680 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1685 int UtcDaliRenderTaskSetCullModeP(void)
1687 TestApplication application;
1689 tet_infoline("Testing RenderTask::SetCullMode()");
1691 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1692 RenderTask task = taskList.GetTask(0u);
1693 DALI_TEST_EQUALS(task.GetCullMode(), true, TEST_LOCATION);
1695 task.SetCullMode(false);
1697 DALI_TEST_EQUALS(task.GetCullMode(), false, TEST_LOCATION);
1702 int UtcDaliRenderTaskSetCullModeN(void)
1704 TestApplication application;
1706 tet_infoline("Testing RenderTask::SetCullMode() on empty handle");
1711 task.SetCullMode(false);
1713 catch(Dali::DaliException& e)
1715 DALI_TEST_PRINT_ASSERT(e);
1716 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1721 int UtcDaliRenderTaskGetCullModeP(void)
1723 TestApplication application;
1725 tet_infoline("Testing RenderTask::GetCullMode()");
1727 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1728 RenderTask task = taskList.GetTask(0u);
1729 DALI_TEST_EQUALS(task.GetCullMode(), true, TEST_LOCATION);
1733 int UtcDaliRenderTaskGetCullModeN(void)
1735 TestApplication application;
1737 tet_infoline("Testing RenderTask::GetCullMode() with empty handle");
1742 bool x = task.GetCullMode();
1745 catch(Dali::DaliException& e)
1747 DALI_TEST_PRINT_ASSERT(e);
1748 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1753 int UtcDaliRenderTaskSetRefreshRate(void)
1755 TestApplication application;
1757 tet_infoline("Testing RenderTask::SetRefreshRate()");
1759 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1761 // By default tasks will be processed every frame
1762 RenderTask task = taskList.GetTask(0u);
1763 DALI_TEST_CHECK(RenderTask::REFRESH_ALWAYS == task.GetRefreshRate());
1765 task.SetRefreshRate(2u); // every-other frame
1766 DALI_TEST_CHECK(2u == task.GetRefreshRate());
1768 task.SetRefreshRate(RenderTask::REFRESH_ALWAYS);
1769 DALI_TEST_CHECK(RenderTask::REFRESH_ALWAYS == task.GetRefreshRate());
1773 int UtcDaliRenderTaskGetRefreshRate(void)
1775 TestApplication application;
1777 tet_infoline("Testing RenderTask::GetRefreshRate()");
1779 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1781 // By default tasks will be processed every frame
1782 RenderTask task = taskList.GetTask(0u);
1783 DALI_TEST_CHECK(RenderTask::REFRESH_ALWAYS == task.GetRefreshRate());
1785 RenderTask newTask = taskList.CreateTask();
1786 DALI_TEST_CHECK(RenderTask::REFRESH_ALWAYS == newTask.GetRefreshRate());
1790 int UtcDaliRenderTaskSignalFinished(void)
1792 TestApplication application;
1794 tet_infoline("Testing RenderTask::SignalFinished()");
1796 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1797 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
1799 CameraActor offscreenCameraActor = CameraActor::New();
1801 application.GetScene().Add(offscreenCameraActor);
1803 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 10, 10);
1804 Actor rootActor = CreateRenderableActor(image);
1805 rootActor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1806 application.GetScene().Add(rootActor);
1808 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1809 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
1810 Texture frameBufferTexture = Texture::New(*testNativeImagePtr);
1811 FrameBuffer frameBuffer = FrameBuffer::New(frameBufferTexture.GetWidth(), frameBufferTexture.GetHeight());
1812 frameBuffer.AttachColorTexture(frameBufferTexture);
1814 RenderTask newTask = taskList.CreateTask();
1815 newTask.SetCameraActor(offscreenCameraActor);
1816 newTask.SetSourceActor(rootActor);
1817 newTask.SetInputEnabled(false);
1818 newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
1819 newTask.SetClearEnabled(true);
1820 newTask.SetExclusive(true);
1821 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
1822 newTask.SetFrameBuffer(frameBuffer);
1823 newTask.SetProperty(RenderTask::Property::REQUIRES_SYNC, true);
1825 bool finished = false;
1826 RenderTaskFinished renderTaskFinished(finished);
1827 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
1829 // Flush the queue and render.
1830 application.SendNotification();
1832 // 1 render to process render task, then wait for sync before finished msg is sent
1833 // from update to the event thread.
1835 application.Render();
1836 application.SendNotification();
1837 DALI_TEST_CHECK(!finished);
1839 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
1840 DALI_TEST_CHECK(lastSyncObj != NULL);
1842 application.Render();
1843 DALI_TEST_EQUALS((Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION);
1844 application.SendNotification();
1845 DALI_TEST_CHECK(!finished);
1847 application.Render();
1848 DALI_TEST_EQUALS((Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION);
1849 application.SendNotification();
1850 DALI_TEST_CHECK(!finished);
1852 sync.SetObjectSynced(lastSyncObj, true);
1854 application.Render();
1855 application.SendNotification();
1856 DALI_TEST_CHECK(!finished);
1858 application.Render();
1859 application.SendNotification();
1860 DALI_TEST_CHECK(finished);
1862 DALI_TEST_EQUALS(application.GetUpdateStatus(), 0, TEST_LOCATION);
1866 int UtcDaliRenderTaskContinuous01(void)
1868 TestApplication application;
1870 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not staged)\nPOST:continuous renders, no Finished signal");
1872 // SETUP AN OFFSCREEN RENDER TASK
1873 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1874 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1875 drawTrace.Enable(true);
1877 Actor rootActor = Actor::New();
1878 application.GetScene().Add(rootActor);
1880 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
1881 application.GetScene().Add(offscreenCameraActor);
1883 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
1885 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1886 bool finished = false;
1887 RenderTaskFinished renderTaskFinished(finished);
1888 application.SendNotification();
1890 // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating
1891 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, false, __LINE__));
1892 application.GetPlatform().ClearReadyResources();
1894 // ADD SOURCE ACTOR TO STAGE - expect continuous renders to start, no finished signal
1895 application.GetScene().Add(secondRootActor);
1896 application.SendNotification();
1898 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1899 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
1903 int UtcDaliRenderTaskContinuous02(void)
1905 TestApplication application;
1907 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not visible)\nPOST:continuous renders, no Finished signal");
1909 // SETUP AN OFFSCREEN RENDER TASK
1910 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1911 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1912 drawTrace.Enable(true);
1914 Actor rootActor = Actor::New();
1915 application.GetScene().Add(rootActor);
1917 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
1918 application.GetScene().Add(offscreenCameraActor);
1920 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
1921 application.GetScene().Add(secondRootActor);
1922 secondRootActor.SetProperty(Actor::Property::VISIBLE, false);
1924 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1925 bool finished = false;
1926 RenderTaskFinished renderTaskFinished(finished);
1927 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
1928 application.SendNotification();
1930 // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating
1931 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, false, __LINE__));
1932 application.GetPlatform().ClearReadyResources();
1934 // MAKE SOURCE ACTOR VISIBLE - expect continuous renders to start, no finished signal
1935 secondRootActor.SetProperty(Actor::Property::VISIBLE, true);
1936 application.SendNotification();
1938 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1939 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
1943 int UtcDaliRenderTaskContinuous03(void)
1945 TestApplication application;
1947 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (camera actor not staged)\nPOST:continuous renders, no Finished signal");
1949 // SETUP AN OFFSCREEN RENDER TASK
1950 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1951 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1952 drawTrace.Enable(true);
1954 Actor rootActor = Actor::New();
1955 application.GetScene().Add(rootActor);
1957 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
1958 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
1959 application.GetScene().Add(secondRootActor);
1961 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1962 bool finished = false;
1963 RenderTaskFinished renderTaskFinished(finished);
1964 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
1965 application.SendNotification();
1967 // START PROCESS/RENDER Input, Expected Input, Expected
1968 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, false, __LINE__));
1969 application.GetPlatform().ClearReadyResources();
1971 // ADD CAMERA ACTOR TO STAGE - expect continuous renders to start, no finished signal
1972 application.GetScene().Add(offscreenCameraActor);
1973 application.SendNotification();
1975 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
1976 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
1980 int UtcDaliRenderTaskContinuous04(void)
1982 TestApplication application;
1984 tet_infoline("Testing RenderTask Render Continuous using loaded image");
1986 // SETUP AN OFFSCREEN RENDER TASK
1987 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1988 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1989 drawTrace.Enable(true);
1991 Actor rootActor = Actor::New();
1992 application.GetScene().Add(rootActor);
1994 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
1995 application.GetScene().Add(offscreenCameraActor);
1996 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
1997 application.GetScene().Add(secondRootActor);
1999 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2000 bool finished = false;
2001 RenderTaskFinished renderTaskFinished(finished);
2002 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2003 application.SendNotification();
2005 // START PROCESS/RENDER Input, Expected Input, Expected
2006 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2010 int UtcDaliRenderTaskOnce01(void)
2012 TestApplication application;
2014 tet_infoline("Testing RenderTask Render Once GlSync, using loaded image");
2016 // SETUP AN OFFSCREEN RENDER TASK
2017 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2018 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2019 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2020 drawTrace.Enable(true);
2022 Actor rootActor = Actor::New();
2023 application.GetScene().Add(rootActor);
2025 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2026 application.GetScene().Add(offscreenCameraActor);
2027 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2029 application.GetScene().Add(secondRootActor);
2031 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
2032 bool finished = false;
2033 RenderTaskFinished renderTaskFinished(finished);
2034 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2035 application.SendNotification();
2037 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2039 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2040 DALI_TEST_CHECK(lastSyncObj != NULL);
2041 sync.SetObjectSynced(lastSyncObj, true);
2043 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, true, __LINE__));
2044 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2048 int UtcDaliRenderTaskOnce02(void)
2050 TestApplication application;
2052 tet_infoline("Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loaded image.\n");
2054 // SETUP AN OFFSCREEN RENDER TASK
2055 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2056 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2057 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2058 drawTrace.Enable(true);
2060 Actor rootActor = Actor::New();
2061 application.GetScene().Add(rootActor);
2063 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2064 application.GetScene().Add(offscreenCameraActor);
2066 Shader shader = CreateShader();
2067 Texture image = CreateTexture();
2068 TextureSet textureSet = CreateTextureSet(image);
2070 Geometry geometry = CreateQuadGeometry();
2071 Renderer renderer = Renderer::New(geometry, shader);
2072 renderer.SetTextures(textureSet);
2073 Actor secondRootActor = Actor::New();
2074 secondRootActor.AddRenderer(renderer);
2075 secondRootActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2076 application.GetScene().Add(secondRootActor);
2078 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
2079 bool finished = false;
2080 RenderTaskFinished renderTaskFinished(finished);
2081 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2082 application.SendNotification();
2084 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2086 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2087 DALI_TEST_CHECK(lastSyncObj != NULL);
2088 sync.SetObjectSynced(lastSyncObj, true);
2090 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, true, __LINE__));
2091 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2096 int UtcDaliRenderTaskOnce03(void)
2098 TestApplication application;
2100 tet_infoline("Testing RenderTask Render Once GlSync, using loaded image. Switch from render always after ready to render once\n");
2102 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2103 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2104 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2105 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2106 drawTrace.Enable(true);
2108 Actor rootActor = Actor::New();
2109 application.GetScene().Add(rootActor);
2111 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2112 application.GetScene().Add(offscreenCameraActor);
2113 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2114 application.GetScene().Add(secondRootActor);
2116 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2117 bool finished = false;
2118 RenderTaskFinished renderTaskFinished(finished);
2119 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2120 application.SendNotification();
2122 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2124 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2125 application.SendNotification();
2127 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2129 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2130 DALI_TEST_CHECK(lastSyncObj != NULL);
2131 sync.SetObjectSynced(lastSyncObj, true);
2133 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, true, __LINE__));
2134 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2139 int UtcDaliRenderTaskOnce04(void)
2141 TestApplication application;
2143 "Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loaded image.\n"
2144 "Switch from render always after ready to render once\n");
2146 // SETUP AN OFFSCREEN RENDER TASK
2147 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2148 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2149 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2150 drawTrace.Enable(true);
2152 Actor rootActor = Actor::New();
2153 application.GetScene().Add(rootActor);
2155 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2156 application.GetScene().Add(offscreenCameraActor);
2158 Shader shader = CreateShader();
2159 Texture image = CreateTexture();
2160 TextureSet textureSet = CreateTextureSet(image);
2162 Geometry geometry = CreateQuadGeometry();
2163 Renderer renderer = Renderer::New(geometry, shader);
2164 renderer.SetTextures(textureSet);
2165 Actor secondRootActor = Actor::New();
2166 secondRootActor.AddRenderer(renderer);
2167 secondRootActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2168 application.GetScene().Add(secondRootActor);
2170 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2171 bool finished = false;
2172 RenderTaskFinished renderTaskFinished(finished);
2173 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2174 application.SendNotification();
2176 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2178 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2179 application.SendNotification();
2181 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2183 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2184 DALI_TEST_CHECK(lastSyncObj != NULL);
2185 sync.SetObjectSynced(lastSyncObj, true);
2187 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, true, __LINE__));
2188 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2193 int UtcDaliRenderTaskOnceNoSync01(void)
2195 TestApplication application;
2197 tet_infoline("Testing RenderTask Render Once, \nPRE: Resources ready\nPOST: Finished signal sent once only");
2199 // SETUP AN OFFSCREEN RENDER TASK
2200 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2201 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2202 drawTrace.Enable(true);
2204 Actor rootActor = Actor::New();
2205 application.GetScene().Add(rootActor);
2207 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2208 application.GetScene().Add(offscreenCameraActor);
2209 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2210 application.GetScene().Add(secondRootActor);
2212 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2213 bool finished = false;
2214 RenderTaskFinished renderTaskFinished(finished);
2215 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2216 application.SendNotification();
2218 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2219 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2223 int UtcDaliRenderTaskOnceNoSync02(void)
2225 TestApplication application;
2228 "Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loaded image.\n"
2229 "PRE: Resources ready\nPOST: Finished signal sent once only");
2230 // SETUP AN OFFSCREEN RENDER TASK
2231 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2232 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2233 drawTrace.Enable(true);
2235 Actor rootActor = Actor::New();
2236 application.GetScene().Add(rootActor);
2238 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2239 application.GetScene().Add(offscreenCameraActor);
2241 Shader shader = CreateShader();
2242 Texture image = CreateTexture();
2243 TextureSet textureSet = CreateTextureSet(image);
2245 Geometry geometry = CreateQuadGeometry();
2246 Renderer renderer = Renderer::New(geometry, shader);
2247 renderer.SetTextures(textureSet);
2248 Actor secondRootActor = Actor::New();
2249 secondRootActor.AddRenderer(renderer);
2250 secondRootActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2251 application.GetScene().Add(secondRootActor);
2253 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2254 bool finished = false;
2255 RenderTaskFinished renderTaskFinished(finished);
2256 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2257 application.SendNotification();
2259 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2260 application.GetPlatform().ClearReadyResources();
2261 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2266 int UtcDaliRenderTaskOnceNoSync03(void)
2268 TestApplication application;
2271 "Testing RenderTask Render Once, using loaded image. Switch from render always after ready to render once\n"
2272 "PRE: Render task ready, Image loaded\n"
2273 "POST: Finished signal sent only once");
2275 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2276 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2277 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2278 drawTrace.Enable(true);
2280 Actor rootActor = Actor::New();
2281 application.GetScene().Add(rootActor);
2283 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2284 application.GetScene().Add(offscreenCameraActor);
2285 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2286 application.GetScene().Add(secondRootActor);
2288 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2289 bool finished = false;
2290 RenderTaskFinished renderTaskFinished(finished);
2291 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2292 application.SendNotification();
2294 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2296 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2297 application.SendNotification(); // Input, Expected Input, Expected
2298 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2299 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2303 int UtcDaliRenderTaskOnceNoSync04(void)
2305 TestApplication application;
2308 "Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loading image.\n"
2309 "Switch from render always after ready to render once\n"
2310 "PRE: Render task ready, Image not loaded\n"
2311 "POST: Finished signal sent only once");
2313 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2314 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2315 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2316 drawTrace.Enable(true);
2318 Actor rootActor = Actor::New();
2319 application.GetScene().Add(rootActor);
2321 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2322 application.GetScene().Add(offscreenCameraActor);
2324 Shader shader = CreateShader();
2325 Texture image = CreateTexture();
2326 TextureSet textureSet = CreateTextureSet(image);
2328 Geometry geometry = CreateQuadGeometry();
2329 Renderer renderer = Renderer::New(geometry, shader);
2330 renderer.SetTextures(textureSet);
2331 Actor secondRootActor = Actor::New();
2332 secondRootActor.AddRenderer(renderer);
2333 secondRootActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2334 application.GetScene().Add(secondRootActor);
2336 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2337 bool finished = false;
2338 RenderTaskFinished renderTaskFinished(finished);
2339 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2340 application.SendNotification();
2342 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2343 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2344 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2345 DALI_TEST_CHECK(lastSyncObj == NULL);
2347 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2348 application.SendNotification(); // Input, Expected Input, Expected
2349 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2350 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2352 lastSyncObj = sync.GetLastSyncObject();
2353 DALI_TEST_CHECK(lastSyncObj == NULL);
2358 int UtcDaliRenderTaskOnceNoSync05(void)
2360 TestApplication application;
2363 "Testing RenderTask Render Once\n"
2364 "SetRefreshRate(ONCE), resource load failed, completes render task.\n"
2365 "PRE: resources failed to load\n"
2366 "POST: No finished signal sent.");
2368 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2369 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2370 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2371 drawTrace.Enable(true);
2373 Actor rootActor = Actor::New();
2374 application.GetScene().Add(rootActor);
2376 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2377 application.GetScene().Add(offscreenCameraActor);
2378 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2379 application.GetScene().Add(secondRootActor);
2381 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2382 bool finished = false;
2383 RenderTaskFinished renderTaskFinished(finished);
2384 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2385 application.SendNotification();
2387 // START PROCESS/RENDER Input, Expected Input, Expected
2388 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2390 // CHANGE TO RENDER ONCE,
2391 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2392 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2397 int UtcDaliRenderTaskOnceChain01(void)
2399 TestApplication application;
2402 "Testing RenderTask Render Once Chained render tasks\n"
2403 "SetRefreshRate(ONCE), resource load completes, both render tasks render.\n"
2404 "PRE: resources ready\n"
2405 "POST: 2 finished signals sent.");
2407 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2408 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2409 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2410 drawTrace.Enable(true);
2412 Actor defaultRootActor = Actor::New(); // Root for default RT
2413 application.GetScene().Add(defaultRootActor);
2415 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2416 application.GetScene().Add(offscreenCameraActor);
2417 Actor firstRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2418 application.GetScene().Add(firstRootActor);
2420 // first render task
2421 RenderTask firstTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, firstRootActor, RenderTask::REFRESH_ONCE, false);
2422 bool firstFinished = false;
2423 RenderTaskFinished renderTask1Finished(firstFinished);
2424 firstTask.FinishedSignal().Connect(&application, renderTask1Finished);
2426 // Second render task
2427 FrameBuffer fbo = firstTask.GetFrameBuffer();
2428 Actor secondRootActor = CreateRenderableActor(fbo.GetColorTexture());
2429 application.GetScene().Add(secondRootActor);
2430 RenderTask secondTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2431 bool secondFinished = false;
2432 RenderTaskFinished renderTask2Finished(secondFinished);
2433 secondTask.FinishedSignal().Connect(&application, renderTask2Finished);
2435 application.SendNotification();
2437 //Both render tasks are executed.
2438 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__));
2439 DALI_TEST_CHECK(firstFinished == false);
2440 DALI_TEST_CHECK(secondFinished == false);
2442 //Nothing else to render and both render task should have finished now
2443 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, firstFinished, true, false, __LINE__));
2444 DALI_TEST_CHECK(firstFinished == true);
2445 DALI_TEST_CHECK(secondFinished == true);
2450 int UtcDaliRenderTaskProperties(void)
2452 TestApplication application;
2454 RenderTask task = application.GetScene().GetRenderTaskList().CreateTask();
2456 Property::IndexContainer indices;
2457 task.GetPropertyIndices(indices);
2458 DALI_TEST_CHECK(indices.Size());
2459 DALI_TEST_EQUALS(indices.Size(), task.GetPropertyCount(), TEST_LOCATION);
2463 int UtcDaliRenderTaskFinishInvisibleSourceActor(void)
2465 TestApplication application;
2467 tet_infoline("Testing RenderTask::FinishInvisibleSourceActor()");
2469 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2470 TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2472 CameraActor offscreenCameraActor = CameraActor::New();
2474 application.GetScene().Add(offscreenCameraActor);
2476 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 10, 10);
2477 Actor rootActor = CreateRenderableActor(image);
2478 rootActor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
2479 rootActor.SetProperty(Actor::Property::VISIBLE, false);
2480 application.GetScene().Add(rootActor);
2482 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2483 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
2484 Texture frameBufferTexture = Texture::New(*testNativeImagePtr);
2485 FrameBuffer frameBuffer = FrameBuffer::New(frameBufferTexture.GetWidth(), frameBufferTexture.GetHeight());
2486 frameBuffer.AttachColorTexture(frameBufferTexture);
2488 // Flush all outstanding messages
2489 application.SendNotification();
2490 application.Render();
2492 RenderTask newTask = taskList.CreateTask();
2493 newTask.SetCameraActor(offscreenCameraActor);
2494 newTask.SetSourceActor(rootActor);
2495 newTask.SetInputEnabled(false);
2496 newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
2497 newTask.SetClearEnabled(true);
2498 newTask.SetExclusive(true);
2499 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2500 newTask.SetFrameBuffer(frameBuffer);
2501 newTask.SetProperty(RenderTask::Property::REQUIRES_SYNC, true);
2503 // Framebuffer doesn't actually get created until Connected, i.e. by previous line
2505 bool finished = false;
2506 RenderTaskFinished renderTaskFinished(finished);
2507 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2509 // Flush the queue and render.
2510 application.SendNotification();
2512 // 1 render to process render task, then wait for sync before finished msg is sent
2513 // from update to the event thread.
2515 application.Render();
2516 application.SendNotification();
2517 DALI_TEST_CHECK(!finished);
2519 Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2520 DALI_TEST_CHECK(lastSyncObj != NULL);
2522 application.Render();
2523 DALI_TEST_EQUALS((Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION);
2524 application.SendNotification();
2525 DALI_TEST_CHECK(!finished);
2527 application.Render();
2528 DALI_TEST_EQUALS((Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION);
2529 application.SendNotification();
2530 DALI_TEST_CHECK(!finished);
2532 sync.SetObjectSynced(lastSyncObj, true);
2534 application.Render();
2535 application.SendNotification();
2536 DALI_TEST_CHECK(!finished);
2538 application.Render();
2539 application.SendNotification();
2540 DALI_TEST_CHECK(finished);
2543 application.Render(); // Double check no more finished signal
2544 application.SendNotification();
2545 DALI_TEST_CHECK(!finished);
2550 int UtcDaliRenderTaskFinishMissingImage(void)
2552 TestApplication application;
2554 // Previously we had bugs where not having a resource ID would cause render-tasks to wait forever
2555 tet_infoline("Testing RenderTask::SignalFinished() when an Actor has no Image set");
2557 Integration::Scene stage = application.GetScene();
2559 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 10, 10);
2560 Actor rootActor = CreateRenderableActor(image);
2561 rootActor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
2562 stage.Add(rootActor);
2564 Actor actorWithMissingImage = CreateRenderableActor(Texture());
2565 actorWithMissingImage.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
2566 stage.Add(actorWithMissingImage);
2568 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2569 RenderTask newTask = taskList.CreateTask();
2570 newTask.SetInputEnabled(false);
2571 newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
2572 newTask.SetClearEnabled(true);
2573 newTask.SetExclusive(true);
2574 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2576 bool finished = false;
2577 RenderTaskFinished renderTaskFinished(finished);
2578 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2580 // 1 render to process render task, then 1 before finished msg is sent from update to the event thread.
2581 application.SendNotification();
2582 application.Render();
2583 application.Render();
2585 application.SendNotification();
2586 DALI_TEST_CHECK(finished);
2591 int UtcDaliRenderTaskWorldToViewport(void)
2593 TestApplication application(400u, 400u); // square surface
2595 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2597 Actor actor = Actor::New();
2598 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2599 actor.SetProperty(Actor::Property::POSITION, Vector3(0.0, 0.0, 0.0));
2601 actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.5, 0.5, 0.5));
2602 actor.SetProperty(Actor::Property::ANCHOR_POINT, Vector3(0.5, 0.5, 0.5));
2604 application.GetScene().Add(actor);
2606 application.SendNotification();
2607 application.Render();
2608 application.SendNotification();
2610 RenderTask task = taskList.GetTask(0u);
2612 CameraActor camera = task.GetCameraActor();
2614 Vector2 screenSize = task.GetCurrentViewportSize();
2616 float screenX = 0.0;
2617 float screenY = 0.0;
2619 bool ok = task.WorldToViewport(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), screenX, screenY);
2620 DALI_TEST_CHECK(ok == true);
2622 DALI_TEST_EQUALS(screenX, screenSize.x / 2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
2623 DALI_TEST_EQUALS(screenY, screenSize.y / 2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
2625 Actor actor2 = Actor::New();
2626 float actor2Size = 100.f;
2627 actor2.SetProperty(Actor::Property::SIZE, Vector2(actor2Size, actor2Size));
2628 actor2.SetProperty(Actor::Property::POSITION, Vector3(0.0, 0.0, 0.0));
2629 actor2.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.5, 0.5, 0.0));
2630 actor2.SetProperty(Actor::Property::ANCHOR_POINT, Vector3(0.5, 0.5, 0.0));
2631 application.GetScene().Add(actor2);
2633 actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0, 0, 0));
2635 application.SendNotification();
2636 application.Render();
2637 application.SendNotification();
2639 ok = task.WorldToViewport(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), screenX, screenY);
2640 DALI_TEST_CHECK(ok == true);
2642 DALI_TEST_EQUALS(screenX, screenSize.x / 2 - actor2Size / 2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
2643 DALI_TEST_EQUALS(screenY, screenSize.y / 2 - actor2Size / 2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
2648 int UtcDaliRenderTaskViewportToLocal(void)
2650 TestApplication application;
2651 Actor actor = Actor::New();
2652 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2653 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2654 actor.SetProperty(Actor::Property::POSITION, Vector2(10.0f, 10.0f));
2655 application.GetScene().Add(actor);
2657 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2658 RenderTask task = taskList.GetTask(0u);
2660 // flush the queue and render once
2661 application.SendNotification();
2662 application.Render();
2663 application.SendNotification();
2664 application.Render();
2672 float screenX = 50.0f;
2673 float screenY = 50.0f;
2675 DALI_TEST_CHECK(actor.ScreenToLocal(localX, localY, screenX, screenY));
2677 DALI_TEST_CHECK(task.ViewportToLocal(actor, screenX, screenY, rtLocalX, rtLocalY));
2679 DALI_TEST_EQUALS(localX, rtLocalX, 0.01f, TEST_LOCATION);
2680 DALI_TEST_EQUALS(localY, rtLocalY, 0.01f, TEST_LOCATION);
2685 int UtcDaliRenderTaskOffscreenViewportToLocal(void)
2687 TestApplication application;
2688 Actor actor = Actor::New();
2689 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2690 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2691 actor.SetProperty(Actor::Property::POSITION, Vector2(10.0f, 10.0f));
2692 application.GetScene().Add(actor);
2694 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2695 RenderTask task = taskList.CreateTask();
2697 FrameBuffer newFrameBuffer = FrameBuffer::New(10, 10);
2698 task.SetFrameBuffer(newFrameBuffer);
2699 task.SetSourceActor(actor);
2700 task.SetScreenToFrameBufferMappingActor(actor);
2702 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2703 application.GetScene().Add(offscreenCameraActor);
2704 task.SetCameraActor(offscreenCameraActor);
2706 // flush the queue and render once
2707 application.SendNotification();
2708 application.Render();
2709 application.SendNotification();
2710 application.Render();
2718 float screenX = 50.0f;
2719 float screenY = 50.0f;
2721 DALI_TEST_CHECK(actor.ScreenToLocal(localX, localY, screenX, screenY));
2723 DALI_TEST_CHECK(task.ViewportToLocal(actor, screenX, screenY, rtLocalX, rtLocalY));
2725 DALI_TEST_EQUALS(localX, rtLocalX, 0.01f, TEST_LOCATION);
2726 DALI_TEST_EQUALS(localY, rtLocalY, 0.01f, TEST_LOCATION);
2731 int UtcDaliRenderTaskRequiresSync(void)
2733 TestApplication application;
2734 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2736 RenderTask newTask = taskList.CreateTask();
2737 newTask.SetProperty(RenderTask::Property::REQUIRES_SYNC, false);
2739 DALI_TEST_EQUALS(newTask.GetProperty<bool>(RenderTask::Property::REQUIRES_SYNC), false, TEST_LOCATION);
2740 DALI_TEST_EQUALS(newTask.GetCurrentProperty<bool>(RenderTask::Property::REQUIRES_SYNC), false, TEST_LOCATION);
2742 newTask.SetProperty(RenderTask::Property::REQUIRES_SYNC, true);
2744 DALI_TEST_EQUALS(newTask.GetProperty<bool>(RenderTask::Property::REQUIRES_SYNC), true, TEST_LOCATION);
2745 DALI_TEST_EQUALS(newTask.GetCurrentProperty<bool>(RenderTask::Property::REQUIRES_SYNC), true, TEST_LOCATION);
2750 int UtcDaliRenderTaskSetClearEnabled(void)
2752 TestApplication application;
2754 tet_infoline("UtcDaliRenderTaskSetClearEnabled");
2756 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2757 TestGlAbstraction& gl = application.GetGlAbstraction();
2759 Actor renderableActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2760 application.GetScene().Add(renderableActor);
2762 Actor rootActor = Actor::New();
2763 application.GetScene().Add(rootActor);
2765 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2766 application.GetScene().Add(offscreenCameraActor);
2768 Actor sourceActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2769 application.GetScene().Add(sourceActor);
2771 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, sourceActor, RenderTask::REFRESH_ALWAYS, false);
2773 DALI_TEST_EQUALS(gl.GetClearCountCalled(), 0, TEST_LOCATION);
2775 application.SendNotification();
2776 application.Render();
2778 // glClear should be called twice - default task and the new task.
2779 DALI_TEST_EQUALS(gl.GetClearCountCalled(), 2, TEST_LOCATION);
2781 newTask.SetClearEnabled(false);
2783 application.SendNotification();
2784 application.Render();
2786 // The count should increase by 1 - default task only.
2787 DALI_TEST_EQUALS(gl.GetClearCountCalled(), 3, TEST_LOCATION);
2792 int UtcDaliRenderTaskMoveConstrctor(void)
2794 TestApplication application;
2796 Vector4 testColor(1.0f, 2.0f, 3.0f, 4.0f);
2798 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2799 RenderTask task = taskList.GetTask(0u);
2800 DALI_TEST_CHECK(task);
2801 DALI_TEST_EQUALS(2, task.GetBaseObject().ReferenceCount(), TEST_LOCATION);
2802 DALI_TEST_CHECK(task.GetClearColor() != testColor);
2804 task.SetClearColor(testColor);
2809 DALI_TEST_EQUALS(task.GetClearColor(), testColor, TEST_LOCATION);
2811 RenderTask move = std::move(task);
2812 DALI_TEST_CHECK(move);
2813 DALI_TEST_EQUALS(2, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
2814 DALI_TEST_EQUALS(move.GetClearColor(), testColor, TEST_LOCATION);
2815 DALI_TEST_CHECK(!task);
2820 int UtcDaliRenderTaskMoveAssignment(void)
2822 TestApplication application;
2824 Vector4 testColor(1.0f, 2.0f, 3.0f, 4.0f);
2826 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2827 RenderTask task = taskList.GetTask(0u);
2828 DALI_TEST_CHECK(task);
2829 DALI_TEST_EQUALS(2, task.GetBaseObject().ReferenceCount(), TEST_LOCATION);
2830 DALI_TEST_CHECK(task.GetClearColor() != testColor);
2832 task.SetClearColor(testColor);
2837 DALI_TEST_EQUALS(task.GetClearColor(), testColor, TEST_LOCATION);
2840 move = std::move(task);
2841 DALI_TEST_CHECK(move);
2842 DALI_TEST_EQUALS(2, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
2843 DALI_TEST_EQUALS(move.GetClearColor(), testColor, TEST_LOCATION);
2844 DALI_TEST_CHECK(!task);
2849 int UtcDaliRenderTaskSetCullModeNegative(void)
2851 TestApplication application;
2852 Dali::RenderTask instance;
2856 instance.SetCullMode(arg1);
2857 DALI_TEST_CHECK(false); // Should not get here
2861 DALI_TEST_CHECK(true); // We expect an assert
2866 int UtcDaliRenderTaskSetViewportNegative(void)
2868 TestApplication application;
2869 Dali::RenderTask instance;
2872 Dali::Rect<int> arg1;
2873 instance.SetViewport(arg1);
2874 DALI_TEST_CHECK(false); // Should not get here
2878 DALI_TEST_CHECK(true); // We expect an assert
2883 int UtcDaliRenderTaskSetExclusiveNegative(void)
2885 TestApplication application;
2886 Dali::RenderTask instance;
2890 instance.SetExclusive(arg1);
2891 DALI_TEST_CHECK(false); // Should not get here
2895 DALI_TEST_CHECK(true); // We expect an assert
2900 int UtcDaliRenderTaskSetClearColorNegative(void)
2902 TestApplication application;
2903 Dali::RenderTask instance;
2907 instance.SetClearColor(arg1);
2908 DALI_TEST_CHECK(false); // Should not get here
2912 DALI_TEST_CHECK(true); // We expect an assert
2917 int UtcDaliRenderTaskFinishedSignalNegative(void)
2919 TestApplication application;
2920 Dali::RenderTask instance;
2923 instance.FinishedSignal();
2924 DALI_TEST_CHECK(false); // Should not get here
2928 DALI_TEST_CHECK(true); // We expect an assert
2933 int UtcDaliRenderTaskSetCameraActorNegative(void)
2935 TestApplication application;
2936 Dali::RenderTask instance;
2939 Dali::CameraActor arg1;
2940 instance.SetCameraActor(arg1);
2941 DALI_TEST_CHECK(false); // Should not get here
2945 DALI_TEST_CHECK(true); // We expect an assert
2950 int UtcDaliRenderTaskSetFrameBufferNegative(void)
2952 TestApplication application;
2953 Dali::RenderTask instance;
2956 Dali::FrameBuffer arg1;
2957 instance.SetFrameBuffer(arg1);
2958 DALI_TEST_CHECK(false); // Should not get here
2962 DALI_TEST_CHECK(true); // We expect an assert
2967 int UtcDaliRenderTaskSetRefreshRateNegative(void)
2969 TestApplication application;
2970 Dali::RenderTask instance;
2973 unsigned int arg1(0u);
2974 instance.SetRefreshRate(arg1);
2975 DALI_TEST_CHECK(false); // Should not get here
2979 DALI_TEST_CHECK(true); // We expect an assert
2984 int UtcDaliRenderTaskSetSourceActorNegative(void)
2986 TestApplication application;
2987 Dali::RenderTask instance;
2991 instance.SetSourceActor(arg1);
2992 DALI_TEST_CHECK(false); // Should not get here
2996 DALI_TEST_CHECK(true); // We expect an assert
3001 int UtcDaliRenderTaskSetClearEnabledNegative(void)
3003 TestApplication application;
3004 Dali::RenderTask instance;
3008 instance.SetClearEnabled(arg1);
3009 DALI_TEST_CHECK(false); // Should not get here
3013 DALI_TEST_CHECK(true); // We expect an assert
3018 int UtcDaliRenderTaskSetInputEnabledNegative(void)
3020 TestApplication application;
3021 Dali::RenderTask instance;
3025 instance.SetInputEnabled(arg1);
3026 DALI_TEST_CHECK(false); // Should not get here
3030 DALI_TEST_CHECK(true); // We expect an assert
3035 int UtcDaliRenderTaskSetViewportSizeNegative(void)
3037 TestApplication application;
3038 Dali::RenderTask instance;
3042 instance.SetViewportSize(arg1);
3043 DALI_TEST_CHECK(false); // Should not get here
3047 DALI_TEST_CHECK(true); // We expect an assert
3052 int UtcDaliRenderTaskSetViewportPositionNegative(void)
3054 TestApplication application;
3055 Dali::RenderTask instance;
3059 instance.SetViewportPosition(arg1);
3060 DALI_TEST_CHECK(false); // Should not get here
3064 DALI_TEST_CHECK(true); // We expect an assert
3069 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionNegative(void)
3071 TestApplication application;
3072 Dali::RenderTask instance;
3075 RenderTask::ScreenToFrameBufferFunction arg1(nullptr);
3076 instance.SetScreenToFrameBufferFunction(arg1);
3077 DALI_TEST_CHECK(false); // Should not get here
3081 DALI_TEST_CHECK(true); // We expect an assert
3086 int UtcDaliRenderTaskSetScreenToFrameBufferMappingActorNegative(void)
3088 TestApplication application;
3089 Dali::RenderTask instance;
3093 instance.SetScreenToFrameBufferMappingActor(arg1);
3094 DALI_TEST_CHECK(false); // Should not get here
3098 DALI_TEST_CHECK(true); // We expect an assert
3103 int UtcDaliRenderTaskGetCullModeNegative(void)
3105 TestApplication application;
3106 Dali::RenderTask instance;
3109 instance.GetCullMode();
3110 DALI_TEST_CHECK(false); // Should not get here
3114 DALI_TEST_CHECK(true); // We expect an assert
3119 int UtcDaliRenderTaskGetViewportNegative(void)
3121 TestApplication application;
3122 Dali::RenderTask instance;
3125 instance.GetViewport();
3126 DALI_TEST_CHECK(false); // Should not get here
3130 DALI_TEST_CHECK(true); // We expect an assert
3135 int UtcDaliRenderTaskIsExclusiveNegative(void)
3137 TestApplication application;
3138 Dali::RenderTask instance;
3141 instance.IsExclusive();
3142 DALI_TEST_CHECK(false); // Should not get here
3146 DALI_TEST_CHECK(true); // We expect an assert
3151 int UtcDaliRenderTaskGetClearColorNegative(void)
3153 TestApplication application;
3154 Dali::RenderTask instance;
3157 instance.GetClearColor();
3158 DALI_TEST_CHECK(false); // Should not get here
3162 DALI_TEST_CHECK(true); // We expect an assert
3167 int UtcDaliRenderTaskGetCameraActorNegative(void)
3169 TestApplication application;
3170 Dali::RenderTask instance;
3173 instance.GetCameraActor();
3174 DALI_TEST_CHECK(false); // Should not get here
3178 DALI_TEST_CHECK(true); // We expect an assert
3183 int UtcDaliRenderTaskGetFrameBufferNegative(void)
3185 TestApplication application;
3186 Dali::RenderTask instance;
3189 instance.GetFrameBuffer();
3190 DALI_TEST_CHECK(false); // Should not get here
3194 DALI_TEST_CHECK(true); // We expect an assert
3199 int UtcDaliRenderTaskGetRefreshRateNegative(void)
3201 TestApplication application;
3202 Dali::RenderTask instance;
3205 instance.GetRefreshRate();
3206 DALI_TEST_CHECK(false); // Should not get here
3210 DALI_TEST_CHECK(true); // We expect an assert
3215 int UtcDaliRenderTaskGetSourceActorNegative(void)
3217 TestApplication application;
3218 Dali::RenderTask instance;
3221 instance.GetSourceActor();
3222 DALI_TEST_CHECK(false); // Should not get here
3226 DALI_TEST_CHECK(true); // We expect an assert
3231 int UtcDaliRenderTaskGetClearEnabledNegative(void)
3233 TestApplication application;
3234 Dali::RenderTask instance;
3237 instance.GetClearEnabled();
3238 DALI_TEST_CHECK(false); // Should not get here
3242 DALI_TEST_CHECK(true); // We expect an assert
3247 int UtcDaliRenderTaskGetInputEnabledNegative(void)
3249 TestApplication application;
3250 Dali::RenderTask instance;
3253 instance.GetInputEnabled();
3254 DALI_TEST_CHECK(false); // Should not get here
3258 DALI_TEST_CHECK(true); // We expect an assert
3263 int UtcDaliRenderTaskViewportToLocalNegative(void)
3265 TestApplication application;
3266 Dali::RenderTask instance;
3269 Dali::Actor arg1(Actor::New());
3274 instance.ViewportToLocal(arg1, arg2, arg3, arg4, arg5);
3275 DALI_TEST_CHECK(false); // Should not get here
3279 DALI_TEST_CHECK(true); // We expect an assert
3284 int UtcDaliRenderTaskWorldToViewportNegative(void)
3286 TestApplication application;
3287 Dali::RenderTask instance;
3293 instance.WorldToViewport(arg1, arg2, arg3);
3294 DALI_TEST_CHECK(false); // Should not get here
3298 DALI_TEST_CHECK(true); // We expect an assert
3303 int UtcDaliRenderTaskGetCurrentViewportSizeNegative(void)
3305 TestApplication application;
3306 Dali::RenderTask instance;
3309 instance.GetCurrentViewportSize();
3310 DALI_TEST_CHECK(false); // Should not get here
3314 DALI_TEST_CHECK(true); // We expect an assert
3319 int UtcDaliRenderTaskGetCurrentViewportPositionNegative(void)
3321 TestApplication application;
3322 Dali::RenderTask instance;
3325 instance.GetCurrentViewportPosition();
3326 DALI_TEST_CHECK(false); // Should not get here
3330 DALI_TEST_CHECK(true); // We expect an assert
3335 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionNegative(void)
3337 TestApplication application;
3338 Dali::RenderTask instance;
3341 instance.GetScreenToFrameBufferFunction();
3342 DALI_TEST_CHECK(false); // Should not get here
3346 DALI_TEST_CHECK(true); // We expect an assert
3351 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorNegative(void)
3353 TestApplication application;
3354 Dali::RenderTask instance;
3357 instance.GetScreenToFrameBufferMappingActor();
3358 DALI_TEST_CHECK(false); // Should not get here
3362 DALI_TEST_CHECK(true); // We expect an assert
3367 int UtcDaliRenderTaskClippingMode01(void)
3369 TestApplication application;
3371 tet_infoline("Testing clipping mode: CLIP_TO_BOUNDING_BOX.\n");
3373 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3374 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3375 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
3377 enabledDisableTrace.Enable(true);
3378 scissorTrace.Enable(true);
3380 // SETUP AN OFFSCREEN RENDER TASK
3381 Actor rootActor = Actor::New();
3382 application.GetScene().Add(rootActor);
3384 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
3385 offscreenCameraActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3386 offscreenCameraActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3387 application.GetScene().Add(offscreenCameraActor);
3389 Shader shader = CreateShader();
3390 Texture image = CreateTexture();
3391 TextureSet textureSet = CreateTextureSet(image);
3393 Geometry geometry = CreateQuadGeometry();
3394 Renderer renderer = Renderer::New(geometry, shader);
3395 renderer.SetTextures(textureSet);
3397 Vector2 position(100.0f, 100.0f);
3398 Vector2 size(200.0f, 200.0f);
3399 Actor secondRootActor = Actor::New();
3400 secondRootActor.AddRenderer(renderer);
3401 secondRootActor.SetProperty(Actor::Property::POSITION, position);
3402 secondRootActor.SetProperty(Actor::Property::SIZE, size);
3403 secondRootActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3404 secondRootActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3405 secondRootActor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
3406 application.GetScene().Add(secondRootActor);
3408 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
3410 application.SendNotification();
3411 application.Render();
3413 std::ostringstream scissor;
3414 scissor << std::hex << GL_SCISSOR_TEST;
3415 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
3417 // Check the scissor was set, and the coordinates are correct.
3418 Vector4 expectResults(position.x, TestApplication::DEFAULT_SURFACE_HEIGHT - size.height - position.y, size.width, size.height); // (100, 500, 200, 200)
3419 std::stringstream compareParametersString;
3420 compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
3421 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with the expected result
3426 int UtcDaliRenderTaskClippingMode02(void)
3428 TestApplication application;
3430 tet_infoline("Testing clipping mode with the inverted camera: CLIP_TO_BOUNDING_BOX.\n");
3432 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3433 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3434 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
3436 enabledDisableTrace.Enable(true);
3437 scissorTrace.Enable(true);
3439 // SETUP AN OFFSCREEN RENDER TASK
3440 Actor rootActor = Actor::New();
3441 application.GetScene().Add(rootActor);
3443 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
3444 offscreenCameraActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3445 offscreenCameraActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3446 offscreenCameraActor.SetInvertYAxis(true);
3447 application.GetScene().Add(offscreenCameraActor);
3449 Shader shader = CreateShader();
3450 Texture image = CreateTexture();
3451 TextureSet textureSet = CreateTextureSet(image);
3453 Geometry geometry = CreateQuadGeometry();
3454 Renderer renderer = Renderer::New(geometry, shader);
3455 renderer.SetTextures(textureSet);
3457 Vector2 position(100.0f, 100.0f);
3458 Vector2 size(200.0f, 200.0f);
3459 Actor secondRootActor = Actor::New();
3460 secondRootActor.AddRenderer(renderer);
3461 secondRootActor.SetProperty(Actor::Property::POSITION, position);
3462 secondRootActor.SetProperty(Actor::Property::SIZE, size);
3463 secondRootActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3464 secondRootActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3465 secondRootActor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
3466 application.GetScene().Add(secondRootActor);
3468 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
3470 application.SendNotification();
3471 application.Render();
3473 std::ostringstream scissor;
3474 scissor << std::hex << GL_SCISSOR_TEST;
3475 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
3477 // Check the scissor was set, and the coordinates are correct.
3478 Vector4 expectResults(position.x, position.y, size.width, size.height); // (100, 100, 200, 200)
3479 std::stringstream compareParametersString;
3480 compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
3481 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with the expected result