2 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <dali-test-suite-utils.h>
19 #include <dali/devel-api/events/hit-test-algorithm.h>
20 #include <dali/integration-api/debug.h>
21 #include <dali/public-api/dali-core.h>
22 #include <mesh-builder.h>
24 #include <test-actor-utils.h>
25 #include <test-native-image.h>
29 #define BOOLSTR(x) ((x) ? "T" : "F")
31 //& set: DaliRenderTask
35 void utc_dali_render_task_startup(void)
37 test_return_value = TET_UNDEF;
40 void utc_dali_render_task_cleanup(void)
42 test_return_value = TET_PASS;
48 * Constructor, Destructor, DownCast, New, copy constructor, assignment operator
50 * SetSourceActor 2+ve, 1-ve
51 * GetSourceActor 1+ve, 1-ve
52 * SetExclusive 2+ve, 0-ve
53 * IsExclusive 2+ve, 0-ve
54 * SetInputEnabled 1+ve, 0-ve
55 * GetInputEnabled 1+ve, 0-ve
56 * SetCameraActor 1+ve, 1-ve
57 * GetCameraActor 1+ve, 1-ve
58 * SetTargetFrameBuffer 1+ve, 1-ve
59 * GetTargetFrameBuffer 1+ve, 1-ve
60 * SetScreenToFrameBufferFunction 1+ve, 1-ve
61 * GetScreenToFrameBufferFunction 1+ve, 1-ve
62 * SetScreenToFrameBufferMappingActor 1+ve, 1-ve
63 * GetScreenToFrameBufferMappingActor 1+ve, 1-ve
64 * SetViewportPosition 1+ve
65 * GetCurrentViewportPosition 1+ve
66 * SetViewportSize 1+ve
67 * GetCurrentViewportSize 1+ve
68 * SetViewport 2+ve, 1-ve
69 * GetViewport 2+ve, 1-ve
70 * SetClearColor 1+ve, 1-ve
71 * GetClearColor 1+ve, 1-ve
72 * SetClearEnabled 1+ve, 1-ve
73 * GetClearEnabled 1+ve, 1-ve
81 namespace // unnamed namespace
83 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
86 const std::string_view SHADER_COLOR_TEST_SHADER_VERT1{
87 R"(INPUT mediump vec2 aPosition;
88 uniform highp mat4 uMvpMatrix;
89 uniform highp vec3 uSize;
91 //Visual size and offset
92 uniform mediump vec2 offset;
93 uniform highp vec2 size;
94 uniform mediump vec4 offsetSizeMode;
95 uniform mediump vec2 origin;
96 uniform mediump vec2 anchorPoint;
97 uniform mediump vec2 extraSize;
99 vec4 ComputeVertexPosition()
101 vec2 visualSize = mix(size * uSize.xy, size, offsetSizeMode.zw ) + extraSize;
102 vec2 visualOffset = mix(offset * uSize.xy, offset, offsetSizeMode.xy);
103 mediump vec2 vPosition = aPosition * visualSize;
104 return vec4(vPosition + anchorPoint * visualSize + visualOffset + origin * uSize.xy, 0.0, 1.0);
109 gl_Position = uMvpMatrix * ComputeVertexPosition();
114 const std::string_view SHADER_COLOR_TEST_SHADER_VERT2{
115 R"(INPUT mediump vec2 aPosition;
116 uniform highp mat4 uMvpMatrix;
117 uniform highp vec3 uSize;
119 //Visual size and offset
120 uniform mediump vec2 offset;
121 uniform highp vec2 size;
122 uniform mediump vec4 offsetSizeMode;
123 uniform mediump vec2 origin;
124 uniform mediump vec2 anchorPoint;
125 uniform mediump vec2 extraSize;
127 vec4 ComputeVertexPosition2()
129 vec2 visualSize = mix(size * uSize.xy, size, offsetSizeMode.zw ) + extraSize;
130 vec2 visualOffset = mix(offset * uSize.xy, offset, offsetSizeMode.xy);
131 mediump vec2 vPosition = aPosition * visualSize;
132 return vec4(vPosition + anchorPoint * visualSize + visualOffset + origin * uSize.xy, 0.0, 1.0);
137 gl_Position = uMvpMatrix * ComputeVertexPosition2();
141 const std::string_view SHADER_COLOR_TEST_SHADER_FRAG{
145 OUT_COLOR = vec4(0.0, 0.0, 1.0, 1.0);
150 * Simulate time passed by.
152 * @note this will always process at least 1 frame (1/60 sec)
154 * @param application Test application instance
155 * @param duration Time to pass in milliseconds.
156 * @return The actual time passed in milliseconds
158 int Wait(TestApplication& application, int duration = 0)
162 for(int i = 0; i <= (duration / RENDER_FRAME_INTERVAL); i++)
164 application.SendNotification();
165 application.Render(RENDER_FRAME_INTERVAL);
166 time += RENDER_FRAME_INTERVAL;
172 struct RenderTaskFinished
174 RenderTaskFinished(bool& finished)
179 void operator()(RenderTask& renderTask)
187 struct RenderTaskFinishedRemoveSource
189 RenderTaskFinishedRemoveSource(bool& finished)
190 : finished(finished),
195 void operator()(RenderTask& renderTask)
197 DALI_TEST_CHECK(finishedOnce == false);
200 Actor srcActor = renderTask.GetSourceActor();
201 UnparentAndReset(srcActor);
208 struct RenderTaskFinishedRenderAgain
210 RenderTaskFinishedRenderAgain(bool& finished)
211 : finished(finished),
216 void operator()(RenderTask& renderTask)
218 DALI_TEST_CHECK(finishedOnce == false);
221 renderTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
228 bool TestScreenToFrameBufferFunction(Vector2& coordinates)
230 coordinates = coordinates + Vector2(1, 2);
235 Actor CreateRenderableActorSuccess(TestApplication& application, std::string filename)
237 Actor actor = CreateRenderableActor();
238 actor.SetProperty(Actor::Property::SIZE, Vector2(80.0f, 80.0f));
242 Texture CreateTexture(void)
244 return Dali::CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 80, 80);
247 RenderTask CreateRenderTask(TestApplication& application,
248 CameraActor offscreenCamera,
249 Actor rootActor, // Reset default render task to point at this actor
250 Actor secondRootActor, // Source actor
251 unsigned int refreshRate,
253 uint32_t frameBufferWidth = 10,
254 uint32_t frameBufferHeight = 10)
256 // Change main render task to use a different root
257 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
258 taskList.GetTask(0u).SetSourceActor(rootActor);
260 FrameBuffer frameBuffer = FrameBuffer::New(frameBufferWidth, frameBufferHeight);
263 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(frameBufferWidth, frameBufferHeight);
264 Texture texture = Texture::New(*testNativeImagePtr);
265 frameBuffer.AttachColorTexture(texture);
268 // Don't draw output framebuffer // '
270 RenderTask newTask = taskList.CreateTask();
271 newTask.SetCameraActor(offscreenCamera);
272 newTask.SetSourceActor(secondRootActor);
273 newTask.SetInputEnabled(false);
274 newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
275 newTask.SetClearEnabled(true);
276 newTask.SetExclusive(true);
277 newTask.SetRefreshRate(refreshRate);
278 newTask.SetFrameBuffer(frameBuffer);
279 newTask.SetProperty(RenderTask::Property::REQUIRES_SYNC, glSync);
283 bool UpdateRender(TestApplication& application, TraceCallStack& callStack, bool testDrawn, bool& finishedSig, bool testFinished, bool testKeepUpdating, int lineNumber)
288 tet_printf("TestApplication::UpdateRender().\n");
290 application.Render(16);
291 application.SendNotification();
293 bool sigPassed = false;
296 sigPassed = finishedSig;
300 sigPassed = !finishedSig;
303 bool drawResult = callStack.FindMethod("DrawElements") || callStack.FindMethod("DrawArrays");
305 bool drawPassed = false;
308 drawPassed = drawResult;
312 drawPassed = !drawResult;
315 bool keepUpdating = (application.GetUpdateStatus() != 0);
316 bool keepUpdatingPassed = false;
319 keepUpdatingPassed = keepUpdating;
323 keepUpdatingPassed = !keepUpdating;
326 bool result = (sigPassed && drawPassed && keepUpdatingPassed);
328 tet_printf("UpdateRender: Expected: Draw:%s Signal:%s KeepUpdating: %s Actual: Draw:%s Signal:%s KeepUpdating: %s %s, line %d\n",
330 BOOLSTR(testFinished),
331 BOOLSTR(testKeepUpdating),
333 BOOLSTR(finishedSig),
334 BOOLSTR(keepUpdating),
335 result ? "Passed" : "Failed",
341 } // unnamed namespace
343 /****************************************************************************************************/
344 /****************************************************************************************************/
345 /******************************** TEST CASES BELOW **********************************************/
346 /****************************************************************************************************/
347 /****************************************************************************************************/
349 int UtcDaliRenderTaskDownCast01(void)
351 TestApplication application;
353 tet_infoline("Testing RenderTask::DownCast()");
355 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
357 BaseHandle base = taskList.GetTask(0u);
358 DALI_TEST_CHECK(base);
360 RenderTask task = RenderTask::DownCast(base);
361 DALI_TEST_CHECK(task);
363 // Try calling a method
364 DALI_TEST_CHECK(task.GetSourceActor());
368 int UtcDaliRenderTaskDownCast02(void)
370 TestApplication application;
372 tet_infoline("Testing RenderTask::DownCast()");
374 Actor actor = Actor::New();
376 RenderTask task = RenderTask::DownCast(actor);
377 DALI_TEST_CHECK(!task);
382 int UtcDaliRenderTaskSetSourceActorN(void)
384 TestApplication application;
385 tet_infoline("Testing RenderTask::SetSourceActor() Negative - try with empty actor handle");
386 Integration::Scene stage = application.GetScene();
390 RenderTaskList taskList = stage.GetRenderTaskList();
391 RenderTask renderTask = taskList.CreateTask();
392 renderTask.SetSourceActor(srcActor);
394 application.SendNotification();
395 application.Render();
397 DALI_TEST_CHECK(!renderTask.GetSourceActor());
401 int UtcDaliRenderTaskSetSourceActorP01(void)
403 TestApplication application;
405 tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that setting a non-renderable actor stops existing source actor being rendered ");
407 Integration::Scene stage = application.GetScene();
408 RenderTaskList taskList = stage.GetRenderTaskList();
409 RenderTask task = taskList.GetTask(0u);
411 Actor actor = task.GetSourceActor();
412 DALI_TEST_CHECK(actor);
414 Texture img = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
415 Actor newActor = CreateRenderableActor(img);
416 newActor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
419 Actor nonRenderableActor = Actor::New();
420 stage.Add(nonRenderableActor);
422 // Stop the newActor from being rendered by changing the source actor
423 DALI_TEST_CHECK(nonRenderableActor);
424 task.SetSourceActor(nonRenderableActor);
425 DALI_TEST_CHECK(task.GetSourceActor() != actor);
426 DALI_TEST_CHECK(task.GetSourceActor() == nonRenderableActor);
428 TestGlAbstraction& gl = application.GetGlAbstraction();
429 TraceCallStack& drawTrace = gl.GetDrawTrace();
430 drawTrace.Enable(true);
432 // Update & Render nothing!
433 application.GetGlAbstraction().ClearBoundTextures();
434 application.SendNotification();
435 application.Render();
437 // Check that nothing was rendered
438 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
443 int UtcDaliRenderTaskSetSourceActorP02(void)
445 TestApplication application;
447 tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that switching source from a non-renderable to a renderable actor causes the texture to be drawn");
449 Integration::Scene stage = application.GetScene();
451 RenderTaskList taskList = stage.GetRenderTaskList();
453 RenderTask task = taskList.GetTask(0u);
455 Actor actor = task.GetSourceActor();
456 DALI_TEST_CHECK(actor);
458 Texture img = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
459 Actor newActor = CreateRenderableActor(img);
460 newActor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
463 Actor nonRenderableActor = Actor::New();
464 stage.Add(nonRenderableActor);
466 TestGlAbstraction& gl = application.GetGlAbstraction();
467 TraceCallStack& drawTrace = gl.GetDrawTrace();
468 drawTrace.Enable(true);
470 // Stop the newActor from being rendered by changing the source actor
471 DALI_TEST_CHECK(nonRenderableActor);
472 task.SetSourceActor(nonRenderableActor);
473 DALI_TEST_CHECK(task.GetSourceActor() != actor);
474 DALI_TEST_CHECK(task.GetSourceActor() == nonRenderableActor);
476 // Update & Render nothing!
477 application.GetGlAbstraction().ClearBoundTextures();
478 application.SendNotification();
479 application.Render();
481 // Check that nothing was rendered
482 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
485 // Set newActor as the new source Actor
486 task.SetSourceActor(newActor);
487 DALI_TEST_CHECK(task.GetSourceActor() != actor);
488 DALI_TEST_CHECK(task.GetSourceActor() == newActor);
490 // Update & Render the newActor
491 application.GetGlAbstraction().ClearBoundTextures();
492 application.SendNotification();
493 application.Render();
495 // Check that the newActor was rendered
496 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
500 int UtcDaliRenderTaskSetSourceActorOffScene(void)
502 TestApplication application;
504 tet_infoline("Testing RenderTask::SetSourceActor (on/off stage testing)");
506 Integration::Scene stage = application.GetScene();
507 RenderTaskList taskList = stage.GetRenderTaskList();
508 RenderTask task = taskList.GetTask(0u);
510 Actor actor = task.GetSourceActor();
511 DALI_TEST_CHECK(actor);
513 TestGlAbstraction& gl = application.GetGlAbstraction();
514 TraceCallStack& drawTrace = gl.GetDrawTrace();
515 drawTrace.Enable(true);
517 Texture img = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
518 Actor newActor = CreateRenderableActor(img);
519 newActor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
520 task.SetSourceActor(newActor);
521 // Don't add newActor to stage yet //'
523 // Update & Render with the actor initially off-stage
524 application.SendNotification();
525 application.Render();
527 // Check that nothing was rendered
528 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
533 // Update & Render with the actor on-stage
534 application.GetGlAbstraction().ClearBoundTextures();
535 application.SendNotification();
536 application.Render();
538 // Check that the newActor was rendered
539 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
542 // Now remove from stage
543 stage.Remove(newActor);
545 // Update & Render with the actor off-stage
546 application.SendNotification();
547 application.Render();
548 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
553 int UtcDaliRenderTaskSetSourceActorEmpty(void)
555 TestApplication application;
557 tet_infoline("Testing RenderTask::SetSourceActor (empty handle case)");
559 Integration::Scene stage = application.GetScene();
560 RenderTaskList taskList = stage.GetRenderTaskList();
561 RenderTask task = taskList.GetTask(0u);
563 Actor actor = task.GetSourceActor();
564 DALI_TEST_CHECK(actor);
566 Texture img = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
567 Actor newActor = CreateRenderableActor(img);
568 newActor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
571 Actor nonRenderableActor = Actor::New();
572 stage.Add(nonRenderableActor);
574 // Set with empty handle
575 task.SetSourceActor(Actor());
576 DALI_TEST_CHECK(!task.GetSourceActor());
578 TestGlAbstraction& gl = application.GetGlAbstraction();
579 TraceCallStack& drawTrace = gl.GetDrawTrace();
580 drawTrace.Enable(true);
582 // Update & Render nothing!
583 application.SendNotification();
584 application.Render();
586 // Check that nothing was rendered
587 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
589 // Set with non-empty handle
590 task.SetSourceActor(newActor);
591 DALI_TEST_CHECK(task.GetSourceActor() == newActor);
593 // Update & Render the newActor
594 application.GetGlAbstraction().ClearBoundTextures();
595 application.SendNotification();
596 application.Render();
598 // Check that the newActor was rendered
599 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
603 int UtcDaliRenderTaskSetSourceActorDestroyed(void)
605 TestApplication application;
607 tet_infoline("Testing RenderTask::SetSourceActor - Set a source actor and destroy the source actor");
609 Integration::Scene stage = application.GetScene();
610 RenderTaskList taskList = stage.GetRenderTaskList();
611 RenderTask task = taskList.GetTask(0u);
613 Actor actor = task.GetSourceActor();
614 DALI_TEST_CHECK(actor);
616 Texture img = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
618 Actor newActor = CreateRenderableActor(img);
619 newActor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
622 task.SetSourceActor(newActor);
624 DALI_TEST_CHECK(task.GetSourceActor() != actor);
625 DALI_TEST_CHECK(task.GetSourceActor() == newActor);
627 application.SendNotification();
628 application.Render();
630 // Destroy the source actor
631 stage.Remove(newActor);
634 DALI_TEST_CHECK(!task.GetSourceActor()); // The source actor should be an empty handle.
639 int UtcDaliRenderTaskGetSourceActorP01(void)
641 TestApplication application;
643 tet_infoline("Testing RenderTask::GetSourceActor() Check the default render task has a valid source actor");
645 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
647 RenderTask task = taskList.GetTask(0u);
649 Actor actor = task.GetSourceActor();
650 DALI_TEST_CHECK(actor);
652 // By default the entire scene should be rendered
653 Actor root = application.GetScene().GetLayer(0);
654 DALI_TEST_CHECK(root == actor);
658 int UtcDaliRenderTaskGetSourceActorP02(void)
660 TestApplication application;
662 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.");
664 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
665 RenderTask task = taskList.CreateTask();
666 Actor actor = Actor::New();
667 application.GetScene().Add(actor);
668 task.SetSourceActor(actor);
670 DALI_TEST_EQUALS(actor, task.GetSourceActor(), TEST_LOCATION);
675 int UtcDaliRenderTaskGetSourceActorN(void)
677 TestApplication application;
679 tet_infoline("Testing RenderTask::GetSourceActor() Try with empty handle");
684 Actor actor = task.GetSourceActor();
686 catch(Dali::DaliException& e)
688 DALI_TEST_PRINT_ASSERT(e);
689 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
695 int UtcDaliRenderTaskGetStopperActorP(void)
697 TestApplication application;
699 tet_infoline("Testing RenderTask::GetStopperActor() Create a new render task, Add a new actor to the stage and set RenderTask::RenderUntil(actor). Get its stopper actor and check it is equivalent to what was set.");
701 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
702 RenderTask task = taskList.CreateTask();
703 Actor actor = Actor::New();
704 application.GetScene().Add(actor);
705 task.RenderUntil(actor);
707 DALI_TEST_EQUALS(actor, task.GetStopperActor(), TEST_LOCATION);
712 int UtcDaliRenderTaskGetStopperActorN(void)
714 TestApplication application;
716 tet_infoline("Testing RenderTask::GetStopperActor() Try with empty handle");
722 Actor actor = task.GetStopperActor();
724 catch(Dali::DaliException& e)
726 DALI_TEST_PRINT_ASSERT(e);
727 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
733 int UtcDaliRenderTaskRenderUntil(void)
735 TestApplication application;
736 tet_infoline("Testing RenderTask::RenderUntil(actor) Check that rendering stops at the actor.");
738 // Make a new render task and compose a tree.
739 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
740 RenderTask task = taskList.GetTask(0u);
742 Integration::Scene stage = application.GetScene();
745 for(int i = 0; i < 5; i++)
747 Actor parent = CreateRenderableActor();
748 parent.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
749 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
750 Actor child = CreateRenderableActor();
751 child.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
761 task.RenderUntil(secondChild);
763 // Update & Render with the actor on-stage
764 TestGlAbstraction& gl = application.GetGlAbstraction();
765 TraceCallStack& drawTrace = gl.GetDrawTrace();
766 drawTrace.Enable(true);
769 application.SendNotification();
770 application.Render();
772 // Check that rendering was cut.
773 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 3, TEST_LOCATION);
778 int UtcDaliRenderTaskSetExclusive(void)
780 TestApplication application;
782 tet_infoline("Testing RenderTask::SetExclusive() Check that exclusion works");
784 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
788 // Actor1 Layer Layer
791 // Task 1 is the default render task, should render from Root, incl Actor2
792 // Task 2 uses Actor2 as a source actor (texture id 9)
794 // Manipulate the GenTextures behaviour, to identify different actors
796 std::vector<GLuint> ids;
797 ids.push_back(8); // 8 = actor1
798 ids.push_back(9); // 9 = actor2
799 ids.push_back(10); // 10 = actor3
800 application.GetGlAbstraction().SetNextTextureIds(ids);
802 Texture img1 = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
803 Actor actor1 = CreateRenderableActor(img1);
804 actor1.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
805 application.GetScene().Add(actor1);
807 // Update & Render actor1
808 application.SendNotification();
809 application.Render();
811 // Check that the actor1 was rendered
812 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures(GL_TEXTURE0);
813 DALI_TEST_GREATER(boundTextures.size(), static_cast<std::vector<GLuint>::size_type>(0), TEST_LOCATION);
815 if(boundTextures.size())
817 int a = boundTextures.size() - 1;
818 DALI_TEST_EQUALS(boundTextures[a], 8u /*unique to actor1*/, TEST_LOCATION);
821 Texture img2 = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
823 Actor actor2 = CreateRenderableActor(img2);
824 actor2.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
826 // Force actor2 to be rendered before actor1
827 Layer layer = Layer::New();
828 application.GetScene().Add(layer);
830 layer.LowerToBottom();
833 application.GetGlAbstraction().ClearBoundTextures();
834 application.SendNotification();
835 application.Render();
837 // Check that the actors were rendered
838 DALI_TEST_GREATER(boundTextures.size(), static_cast<std::vector<GLuint>::size_type>(1), TEST_LOCATION);
840 if(boundTextures.size() >= 2)
842 int a = boundTextures.size() - 2;
843 int b = boundTextures.size() - 1;
844 DALI_TEST_EQUALS(boundTextures[a], 9u /*unique to actor2*/, TEST_LOCATION);
845 DALI_TEST_EQUALS(boundTextures[b], 8u /*unique to actor1*/, TEST_LOCATION);
848 Texture img3 = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
849 Actor actor3 = CreateRenderableActor(img3);
850 actor3.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
852 // Force actor3 to be rendered before actor2
853 layer = Layer::New();
854 application.GetScene().Add(layer);
856 layer.LowerToBottom();
858 // Update & Render all actors
859 application.GetGlAbstraction().ClearBoundTextures();
860 application.SendNotification();
861 application.Render();
863 // Check that the actors were rendered
864 DALI_TEST_GREATER(boundTextures.size(), static_cast<std::vector<GLuint>::size_type>(2), TEST_LOCATION);
866 if(boundTextures.size() >= 3)
868 int a = boundTextures.size() - 3;
869 int b = boundTextures.size() - 2;
870 int c = boundTextures.size() - 1;
871 DALI_TEST_EQUALS(boundTextures[a], 10u /*unique to actor3*/, TEST_LOCATION);
872 DALI_TEST_EQUALS(boundTextures[b], 9u /*unique to actor2*/, TEST_LOCATION);
873 DALI_TEST_EQUALS(boundTextures[c], 8u /*unique to actor1*/, TEST_LOCATION);
876 // Both actors are now connected to the root node
877 // Setup 2 render-tasks - the first will render from the root-node, and the second from actor2
879 // Not exclusive is the default
880 RenderTask task1 = taskList.GetTask(0u);
881 DALI_TEST_CHECK(false == task1.IsExclusive());
883 RenderTask task2 = taskList.CreateTask();
884 DALI_TEST_CHECK(false == task2.IsExclusive());
885 task2.SetSourceActor(actor2);
887 // Task1 should render all actors, and task 2 should render only actor2
889 application.GetGlAbstraction().ClearBoundTextures();
890 application.SendNotification();
891 application.Render();
893 if(boundTextures.size() >= 4)
895 // Test that task 1 renders actor3, then actor2 & then actor1
896 int a = boundTextures.size() - 4;
897 int b = boundTextures.size() - 3;
898 int c = boundTextures.size() - 2;
899 int d = boundTextures.size() - 1;
900 DALI_TEST_EQUALS(boundTextures[a], 10u /*unique to actor3*/, TEST_LOCATION);
901 DALI_TEST_EQUALS(boundTextures[b], 9u /*unique to actor2*/, TEST_LOCATION);
902 DALI_TEST_EQUALS(boundTextures[c], 8u /*unique to actor1*/, TEST_LOCATION);
904 // Test that task 2 renders actor2
905 DALI_TEST_EQUALS(boundTextures[d], 9u, TEST_LOCATION);
908 // Make actor2 exclusive to task2
910 task2.SetExclusive(true);
911 DALI_TEST_CHECK(true == task2.IsExclusive());
913 // Task1 should render only actor1, and task 2 should render only actor2
915 application.GetGlAbstraction().ClearBoundTextures();
916 application.SendNotification();
917 application.Render();
919 DALI_TEST_EQUALS(boundTextures.size(), 3u, TEST_LOCATION);
920 if(boundTextures.size() == 3)
922 // Test that task 1 renders actor3 & actor1
923 DALI_TEST_CHECK(boundTextures[0] == 10u);
924 DALI_TEST_CHECK(boundTextures[1] == 8u);
926 // Test that task 2 renders actor2
927 DALI_TEST_CHECK(boundTextures[2] == 9u);
930 // Create a renderable actor and replace the source actor in task2
931 auto actor4 = CreateRenderableActor();
932 task2.SetSourceActor(actor3);
933 DALI_TEST_EQUALS(actor3, task2.GetSourceActor(), TEST_LOCATION);
938 int UtcDaliRenderTaskSetExclusive02(void)
940 TestApplication application;
942 tet_infoline("Testing RenderTask::SetExclusive() Check that changing from exclusive to not-exclusive works");
944 std::vector<GLuint> ids;
945 ids.push_back(8); // 8 = actor1
946 application.GetGlAbstraction().SetNextTextureIds(ids);
948 Texture img1 = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
949 Actor actor1 = CreateRenderableActor(img1);
950 actor1.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
951 application.GetScene().Add(actor1);
953 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
954 RenderTask task = taskList.CreateTask();
956 task.SetSourceActor(actor1);
957 task.SetExclusive(true); // Actor should only render once
959 TestGlAbstraction& gl = application.GetGlAbstraction();
960 TraceCallStack& drawTrace = gl.GetDrawTrace();
961 drawTrace.Enable(true);
963 // Update & Render actor1
964 application.SendNotification();
965 application.Render();
967 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
969 // Set task to non-exclusive - actor1 should render twice:
971 task.SetExclusive(false);
972 application.SendNotification();
973 application.Render();
975 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 2, TEST_LOCATION);
980 int UtcDaliRenderTaskSetExclusive03(void)
982 TestApplication application;
984 tet_infoline("Testing RenderTask::SetExclusive() Check that changing from exclusive to not-exclusive works");
986 std::vector<GLuint> ids;
987 ids.push_back(8); // 8 = actor1
988 application.GetGlAbstraction().SetNextTextureIds(ids);
990 Texture img1 = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
991 Actor actor1 = CreateRenderableActor(img1);
992 actor1.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
993 application.GetScene().Add(actor1);
995 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
996 RenderTask task = taskList.CreateTask();
998 task.SetSourceActor(actor1);
999 task.SetExclusive(true); // Actor should only render once
1001 TestGlAbstraction& gl = application.GetGlAbstraction();
1002 TraceCallStack& drawTrace = gl.GetDrawTrace();
1003 drawTrace.Enable(true);
1005 // Update & Render actor1
1006 application.SendNotification();
1007 application.Render();
1009 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
1011 // Set task to non-exclusive - actor1 should render twice:
1014 RenderTask task2 = taskList.CreateTask();
1015 task2.SetSourceActor(actor1);
1016 task2.SetExclusive(true); // Actor should only render once
1018 application.SendNotification();
1019 application.Render();
1021 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 2, TEST_LOCATION);
1023 // Set task to non-exclusive - actor1 should render twice:
1025 task.SetExclusive(false);
1026 application.SendNotification();
1027 application.Render();
1029 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
1031 // Set task to non-exclusive - actor1 should render twice:
1033 task2.SetExclusive(false);
1034 application.SendNotification();
1035 application.Render();
1037 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 3, TEST_LOCATION);
1042 int UtcDaliRenderTaskSetExclusiveN(void)
1044 TestApplication application;
1046 tet_infoline("Testing RenderTask::SetExclusive() on empty handle");
1051 task.SetExclusive(true);
1053 catch(Dali::DaliException& e)
1055 DALI_TEST_PRINT_ASSERT(e);
1056 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1061 int UtcDaliRenderTaskIsExclusive01(void)
1063 TestApplication application;
1065 tet_infoline("Testing RenderTask::IsExclusive() Check default values are non-exclusive");
1067 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1069 // Not exclusive is the default
1070 RenderTask task = taskList.GetTask(0u);
1071 DALI_TEST_CHECK(false == task.IsExclusive());
1073 RenderTask newTask = taskList.CreateTask();
1074 DALI_TEST_CHECK(false == newTask.IsExclusive());
1079 int UtcDaliRenderTaskIsExclusive02(void)
1081 TestApplication application;
1083 tet_infoline("Testing RenderTask::IsExclusive() Check the getter returns set values");
1085 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1087 // Not exclusive is the default
1088 RenderTask newTask = taskList.CreateTask();
1089 DALI_TEST_EQUALS(newTask.IsExclusive(), false, TEST_LOCATION);
1091 newTask.SetExclusive(true);
1092 DALI_TEST_EQUALS(newTask.IsExclusive(), true, TEST_LOCATION);
1096 int UtcDaliRenderTaskIsExclusiveN(void)
1098 TestApplication application;
1100 tet_infoline("Testing RenderTask::IsExclusive() on empty handle");
1105 bool x = task.IsExclusive();
1108 catch(Dali::DaliException& e)
1110 DALI_TEST_PRINT_ASSERT(e);
1111 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1116 int UtcDaliRenderTaskSetInputEnabled(void)
1118 TestApplication application;
1120 tet_infoline("Testing RenderTask::SetInputEnabled()");
1122 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1124 // Input is enabled by default
1125 RenderTask task = taskList.GetTask(0u);
1126 DALI_TEST_CHECK(true == task.GetInputEnabled());
1128 task.SetInputEnabled(false);
1129 DALI_TEST_CHECK(false == task.GetInputEnabled());
1131 task.SetInputEnabled(true);
1132 DALI_TEST_CHECK(true == task.GetInputEnabled());
1136 int UtcDaliRenderTaskGetInputEnabled(void)
1138 TestApplication application;
1140 tet_infoline("Testing RenderTask::GetInputEnabled()");
1142 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1144 // Input is enabled by default
1145 RenderTask task = taskList.GetTask(0u);
1146 DALI_TEST_EQUALS(true, task.GetInputEnabled(), TEST_LOCATION);
1148 RenderTask newTask = taskList.CreateTask();
1149 DALI_TEST_EQUALS(true, newTask.GetInputEnabled(), TEST_LOCATION);
1151 newTask.SetInputEnabled(false);
1152 DALI_TEST_EQUALS(false, newTask.GetInputEnabled(), TEST_LOCATION);
1157 int UtcDaliRenderTaskSetCameraActorP(void)
1159 TestApplication application;
1161 tet_infoline("Testing RenderTask::SetCameraActor()");
1163 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1165 RenderTask task = taskList.GetTask(0u);
1167 Actor defaultCameraActor = task.GetCameraActor();
1168 DALI_TEST_CHECK(defaultCameraActor);
1170 CameraActor newCameraActor = CameraActor::New();
1171 DALI_TEST_CHECK(newCameraActor);
1173 task.SetCameraActor(newCameraActor);
1174 DALI_TEST_CHECK(task.GetCameraActor() != defaultCameraActor);
1175 DALI_TEST_EQUALS(task.GetCameraActor(), newCameraActor, TEST_LOCATION);
1179 int UtcDaliRenderTaskSetCameraActorN(void)
1181 TestApplication application;
1183 tet_infoline("Testing RenderTask::SetCameraActor() with empty actor handle");
1185 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1187 RenderTask task = taskList.GetTask(0u);
1189 Actor actor = task.GetCameraActor();
1190 DALI_TEST_CHECK(actor);
1192 CameraActor cameraActor;
1194 task.SetCameraActor(cameraActor);
1195 DALI_TEST_EQUALS((bool)task.GetCameraActor(), false, TEST_LOCATION);
1196 DALI_TEST_EQUALS(task.GetCameraActor(), cameraActor, TEST_LOCATION);
1200 int UtcDaliRenderTaskSetCameraActorDestroyed(void)
1202 TestApplication application;
1204 tet_infoline("Testing RenderTask::SetCameraActor - Set a camera actor and destroy the camera actor");
1206 Integration::Scene stage = application.GetScene();
1207 RenderTaskList taskList = stage.GetRenderTaskList();
1208 RenderTask task = taskList.GetTask(0u);
1210 CameraActor newCameraActor = CameraActor::New();
1211 task.SetCameraActor(newCameraActor);
1213 DALI_TEST_EQUALS(task.GetCameraActor(), newCameraActor, TEST_LOCATION);
1215 // Destroy the camera actor
1216 newCameraActor.Reset();
1218 CameraActor camera = task.GetCameraActor();
1219 DALI_TEST_CHECK(!camera); // The camera actor should be an empty handle.
1224 int UtcDaliRenderTaskGetCameraActorP(void)
1226 TestApplication application;
1228 tet_infoline("Testing RenderTask::GetCameraActor()");
1230 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1232 RenderTask task = taskList.GetTask(0u);
1234 CameraActor actor = task.GetCameraActor();
1235 DALI_TEST_CHECK(actor);
1236 DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION);
1237 DALI_TEST_GREATER(actor.GetFieldOfView(), 0.0f, TEST_LOCATION);
1241 int UtcDaliRenderTaskGetCameraActorN(void)
1243 TestApplication application;
1245 tet_infoline("Testing RenderTask::GetCameraActor() with empty handle");
1250 Actor actor = task.GetCameraActor();
1252 catch(Dali::DaliException& e)
1254 DALI_TEST_PRINT_ASSERT(e);
1255 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1261 int UtcDaliRenderTaskSetFrameBufferP(void)
1263 TestApplication application;
1265 tet_infoline("Testing RenderTask::SetFrameBuffer()");
1267 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1269 RenderTask task = taskList.GetTask(0u);
1271 FrameBuffer newFrameBuffer = FrameBuffer::New(128u, 128u, FrameBuffer::Attachment::NONE);
1272 task.SetFrameBuffer(newFrameBuffer);
1273 DALI_TEST_CHECK(task.GetFrameBuffer() == newFrameBuffer);
1277 int UtcDaliRenderTaskSetFrameBufferN(void)
1279 TestApplication application;
1281 tet_infoline("Testing RenderTask::SetFrameBuffer()");
1283 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1285 RenderTask task = taskList.GetTask(0u);
1286 FrameBuffer newFrameBuffer; // Empty handle
1287 task.SetFrameBuffer(newFrameBuffer);
1288 DALI_TEST_EQUALS((bool)task.GetFrameBuffer(), false, TEST_LOCATION);
1292 int UtcDaliRenderTaskGetFrameBufferP(void)
1294 TestApplication application;
1296 tet_infoline("Testing RenderTask::GetFrameBuffer()");
1298 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1300 RenderTask task = taskList.GetTask(0u);
1302 FrameBuffer newFrameBuffer = FrameBuffer::New(1u, 1u, FrameBuffer::Attachment::NONE);
1303 task.SetFrameBuffer(newFrameBuffer);
1304 DALI_TEST_CHECK(task.GetFrameBuffer() == newFrameBuffer);
1308 int UtcDaliRenderTaskGetFrameBufferN(void)
1310 TestApplication application;
1312 tet_infoline("Testing RenderTask::GetFrameBuffer()");
1314 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1316 RenderTask task = taskList.GetTask(0u);
1318 // By default render-tasks do not render off-screen
1319 FrameBuffer frameBuffer = task.GetFrameBuffer();
1320 DALI_TEST_CHECK(!frameBuffer);
1325 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionP(void)
1327 TestApplication application;
1329 tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1331 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1333 RenderTask task = taskList.GetTask(0u);
1335 task.SetScreenToFrameBufferFunction(TestScreenToFrameBufferFunction);
1337 Vector2 coordinates(5, 10);
1338 Vector2 convertedCoordinates(6, 12); // + Vector(1, 2)
1340 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1341 DALI_TEST_CHECK(func(coordinates));
1342 DALI_TEST_CHECK(coordinates == convertedCoordinates);
1344 task.SetScreenToFrameBufferFunction(RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION);
1345 func = task.GetScreenToFrameBufferFunction();
1346 DALI_TEST_CHECK(func(coordinates));
1348 task.SetScreenToFrameBufferFunction(RenderTask::DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION);
1349 func = task.GetScreenToFrameBufferFunction();
1350 DALI_TEST_CHECK(!func(coordinates));
1354 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionN(void)
1356 TestApplication application;
1358 tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1360 RenderTask task; // Empty handle
1363 task.SetScreenToFrameBufferFunction(TestScreenToFrameBufferFunction);
1365 catch(Dali::DaliException& e)
1367 DALI_TEST_PRINT_ASSERT(e);
1368 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1373 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionP(void)
1375 TestApplication application;
1377 tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction()");
1379 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1381 RenderTask task = taskList.GetTask(0u);
1383 Vector2 originalCoordinates(5, 10);
1384 Vector2 coordinates(5, 10);
1386 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1387 DALI_TEST_CHECK(!func(coordinates)); // conversion should fail by default
1388 DALI_TEST_CHECK(coordinates == originalCoordinates); // coordinates should not be modified
1392 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionN(void)
1394 TestApplication application;
1396 tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction() on empty handle");
1401 RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1404 catch(Dali::DaliException& e)
1406 DALI_TEST_PRINT_ASSERT(e);
1407 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1412 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorP(void)
1414 TestApplication application;
1415 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor ");
1417 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1418 RenderTask renderTask = taskList.CreateTask();
1419 Actor mappingActor = Actor::New();
1420 renderTask.SetScreenToFrameBufferMappingActor(mappingActor);
1422 DALI_TEST_EQUALS(mappingActor, renderTask.GetScreenToFrameBufferMappingActor(), TEST_LOCATION);
1426 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorN(void)
1428 TestApplication application;
1429 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1435 task.SetScreenToFrameBufferMappingActor(mappingActor);
1437 catch(Dali::DaliException& e)
1439 DALI_TEST_PRINT_ASSERT(e);
1440 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1445 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActor02N(void)
1447 TestApplication application;
1448 tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1450 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1451 RenderTask renderTask = taskList.CreateTask();
1453 renderTask.SetScreenToFrameBufferMappingActor(actor);
1455 DALI_TEST_EQUALS((bool)renderTask.GetScreenToFrameBufferMappingActor(), false, TEST_LOCATION);
1459 int UtcDaliRenderTaskGetViewportP01(void)
1461 TestApplication application;
1463 tet_infoline("Testing RenderTask::GetViewport() on default task");
1465 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1466 RenderTask task = taskList.GetTask(0u);
1467 Viewport viewport = task.GetViewport();
1469 // By default the viewport should match the stage width/height
1470 Vector2 stageSize = application.GetScene().GetSize();
1471 Viewport expectedViewport(0, 0, stageSize.width, stageSize.height);
1472 DALI_TEST_CHECK(viewport == expectedViewport);
1476 int UtcDaliRenderTaskGetViewportP02(void)
1478 TestApplication application;
1480 tet_infoline("Testing RenderTask::GetViewport() on new task");
1482 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1483 RenderTask task = taskList.CreateTask();
1484 Viewport viewport = task.GetViewport();
1486 // By default the viewport should match the stage width/height
1487 Vector2 stageSize = application.GetScene().GetSize();
1488 Viewport expectedViewport(0, 0, stageSize.width, stageSize.height);
1489 DALI_TEST_CHECK(viewport == expectedViewport);
1493 int UtcDaliRenderTaskGetViewportN(void)
1495 TestApplication application;
1497 tet_infoline("Testing RenderTask::GetViewport() on empty handle");
1502 Viewport viewport = task.GetViewport();
1505 catch(Dali::DaliException& e)
1507 DALI_TEST_PRINT_ASSERT(e);
1508 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1513 int UtcDaliRenderTaskSetViewportP(void)
1515 TestApplication application;
1517 tet_infoline("Testing RenderTask::SetViewport()");
1519 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1521 RenderTask task = taskList.GetTask(0u);
1522 Vector2 stageSize = application.GetScene().GetSize();
1523 Viewport newViewport(0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f);
1524 task.SetViewport(newViewport);
1526 // Update (viewport is a property)
1527 application.SendNotification();
1528 application.Render();
1530 DALI_TEST_CHECK(task.GetViewport() == newViewport);
1534 int UtcDaliRenderTaskSetViewportN(void)
1536 TestApplication application;
1538 tet_infoline("Testing RenderTask::SetViewport()");
1540 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1545 Vector2 stageSize = application.GetScene().GetSize();
1546 Viewport newViewport(0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f);
1547 task.SetViewport(newViewport);
1549 catch(Dali::DaliException& e)
1551 DALI_TEST_PRINT_ASSERT(e);
1552 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1558 int UtcDaliRenderTaskSetViewportPosition(void)
1560 TestApplication application;
1562 tet_infoline("Testing RenderTask::SetViewportPosition()");
1564 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1566 RenderTask task = taskList.GetTask(0u);
1568 Viewport viewport = task.GetViewport();
1570 // By default the viewport should match the stage width/height
1572 Vector2 stageSize = application.GetScene().GetSize();
1573 Viewport expectedViewport(0, 0, stageSize.width, stageSize.height);
1574 DALI_TEST_CHECK(viewport == expectedViewport);
1577 Vector2 newPosition(25.0f, 50.0f);
1578 task.SetViewportPosition(newPosition);
1580 // Update (viewport is a property)
1581 application.SendNotification();
1582 application.Render();
1584 DALI_TEST_EQUALS(task.GetCurrentViewportPosition(), newPosition, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1586 // Set by Property test
1587 Vector2 newPosition2(32.0f, 32.0f);
1588 task.SetProperty(RenderTask::Property::VIEWPORT_POSITION, newPosition2);
1589 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition2, TEST_LOCATION);
1590 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition, TEST_LOCATION); // still the old position
1593 application.SendNotification();
1594 application.Render();
1596 DALI_TEST_EQUALS(task.GetCurrentViewportPosition(), newPosition2, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1597 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition2, TEST_LOCATION);
1598 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition2, TEST_LOCATION);
1600 Vector2 newPosition3(64.0f, 0.0f);
1601 Animation animation = Animation::New(1.0f);
1602 animation.AnimateTo(Property(task, RenderTask::Property::VIEWPORT_POSITION), newPosition3, AlphaFunction::LINEAR);
1605 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1606 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition2, TEST_LOCATION);
1608 // Perform 1000ms worth of updates at which point animation should have completed.
1609 Wait(application, 1000);
1610 DALI_TEST_EQUALS(task.GetCurrentViewportPosition(), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1611 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1612 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1614 // Create another animation which animates by a certain value
1615 const Vector2 newPosition4(75.0f, 45.0f);
1616 const Vector2 relativePosition(newPosition4 - newPosition3);
1617 animation = Animation::New(1.0f);
1618 animation.AnimateBy(Property(task, RenderTask::Property::VIEWPORT_POSITION), relativePosition);
1621 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1622 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition3, TEST_LOCATION);
1624 // Perform 1000ms worth of updates at which point animation should have completed.
1625 Wait(application, 1000);
1626 DALI_TEST_EQUALS(task.GetCurrentViewportPosition(), newPosition4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1627 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1628 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_POSITION), newPosition4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1633 int UtcDaliRenderTaskSetViewportSize(void)
1635 TestApplication application;
1637 tet_infoline("Testing RenderTask::SetViewportSize()");
1639 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1641 RenderTask task = taskList.GetTask(0u);
1643 Viewport viewport = task.GetViewport();
1645 // By default the viewport should match the stage width/height
1647 Vector2 stageSize = application.GetScene().GetSize();
1648 Viewport expectedViewport(0, 0, stageSize.width, stageSize.height);
1649 DALI_TEST_CHECK(viewport == expectedViewport);
1651 Vector2 newSize(128.0f, 64.0f);
1652 task.SetViewportSize(newSize);
1654 // Update (viewport is a property)
1655 application.SendNotification();
1656 application.Render();
1658 DALI_TEST_EQUALS(task.GetCurrentViewportSize(), newSize, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1660 // Set by Property test
1661 Vector2 newSize2(50.0f, 50.0f);
1662 task.SetProperty(RenderTask::Property::VIEWPORT_SIZE, newSize2);
1663 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize2, TEST_LOCATION);
1664 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize, TEST_LOCATION); // still the old position
1667 application.SendNotification();
1668 application.Render();
1670 DALI_TEST_EQUALS(task.GetCurrentViewportSize(), newSize2, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1671 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize2, TEST_LOCATION);
1672 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize2, TEST_LOCATION);
1674 Vector2 newSize3(10.0f, 10.0f);
1675 Animation animation = Animation::New(1.0f);
1676 animation.AnimateTo(Property(task, RenderTask::Property::VIEWPORT_SIZE), newSize3, AlphaFunction::LINEAR);
1679 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1680 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize2, TEST_LOCATION);
1682 // Perform 1000ms worth of updates at which point animation should have completed.
1683 Wait(application, 1000);
1684 DALI_TEST_EQUALS(task.GetCurrentViewportSize(), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1685 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1686 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1688 // Create another animation which animates by a certain value
1689 const Vector2 newSize4(75.0f, 45.0f);
1690 const Vector2 relativeSize(newSize4 - newSize3);
1691 animation = Animation::New(1.0f);
1692 animation.AnimateBy(Property(task, RenderTask::Property::VIEWPORT_SIZE), relativeSize);
1695 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1696 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize3, TEST_LOCATION);
1698 // Perform 1000ms worth of updates at which point animation should have completed.
1699 Wait(application, 1000);
1700 DALI_TEST_EQUALS(task.GetCurrentViewportSize(), newSize4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1701 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1702 DALI_TEST_EQUALS(task.GetProperty<Vector2>(RenderTask::Property::VIEWPORT_SIZE), newSize4, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1707 int UtcDaliRenderTaskSetClearColorP(void)
1709 TestApplication application;
1711 tet_infoline("Testing RenderTask::SetClearColor()");
1713 Vector4 testColor(1.0f, 2.0f, 3.0f, 4.0f);
1714 Vector4 testColor2(5.0f, 6.0f, 7.0f, 8.0f);
1716 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1718 RenderTask task = taskList.GetTask(0u);
1719 DALI_TEST_CHECK(task.GetClearColor() != testColor);
1721 task.SetClearColor(testColor);
1726 DALI_TEST_EQUALS(task.GetClearColor(), testColor, TEST_LOCATION);
1728 task.SetProperty(RenderTask::Property::CLEAR_COLOR, testColor2);
1729 DALI_TEST_EQUALS(task.GetProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), testColor2, TEST_LOCATION);
1730 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), testColor, TEST_LOCATION); // still the old color
1735 DALI_TEST_EQUALS(task.GetClearColor(), testColor2, TEST_LOCATION);
1736 DALI_TEST_EQUALS(task.GetProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), testColor2, TEST_LOCATION);
1737 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), testColor2, TEST_LOCATION);
1739 Vector4 newColor3(10.0f, 10.0f, 20.0f, 30.0f);
1740 Animation animation = Animation::New(1.0f);
1741 animation.AnimateTo(Property(task, RenderTask::Property::CLEAR_COLOR), newColor3, AlphaFunction::LINEAR);
1744 DALI_TEST_EQUALS(task.GetProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1745 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), testColor2, TEST_LOCATION);
1747 // Perform 1000ms worth of updates at which point animation should have completed.
1748 Wait(application, 1000);
1749 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1750 DALI_TEST_EQUALS(task.GetProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor3, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1752 // Create another animation which animates by a certain value
1753 const Vector4 newColor4(0.45f, 0.35f, 0.25f, 0.1f);
1754 const Vector4 relativeColor(newColor4 - newColor3);
1755 animation = Animation::New(1.0f);
1756 animation.AnimateBy(Property(task, RenderTask::Property::CLEAR_COLOR), relativeColor);
1759 DALI_TEST_EQUALS(task.GetProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor4, Math::MACHINE_EPSILON_10, TEST_LOCATION);
1760 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor3, Math::MACHINE_EPSILON_10, TEST_LOCATION);
1762 // Perform 1000ms worth of updates at which point animation should have completed.
1763 Wait(application, 1000);
1764 DALI_TEST_EQUALS(task.GetCurrentProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor4, Math::MACHINE_EPSILON_10, TEST_LOCATION);
1765 DALI_TEST_EQUALS(task.GetProperty<Vector4>(RenderTask::Property::CLEAR_COLOR), newColor4, Math::MACHINE_EPSILON_10, TEST_LOCATION);
1770 int UtcDaliRenderTaskSetClearColorN(void)
1772 TestApplication application;
1774 tet_infoline("Testing RenderTask::SetClearColor() on empty handle");
1779 task.SetClearColor(Vector4::ZERO);
1781 catch(Dali::DaliException& e)
1783 DALI_TEST_PRINT_ASSERT(e);
1784 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1789 int UtcDaliRenderTaskGetClearColorP(void)
1791 TestApplication application;
1793 tet_infoline("Testing RenderTask::GetClearColor()");
1795 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1796 RenderTask task = taskList.GetTask(0u);
1797 DALI_TEST_EQUALS(task.GetClearColor(), RenderTask::DEFAULT_CLEAR_COLOR, TEST_LOCATION);
1801 int UtcDaliRenderTaskGetClearColorN(void)
1803 TestApplication application;
1805 tet_infoline("Testing RenderTask::GetClearColor()");
1810 Vector4 color = task.GetClearColor();
1813 catch(Dali::DaliException& e)
1815 DALI_TEST_PRINT_ASSERT(e);
1816 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1821 int UtcDaliRenderTaskSetClearEnabledP(void)
1823 TestApplication application;
1825 tet_infoline("Testing RenderTask::SetClearEnabled()");
1827 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1829 RenderTask task = taskList.GetTask(0u);
1830 DALI_TEST_CHECK(task.GetClearEnabled()); // defaults to true
1832 task.SetClearEnabled(false);
1833 DALI_TEST_EQUALS(task.GetClearEnabled(), false, TEST_LOCATION);
1835 task.SetClearEnabled(true);
1836 DALI_TEST_EQUALS(task.GetClearEnabled(), true, TEST_LOCATION);
1840 int UtcDaliRenderTaskSetClearEnabledN(void)
1842 TestApplication application;
1844 tet_infoline("Testing RenderTask::SetClearEnabled() with empty handle");
1849 task.SetClearEnabled(true);
1851 catch(Dali::DaliException& e)
1853 DALI_TEST_PRINT_ASSERT(e);
1854 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1859 int UtcDaliRenderTaskGetClearEnabledP(void)
1861 TestApplication application;
1863 tet_infoline("Testing RenderTask::GetClearEnabled()");
1865 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1867 RenderTask task = taskList.GetTask(0u);
1868 DALI_TEST_CHECK(task.GetClearEnabled()); // defaults to true
1872 int UtcDaliRenderTaskGetClearEnabledN(void)
1874 TestApplication application;
1876 tet_infoline("Testing RenderTask::GetClearEnabled() with empty handle");
1881 bool x = task.GetClearEnabled();
1884 catch(Dali::DaliException& e)
1886 DALI_TEST_PRINT_ASSERT(e);
1887 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1892 int UtcDaliRenderTaskSetCullModeP(void)
1894 TestApplication application;
1896 tet_infoline("Testing RenderTask::SetCullMode()");
1898 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1899 RenderTask task = taskList.GetTask(0u);
1900 DALI_TEST_EQUALS(task.GetCullMode(), true, TEST_LOCATION);
1902 task.SetCullMode(false);
1904 DALI_TEST_EQUALS(task.GetCullMode(), false, TEST_LOCATION);
1909 int UtcDaliRenderTaskSetCullModeN(void)
1911 TestApplication application;
1913 tet_infoline("Testing RenderTask::SetCullMode() on empty handle");
1918 task.SetCullMode(false);
1920 catch(Dali::DaliException& e)
1922 DALI_TEST_PRINT_ASSERT(e);
1923 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1928 int UtcDaliRenderTaskGetCullModeP(void)
1930 TestApplication application;
1932 tet_infoline("Testing RenderTask::GetCullMode()");
1934 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1935 RenderTask task = taskList.GetTask(0u);
1936 DALI_TEST_EQUALS(task.GetCullMode(), true, TEST_LOCATION);
1940 int UtcDaliRenderTaskGetCullModeN(void)
1942 TestApplication application;
1944 tet_infoline("Testing RenderTask::GetCullMode() with empty handle");
1949 bool x = task.GetCullMode();
1952 catch(Dali::DaliException& e)
1954 DALI_TEST_PRINT_ASSERT(e);
1955 DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1960 int UtcDaliRenderTaskSetRefreshRate(void)
1962 TestApplication application;
1964 tet_infoline("Testing RenderTask::SetRefreshRate()");
1966 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1968 // By default tasks will be processed every frame
1969 RenderTask task = taskList.GetTask(0u);
1970 DALI_TEST_CHECK(RenderTask::REFRESH_ALWAYS == task.GetRefreshRate());
1972 task.SetRefreshRate(2u); // every-other frame
1973 DALI_TEST_CHECK(2u == task.GetRefreshRate());
1975 task.SetRefreshRate(RenderTask::REFRESH_ALWAYS);
1976 DALI_TEST_CHECK(RenderTask::REFRESH_ALWAYS == task.GetRefreshRate());
1980 int UtcDaliRenderTaskGetRefreshRate(void)
1982 TestApplication application;
1984 tet_infoline("Testing RenderTask::GetRefreshRate()");
1986 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1988 // By default tasks will be processed every frame
1989 RenderTask task = taskList.GetTask(0u);
1990 DALI_TEST_CHECK(RenderTask::REFRESH_ALWAYS == task.GetRefreshRate());
1992 RenderTask newTask = taskList.CreateTask();
1993 DALI_TEST_CHECK(RenderTask::REFRESH_ALWAYS == newTask.GetRefreshRate());
1997 int UtcDaliRenderTaskSignalFinished(void)
1999 TestApplication application;
2001 tet_infoline("Testing RenderTask::SignalFinished()");
2003 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2004 auto& sync = application.GetGraphicsSyncImpl();
2006 CameraActor offscreenCameraActor = CameraActor::New();
2008 application.GetScene().Add(offscreenCameraActor);
2010 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 10, 10);
2011 Actor rootActor = CreateRenderableActor(image);
2012 rootActor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
2013 application.GetScene().Add(rootActor);
2015 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2016 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
2017 Texture frameBufferTexture = Texture::New(*testNativeImagePtr);
2018 FrameBuffer frameBuffer = FrameBuffer::New(frameBufferTexture.GetWidth(), frameBufferTexture.GetHeight());
2019 frameBuffer.AttachColorTexture(frameBufferTexture);
2021 RenderTask newTask = taskList.CreateTask();
2022 newTask.SetCameraActor(offscreenCameraActor);
2023 newTask.SetSourceActor(rootActor);
2024 newTask.SetInputEnabled(false);
2025 newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
2026 newTask.SetClearEnabled(true);
2027 newTask.SetExclusive(true);
2028 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2029 newTask.SetFrameBuffer(frameBuffer);
2030 newTask.SetProperty(RenderTask::Property::REQUIRES_SYNC, true);
2032 bool finished = false;
2033 RenderTaskFinished renderTaskFinished(finished);
2034 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2036 // Flush the queue and render.
2037 application.SendNotification();
2039 // 1 render to process render task, then wait for sync before finished msg is sent
2040 // from update to the event thread.
2042 application.Render();
2043 application.SendNotification();
2044 DALI_TEST_CHECK(!finished);
2046 Integration::GraphicsSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2047 DALI_TEST_CHECK(lastSyncObj != NULL);
2049 application.Render();
2050 DALI_TEST_EQUALS((Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION);
2051 application.SendNotification();
2052 DALI_TEST_CHECK(!finished);
2054 application.Render();
2055 DALI_TEST_EQUALS((Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION);
2056 application.SendNotification();
2057 DALI_TEST_CHECK(!finished);
2059 sync.SetObjectSynced(lastSyncObj, true);
2061 application.Render();
2062 application.SendNotification();
2063 DALI_TEST_CHECK(!finished);
2065 application.Render();
2066 application.SendNotification();
2067 DALI_TEST_CHECK(finished);
2069 DALI_TEST_EQUALS(application.GetUpdateStatus(), 0, TEST_LOCATION);
2073 int UtcDaliRenderTaskContinuous01(void)
2075 TestApplication application;
2077 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not staged)\nPOST:continuous renders, no Finished signal");
2079 // SETUP AN OFFSCREEN RENDER TASK
2080 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2081 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2082 drawTrace.Enable(true);
2084 Actor rootActor = Actor::New();
2085 application.GetScene().Add(rootActor);
2087 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2088 application.GetScene().Add(offscreenCameraActor);
2090 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2092 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2093 bool finished = false;
2094 RenderTaskFinished renderTaskFinished(finished);
2095 application.SendNotification();
2097 // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating
2098 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, false, __LINE__));
2099 application.GetPlatform().ClearReadyResources();
2101 // ADD SOURCE ACTOR TO STAGE - expect continuous renders to start, no finished signal
2102 application.GetScene().Add(secondRootActor);
2103 application.SendNotification();
2105 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
2106 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2110 int UtcDaliRenderTaskContinuous02(void)
2112 TestApplication application;
2114 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not visible)\nPOST:continuous renders, no Finished signal");
2116 // SETUP AN OFFSCREEN RENDER TASK
2117 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2118 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2119 drawTrace.Enable(true);
2121 Actor rootActor = Actor::New();
2122 application.GetScene().Add(rootActor);
2124 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2125 application.GetScene().Add(offscreenCameraActor);
2127 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2128 application.GetScene().Add(secondRootActor);
2129 secondRootActor.SetProperty(Actor::Property::VISIBLE, false);
2131 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2132 bool finished = false;
2133 RenderTaskFinished renderTaskFinished(finished);
2134 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2135 application.SendNotification();
2137 // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating
2138 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, false, __LINE__));
2139 application.GetPlatform().ClearReadyResources();
2141 // MAKE SOURCE ACTOR VISIBLE - expect continuous renders to start, no finished signal
2142 secondRootActor.SetProperty(Actor::Property::VISIBLE, true);
2143 application.SendNotification();
2145 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
2146 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2150 int UtcDaliRenderTaskContinuous03(void)
2152 TestApplication application;
2154 tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (camera actor not staged)\nPOST:continuous renders, no Finished signal");
2156 // SETUP AN OFFSCREEN RENDER TASK
2157 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2158 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2159 drawTrace.Enable(true);
2161 Actor rootActor = Actor::New();
2162 application.GetScene().Add(rootActor);
2164 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2165 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2166 application.GetScene().Add(secondRootActor);
2168 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2169 bool finished = false;
2170 RenderTaskFinished renderTaskFinished(finished);
2171 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2172 application.SendNotification();
2174 // START PROCESS/RENDER Input, Expected Input, Expected
2175 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, false, __LINE__));
2176 application.GetPlatform().ClearReadyResources();
2178 // ADD CAMERA ACTOR TO STAGE - expect continuous renders to start, no finished signal
2179 application.GetScene().Add(offscreenCameraActor);
2180 application.SendNotification();
2182 // CONTINUE PROCESS/RENDER Input, Expected Input, Expected
2183 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2187 int UtcDaliRenderTaskContinuous04(void)
2189 TestApplication application;
2191 tet_infoline("Testing RenderTask Render Continuous using loaded image");
2193 // SETUP AN OFFSCREEN RENDER TASK
2194 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2195 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2196 drawTrace.Enable(true);
2198 Actor rootActor = Actor::New();
2199 application.GetScene().Add(rootActor);
2201 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2202 application.GetScene().Add(offscreenCameraActor);
2203 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2204 application.GetScene().Add(secondRootActor);
2206 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2207 bool finished = false;
2208 RenderTaskFinished renderTaskFinished(finished);
2209 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2210 application.SendNotification();
2212 // START PROCESS/RENDER Input, Expected Input, Expected
2213 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2217 int UtcDaliRenderTaskOnce01(void)
2219 TestApplication application;
2221 tet_infoline("Testing RenderTask Render Once GlSync, using loaded image");
2223 // SETUP AN OFFSCREEN RENDER TASK
2224 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2225 auto& sync = application.GetGraphicsSyncImpl();
2226 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2227 drawTrace.Enable(true);
2229 Actor rootActor = Actor::New();
2230 application.GetScene().Add(rootActor);
2232 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2233 application.GetScene().Add(offscreenCameraActor);
2234 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2236 application.GetScene().Add(secondRootActor);
2238 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
2239 bool finished = false;
2240 RenderTaskFinished renderTaskFinished(finished);
2241 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2242 application.SendNotification();
2244 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2246 Integration::GraphicsSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2247 DALI_TEST_CHECK(lastSyncObj != NULL);
2248 sync.SetObjectSynced(lastSyncObj, true);
2250 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, true, __LINE__));
2251 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2255 int UtcDaliRenderTaskOnce02(void)
2257 TestApplication application;
2259 tet_infoline("Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loaded image.\n");
2261 // SETUP AN OFFSCREEN RENDER TASK
2262 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2263 auto& sync = application.GetGraphicsSyncImpl();
2264 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2265 drawTrace.Enable(true);
2267 Actor rootActor = Actor::New();
2268 application.GetScene().Add(rootActor);
2270 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2271 application.GetScene().Add(offscreenCameraActor);
2273 Shader shader = CreateShader();
2274 Texture image = CreateTexture();
2275 TextureSet textureSet = CreateTextureSet(image);
2277 Geometry geometry = CreateQuadGeometry();
2278 Renderer renderer = Renderer::New(geometry, shader);
2279 renderer.SetTextures(textureSet);
2280 Actor secondRootActor = Actor::New();
2281 secondRootActor.AddRenderer(renderer);
2282 secondRootActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2283 application.GetScene().Add(secondRootActor);
2285 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
2286 bool finished = false;
2287 RenderTaskFinished renderTaskFinished(finished);
2288 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2289 application.SendNotification();
2291 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2293 Integration::GraphicsSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2294 DALI_TEST_CHECK(lastSyncObj != NULL);
2295 sync.SetObjectSynced(lastSyncObj, true);
2297 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, true, __LINE__));
2298 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2303 int UtcDaliRenderTaskOnce03(void)
2305 TestApplication application;
2307 tet_infoline("Testing RenderTask Render Once GlSync, using loaded image. Switch from render always after ready to render once\n");
2309 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2310 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2311 auto& sync = application.GetGraphicsSyncImpl();
2312 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2313 drawTrace.Enable(true);
2315 Actor rootActor = Actor::New();
2316 application.GetScene().Add(rootActor);
2318 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2319 application.GetScene().Add(offscreenCameraActor);
2320 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2321 application.GetScene().Add(secondRootActor);
2323 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2324 bool finished = false;
2325 RenderTaskFinished renderTaskFinished(finished);
2326 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2327 application.SendNotification();
2329 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2331 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2332 application.SendNotification();
2333 // drawn sig finished Keep updating
2334 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2336 Integration::GraphicsSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2337 DALI_TEST_CHECK(lastSyncObj != NULL);
2338 sync.SetObjectSynced(lastSyncObj, true);
2340 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, true, __LINE__));
2341 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2346 int UtcDaliRenderTaskOnce04(void)
2348 TestApplication application;
2350 "Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loaded image.\n"
2351 "Switch from render always after ready to render once\n");
2353 // SETUP AN OFFSCREEN RENDER TASK
2354 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2355 auto& sync = application.GetGraphicsSyncImpl();
2356 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2357 drawTrace.Enable(true);
2359 Actor rootActor = Actor::New();
2360 application.GetScene().Add(rootActor);
2362 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2363 application.GetScene().Add(offscreenCameraActor);
2365 Shader shader = CreateShader();
2366 Texture image = CreateTexture();
2367 TextureSet textureSet = CreateTextureSet(image);
2369 Geometry geometry = CreateQuadGeometry();
2370 Renderer renderer = Renderer::New(geometry, shader);
2371 renderer.SetTextures(textureSet);
2372 Actor secondRootActor = Actor::New();
2373 secondRootActor.AddRenderer(renderer);
2374 secondRootActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2375 application.GetScene().Add(secondRootActor);
2377 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2378 bool finished = false;
2379 RenderTaskFinished renderTaskFinished(finished);
2380 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2381 application.SendNotification();
2383 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2385 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2386 application.SendNotification();
2387 // FAILS drawn sig finished Keep updating
2388 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2390 Integration::GraphicsSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2391 DALI_TEST_CHECK(lastSyncObj != NULL);
2392 sync.SetObjectSynced(lastSyncObj, true);
2394 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, true, __LINE__));
2395 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2400 int UtcDaliRenderTaskOnceNoSync01(void)
2402 TestApplication application;
2404 tet_infoline("Testing RenderTask Render Once, \nPRE: Resources ready\nPOST: Finished signal sent once only");
2406 // SETUP AN OFFSCREEN RENDER TASK
2407 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2408 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2409 drawTrace.Enable(true);
2411 Actor rootActor = Actor::New();
2412 application.GetScene().Add(rootActor);
2414 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2415 application.GetScene().Add(offscreenCameraActor);
2416 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2417 application.GetScene().Add(secondRootActor);
2419 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2420 bool finished = false;
2421 RenderTaskFinished renderTaskFinished(finished);
2422 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2423 application.SendNotification();
2425 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2426 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2430 int UtcDaliRenderTaskOnceNoSync02(void)
2432 TestApplication application;
2435 "Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loaded image.\n"
2436 "PRE: Resources ready\nPOST: Finished signal sent once only");
2437 // SETUP AN OFFSCREEN RENDER TASK
2438 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2439 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2440 drawTrace.Enable(true);
2442 Actor rootActor = Actor::New();
2443 application.GetScene().Add(rootActor);
2445 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2446 application.GetScene().Add(offscreenCameraActor);
2448 Shader shader = CreateShader();
2449 Texture image = CreateTexture();
2450 TextureSet textureSet = CreateTextureSet(image);
2452 Geometry geometry = CreateQuadGeometry();
2453 Renderer renderer = Renderer::New(geometry, shader);
2454 renderer.SetTextures(textureSet);
2455 Actor secondRootActor = Actor::New();
2456 secondRootActor.AddRenderer(renderer);
2457 secondRootActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2458 application.GetScene().Add(secondRootActor);
2460 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2461 bool finished = false;
2462 RenderTaskFinished renderTaskFinished(finished);
2463 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2464 application.SendNotification();
2466 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2467 application.GetPlatform().ClearReadyResources();
2468 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2473 int UtcDaliRenderTaskOnceNoSync03(void)
2475 TestApplication application;
2478 "Testing RenderTask Render Once, using loaded image. Switch from render always after ready to render once\n"
2479 "PRE: Render task ready, Image loaded\n"
2480 "POST: Finished signal sent only once");
2482 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2483 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2484 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2485 drawTrace.Enable(true);
2487 Actor rootActor = Actor::New();
2488 application.GetScene().Add(rootActor);
2490 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2491 application.GetScene().Add(offscreenCameraActor);
2492 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2493 application.GetScene().Add(secondRootActor);
2495 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2496 bool finished = false;
2497 RenderTaskFinished renderTaskFinished(finished);
2498 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2499 application.SendNotification();
2501 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2503 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2504 application.SendNotification(); // Input, Expected Input, Expected
2505 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2506 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2510 int UtcDaliRenderTaskOnceNoSync04(void)
2512 TestApplication application;
2515 "Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loading image.\n"
2516 "Switch from render always after ready to render once\n"
2517 "PRE: Render task ready, Image not loaded\n"
2518 "POST: Finished signal sent only once");
2520 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2521 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2522 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2523 drawTrace.Enable(true);
2525 Actor rootActor = Actor::New();
2526 application.GetScene().Add(rootActor);
2528 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2529 application.GetScene().Add(offscreenCameraActor);
2531 Shader shader = CreateShader();
2532 Texture image = CreateTexture();
2533 TextureSet textureSet = CreateTextureSet(image);
2535 Geometry geometry = CreateQuadGeometry();
2536 Renderer renderer = Renderer::New(geometry, shader);
2537 renderer.SetTextures(textureSet);
2538 Actor secondRootActor = Actor::New();
2539 secondRootActor.AddRenderer(renderer);
2540 secondRootActor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2541 application.GetScene().Add(secondRootActor);
2543 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2544 bool finished = false;
2545 RenderTaskFinished renderTaskFinished(finished);
2546 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2547 application.SendNotification();
2549 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2550 auto& sync = application.GetGraphicsSyncImpl();
2551 Integration::GraphicsSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2552 DALI_TEST_CHECK(lastSyncObj == NULL);
2554 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2555 application.SendNotification(); // Input, Expected Input, Expected
2556 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2557 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2559 lastSyncObj = sync.GetLastSyncObject();
2560 DALI_TEST_CHECK(lastSyncObj == NULL);
2565 int UtcDaliRenderTaskOnceNoSync05(void)
2567 TestApplication application;
2570 "Testing RenderTask Render Once\n"
2571 "SetRefreshRate(ONCE), resource load failed, completes render task.\n"
2572 "PRE: resources failed to load\n"
2573 "POST: No finished signal sent.");
2575 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2576 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2577 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2578 drawTrace.Enable(true);
2580 Actor rootActor = Actor::New();
2581 application.GetScene().Add(rootActor);
2583 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2584 application.GetScene().Add(offscreenCameraActor);
2585 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2586 application.GetScene().Add(secondRootActor);
2588 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2589 bool finished = false;
2590 RenderTaskFinished renderTaskFinished(finished);
2591 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2592 application.SendNotification();
2594 // START PROCESS/RENDER Input, Expected Input, Expected
2595 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2597 // CHANGE TO RENDER ONCE,
2598 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2599 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2604 int UtcDaliRenderTaskOnceChain01(void)
2606 TestApplication application;
2609 "Testing RenderTask Render Once Chained render tasks\n"
2610 "SetRefreshRate(ONCE), resource load completes, both render tasks render.\n"
2611 "PRE: resources ready\n"
2612 "POST: 2 finished signals sent.");
2614 // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2615 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2616 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2617 drawTrace.Enable(true);
2619 Actor defaultRootActor = Actor::New(); // Root for default RT
2620 application.GetScene().Add(defaultRootActor);
2622 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2623 application.GetScene().Add(offscreenCameraActor);
2624 Actor firstRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2625 application.GetScene().Add(firstRootActor);
2627 // first render task
2628 RenderTask firstTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, firstRootActor, RenderTask::REFRESH_ONCE, false);
2629 bool firstFinished = false;
2630 RenderTaskFinished renderTask1Finished(firstFinished);
2631 firstTask.FinishedSignal().Connect(&application, renderTask1Finished);
2633 // Second render task
2634 FrameBuffer fbo = firstTask.GetFrameBuffer();
2635 Actor secondRootActor = CreateRenderableActor(fbo.GetColorTexture());
2636 application.GetScene().Add(secondRootActor);
2637 RenderTask secondTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2638 bool secondFinished = false;
2639 RenderTaskFinished renderTask2Finished(secondFinished);
2640 secondTask.FinishedSignal().Connect(&application, renderTask2Finished);
2642 application.SendNotification();
2644 // Both render tasks are executed.
2645 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__));
2646 DALI_TEST_CHECK(firstFinished == false);
2647 DALI_TEST_CHECK(secondFinished == false);
2649 // Nothing else to render and both render task should have finished now
2650 DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, firstFinished, true, false, __LINE__));
2651 DALI_TEST_CHECK(firstFinished == true);
2652 DALI_TEST_CHECK(secondFinished == true);
2657 int UtcDaliRenderTaskProperties(void)
2659 TestApplication application;
2661 RenderTask task = application.GetScene().GetRenderTaskList().CreateTask();
2663 Property::IndexContainer indices;
2664 task.GetPropertyIndices(indices);
2665 DALI_TEST_CHECK(indices.Size());
2666 DALI_TEST_EQUALS(indices.Size(), task.GetPropertyCount(), TEST_LOCATION);
2670 int UtcDaliRenderTaskFinishInvisibleSourceActor(void)
2672 TestApplication application;
2674 tet_infoline("Testing RenderTask::FinishInvisibleSourceActor()");
2676 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2677 auto& sync = application.GetGraphicsSyncImpl();
2679 CameraActor offscreenCameraActor = CameraActor::New();
2681 application.GetScene().Add(offscreenCameraActor);
2683 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 10, 10);
2684 Actor rootActor = CreateRenderableActor(image);
2685 rootActor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
2686 rootActor.SetProperty(Actor::Property::VISIBLE, false);
2687 application.GetScene().Add(rootActor);
2689 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2690 NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
2691 Texture frameBufferTexture = Texture::New(*testNativeImagePtr);
2692 FrameBuffer frameBuffer = FrameBuffer::New(frameBufferTexture.GetWidth(), frameBufferTexture.GetHeight());
2693 frameBuffer.AttachColorTexture(frameBufferTexture);
2695 // Flush all outstanding messages
2696 application.SendNotification();
2697 application.Render();
2699 RenderTask newTask = taskList.CreateTask();
2700 newTask.SetCameraActor(offscreenCameraActor);
2701 newTask.SetSourceActor(rootActor);
2702 newTask.SetInputEnabled(false);
2703 newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
2704 newTask.SetClearEnabled(true);
2705 newTask.SetExclusive(true);
2706 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2707 newTask.SetFrameBuffer(frameBuffer);
2708 newTask.SetProperty(RenderTask::Property::REQUIRES_SYNC, true);
2710 // Framebuffer doesn't actually get created until Connected, i.e. by previous line
2712 bool finished = false;
2713 RenderTaskFinished renderTaskFinished(finished);
2714 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2716 // Flush the queue and render.
2717 application.SendNotification();
2719 // 1 render to process render task, then wait for sync before finished msg is sent
2720 // from update to the event thread.
2722 application.Render();
2723 application.SendNotification();
2724 DALI_TEST_CHECK(!finished);
2726 Integration::GraphicsSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2727 DALI_TEST_CHECK(lastSyncObj != NULL);
2729 application.Render();
2730 DALI_TEST_EQUALS((Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION);
2731 application.SendNotification();
2732 DALI_TEST_CHECK(!finished);
2734 application.Render();
2735 DALI_TEST_EQUALS((Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION);
2736 application.SendNotification();
2737 DALI_TEST_CHECK(!finished);
2739 sync.SetObjectSynced(lastSyncObj, true);
2741 application.Render();
2742 application.SendNotification();
2743 DALI_TEST_CHECK(!finished);
2745 application.Render();
2746 application.SendNotification();
2747 DALI_TEST_CHECK(finished);
2750 application.Render(); // Double check no more finished signal
2751 application.SendNotification();
2752 DALI_TEST_CHECK(!finished);
2757 int UtcDaliRenderTaskFinishMissingImage(void)
2759 TestApplication application;
2761 // Previously we had bugs where not having a resource ID would cause render-tasks to wait forever
2762 tet_infoline("Testing RenderTask::SignalFinished() when an Actor has no Image set");
2764 Integration::Scene stage = application.GetScene();
2766 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 10, 10);
2767 Actor rootActor = CreateRenderableActor(image);
2768 rootActor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
2769 stage.Add(rootActor);
2771 Actor actorWithMissingImage = CreateRenderableActor(Texture());
2772 actorWithMissingImage.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
2773 stage.Add(actorWithMissingImage);
2775 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2776 RenderTask newTask = taskList.CreateTask();
2777 newTask.SetInputEnabled(false);
2778 newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
2779 newTask.SetClearEnabled(true);
2780 newTask.SetExclusive(true);
2781 newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2783 bool finished = false;
2784 RenderTaskFinished renderTaskFinished(finished);
2785 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2787 // 1 render to process render task, then 1 before finished msg is sent from update to the event thread.
2788 application.SendNotification();
2789 application.Render();
2790 application.Render();
2792 application.SendNotification();
2793 DALI_TEST_CHECK(finished);
2798 int UtcDaliRenderTaskWorldToViewport(void)
2800 TestApplication application(400u, 400u); // square surface
2802 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2804 Actor actor = Actor::New();
2805 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2806 actor.SetProperty(Actor::Property::POSITION, Vector3(0.0, 0.0, 0.0));
2808 actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.5, 0.5, 0.5));
2809 actor.SetProperty(Actor::Property::ANCHOR_POINT, Vector3(0.5, 0.5, 0.5));
2811 application.GetScene().Add(actor);
2813 application.SendNotification();
2814 application.Render();
2815 application.SendNotification();
2817 RenderTask task = taskList.GetTask(0u);
2819 CameraActor camera = task.GetCameraActor();
2821 Vector2 screenSize = task.GetCurrentViewportSize();
2823 float screenX = 0.0;
2824 float screenY = 0.0;
2826 bool ok = task.WorldToViewport(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), screenX, screenY);
2827 DALI_TEST_CHECK(ok == true);
2829 DALI_TEST_EQUALS(screenX, screenSize.x / 2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
2830 DALI_TEST_EQUALS(screenY, screenSize.y / 2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
2832 Actor actor2 = Actor::New();
2833 float actor2Size = 100.f;
2834 actor2.SetProperty(Actor::Property::SIZE, Vector2(actor2Size, actor2Size));
2835 actor2.SetProperty(Actor::Property::POSITION, Vector3(0.0, 0.0, 0.0));
2836 actor2.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.5, 0.5, 0.0));
2837 actor2.SetProperty(Actor::Property::ANCHOR_POINT, Vector3(0.5, 0.5, 0.0));
2838 application.GetScene().Add(actor2);
2840 actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0, 0, 0));
2842 application.SendNotification();
2843 application.Render();
2844 application.SendNotification();
2846 ok = task.WorldToViewport(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), screenX, screenY);
2847 DALI_TEST_CHECK(ok == true);
2849 DALI_TEST_EQUALS(screenX, screenSize.x / 2 - actor2Size / 2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
2850 DALI_TEST_EQUALS(screenY, screenSize.y / 2 - actor2Size / 2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
2855 int UtcDaliRenderTaskViewportToLocal(void)
2857 TestApplication application;
2858 Actor actor = Actor::New();
2859 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2860 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2861 actor.SetProperty(Actor::Property::POSITION, Vector2(10.0f, 10.0f));
2862 application.GetScene().Add(actor);
2864 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2865 RenderTask task = taskList.GetTask(0u);
2867 // flush the queue and render once
2868 application.SendNotification();
2869 application.Render();
2870 application.SendNotification();
2871 application.Render();
2879 float screenX = 50.0f;
2880 float screenY = 50.0f;
2882 DALI_TEST_CHECK(actor.ScreenToLocal(localX, localY, screenX, screenY));
2884 DALI_TEST_CHECK(task.ViewportToLocal(actor, screenX, screenY, rtLocalX, rtLocalY));
2886 DALI_TEST_EQUALS(localX, rtLocalX, 0.01f, TEST_LOCATION);
2887 DALI_TEST_EQUALS(localY, rtLocalY, 0.01f, TEST_LOCATION);
2892 int UtcDaliRenderTaskOffscreenViewportToLocal(void)
2894 TestApplication application;
2895 Actor actor = Actor::New();
2896 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2897 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2898 actor.SetProperty(Actor::Property::POSITION, Vector2(10.0f, 10.0f));
2899 application.GetScene().Add(actor);
2901 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2902 RenderTask task = taskList.CreateTask();
2904 FrameBuffer newFrameBuffer = FrameBuffer::New(10, 10);
2905 task.SetFrameBuffer(newFrameBuffer);
2906 task.SetSourceActor(actor);
2907 task.SetScreenToFrameBufferMappingActor(actor);
2909 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2910 application.GetScene().Add(offscreenCameraActor);
2911 task.SetCameraActor(offscreenCameraActor);
2913 // flush the queue and render once
2914 application.SendNotification();
2915 application.Render();
2916 application.SendNotification();
2917 application.Render();
2925 float screenX = 50.0f;
2926 float screenY = 50.0f;
2928 DALI_TEST_CHECK(actor.ScreenToLocal(localX, localY, screenX, screenY));
2930 DALI_TEST_CHECK(task.ViewportToLocal(actor, screenX, screenY, rtLocalX, rtLocalY));
2932 DALI_TEST_EQUALS(localX, rtLocalX, 0.01f, TEST_LOCATION);
2933 DALI_TEST_EQUALS(localY, rtLocalY, 0.01f, TEST_LOCATION);
2938 int UtcDaliRenderTaskRequiresSync(void)
2940 TestApplication application;
2941 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2943 RenderTask newTask = taskList.CreateTask();
2944 newTask.SetProperty(RenderTask::Property::REQUIRES_SYNC, false);
2946 DALI_TEST_EQUALS(newTask.GetProperty<bool>(RenderTask::Property::REQUIRES_SYNC), false, TEST_LOCATION);
2947 DALI_TEST_EQUALS(newTask.GetCurrentProperty<bool>(RenderTask::Property::REQUIRES_SYNC), false, TEST_LOCATION);
2949 newTask.SetProperty(RenderTask::Property::REQUIRES_SYNC, true);
2951 DALI_TEST_EQUALS(newTask.GetProperty<bool>(RenderTask::Property::REQUIRES_SYNC), true, TEST_LOCATION);
2952 DALI_TEST_EQUALS(newTask.GetCurrentProperty<bool>(RenderTask::Property::REQUIRES_SYNC), true, TEST_LOCATION);
2957 int UtcDaliRenderTaskSetClearEnabled(void)
2959 TestApplication application;
2961 tet_infoline("UtcDaliRenderTaskSetClearEnabled");
2963 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2964 TestGlAbstraction& gl = application.GetGlAbstraction();
2966 Actor renderableActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2967 application.GetScene().Add(renderableActor);
2969 Actor rootActor = Actor::New();
2970 application.GetScene().Add(rootActor);
2972 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2973 application.GetScene().Add(offscreenCameraActor);
2975 Actor sourceActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2976 application.GetScene().Add(sourceActor);
2978 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, sourceActor, RenderTask::REFRESH_ALWAYS, false);
2980 DALI_TEST_EQUALS(gl.GetClearCountCalled(), 0, TEST_LOCATION);
2982 application.SendNotification();
2983 application.Render();
2985 // glClear should be called twice - default task and the new task.
2986 DALI_TEST_EQUALS(gl.GetClearCountCalled(), 2, TEST_LOCATION);
2988 newTask.SetClearEnabled(false);
2990 application.SendNotification();
2991 application.Render();
2993 // The count should increase by 1 - default task only.
2994 DALI_TEST_EQUALS(gl.GetClearCountCalled(), 3, TEST_LOCATION);
2999 int UtcDaliRenderTaskMoveConstrctor(void)
3001 TestApplication application;
3003 Vector4 testColor(1.0f, 2.0f, 3.0f, 4.0f);
3005 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
3006 RenderTask task = taskList.GetTask(0u);
3007 DALI_TEST_CHECK(task);
3008 DALI_TEST_EQUALS(2, task.GetBaseObject().ReferenceCount(), TEST_LOCATION);
3009 DALI_TEST_CHECK(task.GetClearColor() != testColor);
3011 task.SetClearColor(testColor);
3016 DALI_TEST_EQUALS(task.GetClearColor(), testColor, TEST_LOCATION);
3018 RenderTask move = std::move(task);
3019 DALI_TEST_CHECK(move);
3020 DALI_TEST_EQUALS(2, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
3021 DALI_TEST_EQUALS(move.GetClearColor(), testColor, TEST_LOCATION);
3022 DALI_TEST_CHECK(!task);
3027 int UtcDaliRenderTaskMoveAssignment(void)
3029 TestApplication application;
3031 Vector4 testColor(1.0f, 2.0f, 3.0f, 4.0f);
3033 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
3034 RenderTask task = taskList.GetTask(0u);
3035 DALI_TEST_CHECK(task);
3036 DALI_TEST_EQUALS(2, task.GetBaseObject().ReferenceCount(), TEST_LOCATION);
3037 DALI_TEST_CHECK(task.GetClearColor() != testColor);
3039 task.SetClearColor(testColor);
3044 DALI_TEST_EQUALS(task.GetClearColor(), testColor, TEST_LOCATION);
3047 move = std::move(task);
3048 DALI_TEST_CHECK(move);
3049 DALI_TEST_EQUALS(2, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
3050 DALI_TEST_EQUALS(move.GetClearColor(), testColor, TEST_LOCATION);
3051 DALI_TEST_CHECK(!task);
3056 int UtcDaliRenderTaskSetCullModeNegative(void)
3058 TestApplication application;
3059 Dali::RenderTask instance;
3063 instance.SetCullMode(arg1);
3064 DALI_TEST_CHECK(false); // Should not get here
3068 DALI_TEST_CHECK(true); // We expect an assert
3073 int UtcDaliRenderTaskSetViewportNegative(void)
3075 TestApplication application;
3076 Dali::RenderTask instance;
3079 Dali::Rect<int> arg1;
3080 instance.SetViewport(arg1);
3081 DALI_TEST_CHECK(false); // Should not get here
3085 DALI_TEST_CHECK(true); // We expect an assert
3090 int UtcDaliRenderTaskSetExclusiveNegative(void)
3092 TestApplication application;
3093 Dali::RenderTask instance;
3097 instance.SetExclusive(arg1);
3098 DALI_TEST_CHECK(false); // Should not get here
3102 DALI_TEST_CHECK(true); // We expect an assert
3107 int UtcDaliRenderTaskSetClearColorNegative(void)
3109 TestApplication application;
3110 Dali::RenderTask instance;
3114 instance.SetClearColor(arg1);
3115 DALI_TEST_CHECK(false); // Should not get here
3119 DALI_TEST_CHECK(true); // We expect an assert
3124 int UtcDaliRenderTaskFinishedSignalNegative(void)
3126 TestApplication application;
3127 Dali::RenderTask instance;
3130 instance.FinishedSignal();
3131 DALI_TEST_CHECK(false); // Should not get here
3135 DALI_TEST_CHECK(true); // We expect an assert
3140 int UtcDaliRenderTaskSetCameraActorNegative(void)
3142 TestApplication application;
3143 Dali::RenderTask instance;
3146 Dali::CameraActor arg1;
3147 instance.SetCameraActor(arg1);
3148 DALI_TEST_CHECK(false); // Should not get here
3152 DALI_TEST_CHECK(true); // We expect an assert
3157 int UtcDaliRenderTaskSetFrameBufferNegative(void)
3159 TestApplication application;
3160 Dali::RenderTask instance;
3163 Dali::FrameBuffer arg1;
3164 instance.SetFrameBuffer(arg1);
3165 DALI_TEST_CHECK(false); // Should not get here
3169 DALI_TEST_CHECK(true); // We expect an assert
3174 int UtcDaliRenderTaskSetRefreshRateNegative(void)
3176 TestApplication application;
3177 Dali::RenderTask instance;
3180 unsigned int arg1(0u);
3181 instance.SetRefreshRate(arg1);
3182 DALI_TEST_CHECK(false); // Should not get here
3186 DALI_TEST_CHECK(true); // We expect an assert
3191 int UtcDaliRenderTaskSetSourceActorNegative(void)
3193 TestApplication application;
3194 Dali::RenderTask instance;
3198 instance.SetSourceActor(arg1);
3199 DALI_TEST_CHECK(false); // Should not get here
3203 DALI_TEST_CHECK(true); // We expect an assert
3208 int UtcDaliRenderTaskSetClearEnabledNegative(void)
3210 TestApplication application;
3211 Dali::RenderTask instance;
3215 instance.SetClearEnabled(arg1);
3216 DALI_TEST_CHECK(false); // Should not get here
3220 DALI_TEST_CHECK(true); // We expect an assert
3225 int UtcDaliRenderTaskSetInputEnabledNegative(void)
3227 TestApplication application;
3228 Dali::RenderTask instance;
3232 instance.SetInputEnabled(arg1);
3233 DALI_TEST_CHECK(false); // Should not get here
3237 DALI_TEST_CHECK(true); // We expect an assert
3242 int UtcDaliRenderTaskSetViewportSizeNegative(void)
3244 TestApplication application;
3245 Dali::RenderTask instance;
3249 instance.SetViewportSize(arg1);
3250 DALI_TEST_CHECK(false); // Should not get here
3254 DALI_TEST_CHECK(true); // We expect an assert
3259 int UtcDaliRenderTaskSetViewportPositionNegative(void)
3261 TestApplication application;
3262 Dali::RenderTask instance;
3266 instance.SetViewportPosition(arg1);
3267 DALI_TEST_CHECK(false); // Should not get here
3271 DALI_TEST_CHECK(true); // We expect an assert
3276 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionNegative(void)
3278 TestApplication application;
3279 Dali::RenderTask instance;
3282 RenderTask::ScreenToFrameBufferFunction arg1(nullptr);
3283 instance.SetScreenToFrameBufferFunction(arg1);
3284 DALI_TEST_CHECK(false); // Should not get here
3288 DALI_TEST_CHECK(true); // We expect an assert
3293 int UtcDaliRenderTaskSetScreenToFrameBufferMappingActorNegative(void)
3295 TestApplication application;
3296 Dali::RenderTask instance;
3300 instance.SetScreenToFrameBufferMappingActor(arg1);
3301 DALI_TEST_CHECK(false); // Should not get here
3305 DALI_TEST_CHECK(true); // We expect an assert
3310 int UtcDaliRenderTaskGetCullModeNegative(void)
3312 TestApplication application;
3313 Dali::RenderTask instance;
3316 instance.GetCullMode();
3317 DALI_TEST_CHECK(false); // Should not get here
3321 DALI_TEST_CHECK(true); // We expect an assert
3326 int UtcDaliRenderTaskGetViewportNegative(void)
3328 TestApplication application;
3329 Dali::RenderTask instance;
3332 instance.GetViewport();
3333 DALI_TEST_CHECK(false); // Should not get here
3337 DALI_TEST_CHECK(true); // We expect an assert
3342 int UtcDaliRenderTaskIsExclusiveNegative(void)
3344 TestApplication application;
3345 Dali::RenderTask instance;
3348 instance.IsExclusive();
3349 DALI_TEST_CHECK(false); // Should not get here
3353 DALI_TEST_CHECK(true); // We expect an assert
3358 int UtcDaliRenderTaskGetClearColorNegative(void)
3360 TestApplication application;
3361 Dali::RenderTask instance;
3364 instance.GetClearColor();
3365 DALI_TEST_CHECK(false); // Should not get here
3369 DALI_TEST_CHECK(true); // We expect an assert
3374 int UtcDaliRenderTaskGetCameraActorNegative(void)
3376 TestApplication application;
3377 Dali::RenderTask instance;
3380 instance.GetCameraActor();
3381 DALI_TEST_CHECK(false); // Should not get here
3385 DALI_TEST_CHECK(true); // We expect an assert
3390 int UtcDaliRenderTaskGetFrameBufferNegative(void)
3392 TestApplication application;
3393 Dali::RenderTask instance;
3396 instance.GetFrameBuffer();
3397 DALI_TEST_CHECK(false); // Should not get here
3401 DALI_TEST_CHECK(true); // We expect an assert
3406 int UtcDaliRenderTaskGetRefreshRateNegative(void)
3408 TestApplication application;
3409 Dali::RenderTask instance;
3412 instance.GetRefreshRate();
3413 DALI_TEST_CHECK(false); // Should not get here
3417 DALI_TEST_CHECK(true); // We expect an assert
3422 int UtcDaliRenderTaskGetSourceActorNegative(void)
3424 TestApplication application;
3425 Dali::RenderTask instance;
3428 instance.GetSourceActor();
3429 DALI_TEST_CHECK(false); // Should not get here
3433 DALI_TEST_CHECK(true); // We expect an assert
3438 int UtcDaliRenderTaskGetClearEnabledNegative(void)
3440 TestApplication application;
3441 Dali::RenderTask instance;
3444 instance.GetClearEnabled();
3445 DALI_TEST_CHECK(false); // Should not get here
3449 DALI_TEST_CHECK(true); // We expect an assert
3454 int UtcDaliRenderTaskGetInputEnabledNegative(void)
3456 TestApplication application;
3457 Dali::RenderTask instance;
3460 instance.GetInputEnabled();
3461 DALI_TEST_CHECK(false); // Should not get here
3465 DALI_TEST_CHECK(true); // We expect an assert
3470 int UtcDaliRenderTaskViewportToLocalNegative(void)
3472 TestApplication application;
3473 Dali::RenderTask instance;
3476 Dali::Actor arg1(Actor::New());
3481 instance.ViewportToLocal(arg1, arg2, arg3, arg4, arg5);
3482 DALI_TEST_CHECK(false); // Should not get here
3486 DALI_TEST_CHECK(true); // We expect an assert
3491 int UtcDaliRenderTaskWorldToViewportNegative(void)
3493 TestApplication application;
3494 Dali::RenderTask instance;
3500 instance.WorldToViewport(arg1, arg2, arg3);
3501 DALI_TEST_CHECK(false); // Should not get here
3505 DALI_TEST_CHECK(true); // We expect an assert
3510 int UtcDaliRenderTaskGetCurrentViewportSizeNegative(void)
3512 TestApplication application;
3513 Dali::RenderTask instance;
3516 instance.GetCurrentViewportSize();
3517 DALI_TEST_CHECK(false); // Should not get here
3521 DALI_TEST_CHECK(true); // We expect an assert
3526 int UtcDaliRenderTaskGetCurrentViewportPositionNegative(void)
3528 TestApplication application;
3529 Dali::RenderTask instance;
3532 instance.GetCurrentViewportPosition();
3533 DALI_TEST_CHECK(false); // Should not get here
3537 DALI_TEST_CHECK(true); // We expect an assert
3542 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionNegative(void)
3544 TestApplication application;
3545 Dali::RenderTask instance;
3548 instance.GetScreenToFrameBufferFunction();
3549 DALI_TEST_CHECK(false); // Should not get here
3553 DALI_TEST_CHECK(true); // We expect an assert
3558 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorNegative(void)
3560 TestApplication application;
3561 Dali::RenderTask instance;
3564 instance.GetScreenToFrameBufferMappingActor();
3565 DALI_TEST_CHECK(false); // Should not get here
3569 DALI_TEST_CHECK(true); // We expect an assert
3574 int UtcDaliRenderTaskClippingMode01(void)
3576 TestApplication application;
3578 tet_infoline("Testing clipping mode: CLIP_TO_BOUNDING_BOX.\n");
3580 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3581 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3582 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
3584 enabledDisableTrace.Enable(true);
3585 scissorTrace.Enable(true);
3587 // SETUP AN OFFSCREEN RENDER TASK
3588 Actor rootActor = Actor::New();
3589 application.GetScene().Add(rootActor);
3591 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
3592 offscreenCameraActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3593 offscreenCameraActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3594 application.GetScene().Add(offscreenCameraActor);
3596 Shader shader = CreateShader();
3597 Texture image = CreateTexture();
3598 TextureSet textureSet = CreateTextureSet(image);
3600 Geometry geometry = CreateQuadGeometry();
3601 Renderer renderer = Renderer::New(geometry, shader);
3602 renderer.SetTextures(textureSet);
3604 Vector2 position(100.0f, 100.0f);
3605 Vector2 size(200.0f, 200.0f);
3606 Actor secondRootActor = Actor::New();
3607 secondRootActor.AddRenderer(renderer);
3608 secondRootActor.SetProperty(Actor::Property::POSITION, position);
3609 secondRootActor.SetProperty(Actor::Property::SIZE, size);
3610 secondRootActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3611 secondRootActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3612 secondRootActor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
3613 application.GetScene().Add(secondRootActor);
3615 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
3617 application.SendNotification();
3618 application.Render();
3620 std::ostringstream scissor;
3621 scissor << std::hex << GL_SCISSOR_TEST;
3622 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
3624 // Check the scissor was set, and the coordinates are correct.
3625 Vector4 expectResults(position.x, TestApplication::DEFAULT_SURFACE_HEIGHT - size.height - position.y, size.width, size.height); // (100, 500, 200, 200)
3626 std::stringstream compareParametersString;
3627 compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
3628 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with the expected result
3633 int UtcDaliRenderTaskClippingMode02(void)
3635 TestApplication application;
3637 tet_infoline("Testing clipping mode with the inverted camera: CLIP_TO_BOUNDING_BOX.\n");
3639 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3640 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3641 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
3643 enabledDisableTrace.Enable(true);
3644 scissorTrace.Enable(true);
3646 // SETUP AN OFFSCREEN RENDER TASK
3647 Actor rootActor = Actor::New();
3648 application.GetScene().Add(rootActor);
3650 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
3651 offscreenCameraActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3652 offscreenCameraActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3653 offscreenCameraActor.SetInvertYAxis(true);
3654 application.GetScene().Add(offscreenCameraActor);
3656 Shader shader = CreateShader();
3657 Texture image = CreateTexture();
3658 TextureSet textureSet = CreateTextureSet(image);
3660 Geometry geometry = CreateQuadGeometry();
3661 Renderer renderer = Renderer::New(geometry, shader);
3662 renderer.SetTextures(textureSet);
3664 Vector2 position(100.0f, 100.0f);
3665 Vector2 size(200.0f, 200.0f);
3666 Actor secondRootActor = Actor::New();
3667 secondRootActor.AddRenderer(renderer);
3668 secondRootActor.SetProperty(Actor::Property::POSITION, position);
3669 secondRootActor.SetProperty(Actor::Property::SIZE, size);
3670 secondRootActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3671 secondRootActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3672 secondRootActor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
3673 application.GetScene().Add(secondRootActor);
3675 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
3677 application.SendNotification();
3678 application.Render();
3680 std::ostringstream scissor;
3681 scissor << std::hex << GL_SCISSOR_TEST;
3682 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
3684 // Check the scissor was set, and the coordinates are correct.
3685 Vector4 expectResults(position.x, position.y, size.width, size.height); // (100, 100, 200, 200)
3686 std::stringstream compareParametersString;
3687 compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
3688 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with the expected result
3693 int UtcDaliRenderTaskUploadOnly(void)
3695 TestApplication application;
3697 tet_infoline("Testing RenderTask Render Once GlSync, using loaded image");
3699 // SETUP AN OFFSCREEN RENDER TASK
3700 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3701 auto& sync = application.GetGraphicsSyncImpl();
3702 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
3703 drawTrace.Enable(true);
3705 Actor rootActor = Actor::New();
3706 application.GetScene().Add(rootActor);
3708 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
3709 application.GetScene().Add(offscreenCameraActor);
3710 Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
3712 application.GetScene().Add(secondRootActor);
3714 RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
3715 bool finished = false;
3716 RenderTaskFinished renderTaskFinished(finished);
3717 newTask.FinishedSignal().Connect(&application, renderTaskFinished);
3718 application.SendNotification();
3720 DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
3722 Integration::GraphicsSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
3723 DALI_TEST_CHECK(lastSyncObj != NULL);
3724 sync.SetObjectSynced(lastSyncObj, true);
3726 application.SendNotification();
3727 application.Render(16, nullptr, true);
3729 DALI_TEST_CHECK(!finished);
3731 application.Render(16, nullptr, true);
3732 application.SendNotification();
3734 DALI_TEST_CHECK(!finished);
3738 int UtcDaliRenderTaskSetGetViewportGuideActor(void)
3740 TestApplication application;
3741 tet_infoline("Testing RenderTask with Set/Get ViewportGuideActor");
3743 Stage stage = Stage::GetCurrent();
3744 Vector2 stageSize(stage.GetSize());
3746 Actor blue = Actor::New();
3747 blue[Dali::Actor::Property::NAME] = "Blue";
3748 blue[Dali::Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
3749 blue[Dali::Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
3750 blue[Dali::Actor::Property::SIZE] = Vector2(300, 300);
3751 blue[Dali::Actor::Property::POSITION] = Vector2(0, 0);
3755 RenderTaskList renderTaskList = stage.GetRenderTaskList();
3756 RenderTask renderTask = renderTaskList.CreateTask();
3758 renderTask.SetViewportGuideActor(blue);
3760 Actor actor = renderTask.GetViewportGuideActor();
3761 DALI_TEST_EQUALS(actor, blue, TEST_LOCATION);
3763 renderTask.ResetViewportGuideActor();
3764 actor = renderTask.GetViewportGuideActor();
3766 DALI_TEST_CHECK(!actor);
3771 int UtcDaliRenderTaskViewportGuideActor(void)
3773 TestApplication application;
3774 tet_infoline("Testing RenderTask with ViewportGuideActor");
3776 Stage stage = Stage::GetCurrent();
3777 Vector2 stageSize(stage.GetSize());
3779 Actor blue = Actor::New();
3780 blue[Dali::Actor::Property::NAME] = "Blue";
3781 blue[Dali::Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
3782 blue[Dali::Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
3783 blue[Dali::Actor::Property::SIZE] = Vector2(300, 300);
3784 blue[Dali::Actor::Property::POSITION] = Vector2(0, 0);
3786 Geometry geometry = Geometry::New();
3787 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
3788 Renderer renderer = Renderer::New(geometry, shader);
3789 blue.AddRenderer(renderer);
3793 RenderTaskList renderTaskList = stage.GetRenderTaskList();
3794 RenderTask renderTask = renderTaskList.CreateTask();
3796 Dali::CameraActor cameraActor = Dali::CameraActor::New(stageSize);
3797 cameraActor[Dali::Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
3798 cameraActor[Dali::Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
3799 stage.Add(cameraActor);
3801 renderTask.SetExclusive(true);
3802 renderTask.SetInputEnabled(true);
3803 renderTask.SetCameraActor(cameraActor);
3804 renderTask.SetSourceActor(blue);
3805 renderTask.SetViewportGuideActor(blue);
3807 // Render and notify
3808 application.SendNotification();
3809 application.Render(16);
3811 Vector2 viewportPosition = renderTask.GetCurrentViewportPosition();
3812 Vector2 viewportSize = renderTask.GetCurrentViewportSize();
3814 DALI_TEST_EQUALS(viewportSize, Vector2(300, 300), TEST_LOCATION);
3815 DALI_TEST_EQUALS(viewportPosition, Vector2(90, 250), TEST_LOCATION);
3820 int UtcDaliRenderTaskViewportGuideActor02(void)
3822 TestApplication application(
3823 TestApplication::DEFAULT_SURFACE_WIDTH,
3824 TestApplication::DEFAULT_SURFACE_HEIGHT,
3825 TestApplication::DEFAULT_HORIZONTAL_DPI,
3826 TestApplication::DEFAULT_VERTICAL_DPI,
3829 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3830 TraceCallStack& callStack = glAbstraction.GetViewportTrace();
3831 glAbstraction.EnableViewportCallTrace(true);
3832 tet_infoline("Testing RenderTask with ViewportGuideActor02");
3834 Stage stage = Stage::GetCurrent();
3835 Vector2 stageSize(stage.GetSize());
3837 // Render and notify
3838 application.SendNotification();
3839 application.Render(16);
3840 glAbstraction.ResetViewportCallStack();
3842 Geometry geometry = Geometry::New();
3843 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
3844 Renderer renderer = Renderer::New(geometry, shader);
3846 Actor blue = Actor::New();
3847 blue[Dali::Actor::Property::NAME] = "Blue";
3848 blue[Dali::Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
3849 blue[Dali::Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
3850 blue[Dali::Actor::Property::SIZE] = Vector2(400, 300);
3851 blue[Dali::Actor::Property::POSITION] = Vector2(100, 50);
3852 blue.AddRenderer(renderer);
3855 Actor green = Actor::New();
3856 green[Dali::Actor::Property::NAME] = "Green";
3857 green[Dali::Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
3858 green[Dali::Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
3859 green[Dali::Actor::Property::SIZE] = Vector2(400, 300);
3860 green[Dali::Actor::Property::POSITION] = Vector2(100, 50);
3861 green.AddRenderer(renderer);
3864 RenderTaskList renderTaskList = stage.GetRenderTaskList();
3865 RenderTask renderTask = renderTaskList.CreateTask();
3867 Dali::CameraActor cameraActor = Dali::CameraActor::New(stageSize);
3868 cameraActor[Dali::Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
3869 cameraActor[Dali::Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
3870 stage.Add(cameraActor);
3872 renderTask.SetExclusive(true);
3873 renderTask.SetInputEnabled(true);
3874 renderTask.SetCameraActor(cameraActor);
3875 renderTask.SetSourceActor(blue);
3876 renderTask.SetViewportGuideActor(blue);
3878 application.GetScene().SurfaceRotated(static_cast<float>(TestApplication::DEFAULT_SURFACE_HEIGHT),
3879 static_cast<float>(TestApplication::DEFAULT_SURFACE_WIDTH),
3883 // Render and notify
3884 application.SendNotification();
3885 application.Render(16);
3887 std::string viewportParams1("50, 100, 300, 400"); // to match newSize
3888 std::string viewportParams2("0, 0, 480, 800"); // to match newSize
3890 // Check that the viewport is handled properly
3891 DALI_TEST_CHECK(callStack.FindIndexFromMethodAndParams("Viewport", viewportParams1) >= 0);
3892 DALI_TEST_CHECK(callStack.FindIndexFromMethodAndParams("Viewport", viewportParams2) >= 0);
3897 int UtcDaliRenderTaskViewportGuideActor03(void)
3899 TestApplication application(
3900 TestApplication::DEFAULT_SURFACE_WIDTH,
3901 TestApplication::DEFAULT_SURFACE_HEIGHT,
3902 TestApplication::DEFAULT_HORIZONTAL_DPI,
3903 TestApplication::DEFAULT_VERTICAL_DPI,
3907 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3908 TraceCallStack& callStack = glAbstraction.GetViewportTrace();
3909 glAbstraction.EnableViewportCallTrace(true);
3910 tet_infoline("Testing that adding a viewport guide actor to RenderTask will change the viewport");
3912 Stage stage = Stage::GetCurrent();
3913 Vector2 stageSize(stage.GetSize());
3915 // Render and notify
3916 application.SendNotification();
3917 application.Render(16);
3918 glAbstraction.ResetViewportCallStack();
3920 Geometry geometry = Geometry::New();
3921 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
3922 Renderer renderer = Renderer::New(geometry, shader);
3924 Actor blue = Actor::New();
3925 blue[Dali::Actor::Property::NAME] = "Blue";
3926 blue[Dali::Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
3927 blue[Dali::Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
3928 blue[Dali::Actor::Property::SIZE] = Vector2(400, 300);
3929 blue[Dali::Actor::Property::POSITION] = Vector2(100, 50);
3930 blue.AddRenderer(renderer);
3933 Actor green = Actor::New();
3934 green[Dali::Actor::Property::NAME] = "Green";
3935 green[Dali::Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
3936 green[Dali::Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
3937 green[Dali::Actor::Property::SIZE] = Vector2(400, 300);
3938 green[Dali::Actor::Property::POSITION] = Vector2(100, 50);
3939 green.AddRenderer(renderer);
3942 RenderTaskList renderTaskList = stage.GetRenderTaskList();
3943 RenderTask renderTask = renderTaskList.CreateTask();
3945 Dali::CameraActor cameraActor = Dali::CameraActor::New(stageSize);
3946 cameraActor[Dali::Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
3947 cameraActor[Dali::Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
3948 stage.Add(cameraActor);
3950 renderTask.SetExclusive(true);
3951 renderTask.SetInputEnabled(true);
3952 renderTask.SetCameraActor(cameraActor);
3953 renderTask.SetSourceActor(green);
3955 Viewport viewport(75, 55, 150, 250);
3956 renderTask.SetViewport(viewport);
3958 // Render and notify
3959 application.SendNotification();
3960 application.Render(16);
3962 // Note Y pos: 800 - (250+55) = 495
3963 std::string viewportParams1("75, 495, 150, 250");
3964 DALI_TEST_CHECK(callStack.FindIndexFromMethodAndParams("Viewport", viewportParams1) >= 0);
3965 glAbstraction.ResetViewportCallStack();
3967 // Update to use viewport guide actor instead.
3968 renderTask.SetViewportGuideActor(blue);
3970 // Render and notify
3971 application.SendNotification();
3972 application.Render(16);
3974 // Note: Y pos: 800 - (300+50) = 450
3975 std::string viewportParams2("100, 450, 400, 300");
3976 DALI_TEST_CHECK(callStack.FindIndexFromMethodAndParams("Viewport", viewportParams2) >= 0);
3977 tet_infoline("Testing that removing viewport guide actor from RenderTask will revert the viewport");
3978 glAbstraction.ResetViewportCallStack();
3980 // Remove guide actor, expect that the viewport is reset to its original values
3981 renderTask.SetViewportGuideActor(Actor());
3982 application.SendNotification();
3983 application.Render(16);
3985 // Currently, update manager does not consider that added Resetters should cause another
3986 // update; this is probably right. But, we have to then force another update for the resetter to trigger, and this will register as un-necessary in the test output.
3988 application.SendNotification();
3989 application.Render(16);
3991 DALI_TEST_CHECK(callStack.FindIndexFromMethodAndParams("Viewport", viewportParams1) >= 0);
3996 int UtcDaliRenderTaskViewportGuideActor04(void)
3998 TestApplication application(
3999 TestApplication::DEFAULT_SURFACE_WIDTH,
4000 TestApplication::DEFAULT_SURFACE_HEIGHT,
4001 TestApplication::DEFAULT_HORIZONTAL_DPI,
4002 TestApplication::DEFAULT_VERTICAL_DPI,
4006 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4007 TraceCallStack& callStack = glAbstraction.GetViewportTrace();
4008 glAbstraction.EnableViewportCallTrace(true);
4009 tet_infoline("Testing that adding a viewport guide actor to RenderTask will change the viewport");
4011 Stage stage = Stage::GetCurrent();
4012 Vector2 stageSize(stage.GetSize());
4014 // Render and notify
4015 application.SendNotification();
4016 application.Render(16);
4017 glAbstraction.ResetViewportCallStack();
4019 Geometry geometry = Geometry::New();
4020 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
4021 Renderer renderer = Renderer::New(geometry, shader);
4023 Actor blue = Actor::New();
4024 blue[Dali::Actor::Property::NAME] = "Blue";
4025 blue[Dali::Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
4026 blue[Dali::Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
4027 blue[Dali::Actor::Property::SIZE] = Vector2(400, 300);
4028 blue[Dali::Actor::Property::POSITION] = Vector2(100, 50);
4029 blue.AddRenderer(renderer);
4032 Actor green = Actor::New();
4033 green[Dali::Actor::Property::NAME] = "Green";
4034 green[Dali::Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
4035 green[Dali::Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
4036 green[Dali::Actor::Property::SIZE] = Vector2(400, 300);
4037 green[Dali::Actor::Property::POSITION] = Vector2(100, 50);
4038 green.AddRenderer(renderer);
4041 RenderTaskList renderTaskList = stage.GetRenderTaskList();
4042 RenderTask renderTask = renderTaskList.CreateTask();
4044 Dali::CameraActor cameraActor = Dali::CameraActor::New(stageSize);
4045 cameraActor[Dali::Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
4046 cameraActor[Dali::Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
4047 stage.Add(cameraActor);
4049 renderTask.SetExclusive(true);
4050 renderTask.SetInputEnabled(true);
4051 renderTask.SetCameraActor(cameraActor);
4052 renderTask.SetSourceActor(green);
4054 Viewport viewport(75, 55, 150, 250);
4055 renderTask.SetViewport(viewport);
4057 // Render and notify
4058 application.SendNotification();
4059 application.Render(16);
4061 // Note Y pos: 800 - (250+55) = 495
4062 std::string viewportParams1("75, 495, 150, 250");
4063 DALI_TEST_CHECK(callStack.FindIndexFromMethodAndParams("Viewport", viewportParams1) >= 0);
4064 glAbstraction.ResetViewportCallStack();
4066 // Update to use viewport guide actor instead.
4067 renderTask.SetViewportGuideActor(blue);
4069 // Render and notify
4070 application.SendNotification();
4071 application.Render(16);
4073 std::string viewportParams2("100, 450, 400, 300");
4074 DALI_TEST_CHECK(callStack.FindIndexFromMethodAndParams("Viewport", viewportParams2) >= 0);
4075 tet_infoline("Testing that removing viewport guide actor from RenderTask will revert the viewport");
4077 glAbstraction.ResetViewportCallStack();
4079 // Remove guide actor, expect that the viewport is reset to it's original values
4080 renderTask.ResetViewportGuideActor();
4081 application.SendNotification();
4082 application.Render(16);
4084 // Currently, update manager does not consider that added Resetters should cause another
4085 // update; this is probably right. But, we have to then force another update for the resetter
4086 // to trigger, and this will register as un-necessary in the test output.
4087 application.SendNotification();
4088 application.Render(16);
4090 DALI_TEST_CHECK(callStack.FindIndexFromMethodAndParams("Viewport", viewportParams1) >= 0);
4092 // This should remove the baking resetters, but is again going to show up
4093 // as unnecessary. Also try and figure out if we can test the dirty flags
4094 // here, somehow (Can at least check the property's dirty flags in the debugger).
4095 application.SendNotification();
4096 application.Render(16);
4101 int UtcDaliRenderTaskSetPartialUpdate(void)
4103 TestApplication application(
4104 TestApplication::DEFAULT_SURFACE_WIDTH,
4105 TestApplication::DEFAULT_SURFACE_HEIGHT,
4106 TestApplication::DEFAULT_HORIZONTAL_DPI,
4107 TestApplication::DEFAULT_VERTICAL_DPI,
4111 tet_infoline("Check the damaged rects with render task");
4113 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
4115 Actor actor = CreateRenderableActor();
4116 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4117 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
4118 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
4119 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4120 application.GetScene().Add(actor);
4122 Actor rootActor = CreateRenderableActor();
4123 rootActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4124 rootActor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
4125 rootActor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
4126 rootActor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4127 application.GetScene().Add(rootActor);
4129 CameraActor cameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
4130 cameraActor.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4131 cameraActor.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4132 application.GetScene().Add(cameraActor);
4134 Texture frameBufferTexture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGB888, 16, 16);
4135 FrameBuffer frameBuffer = FrameBuffer::New(frameBufferTexture.GetWidth(), frameBufferTexture.GetHeight());
4136 frameBuffer.AttachColorTexture(frameBufferTexture);
4138 // Create a RenderTask and set a framebuffer
4139 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
4140 RenderTask newTask = taskList.CreateTask();
4141 newTask.SetCameraActor(cameraActor);
4142 newTask.SetSourceActor(rootActor);
4143 newTask.SetInputEnabled(false);
4144 newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
4145 newTask.SetClearEnabled(true);
4146 newTask.SetExclusive(true);
4147 newTask.SetRefreshRate(RenderTask::REFRESH_ALWAYS);
4148 newTask.SetFrameBuffer(frameBuffer);
4150 application.SendNotification();
4152 std::vector<Rect<int>> damagedRects;
4153 Rect<int> clippingRect;
4155 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
4157 // Full update if there is off-screen rendering
4158 clippingRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4159 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
4160 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
4162 application.RenderWithPartialUpdate(damagedRects, clippingRect);
4163 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
4164 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
4165 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
4166 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
4168 // Remove framebuffer
4169 newTask.SetFrameBuffer(FrameBuffer());
4171 application.SendNotification();
4173 damagedRects.clear();
4174 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
4177 clippingRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4178 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
4179 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
4181 application.RenderWithPartialUpdate(damagedRects, clippingRect);
4183 // Set invalid viewport of the render task
4184 newTask.SetViewportSize(Vector2(-100.0f, -100.0f));
4186 application.SendNotification();
4188 damagedRects.clear();
4189 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
4191 // Full update because the camera orientation is changed
4192 clippingRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4193 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
4194 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
4196 application.RenderWithPartialUpdate(damagedRects, clippingRect);
4198 newTask.SetViewportSize(Vector2(0.0f, 0.0f));
4200 // Change orientation of offscreen camera
4201 cameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS));
4203 application.SendNotification();
4205 damagedRects.clear();
4206 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
4208 // Full update because the camera orientation is changed
4209 clippingRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4210 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
4211 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
4213 application.RenderWithPartialUpdate(damagedRects, clippingRect);
4215 // Change camera target
4216 cameraActor.SetTargetPosition(Vector3(10.0f, 10.0f, 0.0f));
4218 application.SendNotification();
4220 damagedRects.clear();
4221 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
4223 // Full update because the camera is moved
4224 clippingRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4225 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
4226 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
4228 application.RenderWithPartialUpdate(damagedRects, clippingRect);
4233 int UtcDaliRenderTaskRenderPassTag(void)
4235 TestApplication application;
4236 tet_infoline("Testing RenderTask with RenderPassTag");
4238 Stage stage = Stage::GetCurrent();
4239 Vector2 stageSize(stage.GetSize());
4241 Actor blue = Actor::New();
4242 blue[Dali::Actor::Property::NAME] = "Blue";
4243 blue[Dali::Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
4244 blue[Dali::Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
4245 blue[Dali::Actor::Property::SIZE] = Vector2(300, 300);
4246 blue[Dali::Actor::Property::POSITION] = Vector2(0, 0);
4248 Geometry geometry = Geometry::New();
4250 Property::Map map[2];
4251 map[0]["vertex"] = SHADER_COLOR_TEST_SHADER_VERT1.data();
4252 map[0]["fragment"] = SHADER_COLOR_TEST_SHADER_FRAG.data();
4253 map[0]["renderPassTag"] = 0;
4255 map[1]["vertex"] = SHADER_COLOR_TEST_SHADER_VERT2.data();
4256 map[1]["fragment"] = SHADER_COLOR_TEST_SHADER_FRAG.data();
4257 map[1]["renderPassTag"] = 1;
4259 Property::Array array;
4260 array.PushBack(map[0]);
4261 array.PushBack(map[1]);
4263 Shader shader = Shader::New(array);
4264 Renderer renderer = Renderer::New(geometry, shader);
4265 blue.AddRenderer(renderer);
4269 auto& gfx = application.GetGraphicsController();
4270 gfx.mCallStack.EnableLogging(true);
4272 RenderTaskList renderTaskList = stage.GetRenderTaskList();
4273 DALI_TEST_EQUALS(0u, renderTaskList.GetTask(0u).GetRenderPassTag(), TEST_LOCATION);
4274 // Render and notify
4275 application.SendNotification();
4276 application.Render(16);
4277 DALI_TEST_CHECK(gfx.mCallStack.FindMethod("CreatePipeline"));
4278 gfx.mCallStack.Reset();
4279 DALI_TEST_EQUALS(0u, renderTaskList.GetTask(0u).GetRenderPassTag(), TEST_LOCATION);
4281 renderTaskList.GetTask(0u).SetRenderPassTag(1u);
4282 DALI_TEST_EQUALS(1u, renderTaskList.GetTask(0u).GetRenderPassTag(), TEST_LOCATION);
4283 // Render and notify
4284 application.SendNotification();
4285 application.Render(16);
4286 DALI_TEST_CHECK(gfx.mCallStack.FindMethod("CreatePipeline"));
4287 gfx.mCallStack.Reset();
4288 DALI_TEST_EQUALS(1u, renderTaskList.GetTask(0u).GetRenderPassTag(), TEST_LOCATION);
4290 renderTaskList.GetTask(0u).SetRenderPassTag(0u);
4291 DALI_TEST_EQUALS(0u, renderTaskList.GetTask(0u).GetRenderPassTag(), TEST_LOCATION);
4292 // Render and notify
4293 application.SendNotification();
4294 application.Render(16);
4295 DALI_TEST_CHECK(!gfx.mCallStack.FindMethod("CreatePipeline"));
4296 gfx.mCallStack.Reset();
4297 DALI_TEST_EQUALS(0u, renderTaskList.GetTask(0u).GetRenderPassTag(), TEST_LOCATION);
4299 renderTaskList.GetTask(0u).SetRenderPassTag(1u);
4300 DALI_TEST_EQUALS(1u, renderTaskList.GetTask(0u).GetRenderPassTag(), TEST_LOCATION);
4301 // Render and notify
4302 application.SendNotification();
4303 application.Render(16);
4304 DALI_TEST_CHECK(!gfx.mCallStack.FindMethod("CreatePipeline"));
4305 gfx.mCallStack.Reset();
4306 DALI_TEST_EQUALS(1u, renderTaskList.GetTask(0u).GetRenderPassTag(), TEST_LOCATION);
4311 int UtcDaliRenderTaskWithWrongShaderData(void)
4313 TestApplication application;
4314 tet_infoline("Testing RenderTask with wrong shader data");
4316 Stage stage = Stage::GetCurrent();
4317 Vector2 stageSize(stage.GetSize());
4319 Actor blue = Actor::New();
4320 blue[Dali::Actor::Property::NAME] = "Blue";
4321 blue[Dali::Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
4322 blue[Dali::Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
4323 blue[Dali::Actor::Property::SIZE] = Vector2(300, 300);
4324 blue[Dali::Actor::Property::POSITION] = Vector2(0, 0);
4326 Geometry geometry = Geometry::New();
4328 Shader shader = Shader::New(Property::Value(10.0f));
4329 Renderer renderer = Renderer::New(geometry, shader);
4330 blue.AddRenderer(renderer);
4334 auto& gfx = application.GetGraphicsController();
4336 RenderTaskList renderTaskList = stage.GetRenderTaskList();
4337 DALI_TEST_EQUALS(0u, renderTaskList.GetTask(0u).GetRenderPassTag(), TEST_LOCATION);
4338 // Render and notify
4339 application.SendNotification();
4340 application.Render(16);
4341 DALI_TEST_CHECK(!gfx.mCallStack.FindMethod("CreatePipeline"));
4342 gfx.mCallStack.Reset();
4343 DALI_TEST_EQUALS(0u, renderTaskList.GetTask(0u).GetRenderPassTag(), TEST_LOCATION);
4348 int UtcDaliRenderTaskOrderIndex01(void)
4350 TestApplication application;
4351 tet_infoline("Testing RenderTask with OrderIndex");
4353 Stage stage = Stage::GetCurrent();
4354 Vector2 stageSize(stage.GetSize());
4356 RenderTaskList renderTaskList = stage.GetRenderTaskList();
4357 RenderTask renderTask1 = renderTaskList.CreateTask();
4359 application.SendNotification();
4360 uint32_t answer1[2] = {0u, 0u};
4361 DALI_TEST_EQUALS(2, renderTaskList.GetTaskCount(), TEST_LOCATION);
4362 for(uint32_t i = 0; i < 2; ++i)
4364 DALI_TEST_EQUALS(answer1[i], renderTaskList.GetTask(i).GetOrderIndex(), TEST_LOCATION);
4367 RenderTask renderTask2 = renderTaskList.CreateTask();
4368 application.SendNotification();
4369 int32_t answer2[3] = {0u, 0u, 0u};
4370 DALI_TEST_EQUALS(3, renderTaskList.GetTaskCount(), TEST_LOCATION);
4371 for(uint32_t i = 0; i < 3; ++i)
4373 DALI_TEST_EQUALS(answer2[i], renderTaskList.GetTask(i).GetOrderIndex(), TEST_LOCATION);
4376 RenderTask renderTask3 = renderTaskList.CreateTask();
4377 application.SendNotification();
4378 int32_t answer3[4] = {0u, 0u, 0u, 0u};
4379 DALI_TEST_EQUALS(4, renderTaskList.GetTaskCount(), TEST_LOCATION);
4380 for(uint32_t i = 0; i < 4; ++i)
4382 DALI_TEST_EQUALS(answer3[i], renderTaskList.GetTask(i).GetOrderIndex(), TEST_LOCATION);
4385 renderTask1.SetOrderIndex(3);
4386 application.SendNotification();
4387 int32_t answer4[4] = {0u, 0u, 0u, 3u};
4388 for(uint32_t i = 0; i < 4; ++i)
4390 DALI_TEST_EQUALS(answer4[i], renderTaskList.GetTask(i).GetOrderIndex(), TEST_LOCATION);
4393 renderTask2.SetOrderIndex(7);
4394 application.SendNotification();
4395 int32_t answer5[4] = {0u, 0u, 3u, 7u};
4396 for(uint32_t i = 0; i < 4; ++i)
4398 DALI_TEST_EQUALS(answer5[i], renderTaskList.GetTask(i).GetOrderIndex(), TEST_LOCATION);
4401 Dali::Integration::Scene scene = application.GetScene();
4402 scene.GetOverlayLayer();
4403 application.SendNotification();
4404 DALI_TEST_EQUALS(5, renderTaskList.GetTaskCount(), TEST_LOCATION);
4405 int32_t answer6[5] = {0u, 0u, 3u, 7u, INT32_MAX};
4406 for(uint32_t i = 0; i < 5; ++i)
4408 DALI_TEST_EQUALS(answer6[i], renderTaskList.GetTask(i).GetOrderIndex(), TEST_LOCATION);
4411 renderTask3.SetOrderIndex(4);
4412 application.SendNotification();
4413 int32_t answer7[5] = {0u, 3u, 4u, 7u, INT32_MAX};
4414 for(uint32_t i = 0; i < 5; ++i)
4416 DALI_TEST_EQUALS(answer7[i], renderTaskList.GetTask(i).GetOrderIndex(), TEST_LOCATION);
4419 renderTask2.SetOrderIndex(2);
4420 application.SendNotification();
4421 int32_t answer8[5] = {0u, 2u, 3u, 4u, INT32_MAX};
4422 for(uint32_t i = 0; i < 5; ++i)
4424 DALI_TEST_EQUALS(answer8[i], renderTaskList.GetTask(i).GetOrderIndex(), TEST_LOCATION);
4430 int UtcDaliRenderTaskOrderIndex02(void)
4432 TestApplication application;
4433 tet_infoline("Testing RenderTask with OrderIndex");
4435 Stage stage = Stage::GetCurrent();
4436 Vector2 stageSize(stage.GetSize());
4438 RenderTaskList renderTaskList = stage.GetRenderTaskList();
4439 RenderTask renderTask1 = renderTaskList.CreateTask();
4440 application.SendNotification();
4441 DALI_TEST_EQUALS(renderTask1, renderTaskList.GetTask(1u), TEST_LOCATION);
4443 RenderTask renderTask2 = renderTaskList.CreateTask();
4444 application.SendNotification();
4445 DALI_TEST_EQUALS(renderTask1, renderTaskList.GetTask(1u), TEST_LOCATION);
4446 DALI_TEST_EQUALS(renderTask2, renderTaskList.GetTask(2u), TEST_LOCATION);
4448 RenderTask renderTask3 = renderTaskList.CreateTask();
4449 application.SendNotification();
4450 DALI_TEST_EQUALS(renderTask1, renderTaskList.GetTask(1u), TEST_LOCATION);
4451 DALI_TEST_EQUALS(renderTask2, renderTaskList.GetTask(2u), TEST_LOCATION);
4452 DALI_TEST_EQUALS(renderTask3, renderTaskList.GetTask(3u), TEST_LOCATION);
4454 RenderTask renderTask4 = renderTaskList.CreateTask();
4455 application.SendNotification();
4456 DALI_TEST_EQUALS(renderTask1, renderTaskList.GetTask(1u), TEST_LOCATION);
4457 DALI_TEST_EQUALS(renderTask2, renderTaskList.GetTask(2u), TEST_LOCATION);
4458 DALI_TEST_EQUALS(renderTask3, renderTaskList.GetTask(3u), TEST_LOCATION);
4459 DALI_TEST_EQUALS(renderTask4, renderTaskList.GetTask(4u), TEST_LOCATION);
4461 renderTask2.SetOrderIndex(2);
4462 application.SendNotification();
4463 DALI_TEST_EQUALS(renderTask1, renderTaskList.GetTask(1u), TEST_LOCATION);
4464 DALI_TEST_EQUALS(renderTask3, renderTaskList.GetTask(2u), TEST_LOCATION);
4465 DALI_TEST_EQUALS(renderTask4, renderTaskList.GetTask(3u), TEST_LOCATION);
4466 DALI_TEST_EQUALS(renderTask2, renderTaskList.GetTask(4u), TEST_LOCATION);
4471 int UtcDaliRenderTaskGetRenderTaskId(void)
4473 TestApplication application;
4474 tet_infoline("Testing RenderTask Id get");
4476 Stage stage = Stage::GetCurrent();
4477 Vector2 stageSize(stage.GetSize());
4479 RenderTaskList renderTaskList = stage.GetRenderTaskList();
4481 RenderTask renderTask1 = renderTaskList.CreateTask();
4482 RenderTask renderTask2 = renderTaskList.CreateTask();
4483 RenderTask renderTask3 = renderTaskList.CreateTask();
4485 DALI_TEST_CHECK(renderTask1.GetRenderTaskId() != 0u);
4486 DALI_TEST_CHECK(renderTask2.GetRenderTaskId() != 0u);
4487 DALI_TEST_CHECK(renderTask3.GetRenderTaskId() != 0u);
4489 DALI_TEST_CHECK(renderTask1.GetRenderTaskId() != renderTask2.GetRenderTaskId());
4490 DALI_TEST_CHECK(renderTask2.GetRenderTaskId() != renderTask3.GetRenderTaskId());
4491 DALI_TEST_CHECK(renderTask3.GetRenderTaskId() != renderTask1.GetRenderTaskId());