[dali_2.3.24] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-RenderTask.cpp
1 /*
2  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
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>
23 #include <stdlib.h>
24 #include <test-actor-utils.h>
25 #include <test-native-image.h>
26
27 #include <iostream>
28
29 #define BOOLSTR(x) ((x) ? "T" : "F")
30
31 //& set: DaliRenderTask
32
33 using namespace Dali;
34
35 void utc_dali_render_task_startup(void)
36 {
37   test_return_value = TET_UNDEF;
38 }
39
40 void utc_dali_render_task_cleanup(void)
41 {
42   test_return_value = TET_PASS;
43 }
44
45 /**
46  * APIs:
47  *
48  * Constructor, Destructor, DownCast, New, copy constructor, assignment operator
49  *
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
74  * SetCullMode
75  * GetCullMode
76  * SetRefreshRate                      Many
77  * GetRefreshRate                      1+ve
78  * FinishedSignal                      1+ve
79  */
80
81 namespace // unnamed namespace
82 {
83 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
84
85 // Test shader codes
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;
90
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;
98
99 vec4 ComputeVertexPosition()
100 {
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);
105 }
106
107 void main()
108 {
109   gl_Position = uMvpMatrix * ComputeVertexPosition();
110 }
111 )"};
112
113 // Test shader codes
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;
118
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;
126
127 vec4 ComputeVertexPosition2()
128 {
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);
133 }
134
135 void main()
136 {
137   gl_Position = uMvpMatrix * ComputeVertexPosition2();
138 }
139 )"};
140
141 const std::string_view SHADER_COLOR_TEST_SHADER_FRAG{
142   R"(
143 void main()
144 {
145   OUT_COLOR = vec4(0.0, 0.0, 1.0, 1.0);
146 }
147 )"};
148
149 /*
150  * Simulate time passed by.
151  *
152  * @note this will always process at least 1 frame (1/60 sec)
153  *
154  * @param application Test application instance
155  * @param duration Time to pass in milliseconds.
156  * @return The actual time passed in milliseconds
157  */
158 int Wait(TestApplication& application, int duration = 0)
159 {
160   int time = 0;
161
162   for(int i = 0; i <= (duration / RENDER_FRAME_INTERVAL); i++)
163   {
164     application.SendNotification();
165     application.Render(RENDER_FRAME_INTERVAL);
166     time += RENDER_FRAME_INTERVAL;
167   }
168
169   return time;
170 }
171
172 struct RenderTaskFinished
173 {
174   RenderTaskFinished(bool& finished)
175   : finished(finished)
176   {
177   }
178
179   void operator()(RenderTask& renderTask)
180   {
181     finished = true;
182   }
183
184   bool& finished;
185 };
186
187 struct RenderTaskFinishedRemoveSource
188 {
189   RenderTaskFinishedRemoveSource(bool& finished)
190   : finished(finished),
191     finishedOnce(false)
192   {
193   }
194
195   void operator()(RenderTask& renderTask)
196   {
197     DALI_TEST_CHECK(finishedOnce == false);
198     finished       = true;
199     finishedOnce   = true;
200     Actor srcActor = renderTask.GetSourceActor();
201     UnparentAndReset(srcActor);
202   }
203
204   bool& finished;
205   bool  finishedOnce;
206 };
207
208 struct RenderTaskFinishedRenderAgain
209 {
210   RenderTaskFinishedRenderAgain(bool& finished)
211   : finished(finished),
212     finishedOnce(false)
213   {
214   }
215
216   void operator()(RenderTask& renderTask)
217   {
218     DALI_TEST_CHECK(finishedOnce == false);
219     finished     = true;
220     finishedOnce = true;
221     renderTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
222   }
223
224   bool& finished;
225   bool  finishedOnce;
226 };
227
228 bool TestScreenToFrameBufferFunction(Vector2& coordinates)
229 {
230   coordinates = coordinates + Vector2(1, 2);
231
232   return true;
233 }
234
235 Actor CreateRenderableActorSuccess(TestApplication& application, std::string filename)
236 {
237   Actor actor = CreateRenderableActor();
238   actor.SetProperty(Actor::Property::SIZE, Vector2(80.0f, 80.0f));
239   return actor;
240 }
241
242 Texture CreateTexture(void)
243 {
244   return Dali::CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 80, 80);
245 }
246
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,
252                             bool             glSync,
253                             uint32_t         frameBufferWidth  = 10,
254                             uint32_t         frameBufferHeight = 10)
255 {
256   // Change main render task to use a different root
257   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
258   taskList.GetTask(0u).SetSourceActor(rootActor);
259
260   FrameBuffer frameBuffer = FrameBuffer::New(frameBufferWidth, frameBufferHeight);
261   if(glSync)
262   {
263     NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(frameBufferWidth, frameBufferHeight);
264     Texture                 texture            = Texture::New(*testNativeImagePtr);
265     frameBuffer.AttachColorTexture(texture);
266   }
267
268   // Don't draw output framebuffer // '
269
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);
280   return newTask;
281 }
282
283 bool UpdateRender(TestApplication& application, TraceCallStack& callStack, bool testDrawn, bool& finishedSig, bool testFinished, bool testKeepUpdating, int lineNumber)
284 {
285   finishedSig = false;
286   callStack.Reset();
287
288   tet_printf("TestApplication::UpdateRender().\n");
289
290   application.Render(16);
291   application.SendNotification();
292
293   bool sigPassed = false;
294   if(testFinished)
295   {
296     sigPassed = finishedSig;
297   }
298   else
299   {
300     sigPassed = !finishedSig;
301   }
302
303   bool drawResult = callStack.FindMethod("DrawElements") || callStack.FindMethod("DrawArrays");
304
305   bool drawPassed = false;
306   if(testDrawn)
307   {
308     drawPassed = drawResult;
309   }
310   else
311   {
312     drawPassed = !drawResult;
313   }
314
315   bool keepUpdating       = (application.GetUpdateStatus() != 0);
316   bool keepUpdatingPassed = false;
317   if(testKeepUpdating)
318   {
319     keepUpdatingPassed = keepUpdating;
320   }
321   else
322   {
323     keepUpdatingPassed = !keepUpdating;
324   }
325
326   bool result = (sigPassed && drawPassed && keepUpdatingPassed);
327
328   tet_printf("UpdateRender: Expected: Draw:%s Signal:%s KeepUpdating: %s  Actual: Draw:%s  Signal:%s KeepUpdating: %s  %s, line %d\n",
329              BOOLSTR(testDrawn),
330              BOOLSTR(testFinished),
331              BOOLSTR(testKeepUpdating),
332              BOOLSTR(drawResult),
333              BOOLSTR(finishedSig),
334              BOOLSTR(keepUpdating),
335              result ? "Passed" : "Failed",
336              lineNumber);
337
338   return result;
339 }
340
341 } // unnamed namespace
342
343 /****************************************************************************************************/
344 /****************************************************************************************************/
345 /********************************   TEST CASES BELOW   **********************************************/
346 /****************************************************************************************************/
347 /****************************************************************************************************/
348
349 int UtcDaliRenderTaskDownCast01(void)
350 {
351   TestApplication application;
352
353   tet_infoline("Testing RenderTask::DownCast()");
354
355   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
356
357   BaseHandle base = taskList.GetTask(0u);
358   DALI_TEST_CHECK(base);
359
360   RenderTask task = RenderTask::DownCast(base);
361   DALI_TEST_CHECK(task);
362
363   // Try calling a method
364   DALI_TEST_CHECK(task.GetSourceActor());
365   END_TEST;
366 }
367
368 int UtcDaliRenderTaskDownCast02(void)
369 {
370   TestApplication application;
371
372   tet_infoline("Testing RenderTask::DownCast()");
373
374   Actor actor = Actor::New();
375
376   RenderTask task = RenderTask::DownCast(actor);
377   DALI_TEST_CHECK(!task);
378
379   END_TEST;
380 }
381
382 int UtcDaliRenderTaskSetSourceActorN(void)
383 {
384   TestApplication application;
385   tet_infoline("Testing RenderTask::SetSourceActor() Negative - try with empty actor handle");
386   Integration::Scene stage = application.GetScene();
387
388   Actor srcActor;
389
390   RenderTaskList taskList   = stage.GetRenderTaskList();
391   RenderTask     renderTask = taskList.CreateTask();
392   renderTask.SetSourceActor(srcActor);
393
394   application.SendNotification();
395   application.Render();
396
397   DALI_TEST_CHECK(!renderTask.GetSourceActor());
398   END_TEST;
399 }
400
401 int UtcDaliRenderTaskSetSourceActorP01(void)
402 {
403   TestApplication application;
404
405   tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that setting a non-renderable actor stops existing source actor being rendered ");
406
407   Integration::Scene stage    = application.GetScene();
408   RenderTaskList     taskList = stage.GetRenderTaskList();
409   RenderTask         task     = taskList.GetTask(0u);
410
411   Actor actor = task.GetSourceActor();
412   DALI_TEST_CHECK(actor);
413
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));
417   stage.Add(newActor);
418
419   Actor nonRenderableActor = Actor::New();
420   stage.Add(nonRenderableActor);
421
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);
427
428   TestGlAbstraction& gl        = application.GetGlAbstraction();
429   TraceCallStack&    drawTrace = gl.GetDrawTrace();
430   drawTrace.Enable(true);
431
432   // Update & Render nothing!
433   application.GetGlAbstraction().ClearBoundTextures();
434   application.SendNotification();
435   application.Render();
436
437   // Check that nothing was rendered
438   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
439
440   END_TEST;
441 }
442
443 int UtcDaliRenderTaskSetSourceActorP02(void)
444 {
445   TestApplication application;
446
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");
448
449   Integration::Scene stage = application.GetScene();
450
451   RenderTaskList taskList = stage.GetRenderTaskList();
452
453   RenderTask task = taskList.GetTask(0u);
454
455   Actor actor = task.GetSourceActor();
456   DALI_TEST_CHECK(actor);
457
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));
461   stage.Add(newActor);
462
463   Actor nonRenderableActor = Actor::New();
464   stage.Add(nonRenderableActor);
465
466   TestGlAbstraction& gl        = application.GetGlAbstraction();
467   TraceCallStack&    drawTrace = gl.GetDrawTrace();
468   drawTrace.Enable(true);
469
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);
475
476   // Update & Render nothing!
477   application.GetGlAbstraction().ClearBoundTextures();
478   application.SendNotification();
479   application.Render();
480
481   // Check that nothing was rendered
482   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
483   drawTrace.Reset();
484
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);
489
490   // Update & Render the newActor
491   application.GetGlAbstraction().ClearBoundTextures();
492   application.SendNotification();
493   application.Render();
494
495   // Check that the newActor was rendered
496   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
497   END_TEST;
498 }
499
500 int UtcDaliRenderTaskSetSourceActorOffScene(void)
501 {
502   TestApplication application;
503
504   tet_infoline("Testing RenderTask::SetSourceActor (on/off stage testing)");
505
506   Integration::Scene stage    = application.GetScene();
507   RenderTaskList     taskList = stage.GetRenderTaskList();
508   RenderTask         task     = taskList.GetTask(0u);
509
510   Actor actor = task.GetSourceActor();
511   DALI_TEST_CHECK(actor);
512
513   TestGlAbstraction& gl        = application.GetGlAbstraction();
514   TraceCallStack&    drawTrace = gl.GetDrawTrace();
515   drawTrace.Enable(true);
516
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   //'
522
523   // Update & Render with the actor initially off-stage
524   application.SendNotification();
525   application.Render();
526
527   // Check that nothing was rendered
528   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
529
530   // Now add to stage
531   stage.Add(newActor);
532
533   // Update & Render with the actor on-stage
534   application.GetGlAbstraction().ClearBoundTextures();
535   application.SendNotification();
536   application.Render();
537
538   // Check that the newActor was rendered
539   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
540   drawTrace.Reset();
541
542   // Now remove from stage
543   stage.Remove(newActor);
544
545   // Update & Render with the actor off-stage
546   application.SendNotification();
547   application.Render();
548   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
549
550   END_TEST;
551 }
552
553 int UtcDaliRenderTaskSetSourceActorEmpty(void)
554 {
555   TestApplication application;
556
557   tet_infoline("Testing RenderTask::SetSourceActor (empty handle case)");
558
559   Integration::Scene stage    = application.GetScene();
560   RenderTaskList     taskList = stage.GetRenderTaskList();
561   RenderTask         task     = taskList.GetTask(0u);
562
563   Actor actor = task.GetSourceActor();
564   DALI_TEST_CHECK(actor);
565
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));
569   stage.Add(newActor);
570
571   Actor nonRenderableActor = Actor::New();
572   stage.Add(nonRenderableActor);
573
574   // Set with empty handle
575   task.SetSourceActor(Actor());
576   DALI_TEST_CHECK(!task.GetSourceActor());
577
578   TestGlAbstraction& gl        = application.GetGlAbstraction();
579   TraceCallStack&    drawTrace = gl.GetDrawTrace();
580   drawTrace.Enable(true);
581
582   // Update & Render nothing!
583   application.SendNotification();
584   application.Render();
585
586   // Check that nothing was rendered
587   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
588
589   // Set with non-empty handle
590   task.SetSourceActor(newActor);
591   DALI_TEST_CHECK(task.GetSourceActor() == newActor);
592
593   // Update & Render the newActor
594   application.GetGlAbstraction().ClearBoundTextures();
595   application.SendNotification();
596   application.Render();
597
598   // Check that the newActor was rendered
599   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
600   END_TEST;
601 }
602
603 int UtcDaliRenderTaskSetSourceActorDestroyed(void)
604 {
605   TestApplication application;
606
607   tet_infoline("Testing RenderTask::SetSourceActor - Set a source actor and destroy the source actor");
608
609   Integration::Scene stage    = application.GetScene();
610   RenderTaskList     taskList = stage.GetRenderTaskList();
611   RenderTask         task     = taskList.GetTask(0u);
612
613   Actor actor = task.GetSourceActor();
614   DALI_TEST_CHECK(actor);
615
616   Texture img = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
617
618   Actor newActor = CreateRenderableActor(img);
619   newActor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
620   stage.Add(newActor);
621
622   task.SetSourceActor(newActor);
623
624   DALI_TEST_CHECK(task.GetSourceActor() != actor);
625   DALI_TEST_CHECK(task.GetSourceActor() == newActor);
626
627   application.SendNotification();
628   application.Render();
629
630   // Destroy the source actor
631   stage.Remove(newActor);
632   newActor.Reset();
633
634   DALI_TEST_CHECK(!task.GetSourceActor()); // The source actor should be an empty handle.
635
636   END_TEST;
637 }
638
639 int UtcDaliRenderTaskGetSourceActorP01(void)
640 {
641   TestApplication application;
642
643   tet_infoline("Testing RenderTask::GetSourceActor() Check the default render task has a valid source actor");
644
645   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
646
647   RenderTask task = taskList.GetTask(0u);
648
649   Actor actor = task.GetSourceActor();
650   DALI_TEST_CHECK(actor);
651
652   // By default the entire scene should be rendered
653   Actor root = application.GetScene().GetLayer(0);
654   DALI_TEST_CHECK(root == actor);
655   END_TEST;
656 }
657
658 int UtcDaliRenderTaskGetSourceActorP02(void)
659 {
660   TestApplication application;
661
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.");
663
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);
669
670   DALI_TEST_EQUALS(actor, task.GetSourceActor(), TEST_LOCATION);
671
672   END_TEST;
673 }
674
675 int UtcDaliRenderTaskGetSourceActorN(void)
676 {
677   TestApplication application;
678
679   tet_infoline("Testing RenderTask::GetSourceActor() Try with empty handle");
680
681   RenderTask task;
682   try
683   {
684     Actor actor = task.GetSourceActor();
685   }
686   catch(Dali::DaliException& e)
687   {
688     DALI_TEST_PRINT_ASSERT(e);
689     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
690   }
691
692   END_TEST;
693 }
694
695 int UtcDaliRenderTaskGetStopperActorP(void)
696 {
697   TestApplication application;
698
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.");
700
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);
706
707   DALI_TEST_EQUALS(actor, task.GetStopperActor(), TEST_LOCATION);
708
709   END_TEST;
710 }
711
712 int UtcDaliRenderTaskGetStopperActorN(void)
713 {
714   TestApplication application;
715
716   tet_infoline("Testing RenderTask::GetStopperActor() Try with empty handle");
717
718   RenderTask task;
719
720   try
721   {
722     Actor actor = task.GetStopperActor();
723   }
724   catch(Dali::DaliException& e)
725   {
726     DALI_TEST_PRINT_ASSERT(e);
727     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
728   }
729
730   END_TEST;
731 }
732
733 int UtcDaliRenderTaskRenderUntil(void)
734 {
735   TestApplication application;
736   tet_infoline("Testing RenderTask::RenderUntil(actor) Check that rendering stops at the actor.");
737
738   // Make a new render task and compose a tree.
739   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
740   RenderTask     task     = taskList.GetTask(0u);
741
742   Integration::Scene stage = application.GetScene();
743
744   Actor secondChild;
745   for(int i = 0; i < 5; i++)
746   {
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));
752
753     stage.Add(parent);
754     parent.Add(child);
755
756     if (i == 1)
757     {
758       secondChild = child;
759     }
760   }
761   task.RenderUntil(secondChild);
762
763   // Update & Render with the actor on-stage
764   TestGlAbstraction& gl        = application.GetGlAbstraction();
765   TraceCallStack&    drawTrace = gl.GetDrawTrace();
766   drawTrace.Enable(true);
767
768   // Update & Render
769   application.SendNotification();
770   application.Render();
771
772   // Check that rendering was cut.
773   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 3, TEST_LOCATION);
774
775   END_TEST;
776 }
777
778 int UtcDaliRenderTaskSetExclusive(void)
779 {
780   TestApplication application;
781
782   tet_infoline("Testing RenderTask::SetExclusive() Check that exclusion works");
783
784   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
785
786   // Creates:
787   //           Root
788   //  Actor1   Layer    Layer
789   //           Actor2  Actor3
790
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)
793
794   // Manipulate the GenTextures behaviour, to identify different actors
795
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);
801
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);
806
807   // Update & Render actor1
808   application.SendNotification();
809   application.Render();
810
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);
814
815   if(boundTextures.size())
816   {
817     int a = boundTextures.size() - 1;
818     DALI_TEST_EQUALS(boundTextures[a], 8u /*unique to actor1*/, TEST_LOCATION);
819   }
820
821   Texture img2 = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
822
823   Actor actor2 = CreateRenderableActor(img2);
824   actor2.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
825
826   // Force actor2 to be rendered before actor1
827   Layer layer = Layer::New();
828   application.GetScene().Add(layer);
829   layer.Add(actor2);
830   layer.LowerToBottom();
831
832   // Update & Render
833   application.GetGlAbstraction().ClearBoundTextures();
834   application.SendNotification();
835   application.Render();
836
837   // Check that the actors were rendered
838   DALI_TEST_GREATER(boundTextures.size(), static_cast<std::vector<GLuint>::size_type>(1), TEST_LOCATION);
839
840   if(boundTextures.size() >= 2)
841   {
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);
846   }
847
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));
851
852   // Force actor3 to be rendered before actor2
853   layer = Layer::New();
854   application.GetScene().Add(layer);
855   layer.Add(actor3);
856   layer.LowerToBottom();
857
858   // Update & Render all actors
859   application.GetGlAbstraction().ClearBoundTextures();
860   application.SendNotification();
861   application.Render();
862
863   // Check that the actors were rendered
864   DALI_TEST_GREATER(boundTextures.size(), static_cast<std::vector<GLuint>::size_type>(2), TEST_LOCATION);
865
866   if(boundTextures.size() >= 3)
867   {
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);
874   }
875
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
878
879   // Not exclusive is the default
880   RenderTask task1 = taskList.GetTask(0u);
881   DALI_TEST_CHECK(false == task1.IsExclusive());
882
883   RenderTask task2 = taskList.CreateTask();
884   DALI_TEST_CHECK(false == task2.IsExclusive());
885   task2.SetSourceActor(actor2);
886
887   // Task1 should render all actors, and task 2 should render only actor2
888
889   application.GetGlAbstraction().ClearBoundTextures();
890   application.SendNotification();
891   application.Render();
892
893   if(boundTextures.size() >= 4)
894   {
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);
903
904     // Test that task 2 renders actor2
905     DALI_TEST_EQUALS(boundTextures[d], 9u, TEST_LOCATION);
906   }
907
908   // Make actor2 exclusive to task2
909
910   task2.SetExclusive(true);
911   DALI_TEST_CHECK(true == task2.IsExclusive());
912
913   // Task1 should render only actor1, and task 2 should render only actor2
914
915   application.GetGlAbstraction().ClearBoundTextures();
916   application.SendNotification();
917   application.Render();
918
919   DALI_TEST_EQUALS(boundTextures.size(), 3u, TEST_LOCATION);
920   if(boundTextures.size() == 3)
921   {
922     // Test that task 1 renders actor3 & actor1
923     DALI_TEST_CHECK(boundTextures[0] == 10u);
924     DALI_TEST_CHECK(boundTextures[1] == 8u);
925
926     // Test that task 2 renders actor2
927     DALI_TEST_CHECK(boundTextures[2] == 9u);
928   }
929
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);
934
935   END_TEST;
936 }
937
938 int UtcDaliRenderTaskSetExclusive02(void)
939 {
940   TestApplication application;
941
942   tet_infoline("Testing RenderTask::SetExclusive() Check that changing from exclusive to not-exclusive works");
943
944   std::vector<GLuint> ids;
945   ids.push_back(8); // 8 = actor1
946   application.GetGlAbstraction().SetNextTextureIds(ids);
947
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);
952
953   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
954   RenderTask     task     = taskList.CreateTask();
955
956   task.SetSourceActor(actor1);
957   task.SetExclusive(true); // Actor should only render once
958
959   TestGlAbstraction& gl        = application.GetGlAbstraction();
960   TraceCallStack&    drawTrace = gl.GetDrawTrace();
961   drawTrace.Enable(true);
962
963   // Update & Render actor1
964   application.SendNotification();
965   application.Render();
966
967   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
968
969   // Set task to non-exclusive - actor1 should render twice:
970   drawTrace.Reset();
971   task.SetExclusive(false);
972   application.SendNotification();
973   application.Render();
974
975   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 2, TEST_LOCATION);
976
977   END_TEST;
978 }
979
980 int UtcDaliRenderTaskSetExclusive03(void)
981 {
982   TestApplication application;
983
984   tet_infoline("Testing RenderTask::SetExclusive() Check that changing from exclusive to not-exclusive works");
985
986   std::vector<GLuint> ids;
987   ids.push_back(8); // 8 = actor1
988   application.GetGlAbstraction().SetNextTextureIds(ids);
989
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);
994
995   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
996   RenderTask     task     = taskList.CreateTask();
997
998   task.SetSourceActor(actor1);
999   task.SetExclusive(true); // Actor should only render once
1000
1001   TestGlAbstraction& gl        = application.GetGlAbstraction();
1002   TraceCallStack&    drawTrace = gl.GetDrawTrace();
1003   drawTrace.Enable(true);
1004
1005   // Update & Render actor1
1006   application.SendNotification();
1007   application.Render();
1008
1009   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
1010
1011   // Set task to non-exclusive - actor1 should render twice:
1012   drawTrace.Reset();
1013
1014   RenderTask task2 = taskList.CreateTask();
1015   task2.SetSourceActor(actor1);
1016   task2.SetExclusive(true); // Actor should only render once
1017
1018   application.SendNotification();
1019   application.Render();
1020
1021   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 2, TEST_LOCATION);
1022
1023   // Set task to non-exclusive - actor1 should render twice:
1024   drawTrace.Reset();
1025   task.SetExclusive(false);
1026   application.SendNotification();
1027   application.Render();
1028
1029   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
1030
1031   // Set task to non-exclusive - actor1 should render twice:
1032   drawTrace.Reset();
1033   task2.SetExclusive(false);
1034   application.SendNotification();
1035   application.Render();
1036
1037   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 3, TEST_LOCATION);
1038
1039   END_TEST;
1040 }
1041
1042 int UtcDaliRenderTaskSetExclusiveN(void)
1043 {
1044   TestApplication application;
1045
1046   tet_infoline("Testing RenderTask::SetExclusive() on empty handle");
1047
1048   RenderTask task;
1049   try
1050   {
1051     task.SetExclusive(true);
1052   }
1053   catch(Dali::DaliException& e)
1054   {
1055     DALI_TEST_PRINT_ASSERT(e);
1056     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1057   }
1058   END_TEST;
1059 }
1060
1061 int UtcDaliRenderTaskIsExclusive01(void)
1062 {
1063   TestApplication application;
1064
1065   tet_infoline("Testing RenderTask::IsExclusive() Check default values are non-exclusive");
1066
1067   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1068
1069   // Not exclusive is the default
1070   RenderTask task = taskList.GetTask(0u);
1071   DALI_TEST_CHECK(false == task.IsExclusive());
1072
1073   RenderTask newTask = taskList.CreateTask();
1074   DALI_TEST_CHECK(false == newTask.IsExclusive());
1075
1076   END_TEST;
1077 }
1078
1079 int UtcDaliRenderTaskIsExclusive02(void)
1080 {
1081   TestApplication application;
1082
1083   tet_infoline("Testing RenderTask::IsExclusive() Check the getter returns set values");
1084
1085   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1086
1087   // Not exclusive is the default
1088   RenderTask newTask = taskList.CreateTask();
1089   DALI_TEST_EQUALS(newTask.IsExclusive(), false, TEST_LOCATION);
1090
1091   newTask.SetExclusive(true);
1092   DALI_TEST_EQUALS(newTask.IsExclusive(), true, TEST_LOCATION);
1093   END_TEST;
1094 }
1095
1096 int UtcDaliRenderTaskIsExclusiveN(void)
1097 {
1098   TestApplication application;
1099
1100   tet_infoline("Testing RenderTask::IsExclusive() on empty handle");
1101
1102   RenderTask task;
1103   try
1104   {
1105     bool x = task.IsExclusive();
1106     (void)x;
1107   }
1108   catch(Dali::DaliException& e)
1109   {
1110     DALI_TEST_PRINT_ASSERT(e);
1111     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1112   }
1113   END_TEST;
1114 }
1115
1116 int UtcDaliRenderTaskSetInputEnabled(void)
1117 {
1118   TestApplication application;
1119
1120   tet_infoline("Testing RenderTask::SetInputEnabled()");
1121
1122   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1123
1124   // Input is enabled by default
1125   RenderTask task = taskList.GetTask(0u);
1126   DALI_TEST_CHECK(true == task.GetInputEnabled());
1127
1128   task.SetInputEnabled(false);
1129   DALI_TEST_CHECK(false == task.GetInputEnabled());
1130
1131   task.SetInputEnabled(true);
1132   DALI_TEST_CHECK(true == task.GetInputEnabled());
1133   END_TEST;
1134 }
1135
1136 int UtcDaliRenderTaskGetInputEnabled(void)
1137 {
1138   TestApplication application;
1139
1140   tet_infoline("Testing RenderTask::GetInputEnabled()");
1141
1142   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1143
1144   // Input is enabled by default
1145   RenderTask task = taskList.GetTask(0u);
1146   DALI_TEST_EQUALS(true, task.GetInputEnabled(), TEST_LOCATION);
1147
1148   RenderTask newTask = taskList.CreateTask();
1149   DALI_TEST_EQUALS(true, newTask.GetInputEnabled(), TEST_LOCATION);
1150
1151   newTask.SetInputEnabled(false);
1152   DALI_TEST_EQUALS(false, newTask.GetInputEnabled(), TEST_LOCATION);
1153
1154   END_TEST;
1155 }
1156
1157 int UtcDaliRenderTaskSetCameraActorP(void)
1158 {
1159   TestApplication application;
1160
1161   tet_infoline("Testing RenderTask::SetCameraActor()");
1162
1163   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1164
1165   RenderTask task = taskList.GetTask(0u);
1166
1167   Actor defaultCameraActor = task.GetCameraActor();
1168   DALI_TEST_CHECK(defaultCameraActor);
1169
1170   CameraActor newCameraActor = CameraActor::New();
1171   DALI_TEST_CHECK(newCameraActor);
1172
1173   task.SetCameraActor(newCameraActor);
1174   DALI_TEST_CHECK(task.GetCameraActor() != defaultCameraActor);
1175   DALI_TEST_EQUALS(task.GetCameraActor(), newCameraActor, TEST_LOCATION);
1176   END_TEST;
1177 }
1178
1179 int UtcDaliRenderTaskSetCameraActorN(void)
1180 {
1181   TestApplication application;
1182
1183   tet_infoline("Testing RenderTask::SetCameraActor() with empty actor handle");
1184
1185   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1186
1187   RenderTask task = taskList.GetTask(0u);
1188
1189   Actor actor = task.GetCameraActor();
1190   DALI_TEST_CHECK(actor);
1191
1192   CameraActor cameraActor;
1193
1194   task.SetCameraActor(cameraActor);
1195   DALI_TEST_EQUALS((bool)task.GetCameraActor(), false, TEST_LOCATION);
1196   DALI_TEST_EQUALS(task.GetCameraActor(), cameraActor, TEST_LOCATION);
1197   END_TEST;
1198 }
1199
1200 int UtcDaliRenderTaskSetCameraActorDestroyed(void)
1201 {
1202   TestApplication application;
1203
1204   tet_infoline("Testing RenderTask::SetCameraActor - Set a camera actor and destroy the camera actor");
1205
1206   Integration::Scene stage    = application.GetScene();
1207   RenderTaskList     taskList = stage.GetRenderTaskList();
1208   RenderTask         task     = taskList.GetTask(0u);
1209
1210   CameraActor newCameraActor = CameraActor::New();
1211   task.SetCameraActor(newCameraActor);
1212
1213   DALI_TEST_EQUALS(task.GetCameraActor(), newCameraActor, TEST_LOCATION);
1214
1215   // Destroy the camera actor
1216   newCameraActor.Reset();
1217
1218   CameraActor camera = task.GetCameraActor();
1219   DALI_TEST_CHECK(!camera); // The camera actor should be an empty handle.
1220
1221   END_TEST;
1222 }
1223
1224 int UtcDaliRenderTaskGetCameraActorP(void)
1225 {
1226   TestApplication application;
1227
1228   tet_infoline("Testing RenderTask::GetCameraActor()");
1229
1230   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1231
1232   RenderTask task = taskList.GetTask(0u);
1233
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);
1238   END_TEST;
1239 }
1240
1241 int UtcDaliRenderTaskGetCameraActorN(void)
1242 {
1243   TestApplication application;
1244
1245   tet_infoline("Testing RenderTask::GetCameraActor() with empty handle");
1246   RenderTask task;
1247
1248   try
1249   {
1250     Actor actor = task.GetCameraActor();
1251   }
1252   catch(Dali::DaliException& e)
1253   {
1254     DALI_TEST_PRINT_ASSERT(e);
1255     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1256   }
1257
1258   END_TEST;
1259 }
1260
1261 int UtcDaliRenderTaskSetFrameBufferP(void)
1262 {
1263   TestApplication application;
1264
1265   tet_infoline("Testing RenderTask::SetFrameBuffer()");
1266
1267   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1268
1269   RenderTask task = taskList.GetTask(0u);
1270
1271   FrameBuffer newFrameBuffer = FrameBuffer::New(128u, 128u, FrameBuffer::Attachment::NONE);
1272   task.SetFrameBuffer(newFrameBuffer);
1273   DALI_TEST_CHECK(task.GetFrameBuffer() == newFrameBuffer);
1274   END_TEST;
1275 }
1276
1277 int UtcDaliRenderTaskSetFrameBufferN(void)
1278 {
1279   TestApplication application;
1280
1281   tet_infoline("Testing RenderTask::SetFrameBuffer()");
1282
1283   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1284
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);
1289   END_TEST;
1290 }
1291
1292 int UtcDaliRenderTaskGetFrameBufferP(void)
1293 {
1294   TestApplication application;
1295
1296   tet_infoline("Testing RenderTask::GetFrameBuffer()");
1297
1298   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1299
1300   RenderTask task = taskList.GetTask(0u);
1301
1302   FrameBuffer newFrameBuffer = FrameBuffer::New(1u, 1u, FrameBuffer::Attachment::NONE);
1303   task.SetFrameBuffer(newFrameBuffer);
1304   DALI_TEST_CHECK(task.GetFrameBuffer() == newFrameBuffer);
1305   END_TEST;
1306 }
1307
1308 int UtcDaliRenderTaskGetFrameBufferN(void)
1309 {
1310   TestApplication application;
1311
1312   tet_infoline("Testing RenderTask::GetFrameBuffer()");
1313
1314   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1315
1316   RenderTask task = taskList.GetTask(0u);
1317
1318   // By default render-tasks do not render off-screen
1319   FrameBuffer frameBuffer = task.GetFrameBuffer();
1320   DALI_TEST_CHECK(!frameBuffer);
1321
1322   END_TEST;
1323 }
1324
1325 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionP(void)
1326 {
1327   TestApplication application;
1328
1329   tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1330
1331   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1332
1333   RenderTask task = taskList.GetTask(0u);
1334
1335   task.SetScreenToFrameBufferFunction(TestScreenToFrameBufferFunction);
1336
1337   Vector2 coordinates(5, 10);
1338   Vector2 convertedCoordinates(6, 12); // + Vector(1, 2)
1339
1340   RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1341   DALI_TEST_CHECK(func(coordinates));
1342   DALI_TEST_CHECK(coordinates == convertedCoordinates);
1343
1344   task.SetScreenToFrameBufferFunction(RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION);
1345   func = task.GetScreenToFrameBufferFunction();
1346   DALI_TEST_CHECK(func(coordinates));
1347
1348   task.SetScreenToFrameBufferFunction(RenderTask::DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION);
1349   func = task.GetScreenToFrameBufferFunction();
1350   DALI_TEST_CHECK(!func(coordinates));
1351   END_TEST;
1352 }
1353
1354 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionN(void)
1355 {
1356   TestApplication application;
1357
1358   tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1359
1360   RenderTask task; // Empty handle
1361   try
1362   {
1363     task.SetScreenToFrameBufferFunction(TestScreenToFrameBufferFunction);
1364   }
1365   catch(Dali::DaliException& e)
1366   {
1367     DALI_TEST_PRINT_ASSERT(e);
1368     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1369   }
1370   END_TEST;
1371 }
1372
1373 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionP(void)
1374 {
1375   TestApplication application;
1376
1377   tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction()");
1378
1379   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1380
1381   RenderTask task = taskList.GetTask(0u);
1382
1383   Vector2 originalCoordinates(5, 10);
1384   Vector2 coordinates(5, 10);
1385
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
1389   END_TEST;
1390 }
1391
1392 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionN(void)
1393 {
1394   TestApplication application;
1395
1396   tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction() on empty handle");
1397
1398   RenderTask task;
1399   try
1400   {
1401     RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1402     (void)func;
1403   }
1404   catch(Dali::DaliException& e)
1405   {
1406     DALI_TEST_PRINT_ASSERT(e);
1407     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1408   }
1409   END_TEST;
1410 }
1411
1412 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorP(void)
1413 {
1414   TestApplication application;
1415   tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor ");
1416
1417   RenderTaskList taskList     = application.GetScene().GetRenderTaskList();
1418   RenderTask     renderTask   = taskList.CreateTask();
1419   Actor          mappingActor = Actor::New();
1420   renderTask.SetScreenToFrameBufferMappingActor(mappingActor);
1421
1422   DALI_TEST_EQUALS(mappingActor, renderTask.GetScreenToFrameBufferMappingActor(), TEST_LOCATION);
1423   END_TEST;
1424 }
1425
1426 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorN(void)
1427 {
1428   TestApplication application;
1429   tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1430
1431   RenderTask task;
1432   try
1433   {
1434     Actor mappingActor;
1435     task.SetScreenToFrameBufferMappingActor(mappingActor);
1436   }
1437   catch(Dali::DaliException& e)
1438   {
1439     DALI_TEST_PRINT_ASSERT(e);
1440     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1441   }
1442   END_TEST;
1443 }
1444
1445 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActor02N(void)
1446 {
1447   TestApplication application;
1448   tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1449
1450   RenderTaskList taskList   = application.GetScene().GetRenderTaskList();
1451   RenderTask     renderTask = taskList.CreateTask();
1452   Actor          actor;
1453   renderTask.SetScreenToFrameBufferMappingActor(actor);
1454
1455   DALI_TEST_EQUALS((bool)renderTask.GetScreenToFrameBufferMappingActor(), false, TEST_LOCATION);
1456   END_TEST;
1457 }
1458
1459 int UtcDaliRenderTaskGetViewportP01(void)
1460 {
1461   TestApplication application;
1462
1463   tet_infoline("Testing RenderTask::GetViewport() on default task");
1464
1465   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1466   RenderTask     task     = taskList.GetTask(0u);
1467   Viewport       viewport = task.GetViewport();
1468
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);
1473   END_TEST;
1474 }
1475
1476 int UtcDaliRenderTaskGetViewportP02(void)
1477 {
1478   TestApplication application;
1479
1480   tet_infoline("Testing RenderTask::GetViewport() on new task");
1481
1482   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1483   RenderTask     task     = taskList.CreateTask();
1484   Viewport       viewport = task.GetViewport();
1485
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);
1490   END_TEST;
1491 }
1492
1493 int UtcDaliRenderTaskGetViewportN(void)
1494 {
1495   TestApplication application;
1496
1497   tet_infoline("Testing RenderTask::GetViewport() on empty handle");
1498
1499   RenderTask task;
1500   try
1501   {
1502     Viewport viewport = task.GetViewport();
1503     (void)viewport;
1504   }
1505   catch(Dali::DaliException& e)
1506   {
1507     DALI_TEST_PRINT_ASSERT(e);
1508     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1509   }
1510   END_TEST;
1511 }
1512
1513 int UtcDaliRenderTaskSetViewportP(void)
1514 {
1515   TestApplication application;
1516
1517   tet_infoline("Testing RenderTask::SetViewport()");
1518
1519   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1520
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);
1525
1526   // Update (viewport is a property)
1527   application.SendNotification();
1528   application.Render();
1529
1530   DALI_TEST_CHECK(task.GetViewport() == newViewport);
1531   END_TEST;
1532 }
1533
1534 int UtcDaliRenderTaskSetViewportN(void)
1535 {
1536   TestApplication application;
1537
1538   tet_infoline("Testing RenderTask::SetViewport()");
1539
1540   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1541
1542   RenderTask task;
1543   try
1544   {
1545     Vector2  stageSize = application.GetScene().GetSize();
1546     Viewport newViewport(0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f);
1547     task.SetViewport(newViewport);
1548   }
1549   catch(Dali::DaliException& e)
1550   {
1551     DALI_TEST_PRINT_ASSERT(e);
1552     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1553   }
1554
1555   END_TEST;
1556 }
1557
1558 int UtcDaliRenderTaskSetViewportPosition(void)
1559 {
1560   TestApplication application;
1561
1562   tet_infoline("Testing RenderTask::SetViewportPosition()");
1563
1564   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1565
1566   RenderTask task = taskList.GetTask(0u);
1567
1568   Viewport viewport = task.GetViewport();
1569
1570   // By default the viewport should match the stage width/height
1571
1572   Vector2  stageSize = application.GetScene().GetSize();
1573   Viewport expectedViewport(0, 0, stageSize.width, stageSize.height);
1574   DALI_TEST_CHECK(viewport == expectedViewport);
1575
1576   // 'Setter' test
1577   Vector2 newPosition(25.0f, 50.0f);
1578   task.SetViewportPosition(newPosition);
1579
1580   // Update (viewport is a property)
1581   application.SendNotification();
1582   application.Render();
1583
1584   DALI_TEST_EQUALS(task.GetCurrentViewportPosition(), newPosition, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1585
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
1591
1592   // Update
1593   application.SendNotification();
1594   application.Render();
1595
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);
1599
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);
1603   animation.Play();
1604
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);
1607
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);
1613
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);
1619   animation.Play();
1620
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);
1623
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);
1629
1630   END_TEST;
1631 }
1632
1633 int UtcDaliRenderTaskSetViewportSize(void)
1634 {
1635   TestApplication application;
1636
1637   tet_infoline("Testing RenderTask::SetViewportSize()");
1638
1639   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1640
1641   RenderTask task = taskList.GetTask(0u);
1642
1643   Viewport viewport = task.GetViewport();
1644
1645   // By default the viewport should match the stage width/height
1646
1647   Vector2  stageSize = application.GetScene().GetSize();
1648   Viewport expectedViewport(0, 0, stageSize.width, stageSize.height);
1649   DALI_TEST_CHECK(viewport == expectedViewport);
1650
1651   Vector2 newSize(128.0f, 64.0f);
1652   task.SetViewportSize(newSize);
1653
1654   // Update (viewport is a property)
1655   application.SendNotification();
1656   application.Render();
1657
1658   DALI_TEST_EQUALS(task.GetCurrentViewportSize(), newSize, Math::MACHINE_EPSILON_1, TEST_LOCATION);
1659
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
1665
1666   // Update
1667   application.SendNotification();
1668   application.Render();
1669
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);
1673
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);
1677   animation.Play();
1678
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);
1681
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);
1687
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);
1693   animation.Play();
1694
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);
1697
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);
1703
1704   END_TEST;
1705 }
1706
1707 int UtcDaliRenderTaskSetClearColorP(void)
1708 {
1709   TestApplication application;
1710
1711   tet_infoline("Testing RenderTask::SetClearColor()");
1712
1713   Vector4 testColor(1.0f, 2.0f, 3.0f, 4.0f);
1714   Vector4 testColor2(5.0f, 6.0f, 7.0f, 8.0f);
1715
1716   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1717
1718   RenderTask task = taskList.GetTask(0u);
1719   DALI_TEST_CHECK(task.GetClearColor() != testColor);
1720
1721   task.SetClearColor(testColor);
1722
1723   // Wait a frame.
1724   Wait(application);
1725
1726   DALI_TEST_EQUALS(task.GetClearColor(), testColor, TEST_LOCATION);
1727
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
1731
1732   // Wait a frame.
1733   Wait(application);
1734
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);
1738
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);
1742   animation.Play();
1743
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);
1746
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);
1751
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);
1757   animation.Play();
1758
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);
1761
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);
1766
1767   END_TEST;
1768 }
1769
1770 int UtcDaliRenderTaskSetClearColorN(void)
1771 {
1772   TestApplication application;
1773
1774   tet_infoline("Testing RenderTask::SetClearColor() on empty handle");
1775
1776   RenderTask task;
1777   try
1778   {
1779     task.SetClearColor(Vector4::ZERO);
1780   }
1781   catch(Dali::DaliException& e)
1782   {
1783     DALI_TEST_PRINT_ASSERT(e);
1784     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1785   }
1786   END_TEST;
1787 }
1788
1789 int UtcDaliRenderTaskGetClearColorP(void)
1790 {
1791   TestApplication application;
1792
1793   tet_infoline("Testing RenderTask::GetClearColor()");
1794
1795   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1796   RenderTask     task     = taskList.GetTask(0u);
1797   DALI_TEST_EQUALS(task.GetClearColor(), RenderTask::DEFAULT_CLEAR_COLOR, TEST_LOCATION);
1798   END_TEST;
1799 }
1800
1801 int UtcDaliRenderTaskGetClearColorN(void)
1802 {
1803   TestApplication application;
1804
1805   tet_infoline("Testing RenderTask::GetClearColor()");
1806
1807   RenderTask task;
1808   try
1809   {
1810     Vector4 color = task.GetClearColor();
1811     (void)color;
1812   }
1813   catch(Dali::DaliException& e)
1814   {
1815     DALI_TEST_PRINT_ASSERT(e);
1816     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1817   }
1818   END_TEST;
1819 }
1820
1821 int UtcDaliRenderTaskSetClearEnabledP(void)
1822 {
1823   TestApplication application;
1824
1825   tet_infoline("Testing RenderTask::SetClearEnabled()");
1826
1827   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1828
1829   RenderTask task = taskList.GetTask(0u);
1830   DALI_TEST_CHECK(task.GetClearEnabled()); // defaults to true
1831
1832   task.SetClearEnabled(false);
1833   DALI_TEST_EQUALS(task.GetClearEnabled(), false, TEST_LOCATION);
1834
1835   task.SetClearEnabled(true);
1836   DALI_TEST_EQUALS(task.GetClearEnabled(), true, TEST_LOCATION);
1837   END_TEST;
1838 }
1839
1840 int UtcDaliRenderTaskSetClearEnabledN(void)
1841 {
1842   TestApplication application;
1843
1844   tet_infoline("Testing RenderTask::SetClearEnabled() with empty handle");
1845
1846   RenderTask task;
1847   try
1848   {
1849     task.SetClearEnabled(true);
1850   }
1851   catch(Dali::DaliException& e)
1852   {
1853     DALI_TEST_PRINT_ASSERT(e);
1854     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1855   }
1856   END_TEST;
1857 }
1858
1859 int UtcDaliRenderTaskGetClearEnabledP(void)
1860 {
1861   TestApplication application;
1862
1863   tet_infoline("Testing RenderTask::GetClearEnabled()");
1864
1865   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1866
1867   RenderTask task = taskList.GetTask(0u);
1868   DALI_TEST_CHECK(task.GetClearEnabled()); // defaults to true
1869   END_TEST;
1870 }
1871
1872 int UtcDaliRenderTaskGetClearEnabledN(void)
1873 {
1874   TestApplication application;
1875
1876   tet_infoline("Testing RenderTask::GetClearEnabled() with empty handle");
1877
1878   RenderTask task;
1879   try
1880   {
1881     bool x = task.GetClearEnabled();
1882     (void)x;
1883   }
1884   catch(Dali::DaliException& e)
1885   {
1886     DALI_TEST_PRINT_ASSERT(e);
1887     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1888   }
1889   END_TEST;
1890 }
1891
1892 int UtcDaliRenderTaskSetCullModeP(void)
1893 {
1894   TestApplication application;
1895
1896   tet_infoline("Testing RenderTask::SetCullMode()");
1897
1898   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1899   RenderTask     task     = taskList.GetTask(0u);
1900   DALI_TEST_EQUALS(task.GetCullMode(), true, TEST_LOCATION);
1901
1902   task.SetCullMode(false);
1903
1904   DALI_TEST_EQUALS(task.GetCullMode(), false, TEST_LOCATION);
1905
1906   END_TEST;
1907 }
1908
1909 int UtcDaliRenderTaskSetCullModeN(void)
1910 {
1911   TestApplication application;
1912
1913   tet_infoline("Testing RenderTask::SetCullMode() on empty handle");
1914
1915   RenderTask task;
1916   try
1917   {
1918     task.SetCullMode(false);
1919   }
1920   catch(Dali::DaliException& e)
1921   {
1922     DALI_TEST_PRINT_ASSERT(e);
1923     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1924   }
1925   END_TEST;
1926 }
1927
1928 int UtcDaliRenderTaskGetCullModeP(void)
1929 {
1930   TestApplication application;
1931
1932   tet_infoline("Testing RenderTask::GetCullMode()");
1933
1934   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1935   RenderTask     task     = taskList.GetTask(0u);
1936   DALI_TEST_EQUALS(task.GetCullMode(), true, TEST_LOCATION);
1937   END_TEST;
1938 }
1939
1940 int UtcDaliRenderTaskGetCullModeN(void)
1941 {
1942   TestApplication application;
1943
1944   tet_infoline("Testing RenderTask::GetCullMode() with empty handle");
1945
1946   RenderTask task;
1947   try
1948   {
1949     bool x = task.GetCullMode();
1950     (void)x;
1951   }
1952   catch(Dali::DaliException& e)
1953   {
1954     DALI_TEST_PRINT_ASSERT(e);
1955     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1956   }
1957   END_TEST;
1958 }
1959
1960 int UtcDaliRenderTaskSetRefreshRate(void)
1961 {
1962   TestApplication application;
1963
1964   tet_infoline("Testing RenderTask::SetRefreshRate()");
1965
1966   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1967
1968   // By default tasks will be processed every frame
1969   RenderTask task = taskList.GetTask(0u);
1970   DALI_TEST_CHECK(RenderTask::REFRESH_ALWAYS == task.GetRefreshRate());
1971
1972   task.SetRefreshRate(2u); // every-other frame
1973   DALI_TEST_CHECK(2u == task.GetRefreshRate());
1974
1975   task.SetRefreshRate(RenderTask::REFRESH_ALWAYS);
1976   DALI_TEST_CHECK(RenderTask::REFRESH_ALWAYS == task.GetRefreshRate());
1977   END_TEST;
1978 }
1979
1980 int UtcDaliRenderTaskGetRefreshRate(void)
1981 {
1982   TestApplication application;
1983
1984   tet_infoline("Testing RenderTask::GetRefreshRate()");
1985
1986   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
1987
1988   // By default tasks will be processed every frame
1989   RenderTask task = taskList.GetTask(0u);
1990   DALI_TEST_CHECK(RenderTask::REFRESH_ALWAYS == task.GetRefreshRate());
1991
1992   RenderTask newTask = taskList.CreateTask();
1993   DALI_TEST_CHECK(RenderTask::REFRESH_ALWAYS == newTask.GetRefreshRate());
1994   END_TEST;
1995 }
1996
1997 int UtcDaliRenderTaskSignalFinished(void)
1998 {
1999   TestApplication application;
2000
2001   tet_infoline("Testing RenderTask::SignalFinished()");
2002
2003   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2004   auto& sync = application.GetGraphicsSyncImpl();
2005
2006   CameraActor offscreenCameraActor = CameraActor::New();
2007
2008   application.GetScene().Add(offscreenCameraActor);
2009
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);
2014
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);
2020
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);
2031
2032   bool               finished = false;
2033   RenderTaskFinished renderTaskFinished(finished);
2034   newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2035
2036   // Flush the queue and render.
2037   application.SendNotification();
2038
2039   // 1 render to process render task, then wait for sync before finished msg is sent
2040   // from update to the event thread.
2041
2042   application.Render();
2043   application.SendNotification();
2044   DALI_TEST_CHECK(!finished);
2045
2046   Integration::GraphicsSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2047   DALI_TEST_CHECK(lastSyncObj != NULL);
2048
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);
2053
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);
2058
2059   sync.SetObjectSynced(lastSyncObj, true);
2060
2061   application.Render();
2062   application.SendNotification();
2063   DALI_TEST_CHECK(!finished);
2064
2065   application.Render();
2066   application.SendNotification();
2067   DALI_TEST_CHECK(finished);
2068
2069   DALI_TEST_EQUALS(application.GetUpdateStatus(), 0, TEST_LOCATION);
2070   END_TEST;
2071 }
2072
2073 int UtcDaliRenderTaskContinuous01(void)
2074 {
2075   TestApplication application;
2076
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");
2078
2079   // SETUP AN OFFSCREEN RENDER TASK
2080   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2081   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2082   drawTrace.Enable(true);
2083
2084   Actor rootActor = Actor::New();
2085   application.GetScene().Add(rootActor);
2086
2087   CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2088   application.GetScene().Add(offscreenCameraActor);
2089
2090   Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2091
2092   RenderTask         newTask  = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2093   bool               finished = false;
2094   RenderTaskFinished renderTaskFinished(finished);
2095   application.SendNotification();
2096
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();
2100
2101   // ADD SOURCE ACTOR TO STAGE - expect continuous renders to start, no finished signal
2102   application.GetScene().Add(secondRootActor);
2103   application.SendNotification();
2104
2105   // CONTINUE PROCESS/RENDER                  Input,    Expected  Input,    Expected
2106   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2107   END_TEST;
2108 }
2109
2110 int UtcDaliRenderTaskContinuous02(void)
2111 {
2112   TestApplication application;
2113
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");
2115
2116   // SETUP AN OFFSCREEN RENDER TASK
2117   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2118   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2119   drawTrace.Enable(true);
2120
2121   Actor rootActor = Actor::New();
2122   application.GetScene().Add(rootActor);
2123
2124   CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2125   application.GetScene().Add(offscreenCameraActor);
2126
2127   Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2128   application.GetScene().Add(secondRootActor);
2129   secondRootActor.SetProperty(Actor::Property::VISIBLE, false);
2130
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();
2136
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();
2140
2141   // MAKE SOURCE ACTOR VISIBLE - expect continuous renders to start, no finished signal
2142   secondRootActor.SetProperty(Actor::Property::VISIBLE, true);
2143   application.SendNotification();
2144
2145   // CONTINUE PROCESS/RENDER                 Input,    Expected  Input,    Expected
2146   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2147   END_TEST;
2148 }
2149
2150 int UtcDaliRenderTaskContinuous03(void)
2151 {
2152   TestApplication application;
2153
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");
2155
2156   // SETUP AN OFFSCREEN RENDER TASK
2157   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2158   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2159   drawTrace.Enable(true);
2160
2161   Actor rootActor = Actor::New();
2162   application.GetScene().Add(rootActor);
2163
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);
2167
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();
2173
2174   // START PROCESS/RENDER                    Input,    Expected  Input,    Expected
2175   DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, false, __LINE__));
2176   application.GetPlatform().ClearReadyResources();
2177
2178   // ADD CAMERA ACTOR TO STAGE - expect continuous renders to start, no finished signal
2179   application.GetScene().Add(offscreenCameraActor);
2180   application.SendNotification();
2181
2182   // CONTINUE PROCESS/RENDER                 Input,    Expected  Input,    Expected
2183   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2184   END_TEST;
2185 }
2186
2187 int UtcDaliRenderTaskContinuous04(void)
2188 {
2189   TestApplication application;
2190
2191   tet_infoline("Testing RenderTask Render Continuous using loaded image");
2192
2193   // SETUP AN OFFSCREEN RENDER TASK
2194   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2195   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2196   drawTrace.Enable(true);
2197
2198   Actor rootActor = Actor::New();
2199   application.GetScene().Add(rootActor);
2200
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);
2205
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();
2211
2212   // START PROCESS/RENDER                    Input,    Expected  Input,    Expected
2213   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2214   END_TEST;
2215 }
2216
2217 int UtcDaliRenderTaskOnce01(void)
2218 {
2219   TestApplication application;
2220
2221   tet_infoline("Testing RenderTask Render Once GlSync, using loaded image");
2222
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);
2228
2229   Actor rootActor = Actor::New();
2230   application.GetScene().Add(rootActor);
2231
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");
2235
2236   application.GetScene().Add(secondRootActor);
2237
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();
2243
2244   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2245
2246   Integration::GraphicsSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2247   DALI_TEST_CHECK(lastSyncObj != NULL);
2248   sync.SetObjectSynced(lastSyncObj, true);
2249
2250   DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, true, __LINE__));
2251   DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2252   END_TEST;
2253 }
2254
2255 int UtcDaliRenderTaskOnce02(void)
2256 {
2257   TestApplication application;
2258
2259   tet_infoline("Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loaded image.\n");
2260
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);
2266
2267   Actor rootActor = Actor::New();
2268   application.GetScene().Add(rootActor);
2269
2270   CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2271   application.GetScene().Add(offscreenCameraActor);
2272
2273   Shader     shader     = CreateShader();
2274   Texture    image      = CreateTexture();
2275   TextureSet textureSet = CreateTextureSet(image);
2276
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);
2284
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();
2290
2291   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2292
2293   Integration::GraphicsSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2294   DALI_TEST_CHECK(lastSyncObj != NULL);
2295   sync.SetObjectSynced(lastSyncObj, true);
2296
2297   DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, true, __LINE__));
2298   DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2299
2300   END_TEST;
2301 }
2302
2303 int UtcDaliRenderTaskOnce03(void)
2304 {
2305   TestApplication application;
2306
2307   tet_infoline("Testing RenderTask Render Once GlSync, using loaded image. Switch from render always after ready to render once\n");
2308
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);
2314
2315   Actor rootActor = Actor::New();
2316   application.GetScene().Add(rootActor);
2317
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);
2322
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();
2328
2329   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2330
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__));
2335
2336   Integration::GraphicsSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2337   DALI_TEST_CHECK(lastSyncObj != NULL);
2338   sync.SetObjectSynced(lastSyncObj, true);
2339
2340   DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, true, __LINE__));
2341   DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2342
2343   END_TEST;
2344 }
2345
2346 int UtcDaliRenderTaskOnce04(void)
2347 {
2348   TestApplication application;
2349   tet_infoline(
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");
2352
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);
2358
2359   Actor rootActor = Actor::New();
2360   application.GetScene().Add(rootActor);
2361
2362   CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2363   application.GetScene().Add(offscreenCameraActor);
2364
2365   Shader     shader     = CreateShader();
2366   Texture    image      = CreateTexture();
2367   TextureSet textureSet = CreateTextureSet(image);
2368
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);
2376
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();
2382
2383   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2384
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__));
2389
2390   Integration::GraphicsSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2391   DALI_TEST_CHECK(lastSyncObj != NULL);
2392   sync.SetObjectSynced(lastSyncObj, true);
2393
2394   DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, false, true, __LINE__));
2395   DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2396
2397   END_TEST;
2398 }
2399
2400 int UtcDaliRenderTaskOnceNoSync01(void)
2401 {
2402   TestApplication application;
2403
2404   tet_infoline("Testing RenderTask Render Once, \nPRE: Resources ready\nPOST: Finished signal sent once only");
2405
2406   // SETUP AN OFFSCREEN RENDER TASK
2407   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2408   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2409   drawTrace.Enable(true);
2410
2411   Actor rootActor = Actor::New();
2412   application.GetScene().Add(rootActor);
2413
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);
2418
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();
2424
2425   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
2426   DALI_TEST_CHECK(UpdateRender(application, drawTrace, false, finished, true, false, __LINE__));
2427   END_TEST;
2428 }
2429
2430 int UtcDaliRenderTaskOnceNoSync02(void)
2431 {
2432   TestApplication application;
2433
2434   tet_infoline(
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);
2441
2442   Actor rootActor = Actor::New();
2443   application.GetScene().Add(rootActor);
2444
2445   CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2446   application.GetScene().Add(offscreenCameraActor);
2447
2448   Shader     shader     = CreateShader();
2449   Texture    image      = CreateTexture();
2450   TextureSet textureSet = CreateTextureSet(image);
2451
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);
2459
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();
2465
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__));
2469
2470   END_TEST;
2471 }
2472
2473 int UtcDaliRenderTaskOnceNoSync03(void)
2474 {
2475   TestApplication application;
2476
2477   tet_infoline(
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");
2481
2482   // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2483   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2484   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2485   drawTrace.Enable(true);
2486
2487   Actor rootActor = Actor::New();
2488   application.GetScene().Add(rootActor);
2489
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);
2494
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();
2500
2501   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2502
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__));
2507   END_TEST;
2508 }
2509
2510 int UtcDaliRenderTaskOnceNoSync04(void)
2511 {
2512   TestApplication application;
2513
2514   tet_infoline(
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");
2519
2520   // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2521   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2522   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2523   drawTrace.Enable(true);
2524
2525   Actor rootActor = Actor::New();
2526   application.GetScene().Add(rootActor);
2527
2528   CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2529   application.GetScene().Add(offscreenCameraActor);
2530
2531   Shader     shader     = CreateShader();
2532   Texture    image      = CreateTexture();
2533   TextureSet textureSet = CreateTextureSet(image);
2534
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);
2542
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();
2548
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);
2553
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__));
2558
2559   lastSyncObj = sync.GetLastSyncObject();
2560   DALI_TEST_CHECK(lastSyncObj == NULL);
2561
2562   END_TEST;
2563 }
2564
2565 int UtcDaliRenderTaskOnceNoSync05(void)
2566 {
2567   TestApplication application;
2568
2569   tet_infoline(
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.");
2574
2575   // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2576   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2577   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2578   drawTrace.Enable(true);
2579
2580   Actor rootActor = Actor::New();
2581   application.GetScene().Add(rootActor);
2582
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);
2587
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();
2593
2594   // START PROCESS/RENDER                    Input,     Expected  Input,    Expected
2595   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2596
2597   // CHANGE TO RENDER ONCE,
2598   newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2599   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
2600
2601   END_TEST;
2602 }
2603
2604 int UtcDaliRenderTaskOnceChain01(void)
2605 {
2606   TestApplication application;
2607
2608   tet_infoline(
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.");
2613
2614   // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2615   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2616   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2617   drawTrace.Enable(true);
2618
2619   Actor defaultRootActor = Actor::New(); // Root for default RT
2620   application.GetScene().Add(defaultRootActor);
2621
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);
2626
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);
2632
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);
2641
2642   application.SendNotification();
2643
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);
2648
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);
2653
2654   END_TEST;
2655 }
2656
2657 int UtcDaliRenderTaskProperties(void)
2658 {
2659   TestApplication application;
2660
2661   RenderTask task = application.GetScene().GetRenderTaskList().CreateTask();
2662
2663   Property::IndexContainer indices;
2664   task.GetPropertyIndices(indices);
2665   DALI_TEST_CHECK(indices.Size());
2666   DALI_TEST_EQUALS(indices.Size(), task.GetPropertyCount(), TEST_LOCATION);
2667   END_TEST;
2668 }
2669
2670 int UtcDaliRenderTaskFinishInvisibleSourceActor(void)
2671 {
2672   TestApplication application;
2673
2674   tet_infoline("Testing RenderTask::FinishInvisibleSourceActor()");
2675
2676   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2677   auto& sync = application.GetGraphicsSyncImpl();
2678
2679   CameraActor offscreenCameraActor = CameraActor::New();
2680
2681   application.GetScene().Add(offscreenCameraActor);
2682
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);
2688
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);
2694
2695   // Flush all outstanding messages
2696   application.SendNotification();
2697   application.Render();
2698
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);
2709
2710   // Framebuffer doesn't actually get created until Connected, i.e. by previous line
2711
2712   bool               finished = false;
2713   RenderTaskFinished renderTaskFinished(finished);
2714   newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2715
2716   // Flush the queue and render.
2717   application.SendNotification();
2718
2719   // 1 render to process render task, then wait for sync before finished msg is sent
2720   // from update to the event thread.
2721
2722   application.Render();
2723   application.SendNotification();
2724   DALI_TEST_CHECK(!finished);
2725
2726   Integration::GraphicsSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2727   DALI_TEST_CHECK(lastSyncObj != NULL);
2728
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);
2733
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);
2738
2739   sync.SetObjectSynced(lastSyncObj, true);
2740
2741   application.Render();
2742   application.SendNotification();
2743   DALI_TEST_CHECK(!finished);
2744
2745   application.Render();
2746   application.SendNotification();
2747   DALI_TEST_CHECK(finished);
2748   finished = false;
2749
2750   application.Render(); // Double check no more finished signal
2751   application.SendNotification();
2752   DALI_TEST_CHECK(!finished);
2753
2754   END_TEST;
2755 }
2756
2757 int UtcDaliRenderTaskFinishMissingImage(void)
2758 {
2759   TestApplication application;
2760
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");
2763
2764   Integration::Scene stage = application.GetScene();
2765
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);
2770
2771   Actor actorWithMissingImage = CreateRenderableActor(Texture());
2772   actorWithMissingImage.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
2773   stage.Add(actorWithMissingImage);
2774
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);
2782
2783   bool               finished = false;
2784   RenderTaskFinished renderTaskFinished(finished);
2785   newTask.FinishedSignal().Connect(&application, renderTaskFinished);
2786
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();
2791
2792   application.SendNotification();
2793   DALI_TEST_CHECK(finished);
2794
2795   END_TEST;
2796 }
2797
2798 int UtcDaliRenderTaskWorldToViewport(void)
2799 {
2800   TestApplication application(400u, 400u); // square surface
2801
2802   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2803
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));
2807
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));
2810
2811   application.GetScene().Add(actor);
2812
2813   application.SendNotification();
2814   application.Render();
2815   application.SendNotification();
2816
2817   RenderTask task = taskList.GetTask(0u);
2818
2819   CameraActor camera = task.GetCameraActor();
2820
2821   Vector2 screenSize = task.GetCurrentViewportSize();
2822
2823   float screenX = 0.0;
2824   float screenY = 0.0;
2825
2826   bool ok = task.WorldToViewport(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), screenX, screenY);
2827   DALI_TEST_CHECK(ok == true);
2828
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);
2831
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);
2839   actor2.Add(actor);
2840   actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0, 0, 0));
2841
2842   application.SendNotification();
2843   application.Render();
2844   application.SendNotification();
2845
2846   ok = task.WorldToViewport(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), screenX, screenY);
2847   DALI_TEST_CHECK(ok == true);
2848
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);
2851
2852   END_TEST;
2853 }
2854
2855 int UtcDaliRenderTaskViewportToLocal(void)
2856 {
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);
2863
2864   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2865   RenderTask     task     = taskList.GetTask(0u);
2866
2867   // flush the queue and render once
2868   application.SendNotification();
2869   application.Render();
2870   application.SendNotification();
2871   application.Render();
2872
2873   float localX;
2874   float localY;
2875
2876   float rtLocalX;
2877   float rtLocalY;
2878
2879   float screenX = 50.0f;
2880   float screenY = 50.0f;
2881
2882   DALI_TEST_CHECK(actor.ScreenToLocal(localX, localY, screenX, screenY));
2883
2884   DALI_TEST_CHECK(task.ViewportToLocal(actor, screenX, screenY, rtLocalX, rtLocalY));
2885
2886   DALI_TEST_EQUALS(localX, rtLocalX, 0.01f, TEST_LOCATION);
2887   DALI_TEST_EQUALS(localY, rtLocalY, 0.01f, TEST_LOCATION);
2888
2889   END_TEST;
2890 }
2891
2892 int UtcDaliRenderTaskOffscreenViewportToLocal(void)
2893 {
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);
2900
2901   RenderTaskList taskList = application.GetScene().GetRenderTaskList();
2902   RenderTask     task     = taskList.CreateTask();
2903
2904   FrameBuffer newFrameBuffer = FrameBuffer::New(10, 10);
2905   task.SetFrameBuffer(newFrameBuffer);
2906   task.SetSourceActor(actor);
2907   task.SetScreenToFrameBufferMappingActor(actor);
2908
2909   CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2910   application.GetScene().Add(offscreenCameraActor);
2911   task.SetCameraActor(offscreenCameraActor);
2912
2913   // flush the queue and render once
2914   application.SendNotification();
2915   application.Render();
2916   application.SendNotification();
2917   application.Render();
2918
2919   float localX;
2920   float localY;
2921
2922   float rtLocalX;
2923   float rtLocalY;
2924
2925   float screenX = 50.0f;
2926   float screenY = 50.0f;
2927
2928   DALI_TEST_CHECK(actor.ScreenToLocal(localX, localY, screenX, screenY));
2929
2930   DALI_TEST_CHECK(task.ViewportToLocal(actor, screenX, screenY, rtLocalX, rtLocalY));
2931
2932   DALI_TEST_EQUALS(localX, rtLocalX, 0.01f, TEST_LOCATION);
2933   DALI_TEST_EQUALS(localY, rtLocalY, 0.01f, TEST_LOCATION);
2934
2935   END_TEST;
2936 }
2937
2938 int UtcDaliRenderTaskRequiresSync(void)
2939 {
2940   TestApplication application;
2941   RenderTaskList  taskList = application.GetScene().GetRenderTaskList();
2942
2943   RenderTask newTask = taskList.CreateTask();
2944   newTask.SetProperty(RenderTask::Property::REQUIRES_SYNC, false);
2945
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);
2948
2949   newTask.SetProperty(RenderTask::Property::REQUIRES_SYNC, true);
2950
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);
2953
2954   END_TEST;
2955 }
2956
2957 int UtcDaliRenderTaskSetClearEnabled(void)
2958 {
2959   TestApplication application;
2960
2961   tet_infoline("UtcDaliRenderTaskSetClearEnabled");
2962
2963   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2964   TestGlAbstraction& gl = application.GetGlAbstraction();
2965
2966   Actor renderableActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2967   application.GetScene().Add(renderableActor);
2968
2969   Actor rootActor = Actor::New();
2970   application.GetScene().Add(rootActor);
2971
2972   CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
2973   application.GetScene().Add(offscreenCameraActor);
2974
2975   Actor sourceActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2976   application.GetScene().Add(sourceActor);
2977
2978   RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, sourceActor, RenderTask::REFRESH_ALWAYS, false);
2979
2980   DALI_TEST_EQUALS(gl.GetClearCountCalled(), 0, TEST_LOCATION);
2981
2982   application.SendNotification();
2983   application.Render();
2984
2985   // glClear should be called twice - default task and the new task.
2986   DALI_TEST_EQUALS(gl.GetClearCountCalled(), 2, TEST_LOCATION);
2987
2988   newTask.SetClearEnabled(false);
2989
2990   application.SendNotification();
2991   application.Render();
2992
2993   // The count should increase by 1 - default task only.
2994   DALI_TEST_EQUALS(gl.GetClearCountCalled(), 3, TEST_LOCATION);
2995
2996   END_TEST;
2997 }
2998
2999 int UtcDaliRenderTaskMoveConstrctor(void)
3000 {
3001   TestApplication application;
3002
3003   Vector4 testColor(1.0f, 2.0f, 3.0f, 4.0f);
3004
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);
3010
3011   task.SetClearColor(testColor);
3012
3013   // Wait a frame.
3014   Wait(application);
3015
3016   DALI_TEST_EQUALS(task.GetClearColor(), testColor, TEST_LOCATION);
3017
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);
3023
3024   END_TEST;
3025 }
3026
3027 int UtcDaliRenderTaskMoveAssignment(void)
3028 {
3029   TestApplication application;
3030
3031   Vector4 testColor(1.0f, 2.0f, 3.0f, 4.0f);
3032
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);
3038
3039   task.SetClearColor(testColor);
3040
3041   // Wait a frame.
3042   Wait(application);
3043
3044   DALI_TEST_EQUALS(task.GetClearColor(), testColor, TEST_LOCATION);
3045
3046   RenderTask move;
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);
3052
3053   END_TEST;
3054 }
3055
3056 int UtcDaliRenderTaskSetCullModeNegative(void)
3057 {
3058   TestApplication  application;
3059   Dali::RenderTask instance;
3060   try
3061   {
3062     bool arg1(false);
3063     instance.SetCullMode(arg1);
3064     DALI_TEST_CHECK(false); // Should not get here
3065   }
3066   catch(...)
3067   {
3068     DALI_TEST_CHECK(true); // We expect an assert
3069   }
3070   END_TEST;
3071 }
3072
3073 int UtcDaliRenderTaskSetViewportNegative(void)
3074 {
3075   TestApplication  application;
3076   Dali::RenderTask instance;
3077   try
3078   {
3079     Dali::Rect<int> arg1;
3080     instance.SetViewport(arg1);
3081     DALI_TEST_CHECK(false); // Should not get here
3082   }
3083   catch(...)
3084   {
3085     DALI_TEST_CHECK(true); // We expect an assert
3086   }
3087   END_TEST;
3088 }
3089
3090 int UtcDaliRenderTaskSetExclusiveNegative(void)
3091 {
3092   TestApplication  application;
3093   Dali::RenderTask instance;
3094   try
3095   {
3096     bool arg1(false);
3097     instance.SetExclusive(arg1);
3098     DALI_TEST_CHECK(false); // Should not get here
3099   }
3100   catch(...)
3101   {
3102     DALI_TEST_CHECK(true); // We expect an assert
3103   }
3104   END_TEST;
3105 }
3106
3107 int UtcDaliRenderTaskSetClearColorNegative(void)
3108 {
3109   TestApplication  application;
3110   Dali::RenderTask instance;
3111   try
3112   {
3113     Dali::Vector4 arg1;
3114     instance.SetClearColor(arg1);
3115     DALI_TEST_CHECK(false); // Should not get here
3116   }
3117   catch(...)
3118   {
3119     DALI_TEST_CHECK(true); // We expect an assert
3120   }
3121   END_TEST;
3122 }
3123
3124 int UtcDaliRenderTaskFinishedSignalNegative(void)
3125 {
3126   TestApplication  application;
3127   Dali::RenderTask instance;
3128   try
3129   {
3130     instance.FinishedSignal();
3131     DALI_TEST_CHECK(false); // Should not get here
3132   }
3133   catch(...)
3134   {
3135     DALI_TEST_CHECK(true); // We expect an assert
3136   }
3137   END_TEST;
3138 }
3139
3140 int UtcDaliRenderTaskSetCameraActorNegative(void)
3141 {
3142   TestApplication  application;
3143   Dali::RenderTask instance;
3144   try
3145   {
3146     Dali::CameraActor arg1;
3147     instance.SetCameraActor(arg1);
3148     DALI_TEST_CHECK(false); // Should not get here
3149   }
3150   catch(...)
3151   {
3152     DALI_TEST_CHECK(true); // We expect an assert
3153   }
3154   END_TEST;
3155 }
3156
3157 int UtcDaliRenderTaskSetFrameBufferNegative(void)
3158 {
3159   TestApplication  application;
3160   Dali::RenderTask instance;
3161   try
3162   {
3163     Dali::FrameBuffer arg1;
3164     instance.SetFrameBuffer(arg1);
3165     DALI_TEST_CHECK(false); // Should not get here
3166   }
3167   catch(...)
3168   {
3169     DALI_TEST_CHECK(true); // We expect an assert
3170   }
3171   END_TEST;
3172 }
3173
3174 int UtcDaliRenderTaskSetRefreshRateNegative(void)
3175 {
3176   TestApplication  application;
3177   Dali::RenderTask instance;
3178   try
3179   {
3180     unsigned int arg1(0u);
3181     instance.SetRefreshRate(arg1);
3182     DALI_TEST_CHECK(false); // Should not get here
3183   }
3184   catch(...)
3185   {
3186     DALI_TEST_CHECK(true); // We expect an assert
3187   }
3188   END_TEST;
3189 }
3190
3191 int UtcDaliRenderTaskSetSourceActorNegative(void)
3192 {
3193   TestApplication  application;
3194   Dali::RenderTask instance;
3195   try
3196   {
3197     Dali::Actor arg1;
3198     instance.SetSourceActor(arg1);
3199     DALI_TEST_CHECK(false); // Should not get here
3200   }
3201   catch(...)
3202   {
3203     DALI_TEST_CHECK(true); // We expect an assert
3204   }
3205   END_TEST;
3206 }
3207
3208 int UtcDaliRenderTaskSetClearEnabledNegative(void)
3209 {
3210   TestApplication  application;
3211   Dali::RenderTask instance;
3212   try
3213   {
3214     bool arg1(false);
3215     instance.SetClearEnabled(arg1);
3216     DALI_TEST_CHECK(false); // Should not get here
3217   }
3218   catch(...)
3219   {
3220     DALI_TEST_CHECK(true); // We expect an assert
3221   }
3222   END_TEST;
3223 }
3224
3225 int UtcDaliRenderTaskSetInputEnabledNegative(void)
3226 {
3227   TestApplication  application;
3228   Dali::RenderTask instance;
3229   try
3230   {
3231     bool arg1(false);
3232     instance.SetInputEnabled(arg1);
3233     DALI_TEST_CHECK(false); // Should not get here
3234   }
3235   catch(...)
3236   {
3237     DALI_TEST_CHECK(true); // We expect an assert
3238   }
3239   END_TEST;
3240 }
3241
3242 int UtcDaliRenderTaskSetViewportSizeNegative(void)
3243 {
3244   TestApplication  application;
3245   Dali::RenderTask instance;
3246   try
3247   {
3248     Dali::Vector2 arg1;
3249     instance.SetViewportSize(arg1);
3250     DALI_TEST_CHECK(false); // Should not get here
3251   }
3252   catch(...)
3253   {
3254     DALI_TEST_CHECK(true); // We expect an assert
3255   }
3256   END_TEST;
3257 }
3258
3259 int UtcDaliRenderTaskSetViewportPositionNegative(void)
3260 {
3261   TestApplication  application;
3262   Dali::RenderTask instance;
3263   try
3264   {
3265     Dali::Vector2 arg1;
3266     instance.SetViewportPosition(arg1);
3267     DALI_TEST_CHECK(false); // Should not get here
3268   }
3269   catch(...)
3270   {
3271     DALI_TEST_CHECK(true); // We expect an assert
3272   }
3273   END_TEST;
3274 }
3275
3276 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionNegative(void)
3277 {
3278   TestApplication  application;
3279   Dali::RenderTask instance;
3280   try
3281   {
3282     RenderTask::ScreenToFrameBufferFunction arg1(nullptr);
3283     instance.SetScreenToFrameBufferFunction(arg1);
3284     DALI_TEST_CHECK(false); // Should not get here
3285   }
3286   catch(...)
3287   {
3288     DALI_TEST_CHECK(true); // We expect an assert
3289   }
3290   END_TEST;
3291 }
3292
3293 int UtcDaliRenderTaskSetScreenToFrameBufferMappingActorNegative(void)
3294 {
3295   TestApplication  application;
3296   Dali::RenderTask instance;
3297   try
3298   {
3299     Dali::Actor arg1;
3300     instance.SetScreenToFrameBufferMappingActor(arg1);
3301     DALI_TEST_CHECK(false); // Should not get here
3302   }
3303   catch(...)
3304   {
3305     DALI_TEST_CHECK(true); // We expect an assert
3306   }
3307   END_TEST;
3308 }
3309
3310 int UtcDaliRenderTaskGetCullModeNegative(void)
3311 {
3312   TestApplication  application;
3313   Dali::RenderTask instance;
3314   try
3315   {
3316     instance.GetCullMode();
3317     DALI_TEST_CHECK(false); // Should not get here
3318   }
3319   catch(...)
3320   {
3321     DALI_TEST_CHECK(true); // We expect an assert
3322   }
3323   END_TEST;
3324 }
3325
3326 int UtcDaliRenderTaskGetViewportNegative(void)
3327 {
3328   TestApplication  application;
3329   Dali::RenderTask instance;
3330   try
3331   {
3332     instance.GetViewport();
3333     DALI_TEST_CHECK(false); // Should not get here
3334   }
3335   catch(...)
3336   {
3337     DALI_TEST_CHECK(true); // We expect an assert
3338   }
3339   END_TEST;
3340 }
3341
3342 int UtcDaliRenderTaskIsExclusiveNegative(void)
3343 {
3344   TestApplication  application;
3345   Dali::RenderTask instance;
3346   try
3347   {
3348     instance.IsExclusive();
3349     DALI_TEST_CHECK(false); // Should not get here
3350   }
3351   catch(...)
3352   {
3353     DALI_TEST_CHECK(true); // We expect an assert
3354   }
3355   END_TEST;
3356 }
3357
3358 int UtcDaliRenderTaskGetClearColorNegative(void)
3359 {
3360   TestApplication  application;
3361   Dali::RenderTask instance;
3362   try
3363   {
3364     instance.GetClearColor();
3365     DALI_TEST_CHECK(false); // Should not get here
3366   }
3367   catch(...)
3368   {
3369     DALI_TEST_CHECK(true); // We expect an assert
3370   }
3371   END_TEST;
3372 }
3373
3374 int UtcDaliRenderTaskGetCameraActorNegative(void)
3375 {
3376   TestApplication  application;
3377   Dali::RenderTask instance;
3378   try
3379   {
3380     instance.GetCameraActor();
3381     DALI_TEST_CHECK(false); // Should not get here
3382   }
3383   catch(...)
3384   {
3385     DALI_TEST_CHECK(true); // We expect an assert
3386   }
3387   END_TEST;
3388 }
3389
3390 int UtcDaliRenderTaskGetFrameBufferNegative(void)
3391 {
3392   TestApplication  application;
3393   Dali::RenderTask instance;
3394   try
3395   {
3396     instance.GetFrameBuffer();
3397     DALI_TEST_CHECK(false); // Should not get here
3398   }
3399   catch(...)
3400   {
3401     DALI_TEST_CHECK(true); // We expect an assert
3402   }
3403   END_TEST;
3404 }
3405
3406 int UtcDaliRenderTaskGetRefreshRateNegative(void)
3407 {
3408   TestApplication  application;
3409   Dali::RenderTask instance;
3410   try
3411   {
3412     instance.GetRefreshRate();
3413     DALI_TEST_CHECK(false); // Should not get here
3414   }
3415   catch(...)
3416   {
3417     DALI_TEST_CHECK(true); // We expect an assert
3418   }
3419   END_TEST;
3420 }
3421
3422 int UtcDaliRenderTaskGetSourceActorNegative(void)
3423 {
3424   TestApplication  application;
3425   Dali::RenderTask instance;
3426   try
3427   {
3428     instance.GetSourceActor();
3429     DALI_TEST_CHECK(false); // Should not get here
3430   }
3431   catch(...)
3432   {
3433     DALI_TEST_CHECK(true); // We expect an assert
3434   }
3435   END_TEST;
3436 }
3437
3438 int UtcDaliRenderTaskGetClearEnabledNegative(void)
3439 {
3440   TestApplication  application;
3441   Dali::RenderTask instance;
3442   try
3443   {
3444     instance.GetClearEnabled();
3445     DALI_TEST_CHECK(false); // Should not get here
3446   }
3447   catch(...)
3448   {
3449     DALI_TEST_CHECK(true); // We expect an assert
3450   }
3451   END_TEST;
3452 }
3453
3454 int UtcDaliRenderTaskGetInputEnabledNegative(void)
3455 {
3456   TestApplication  application;
3457   Dali::RenderTask instance;
3458   try
3459   {
3460     instance.GetInputEnabled();
3461     DALI_TEST_CHECK(false); // Should not get here
3462   }
3463   catch(...)
3464   {
3465     DALI_TEST_CHECK(true); // We expect an assert
3466   }
3467   END_TEST;
3468 }
3469
3470 int UtcDaliRenderTaskViewportToLocalNegative(void)
3471 {
3472   TestApplication  application;
3473   Dali::RenderTask instance;
3474   try
3475   {
3476     Dali::Actor arg1(Actor::New());
3477     float       arg2(0.0f);
3478     float       arg3(0.0f);
3479     float       arg4(0.0f);
3480     float       arg5(0.0f);
3481     instance.ViewportToLocal(arg1, arg2, arg3, arg4, arg5);
3482     DALI_TEST_CHECK(false); // Should not get here
3483   }
3484   catch(...)
3485   {
3486     DALI_TEST_CHECK(true); // We expect an assert
3487   }
3488   END_TEST;
3489 }
3490
3491 int UtcDaliRenderTaskWorldToViewportNegative(void)
3492 {
3493   TestApplication  application;
3494   Dali::RenderTask instance;
3495   try
3496   {
3497     Dali::Vector3 arg1;
3498     float         arg2(0.0f);
3499     float         arg3(0.0f);
3500     instance.WorldToViewport(arg1, arg2, arg3);
3501     DALI_TEST_CHECK(false); // Should not get here
3502   }
3503   catch(...)
3504   {
3505     DALI_TEST_CHECK(true); // We expect an assert
3506   }
3507   END_TEST;
3508 }
3509
3510 int UtcDaliRenderTaskGetCurrentViewportSizeNegative(void)
3511 {
3512   TestApplication  application;
3513   Dali::RenderTask instance;
3514   try
3515   {
3516     instance.GetCurrentViewportSize();
3517     DALI_TEST_CHECK(false); // Should not get here
3518   }
3519   catch(...)
3520   {
3521     DALI_TEST_CHECK(true); // We expect an assert
3522   }
3523   END_TEST;
3524 }
3525
3526 int UtcDaliRenderTaskGetCurrentViewportPositionNegative(void)
3527 {
3528   TestApplication  application;
3529   Dali::RenderTask instance;
3530   try
3531   {
3532     instance.GetCurrentViewportPosition();
3533     DALI_TEST_CHECK(false); // Should not get here
3534   }
3535   catch(...)
3536   {
3537     DALI_TEST_CHECK(true); // We expect an assert
3538   }
3539   END_TEST;
3540 }
3541
3542 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionNegative(void)
3543 {
3544   TestApplication  application;
3545   Dali::RenderTask instance;
3546   try
3547   {
3548     instance.GetScreenToFrameBufferFunction();
3549     DALI_TEST_CHECK(false); // Should not get here
3550   }
3551   catch(...)
3552   {
3553     DALI_TEST_CHECK(true); // We expect an assert
3554   }
3555   END_TEST;
3556 }
3557
3558 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorNegative(void)
3559 {
3560   TestApplication  application;
3561   Dali::RenderTask instance;
3562   try
3563   {
3564     instance.GetScreenToFrameBufferMappingActor();
3565     DALI_TEST_CHECK(false); // Should not get here
3566   }
3567   catch(...)
3568   {
3569     DALI_TEST_CHECK(true); // We expect an assert
3570   }
3571   END_TEST;
3572 }
3573
3574 int UtcDaliRenderTaskClippingMode01(void)
3575 {
3576   TestApplication application;
3577
3578   tet_infoline("Testing clipping mode: CLIP_TO_BOUNDING_BOX.\n");
3579
3580   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
3581   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3582   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
3583
3584   enabledDisableTrace.Enable(true);
3585   scissorTrace.Enable(true);
3586
3587   // SETUP AN OFFSCREEN RENDER TASK
3588   Actor rootActor = Actor::New();
3589   application.GetScene().Add(rootActor);
3590
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);
3595
3596   Shader     shader     = CreateShader();
3597   Texture    image      = CreateTexture();
3598   TextureSet textureSet = CreateTextureSet(image);
3599
3600   Geometry geometry = CreateQuadGeometry();
3601   Renderer renderer = Renderer::New(geometry, shader);
3602   renderer.SetTextures(textureSet);
3603
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);
3614
3615   RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
3616
3617   application.SendNotification();
3618   application.Render();
3619
3620   std::ostringstream scissor;
3621   scissor << std::hex << GL_SCISSOR_TEST;
3622   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
3623
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
3629
3630   END_TEST;
3631 }
3632
3633 int UtcDaliRenderTaskClippingMode02(void)
3634 {
3635   TestApplication application;
3636
3637   tet_infoline("Testing clipping mode with the inverted camera: CLIP_TO_BOUNDING_BOX.\n");
3638
3639   TestGlAbstraction& glAbstraction       = application.GetGlAbstraction();
3640   TraceCallStack&    enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3641   TraceCallStack&    scissorTrace        = glAbstraction.GetScissorTrace();
3642
3643   enabledDisableTrace.Enable(true);
3644   scissorTrace.Enable(true);
3645
3646   // SETUP AN OFFSCREEN RENDER TASK
3647   Actor rootActor = Actor::New();
3648   application.GetScene().Add(rootActor);
3649
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);
3655
3656   Shader     shader     = CreateShader();
3657   Texture    image      = CreateTexture();
3658   TextureSet textureSet = CreateTextureSet(image);
3659
3660   Geometry geometry = CreateQuadGeometry();
3661   Renderer renderer = Renderer::New(geometry, shader);
3662   renderer.SetTextures(textureSet);
3663
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);
3674
3675   RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
3676
3677   application.SendNotification();
3678   application.Render();
3679
3680   std::ostringstream scissor;
3681   scissor << std::hex << GL_SCISSOR_TEST;
3682   DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
3683
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
3689
3690   END_TEST;
3691 }
3692
3693 int UtcDaliRenderTaskUploadOnly(void)
3694 {
3695   TestApplication application;
3696
3697   tet_infoline("Testing RenderTask Render Once GlSync, using loaded image");
3698
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);
3704
3705   Actor rootActor = Actor::New();
3706   application.GetScene().Add(rootActor);
3707
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");
3711
3712   application.GetScene().Add(secondRootActor);
3713
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();
3719
3720   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
3721
3722   Integration::GraphicsSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
3723   DALI_TEST_CHECK(lastSyncObj != NULL);
3724   sync.SetObjectSynced(lastSyncObj, true);
3725
3726   application.SendNotification();
3727   application.Render(16, nullptr, true);
3728
3729   DALI_TEST_CHECK(!finished);
3730
3731   application.Render(16, nullptr, true);
3732   application.SendNotification();
3733
3734   DALI_TEST_CHECK(!finished);
3735   END_TEST;
3736 }
3737
3738 int UtcDaliRenderTaskSetGetViewportGuideActor(void)
3739 {
3740   TestApplication application;
3741   tet_infoline("Testing RenderTask with Set/Get ViewportGuideActor");
3742
3743   Stage   stage = Stage::GetCurrent();
3744   Vector2 stageSize(stage.GetSize());
3745
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);
3752
3753   stage.Add(blue);
3754
3755   RenderTaskList renderTaskList = stage.GetRenderTaskList();
3756   RenderTask     renderTask     = renderTaskList.CreateTask();
3757
3758   renderTask.SetViewportGuideActor(blue);
3759
3760   Actor actor = renderTask.GetViewportGuideActor();
3761   DALI_TEST_EQUALS(actor, blue, TEST_LOCATION);
3762
3763   renderTask.ResetViewportGuideActor();
3764   actor = renderTask.GetViewportGuideActor();
3765
3766   DALI_TEST_CHECK(!actor);
3767
3768   END_TEST;
3769 }
3770
3771 int UtcDaliRenderTaskViewportGuideActor(void)
3772 {
3773   TestApplication application;
3774   tet_infoline("Testing RenderTask with ViewportGuideActor");
3775
3776   Stage   stage = Stage::GetCurrent();
3777   Vector2 stageSize(stage.GetSize());
3778
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);
3785
3786   Geometry geometry = Geometry::New();
3787   Shader   shader   = Shader::New("vertexSrc", "fragmentSrc");
3788   Renderer renderer = Renderer::New(geometry, shader);
3789   blue.AddRenderer(renderer);
3790
3791   stage.Add(blue);
3792
3793   RenderTaskList renderTaskList = stage.GetRenderTaskList();
3794   RenderTask     renderTask     = renderTaskList.CreateTask();
3795
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);
3800
3801   renderTask.SetExclusive(true);
3802   renderTask.SetInputEnabled(true);
3803   renderTask.SetCameraActor(cameraActor);
3804   renderTask.SetSourceActor(blue);
3805   renderTask.SetViewportGuideActor(blue);
3806
3807   // Render and notify
3808   application.SendNotification();
3809   application.Render(16);
3810
3811   Vector2 viewportPosition = renderTask.GetCurrentViewportPosition();
3812   Vector2 viewportSize     = renderTask.GetCurrentViewportSize();
3813
3814   DALI_TEST_EQUALS(viewportSize, Vector2(300, 300), TEST_LOCATION);
3815   DALI_TEST_EQUALS(viewportPosition, Vector2(90, 250), TEST_LOCATION);
3816
3817   END_TEST;
3818 }
3819
3820 int UtcDaliRenderTaskViewportGuideActor02(void)
3821 {
3822   TestApplication application(
3823     TestApplication::DEFAULT_SURFACE_WIDTH,
3824     TestApplication::DEFAULT_SURFACE_HEIGHT,
3825     TestApplication::DEFAULT_HORIZONTAL_DPI,
3826     TestApplication::DEFAULT_VERTICAL_DPI,
3827     true,
3828     true);
3829   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3830   TraceCallStack&    callStack     = glAbstraction.GetViewportTrace();
3831   glAbstraction.EnableViewportCallTrace(true);
3832   tet_infoline("Testing RenderTask with ViewportGuideActor02");
3833
3834   Stage   stage = Stage::GetCurrent();
3835   Vector2 stageSize(stage.GetSize());
3836
3837   // Render and notify
3838   application.SendNotification();
3839   application.Render(16);
3840   glAbstraction.ResetViewportCallStack();
3841
3842   Geometry geometry = Geometry::New();
3843   Shader   shader   = Shader::New("vertexSrc", "fragmentSrc");
3844   Renderer renderer = Renderer::New(geometry, shader);
3845
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);
3853   stage.Add(blue);
3854
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);
3862   stage.Add(green);
3863
3864   RenderTaskList renderTaskList = stage.GetRenderTaskList();
3865   RenderTask     renderTask     = renderTaskList.CreateTask();
3866
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);
3871
3872   renderTask.SetExclusive(true);
3873   renderTask.SetInputEnabled(true);
3874   renderTask.SetCameraActor(cameraActor);
3875   renderTask.SetSourceActor(blue);
3876   renderTask.SetViewportGuideActor(blue);
3877
3878   application.GetScene().SurfaceRotated(static_cast<float>(TestApplication::DEFAULT_SURFACE_HEIGHT),
3879                                         static_cast<float>(TestApplication::DEFAULT_SURFACE_WIDTH),
3880                                         90,
3881                                         0);
3882
3883   // Render and notify
3884   application.SendNotification();
3885   application.Render(16);
3886
3887   std::string viewportParams1("50, 100, 300, 400"); // to match newSize
3888   std::string viewportParams2("0, 0, 480, 800");    // to match newSize
3889
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);
3893
3894   END_TEST;
3895 }
3896
3897 int UtcDaliRenderTaskViewportGuideActor03(void)
3898 {
3899   TestApplication application(
3900     TestApplication::DEFAULT_SURFACE_WIDTH,
3901     TestApplication::DEFAULT_SURFACE_HEIGHT,
3902     TestApplication::DEFAULT_HORIZONTAL_DPI,
3903     TestApplication::DEFAULT_VERTICAL_DPI,
3904     true,
3905     true);
3906
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");
3911
3912   Stage   stage = Stage::GetCurrent();
3913   Vector2 stageSize(stage.GetSize());
3914
3915   // Render and notify
3916   application.SendNotification();
3917   application.Render(16);
3918   glAbstraction.ResetViewportCallStack();
3919
3920   Geometry geometry = Geometry::New();
3921   Shader   shader   = Shader::New("vertexSrc", "fragmentSrc");
3922   Renderer renderer = Renderer::New(geometry, shader);
3923
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);
3931   stage.Add(blue);
3932
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);
3940   stage.Add(green);
3941
3942   RenderTaskList renderTaskList = stage.GetRenderTaskList();
3943   RenderTask     renderTask     = renderTaskList.CreateTask();
3944
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);
3949
3950   renderTask.SetExclusive(true);
3951   renderTask.SetInputEnabled(true);
3952   renderTask.SetCameraActor(cameraActor);
3953   renderTask.SetSourceActor(green);
3954
3955   Viewport viewport(75, 55, 150, 250);
3956   renderTask.SetViewport(viewport);
3957
3958   // Render and notify
3959   application.SendNotification();
3960   application.Render(16);
3961
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();
3966
3967   // Update to use viewport guide actor instead.
3968   renderTask.SetViewportGuideActor(blue);
3969
3970   // Render and notify
3971   application.SendNotification();
3972   application.Render(16);
3973
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();
3979
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);
3984
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.
3987   //
3988   application.SendNotification();
3989   application.Render(16);
3990
3991   DALI_TEST_CHECK(callStack.FindIndexFromMethodAndParams("Viewport", viewportParams1) >= 0);
3992
3993   END_TEST;
3994 }
3995
3996 int UtcDaliRenderTaskViewportGuideActor04(void)
3997 {
3998   TestApplication application(
3999     TestApplication::DEFAULT_SURFACE_WIDTH,
4000     TestApplication::DEFAULT_SURFACE_HEIGHT,
4001     TestApplication::DEFAULT_HORIZONTAL_DPI,
4002     TestApplication::DEFAULT_VERTICAL_DPI,
4003     true,
4004     true);
4005
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");
4010
4011   Stage   stage = Stage::GetCurrent();
4012   Vector2 stageSize(stage.GetSize());
4013
4014   // Render and notify
4015   application.SendNotification();
4016   application.Render(16);
4017   glAbstraction.ResetViewportCallStack();
4018
4019   Geometry geometry = Geometry::New();
4020   Shader   shader   = Shader::New("vertexSrc", "fragmentSrc");
4021   Renderer renderer = Renderer::New(geometry, shader);
4022
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);
4030   stage.Add(blue);
4031
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);
4039   stage.Add(green);
4040
4041   RenderTaskList renderTaskList = stage.GetRenderTaskList();
4042   RenderTask     renderTask     = renderTaskList.CreateTask();
4043
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);
4048
4049   renderTask.SetExclusive(true);
4050   renderTask.SetInputEnabled(true);
4051   renderTask.SetCameraActor(cameraActor);
4052   renderTask.SetSourceActor(green);
4053
4054   Viewport viewport(75, 55, 150, 250);
4055   renderTask.SetViewport(viewport);
4056
4057   // Render and notify
4058   application.SendNotification();
4059   application.Render(16);
4060
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();
4065
4066   // Update to use viewport guide actor instead.
4067   renderTask.SetViewportGuideActor(blue);
4068
4069   // Render and notify
4070   application.SendNotification();
4071   application.Render(16);
4072
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");
4076
4077   glAbstraction.ResetViewportCallStack();
4078
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);
4083
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);
4089
4090   DALI_TEST_CHECK(callStack.FindIndexFromMethodAndParams("Viewport", viewportParams1) >= 0);
4091
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);
4097
4098   END_TEST;
4099 }
4100
4101 int UtcDaliRenderTaskSetPartialUpdate(void)
4102 {
4103   TestApplication application(
4104     TestApplication::DEFAULT_SURFACE_WIDTH,
4105     TestApplication::DEFAULT_SURFACE_HEIGHT,
4106     TestApplication::DEFAULT_HORIZONTAL_DPI,
4107     TestApplication::DEFAULT_VERTICAL_DPI,
4108     true,
4109     true);
4110
4111   tet_infoline("Check the damaged rects with render task");
4112
4113   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
4114
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);
4121
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);
4128
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);
4133
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);
4137
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);
4149
4150   application.SendNotification();
4151
4152   std::vector<Rect<int>> damagedRects;
4153   Rect<int>              clippingRect;
4154
4155   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
4156
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);
4161
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);
4167
4168   // Remove framebuffer
4169   newTask.SetFrameBuffer(FrameBuffer());
4170
4171   application.SendNotification();
4172
4173   damagedRects.clear();
4174   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
4175
4176   // Full update
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);
4180
4181   application.RenderWithPartialUpdate(damagedRects, clippingRect);
4182
4183   // Set invalid viewport of the render task
4184   newTask.SetViewportSize(Vector2(-100.0f, -100.0f));
4185
4186   application.SendNotification();
4187
4188   damagedRects.clear();
4189   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
4190
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);
4195
4196   application.RenderWithPartialUpdate(damagedRects, clippingRect);
4197
4198   newTask.SetViewportSize(Vector2(0.0f, 0.0f));
4199
4200   // Change orientation of offscreen camera
4201   cameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS));
4202
4203   application.SendNotification();
4204
4205   damagedRects.clear();
4206   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
4207
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);
4212
4213   application.RenderWithPartialUpdate(damagedRects, clippingRect);
4214
4215   // Change camera target
4216   cameraActor.SetTargetPosition(Vector3(10.0f, 10.0f, 0.0f));
4217
4218   application.SendNotification();
4219
4220   damagedRects.clear();
4221   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
4222
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);
4227
4228   application.RenderWithPartialUpdate(damagedRects, clippingRect);
4229
4230   END_TEST;
4231 }
4232
4233 int UtcDaliRenderTaskRenderPassTag(void)
4234 {
4235   TestApplication application;
4236   tet_infoline("Testing RenderTask with RenderPassTag");
4237
4238   Stage   stage = Stage::GetCurrent();
4239   Vector2 stageSize(stage.GetSize());
4240
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);
4247
4248   Geometry geometry = Geometry::New();
4249
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;
4254
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;
4258
4259   Property::Array array;
4260   array.PushBack(map[0]);
4261   array.PushBack(map[1]);
4262
4263   Shader   shader   = Shader::New(array);
4264   Renderer renderer = Renderer::New(geometry, shader);
4265   blue.AddRenderer(renderer);
4266
4267   stage.Add(blue);
4268
4269   auto& gfx = application.GetGraphicsController();
4270   gfx.mCallStack.EnableLogging(true);
4271
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);
4280
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);
4289
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);
4298
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);
4307
4308   END_TEST;
4309 }
4310
4311 int UtcDaliRenderTaskWithWrongShaderData(void)
4312 {
4313   TestApplication application;
4314   tet_infoline("Testing RenderTask with wrong shader data");
4315
4316   Stage   stage = Stage::GetCurrent();
4317   Vector2 stageSize(stage.GetSize());
4318
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);
4325
4326   Geometry geometry = Geometry::New();
4327
4328   Shader   shader   = Shader::New(Property::Value(10.0f));
4329   Renderer renderer = Renderer::New(geometry, shader);
4330   blue.AddRenderer(renderer);
4331
4332   stage.Add(blue);
4333
4334   auto& gfx = application.GetGraphicsController();
4335
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);
4344
4345   END_TEST;
4346 }
4347
4348 int UtcDaliRenderTaskOrderIndex01(void)
4349 {
4350   TestApplication application;
4351   tet_infoline("Testing RenderTask with OrderIndex");
4352
4353   Stage   stage = Stage::GetCurrent();
4354   Vector2 stageSize(stage.GetSize());
4355
4356   RenderTaskList renderTaskList = stage.GetRenderTaskList();
4357   RenderTask     renderTask1    = renderTaskList.CreateTask();
4358
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)
4363   {
4364     DALI_TEST_EQUALS(answer1[i], renderTaskList.GetTask(i).GetOrderIndex(), TEST_LOCATION);
4365   }
4366
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)
4372   {
4373     DALI_TEST_EQUALS(answer2[i], renderTaskList.GetTask(i).GetOrderIndex(), TEST_LOCATION);
4374   }
4375
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)
4381   {
4382     DALI_TEST_EQUALS(answer3[i], renderTaskList.GetTask(i).GetOrderIndex(), TEST_LOCATION);
4383   }
4384
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)
4389   {
4390     DALI_TEST_EQUALS(answer4[i], renderTaskList.GetTask(i).GetOrderIndex(), TEST_LOCATION);
4391   }
4392
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)
4397   {
4398     DALI_TEST_EQUALS(answer5[i], renderTaskList.GetTask(i).GetOrderIndex(), TEST_LOCATION);
4399   }
4400
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)
4407   {
4408     DALI_TEST_EQUALS(answer6[i], renderTaskList.GetTask(i).GetOrderIndex(), TEST_LOCATION);
4409   }
4410
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)
4415   {
4416     DALI_TEST_EQUALS(answer7[i], renderTaskList.GetTask(i).GetOrderIndex(), TEST_LOCATION);
4417   }
4418
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)
4423   {
4424     DALI_TEST_EQUALS(answer8[i], renderTaskList.GetTask(i).GetOrderIndex(), TEST_LOCATION);
4425   }
4426
4427   END_TEST;
4428 }
4429
4430 int UtcDaliRenderTaskOrderIndex02(void)
4431 {
4432   TestApplication application;
4433   tet_infoline("Testing RenderTask with OrderIndex");
4434
4435   Stage   stage = Stage::GetCurrent();
4436   Vector2 stageSize(stage.GetSize());
4437
4438   RenderTaskList renderTaskList = stage.GetRenderTaskList();
4439   RenderTask     renderTask1    = renderTaskList.CreateTask();
4440   application.SendNotification();
4441   DALI_TEST_EQUALS(renderTask1, renderTaskList.GetTask(1u), TEST_LOCATION);
4442   
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);
4447
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);
4453
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);
4460
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);
4467
4468   END_TEST;
4469 }
4470
4471 int UtcDaliRenderTaskGetRenderTaskId(void)
4472 {
4473   TestApplication application;
4474   tet_infoline("Testing RenderTask Id get");
4475
4476   Stage   stage = Stage::GetCurrent();
4477   Vector2 stageSize(stage.GetSize());
4478
4479   RenderTaskList renderTaskList = stage.GetRenderTaskList();
4480
4481   RenderTask renderTask1 = renderTaskList.CreateTask();
4482   RenderTask renderTask2 = renderTaskList.CreateTask();
4483   RenderTask renderTask3 = renderTaskList.CreateTask();
4484
4485   DALI_TEST_CHECK(renderTask1.GetRenderTaskId() != 0u);
4486   DALI_TEST_CHECK(renderTask2.GetRenderTaskId() != 0u);
4487   DALI_TEST_CHECK(renderTask3.GetRenderTaskId() != 0u);
4488   
4489   DALI_TEST_CHECK(renderTask1.GetRenderTaskId() != renderTask2.GetRenderTaskId());
4490   DALI_TEST_CHECK(renderTask2.GetRenderTaskId() != renderTask3.GetRenderTaskId());
4491   DALI_TEST_CHECK(renderTask3.GetRenderTaskId() != renderTask1.GetRenderTaskId());
4492
4493   END_TEST;
4494 }