Merge "Support multiple window rendering" into devel/master
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-RenderTask.cpp
1 /*
2  * Copyright (c) 2017 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 <iostream>
19 #include <stdlib.h>
20 #include <dali/public-api/dali-core.h>
21 #include <dali/devel-api/events/hit-test-algorithm.h>
22 #include <dali-test-suite-utils.h>
23 #include <dali/integration-api/debug.h>
24 #include <test-native-image.h>
25
26 #include <mesh-builder.h>
27
28 #define BOOLSTR(x) ((x)?"T":"F")
29
30 //& set: DaliRenderTask
31
32 using namespace Dali;
33
34 void utc_dali_render_task_startup(void)
35 {
36   test_return_value = TET_UNDEF;
37 }
38
39 void utc_dali_render_task_cleanup(void)
40 {
41   test_return_value = TET_PASS;
42 }
43
44 /**
45  * APIs:
46  *
47  * Constructor, Destructor, DownCast, New, copy constructor, assignment operator
48  *
49  * SetSourceActor                      2+ve, 1-ve
50  * GetSourceActor                      1+ve, 1-ve
51  * SetExclusive                        2+ve, 0-ve
52  * IsExclusive                         2+ve, 0-ve
53  * SetInputEnabled                     1+ve, 0-ve
54  * GetInputEnabled                     1+ve, 0-ve
55  * SetCameraActor                      1+ve, 1-ve
56  * GetCameraActor                      1+ve, 1-ve
57  * SetTargetFrameBuffer                1+ve, 1-ve
58  * GetTargetFrameBuffer                1+ve, 1-ve
59  * SetScreenToFrameBufferFunction      1+ve, 1-ve
60  * GetScreenToFrameBufferFunction      1+ve, 1-ve
61  * SetScreenToFrameBufferMappingActor  1+ve, 1-ve
62  * GetScreenToFrameBufferMappingActor  1+ve, 1-ve
63  * SetViewportPosition                 1+ve
64  * GetCurrentViewportPosition          1+ve
65  * SetViewportSize                     1+ve
66  * GetCurrentViewportSize              1+ve
67  * SetViewport                         2+ve, 1-ve
68  * GetViewport                         2+ve, 1-ve
69  * SetClearColor                       1+ve, 1-ve
70  * GetClearColor                       1+ve, 1-ve
71  * SetClearEnabled                     1+ve, 1-ve
72  * GetClearEnabled                     1+ve, 1-ve
73  * SetCullMode
74  * GetCullMode
75  * SetRefreshRate                      Many
76  * GetRefreshRate                      1+ve
77  * FinishedSignal                      1+ve
78  */
79
80 namespace // unnamed namespace
81 {
82
83 const int RENDER_FRAME_INTERVAL = 16;                           ///< Duration of each frame in ms. (at approx 60FPS)
84
85 /*
86  * Simulate time passed by.
87  *
88  * @note this will always process at least 1 frame (1/60 sec)
89  *
90  * @param application Test application instance
91  * @param duration Time to pass in milliseconds.
92  * @return The actual time passed in milliseconds
93  */
94 int Wait(TestApplication& application, int duration = 0)
95 {
96   int time = 0;
97
98   for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
99   {
100     application.SendNotification();
101     application.Render(RENDER_FRAME_INTERVAL);
102     time += RENDER_FRAME_INTERVAL;
103   }
104
105   return time;
106 }
107
108 struct RenderTaskFinished
109 {
110   RenderTaskFinished( bool& finished )
111   : finished( finished )
112   {
113   }
114
115   void operator()( RenderTask& renderTask )
116   {
117     finished = true;
118   }
119
120   bool& finished;
121 };
122
123 struct RenderTaskFinishedRemoveSource
124 {
125   RenderTaskFinishedRemoveSource( bool& finished )
126   : finished( finished ),
127     finishedOnce(false)
128   {
129   }
130
131   void operator()( RenderTask& renderTask )
132   {
133     DALI_TEST_CHECK(finishedOnce == false);
134     finished = true;
135     finishedOnce = true;
136     Actor srcActor = renderTask.GetSourceActor();
137     UnparentAndReset(srcActor);
138   }
139
140   bool& finished;
141   bool finishedOnce;
142 };
143
144 struct RenderTaskFinishedRenderAgain
145 {
146   RenderTaskFinishedRenderAgain( bool& finished )
147   : finished( finished ),
148     finishedOnce(false)
149   {
150   }
151
152   void operator()( RenderTask& renderTask )
153   {
154     DALI_TEST_CHECK(finishedOnce == false);
155     finished = true;
156     finishedOnce = true;
157     renderTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
158   }
159
160   bool& finished;
161   bool finishedOnce;
162 };
163
164
165 bool TestScreenToFrameBufferFunction( Vector2& coordinates )
166 {
167   coordinates = coordinates + Vector2( 1, 2 );
168
169   return true;
170 }
171
172 Actor CreateRenderableActorSuccess(TestApplication& application, std::string filename)
173 {
174   PrepareResourceImage( application, 80u, 80u, Pixel::RGBA8888 );
175   Image image = ResourceImage::New(filename);
176   Actor actor = CreateRenderableActor(image);
177   actor.SetSize( 80, 80 );
178   return actor;
179 }
180
181 Actor CreateRenderableActorFailed(TestApplication& application, std::string filename)
182 {
183   Image image = ResourceImage::New(filename);
184   DALI_TEST_CHECK( image );
185   Actor actor = CreateRenderableActor(image);
186   actor.SetSize( 80, 80 );
187   return actor;
188 }
189
190 Image CreateResourceImage(TestApplication& application, std::string filename)
191 {
192   PrepareResourceImage( application, 80u, 80u, Pixel::RGBA8888 );
193   Image image = ResourceImage::New(filename);
194   DALI_TEST_CHECK( image );
195   return image;
196 }
197
198 RenderTask CreateRenderTask(TestApplication& application,
199                             CameraActor offscreenCamera,
200                             Actor rootActor,       // Reset default render task to point at this actor
201                             Actor secondRootActor, // Source actor
202                             unsigned int refreshRate,
203                             bool glSync)
204 {
205   // Change main render task to use a different root
206   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
207   taskList.GetTask(0u).SetSourceActor( rootActor );
208
209   FrameBufferImage frameBufferImage;
210   if( glSync )
211   {
212     NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
213     frameBufferImage= FrameBufferImage::New( *(testNativeImagePtr.Get()) );
214   }
215   else
216   {
217     frameBufferImage = FrameBufferImage::New( 10, 10 );
218   }
219
220   // Don't draw output framebuffer // '
221
222   RenderTask newTask = taskList.CreateTask();
223   newTask.SetCameraActor( offscreenCamera );
224   newTask.SetSourceActor( secondRootActor );
225   newTask.SetInputEnabled( false );
226   newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
227   newTask.SetClearEnabled( true );
228   newTask.SetExclusive( true );
229   newTask.SetRefreshRate( refreshRate );
230   newTask.SetTargetFrameBuffer( frameBufferImage );
231   newTask.SetProperty( RenderTask::Property::REQUIRES_SYNC, glSync );
232   return newTask;
233 }
234
235 bool UpdateRender(TestApplication& application, TraceCallStack& callStack, bool testDrawn, bool& finishedSig, bool testFinished, bool testKeepUpdating, int lineNumber )
236 {
237   finishedSig = false;
238   callStack.Reset();
239
240   tet_printf("TestApplication::UpdateRender().\n");
241
242   application.Render(16);
243   application.SendNotification();
244
245   bool sigPassed = false;
246   if( testFinished )
247   {
248     sigPassed = finishedSig;
249   }
250   else
251   {
252     sigPassed = ! finishedSig;
253   }
254
255   bool drawResult = callStack.FindMethod("DrawElements") || callStack.FindMethod("DrawArrays");
256
257   bool drawPassed = false;
258   if( testDrawn )
259   {
260     drawPassed = drawResult;
261   }
262   else
263   {
264     drawPassed = !drawResult;
265   }
266
267   bool keepUpdating = (application.GetUpdateStatus() != 0);
268   bool keepUpdatingPassed = false;
269   if( testKeepUpdating )
270   {
271     keepUpdatingPassed = keepUpdating;
272   }
273   else
274   {
275     keepUpdatingPassed = !keepUpdating;
276   }
277
278   bool result = (sigPassed && drawPassed && keepUpdatingPassed);
279
280   tet_printf("UpdateRender: Expected: Draw:%s Signal:%s KeepUpdating: %s  Actual: Draw:%s  Signal:%s KeepUpdating: %s  %s, line %d\n",
281              BOOLSTR(testDrawn), BOOLSTR(testFinished), BOOLSTR(testKeepUpdating),
282              BOOLSTR(drawResult), BOOLSTR(finishedSig), BOOLSTR(keepUpdating),
283              result ? "Passed":"Failed",
284              lineNumber );
285
286   return result;
287 }
288
289 // The functor to be used in the hit-test algorithm to check whether the actor is hittable.
290 bool IsActorHittableFunction(Actor actor, Dali::HitTestAlgorithm::TraverseType type)
291 {
292   bool hittable = false;
293
294   switch (type)
295   {
296     case Dali::HitTestAlgorithm::CHECK_ACTOR:
297     {
298       // Check whether the actor is visible and not fully transparent.
299       if( actor.IsVisible()
300           && actor.GetCurrentWorldColor().a > 0.01f) // not FULLY_TRANSPARENT
301       {
302
303         hittable = true;
304       }
305       break;
306     }
307     case Dali::HitTestAlgorithm::DESCEND_ACTOR_TREE:
308     {
309       if( actor.IsVisible() ) // Actor is visible, if not visible then none of its children are visible.
310       {
311         hittable = true;
312       }
313       break;
314     }
315     default:
316     {
317       break;
318     }
319   }
320
321   return hittable;
322 }
323
324 } // unnamed namespace
325
326
327 /****************************************************************************************************/
328 /****************************************************************************************************/
329 /********************************   TEST CASES BELOW   **********************************************/
330 /****************************************************************************************************/
331 /****************************************************************************************************/
332
333 int UtcDaliRenderTaskDownCast01(void)
334 {
335   TestApplication application;
336
337   tet_infoline("Testing RenderTask::DownCast()");
338
339   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
340
341   BaseHandle base = taskList.GetTask( 0u );
342   DALI_TEST_CHECK( base );
343
344   RenderTask task = RenderTask::DownCast( base );
345   DALI_TEST_CHECK( task );
346
347   // Try calling a method
348   DALI_TEST_CHECK( task.GetSourceActor() );
349   END_TEST;
350 }
351
352 int UtcDaliRenderTaskDownCast02(void)
353 {
354   TestApplication application;
355
356   tet_infoline("Testing RenderTask::DownCast()");
357
358   Actor actor = Actor::New();
359
360   RenderTask task = RenderTask::DownCast( actor );
361   DALI_TEST_CHECK( ! task );
362
363   END_TEST;
364 }
365
366 int UtcDaliRenderTaskSetSourceActorN(void)
367 {
368   TestApplication application;
369   tet_infoline("Testing RenderTask::SetSourceActor() Negative - try with empty actor handle");
370   Stage stage = Stage::GetCurrent();
371
372   Actor srcActor;
373
374   RenderTaskList taskList = stage.GetRenderTaskList();
375   RenderTask renderTask = taskList.CreateTask();
376   renderTask.SetSourceActor(srcActor);
377
378   application.SendNotification();
379   application.Render();
380
381   DALI_TEST_CHECK( ! renderTask.GetSourceActor() );
382   END_TEST;
383 }
384
385
386 int UtcDaliRenderTaskSetSourceActorP01(void)
387 {
388   TestApplication application;
389
390   tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that setting a non-renderable actor stops existing source actor being rendered ");
391
392   Stage stage = Stage::GetCurrent();
393   RenderTaskList taskList = stage.GetRenderTaskList();
394   RenderTask task = taskList.GetTask( 0u );
395
396   Actor actor = task.GetSourceActor();
397   DALI_TEST_CHECK( actor );
398
399   BufferImage img = BufferImage::New( 1,1 );
400   Actor newActor = CreateRenderableActor( img );
401   newActor.SetSize(1,1);
402   stage.Add( newActor );
403
404   Actor nonRenderableActor = Actor::New();
405   stage.Add( nonRenderableActor );
406
407   // Stop the newActor from being rendered by changing the source actor
408   DALI_TEST_CHECK( nonRenderableActor );
409   task.SetSourceActor( nonRenderableActor );
410   DALI_TEST_CHECK( task.GetSourceActor() != actor );
411   DALI_TEST_CHECK( task.GetSourceActor() == nonRenderableActor );
412
413   TestGlAbstraction& gl = application.GetGlAbstraction();
414   TraceCallStack& drawTrace = gl.GetDrawTrace();
415   drawTrace.Enable(true);
416
417   // Update & Render nothing!
418   application.GetGlAbstraction().ClearBoundTextures();
419   application.SendNotification();
420   application.Render();
421
422   // Check that nothing was rendered
423   DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION );
424
425   END_TEST;
426 }
427
428
429 int UtcDaliRenderTaskSetSourceActorP02(void)
430 {
431   TestApplication application;
432
433   tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that switching source from a non-renderable to a renderable actor causes the texture to be drawn");
434
435   Stage stage = Stage::GetCurrent();
436
437   RenderTaskList taskList = stage.GetRenderTaskList();
438
439   RenderTask task = taskList.GetTask( 0u );
440
441   Actor actor = task.GetSourceActor();
442   DALI_TEST_CHECK( actor );
443
444
445   BufferImage img = BufferImage::New( 1,1 );
446   Actor newActor = CreateRenderableActor( img );
447   newActor.SetSize(1,1);
448   stage.Add( newActor );
449
450   Actor nonRenderableActor = Actor::New();
451   stage.Add( nonRenderableActor );
452
453   TestGlAbstraction& gl = application.GetGlAbstraction();
454   TraceCallStack& drawTrace = gl.GetDrawTrace();
455   drawTrace.Enable(true);
456
457   // Stop the newActor from being rendered by changing the source actor
458   DALI_TEST_CHECK( nonRenderableActor );
459   task.SetSourceActor( nonRenderableActor );
460   DALI_TEST_CHECK( task.GetSourceActor() != actor );
461   DALI_TEST_CHECK( task.GetSourceActor() == nonRenderableActor );
462
463   // Update & Render nothing!
464   application.GetGlAbstraction().ClearBoundTextures();
465   application.SendNotification();
466   application.Render();
467
468   // Check that nothing was rendered
469   DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION );
470   drawTrace.Reset();
471
472   // Set newActor as the new source Actor
473   task.SetSourceActor( newActor );
474   DALI_TEST_CHECK( task.GetSourceActor() != actor );
475   DALI_TEST_CHECK( task.GetSourceActor() == newActor );
476
477   // Update & Render the newActor
478   application.GetGlAbstraction().ClearBoundTextures();
479   application.SendNotification();
480   application.Render();
481
482   // Check that the newActor was rendered
483   DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION );
484   END_TEST;
485 }
486
487 int UtcDaliRenderTaskSetSourceActorOffStage(void)
488 {
489   TestApplication application;
490
491   tet_infoline("Testing RenderTask::SetSourceActor (on/off stage testing)");
492
493   Stage stage = Stage::GetCurrent();
494   RenderTaskList taskList = stage.GetRenderTaskList();
495   RenderTask task = taskList.GetTask( 0u );
496
497   Actor actor = task.GetSourceActor();
498   DALI_TEST_CHECK( actor );
499
500   TestGlAbstraction& gl = application.GetGlAbstraction();
501   TraceCallStack& drawTrace = gl.GetDrawTrace();
502   drawTrace.Enable(true);
503
504   BufferImage img = BufferImage::New( 1,1 );
505   Actor newActor = CreateRenderableActor( img );
506   newActor.SetSize(1,1);
507   task.SetSourceActor( newActor );
508   // Don't add newActor to stage yet   //'
509
510   // Update & Render with the actor initially off-stage
511   application.SendNotification();
512   application.Render();
513
514   // Check that nothing was rendered
515   DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION );
516
517   // Now add to stage
518   stage.Add( newActor );
519
520   // Update & Render with the actor on-stage
521   application.GetGlAbstraction().ClearBoundTextures();
522   application.SendNotification();
523   application.Render();
524
525   // Check that the newActor was rendered
526   DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION );
527   drawTrace.Reset();
528
529   // Now remove from stage
530   stage.Remove( newActor );
531
532   // Update & Render with the actor off-stage
533   application.SendNotification();
534   application.Render();
535   DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION );
536
537   END_TEST;
538 }
539
540 int UtcDaliRenderTaskSetSourceActorEmpty(void)
541 {
542   TestApplication application;
543
544   tet_infoline("Testing RenderTask::SetSourceActor (empty handle case)");
545
546   Stage stage = Stage::GetCurrent();
547   RenderTaskList taskList = stage.GetRenderTaskList();
548   RenderTask task = taskList.GetTask( 0u );
549
550   Actor actor = task.GetSourceActor();
551   DALI_TEST_CHECK( actor );
552
553   BufferImage img = BufferImage::New( 1,1 );
554   Actor newActor = CreateRenderableActor( img );
555   newActor.SetSize(1,1);
556   stage.Add( newActor );
557
558   Actor nonRenderableActor = Actor::New();
559   stage.Add( nonRenderableActor );
560
561   // Set with empty handle
562   task.SetSourceActor( Actor() );
563   DALI_TEST_CHECK( ! task.GetSourceActor() );
564
565   TestGlAbstraction& gl = application.GetGlAbstraction();
566   TraceCallStack& drawTrace = gl.GetDrawTrace();
567   drawTrace.Enable(true);
568
569   // Update & Render nothing!
570   application.SendNotification();
571   application.Render();
572
573   // Check that nothing was rendered
574   DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION );
575
576   // Set with non-empty handle
577   task.SetSourceActor( newActor );
578   DALI_TEST_CHECK( task.GetSourceActor() == newActor );
579
580   // Update & Render the newActor
581   application.GetGlAbstraction().ClearBoundTextures();
582   application.SendNotification();
583   application.Render();
584
585   // Check that the newActor was rendered
586   DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION );
587   END_TEST;
588 }
589
590 int UtcDaliRenderTaskGetSourceActorP01(void)
591 {
592   TestApplication application;
593
594   tet_infoline("Testing RenderTask::GetSourceActor() Check the default render task has a valid source actor");
595
596   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
597
598   RenderTask task = taskList.GetTask( 0u );
599
600   Actor actor = task.GetSourceActor();
601   DALI_TEST_CHECK( actor );
602
603   // By default the entire scene should be rendered
604   Actor root = Stage::GetCurrent().GetLayer( 0 );
605   DALI_TEST_CHECK( root == actor );
606   END_TEST;
607 }
608
609 int UtcDaliRenderTaskGetSourceActorP02(void)
610 {
611   TestApplication application;
612
613   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.");
614
615   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
616   RenderTask task = taskList.CreateTask();
617   Actor actor = Actor::New();
618   Stage::GetCurrent().Add(actor);
619   task.SetSourceActor( actor );
620
621   DALI_TEST_EQUALS( actor, task.GetSourceActor(), TEST_LOCATION );
622
623   END_TEST;
624 }
625
626 int UtcDaliRenderTaskGetSourceActorN(void)
627 {
628   TestApplication application;
629
630   tet_infoline("Testing RenderTask::GetSourceActor() Try with empty handle");
631
632   RenderTask task;
633   try
634   {
635     Actor actor = task.GetSourceActor();
636   }
637   catch (Dali::DaliException& e)
638   {
639     DALI_TEST_PRINT_ASSERT( e );
640     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
641   }
642
643   END_TEST;
644 }
645
646 int UtcDaliRenderTaskSetExclusive(void)
647 {
648   TestApplication application;
649
650   tet_infoline("Testing RenderTask::SetExclusive() Check that exclusion works");
651
652   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
653
654   // Manipulate the GenTextures behaviour, to identify different actors
655
656   std::vector<GLuint> ids;
657   ids.push_back( 8 ); // 8 = actor1
658   ids.push_back( 9 ); // 9 = actor2
659   ids.push_back( 10 ); // 10 = actor3
660   application.GetGlAbstraction().SetNextTextureIds( ids );
661
662   BufferImage img1 = BufferImage::New( 1,1 );
663   Actor actor1 = CreateRenderableActor( img1 );
664   actor1.SetSize(1,1);
665   Stage::GetCurrent().Add( actor1 );
666
667   // Update & Render actor1
668   application.SendNotification();
669   application.Render();
670
671   // Check that the actor1 was rendered
672   const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
673   DALI_TEST_GREATER( boundTextures.size(), static_cast<std::vector<GLuint>::size_type>( 0 ), TEST_LOCATION );
674
675   if ( boundTextures.size() )
676   {
677     int c = 0;
678     DALI_TEST_EQUALS( boundTextures[c++], 8u/*unique to actor1*/, TEST_LOCATION );
679     if( boundTextures.size() > 1 )
680     {
681       DALI_TEST_EQUALS( boundTextures[c++], 8u/*unique to actor1*/, TEST_LOCATION );
682     }
683   }
684
685   BufferImage img2 = BufferImage::New( 1,1 );
686   Actor actor2 = CreateRenderableActor( img2 );
687   actor2.SetSize(1,1);
688
689   // Force actor2 to be rendered before actor1
690   Layer layer = Layer::New();
691   Stage::GetCurrent().Add( layer );
692   layer.Add( actor2 );
693   layer.LowerToBottom();
694
695   // Update & Render
696   application.GetGlAbstraction().ClearBoundTextures();
697   application.SendNotification();
698   application.Render();
699
700   // Check that the actors were rendered
701   DALI_TEST_GREATER( boundTextures.size(), static_cast<std::vector<GLuint>::size_type>( 1 ), TEST_LOCATION );
702
703   if ( boundTextures.size() )
704   {
705     int c = 0;
706     DALI_TEST_EQUALS( boundTextures[c++], 9u/*unique to actor2*/, TEST_LOCATION );
707     if( boundTextures.size() > 2 )
708     {
709       DALI_TEST_EQUALS( boundTextures[c++], 9u/*unique to actor1*/, TEST_LOCATION );
710     }
711     DALI_TEST_EQUALS( boundTextures[c++], 8u/*unique to actor1*/, TEST_LOCATION );
712   }
713
714   BufferImage img3 = BufferImage::New( 1,1 );
715   Actor actor3 = CreateRenderableActor( img3 );
716   actor3.SetSize(1,1);
717
718   // Force actor3 to be rendered before actor2
719   layer = Layer::New();
720   Stage::GetCurrent().Add( layer );
721   layer.Add( actor3 );
722   layer.LowerToBottom();
723
724   // Update & Render all actors
725   application.GetGlAbstraction().ClearBoundTextures();
726   application.SendNotification();
727   application.Render();
728
729   // Check that the actors were rendered
730   DALI_TEST_GREATER( boundTextures.size(), static_cast<std::vector<GLuint>::size_type>( 2 ), TEST_LOCATION );
731
732   if ( boundTextures.size() )
733   {
734     int c = 0;
735     DALI_TEST_EQUALS( boundTextures[c++], 10u/*unique to actor3*/, TEST_LOCATION );
736     if( boundTextures.size() > 3 )
737     {
738       DALI_TEST_EQUALS( boundTextures[c++], 10u/*unique to actor2*/, TEST_LOCATION );
739     }
740     DALI_TEST_EQUALS( boundTextures[c++], 9u/*unique to actor2*/, TEST_LOCATION );
741     DALI_TEST_EQUALS( boundTextures[c++], 8u/*unique to actor1*/, TEST_LOCATION );
742   }
743
744   // Both actors are now connected to the root node
745   // Setup 2 render-tasks - the first will render from the root-node, and the second from actor2
746
747   // Not exclusive is the default
748   RenderTask task1 = taskList.GetTask( 0u );
749   DALI_TEST_CHECK( false == task1.IsExclusive() );
750
751   RenderTask task2 = taskList.CreateTask();
752   DALI_TEST_CHECK( false == task2.IsExclusive() );
753   task2.SetSourceActor( actor2 );
754
755   // Task1 should render all actors, and task 2 should render only actor2
756
757   application.GetGlAbstraction().ClearBoundTextures();
758   application.SendNotification();
759   application.Render();
760
761   DALI_TEST_EQUALS( boundTextures.size(), 4u, TEST_LOCATION );
762
763   if ( boundTextures.size() == 4 )
764   {
765     // Test that task 1 renders actor3, then actor2 & then actor1
766     DALI_TEST_CHECK( boundTextures[0] == 10u );
767     DALI_TEST_CHECK( boundTextures[1] == 9u );
768     DALI_TEST_CHECK( boundTextures[2] == 8u );
769
770     // Test that task 2 renders actor2
771     DALI_TEST_EQUALS( boundTextures[3], 9u, TEST_LOCATION );
772   }
773
774   // Make actor2 exclusive to task2
775
776   task2.SetExclusive( true );
777   DALI_TEST_CHECK( true == task2.IsExclusive() );
778
779   // Task1 should render only actor1, and task 2 should render only actor2
780
781   application.GetGlAbstraction().ClearBoundTextures();
782   application.SendNotification();
783   application.Render();
784
785   DALI_TEST_EQUALS( boundTextures.size(), 3u, TEST_LOCATION );
786   if ( boundTextures.size() == 3 )
787   {
788     // Test that task 1 renders actor3 & actor1
789     DALI_TEST_CHECK( boundTextures[0] == 10u );
790     DALI_TEST_CHECK( boundTextures[1] == 8u );
791
792     // Test that task 2 renders actor2
793     DALI_TEST_CHECK( boundTextures[2] == 9u );
794   }
795   END_TEST;
796 }
797
798 int UtcDaliRenderTaskSetExclusive02(void)
799 {
800   TestApplication application;
801
802   tet_infoline("Testing RenderTask::SetExclusive() Check that changing from exclusive to not-exclusive works");
803
804   std::vector<GLuint> ids;
805   ids.push_back( 8 ); // 8 = actor1
806   application.GetGlAbstraction().SetNextTextureIds( ids );
807
808   BufferImage img1 = BufferImage::New( 1,1 );
809   Actor actor1 = CreateRenderableActor( img1 );
810   actor1.SetSize(1,1);
811   Stage::GetCurrent().Add( actor1 );
812
813   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
814   RenderTask task = taskList.CreateTask();
815
816   task.SetSourceActor( actor1 );
817   task.SetExclusive(true); // Actor should only render once
818
819   TestGlAbstraction& gl = application.GetGlAbstraction();
820   TraceCallStack& drawTrace = gl.GetDrawTrace();
821   drawTrace.Enable(true);
822
823   // Update & Render actor1
824   application.SendNotification();
825   application.Render();
826
827   DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION );
828
829   // Set task to non-exclusive - actor1 should render twice:
830   drawTrace.Reset();
831   task.SetExclusive(false);
832   application.SendNotification();
833   application.Render();
834
835   DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 2, TEST_LOCATION );
836
837   END_TEST;
838 }
839
840 int UtcDaliRenderTaskSetExclusiveN(void)
841 {
842   TestApplication application;
843
844   tet_infoline("Testing RenderTask::SetExclusive() on empty handle");
845
846   RenderTask task;
847   try
848   {
849     task.SetExclusive(true);
850   }
851   catch (Dali::DaliException& e)
852   {
853     DALI_TEST_PRINT_ASSERT( e );
854     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
855   }
856   END_TEST;
857 }
858
859 int UtcDaliRenderTaskIsExclusive01(void)
860 {
861   TestApplication application;
862
863   tet_infoline("Testing RenderTask::IsExclusive() Check default values are non-exclusive");
864
865   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
866
867   // Not exclusive is the default
868   RenderTask task = taskList.GetTask( 0u );
869   DALI_TEST_CHECK( false == task.IsExclusive() );
870
871   RenderTask newTask = taskList.CreateTask();
872   DALI_TEST_CHECK( false == newTask.IsExclusive() );
873
874   END_TEST;
875 }
876
877 int UtcDaliRenderTaskIsExclusive02(void)
878 {
879   TestApplication application;
880
881   tet_infoline("Testing RenderTask::IsExclusive() Check the getter returns set values");
882
883   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
884
885   // Not exclusive is the default
886   RenderTask newTask = taskList.CreateTask();
887   DALI_TEST_EQUALS( newTask.IsExclusive(), false, TEST_LOCATION );
888
889   newTask.SetExclusive(true);
890   DALI_TEST_EQUALS( newTask.IsExclusive(), true, TEST_LOCATION );
891   END_TEST;
892 }
893
894 int UtcDaliRenderTaskIsExclusiveN(void)
895 {
896   TestApplication application;
897
898   tet_infoline("Testing RenderTask::IsExclusive() on empty handle");
899
900   RenderTask task;
901   try
902   {
903     bool x = task.IsExclusive();
904     (void) x;
905   }
906   catch (Dali::DaliException& e)
907   {
908     DALI_TEST_PRINT_ASSERT( e );
909     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
910   }
911   END_TEST;
912 }
913
914 int UtcDaliRenderTaskSetInputEnabled(void)
915 {
916   TestApplication application;
917
918   tet_infoline("Testing RenderTask::SetInputEnabled()");
919
920   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
921
922   // Input is enabled by default
923   RenderTask task = taskList.GetTask( 0u );
924   DALI_TEST_CHECK( true == task.GetInputEnabled() );
925
926   task.SetInputEnabled( false );
927   DALI_TEST_CHECK( false == task.GetInputEnabled() );
928
929   task.SetInputEnabled( true );
930   DALI_TEST_CHECK( true == task.GetInputEnabled() );
931   END_TEST;
932 }
933
934 int UtcDaliRenderTaskGetInputEnabled(void)
935 {
936   TestApplication application;
937
938   tet_infoline("Testing RenderTask::GetInputEnabled()");
939
940   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
941
942   // Input is enabled by default
943   RenderTask task = taskList.GetTask( 0u );
944   DALI_TEST_EQUALS( true, task.GetInputEnabled(), TEST_LOCATION );
945
946   RenderTask newTask = taskList.CreateTask();
947   DALI_TEST_EQUALS( true, newTask.GetInputEnabled(), TEST_LOCATION );
948
949   newTask.SetInputEnabled(false);
950   DALI_TEST_EQUALS( false, newTask.GetInputEnabled(), TEST_LOCATION );
951
952   END_TEST;
953 }
954
955 int UtcDaliRenderTaskSetCameraActorP(void)
956 {
957   TestApplication application;
958
959   tet_infoline("Testing RenderTask::SetCameraActor()");
960
961   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
962
963   RenderTask task = taskList.GetTask( 0u );
964
965   Actor defaultCameraActor = task.GetCameraActor();
966   DALI_TEST_CHECK( defaultCameraActor );
967
968   CameraActor newCameraActor = CameraActor::New();
969   DALI_TEST_CHECK( newCameraActor );
970
971   task.SetCameraActor( newCameraActor );
972   DALI_TEST_CHECK( task.GetCameraActor() != defaultCameraActor );
973   DALI_TEST_EQUALS( task.GetCameraActor(), newCameraActor, TEST_LOCATION );
974   END_TEST;
975 }
976
977
978 int UtcDaliRenderTaskSetCameraActorN(void)
979 {
980   TestApplication application;
981
982   tet_infoline("Testing RenderTask::SetCameraActor() with empty actor handle");
983
984   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
985
986   RenderTask task = taskList.GetTask( 0u );
987
988   Actor actor = task.GetCameraActor();
989   DALI_TEST_CHECK( actor );
990
991   CameraActor cameraActor;
992
993   task.SetCameraActor( cameraActor );
994   DALI_TEST_EQUALS( (bool)task.GetCameraActor(), false, TEST_LOCATION );
995   DALI_TEST_EQUALS( task.GetCameraActor(), cameraActor, TEST_LOCATION );
996   END_TEST;
997 }
998
999
1000 int UtcDaliRenderTaskGetCameraActorP(void)
1001 {
1002   TestApplication application;
1003
1004   tet_infoline("Testing RenderTask::GetCameraActor()");
1005
1006   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1007
1008   RenderTask task = taskList.GetTask( 0u );
1009
1010   CameraActor actor = task.GetCameraActor();
1011   DALI_TEST_CHECK( actor );
1012   DALI_TEST_EQUALS( actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION );
1013   DALI_TEST_GREATER( actor.GetFieldOfView(), 0.0f, TEST_LOCATION );
1014   END_TEST;
1015 }
1016
1017 int UtcDaliRenderTaskGetCameraActorN(void)
1018 {
1019   TestApplication application;
1020
1021   tet_infoline("Testing RenderTask::GetCameraActor() with empty handle");
1022   RenderTask task;
1023
1024   try
1025   {
1026     Actor actor = task.GetCameraActor();
1027   }
1028   catch (Dali::DaliException& e)
1029   {
1030     DALI_TEST_PRINT_ASSERT( e );
1031     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1032   }
1033
1034   END_TEST;
1035 }
1036
1037 int UtcDaliRenderTaskSetTargetFrameBufferP(void)
1038 {
1039   TestApplication application;
1040
1041   tet_infoline("Testing RenderTask::SetTargetFrameBuffer()");
1042
1043   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1044
1045   RenderTask task = taskList.GetTask( 0u );
1046
1047   FrameBufferImage newImage = FrameBufferImage::New();
1048   task.SetTargetFrameBuffer( newImage );
1049   DALI_TEST_CHECK( task.GetTargetFrameBuffer() == newImage );
1050   END_TEST;
1051 }
1052
1053 int UtcDaliRenderTaskSetTargetFrameBufferN(void)
1054 {
1055   TestApplication application;
1056
1057   tet_infoline("Testing RenderTask::SetTargetFrameBuffer()");
1058
1059   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1060
1061   RenderTask task = taskList.GetTask( 0u );
1062   FrameBufferImage newImage; // Empty handle
1063   task.SetTargetFrameBuffer( newImage );
1064   DALI_TEST_EQUALS( (bool)task.GetTargetFrameBuffer(), false, TEST_LOCATION );
1065   END_TEST;
1066 }
1067
1068 int UtcDaliRenderTaskGetTargetFrameBufferP(void)
1069 {
1070   TestApplication application;
1071
1072   tet_infoline("Testing RenderTask::GetTargetFrameBuffer()");
1073
1074   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1075
1076   RenderTask newTask = taskList.CreateTask();
1077   FrameBufferImage fb = FrameBufferImage::New(128, 128, Pixel::RGBA8888);
1078   newTask.SetTargetFrameBuffer( fb );
1079   DALI_TEST_EQUALS( newTask.GetTargetFrameBuffer(), fb, TEST_LOCATION );
1080   END_TEST;
1081 }
1082
1083 int UtcDaliRenderTaskGetTargetFrameBufferN(void)
1084 {
1085   TestApplication application;
1086
1087   tet_infoline("Testing RenderTask::GetTargetFrameBuffer()");
1088
1089   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1090
1091   RenderTask task = taskList.GetTask( 0u );
1092
1093   // By default render-tasks do not render off-screen
1094   FrameBufferImage image = task.GetTargetFrameBuffer();
1095   DALI_TEST_CHECK( !image );
1096
1097   END_TEST;
1098 }
1099
1100 int UtcDaliRenderTaskSetFrameBufferP(void)
1101 {
1102   TestApplication application;
1103
1104   tet_infoline("Testing RenderTask::SetFrameBuffer()");
1105
1106   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1107
1108   RenderTask task = taskList.GetTask( 0u );
1109
1110   FrameBuffer newFrameBuffer = FrameBuffer::New( 128u, 128u, FrameBuffer::Attachment::NONE );
1111   task.SetFrameBuffer( newFrameBuffer );
1112   DALI_TEST_CHECK( task.GetFrameBuffer() == newFrameBuffer );
1113   END_TEST;
1114 }
1115
1116 int UtcDaliRenderTaskSetFrameBufferN(void)
1117 {
1118   TestApplication application;
1119
1120   tet_infoline("Testing RenderTask::SetFrameBuffer()");
1121
1122   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1123
1124   RenderTask task = taskList.GetTask( 0u );
1125   FrameBuffer newFrameBuffer; // Empty handle
1126   task.SetFrameBuffer( newFrameBuffer );
1127   DALI_TEST_EQUALS( (bool)task.GetFrameBuffer(), false, TEST_LOCATION );
1128   END_TEST;
1129 }
1130
1131 int UtcDaliRenderTaskGetFrameBufferP(void)
1132 {
1133   TestApplication application;
1134
1135   tet_infoline("Testing RenderTask::GetFrameBuffer()");
1136
1137   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1138
1139   RenderTask task = taskList.GetTask( 0u );
1140
1141   FrameBuffer newFrameBuffer = FrameBuffer::New( 1u, 1u, FrameBuffer::Attachment::NONE  );
1142   task.SetFrameBuffer( newFrameBuffer );
1143   DALI_TEST_CHECK( task.GetFrameBuffer() == newFrameBuffer );
1144   END_TEST;
1145 }
1146
1147 int UtcDaliRenderTaskGetFrameBufferN(void)
1148 {
1149   TestApplication application;
1150
1151   tet_infoline("Testing RenderTask::GetFrameBuffer()");
1152
1153   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1154
1155   RenderTask task = taskList.GetTask( 0u );
1156
1157   // A scene creates frame buffer by default
1158   FrameBuffer frameBuffer = task.GetFrameBuffer();
1159   DALI_TEST_CHECK( frameBuffer );
1160
1161   END_TEST;
1162 }
1163
1164 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionP(void)
1165 {
1166   TestApplication application;
1167
1168   tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1169
1170   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1171
1172   RenderTask task = taskList.GetTask( 0u );
1173
1174   task.SetScreenToFrameBufferFunction( TestScreenToFrameBufferFunction );
1175
1176   Vector2 coordinates( 5, 10 );
1177   Vector2 convertedCoordinates( 6, 12 ); // + Vector(1, 2)
1178
1179   RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1180   DALI_TEST_CHECK( func( coordinates ) );
1181   DALI_TEST_CHECK( coordinates == convertedCoordinates );
1182
1183   task.SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
1184   func = task.GetScreenToFrameBufferFunction();
1185   DALI_TEST_CHECK( func( coordinates ) );
1186
1187   task.SetScreenToFrameBufferFunction( RenderTask::DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION );
1188   func = task.GetScreenToFrameBufferFunction();
1189   DALI_TEST_CHECK( ! func( coordinates ) );
1190   END_TEST;
1191 }
1192
1193 int UtcDaliRenderTaskSetScreenToFrameBufferFunctionN(void)
1194 {
1195   TestApplication application;
1196
1197   tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()");
1198
1199   RenderTask task; // Empty handle
1200   try
1201   {
1202     task.SetScreenToFrameBufferFunction( TestScreenToFrameBufferFunction );
1203   }
1204   catch (Dali::DaliException& e)
1205   {
1206     DALI_TEST_PRINT_ASSERT( e );
1207     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1208   }
1209   END_TEST;
1210 }
1211
1212 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionP(void)
1213 {
1214   TestApplication application;
1215
1216   tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction()");
1217
1218   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1219
1220   RenderTask task = taskList.GetTask( 0u );
1221
1222   Vector2 originalCoordinates( 5, 10 );
1223   Vector2 coordinates( 5, 10 );
1224
1225   RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1226   DALI_TEST_CHECK( !func( coordinates ) ); // conversion should fail by default
1227   DALI_TEST_CHECK( coordinates == originalCoordinates ); // coordinates should not be modified
1228   END_TEST;
1229 }
1230
1231 int UtcDaliRenderTaskGetScreenToFrameBufferFunctionN(void)
1232 {
1233   TestApplication application;
1234
1235   tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction() on empty handle");
1236
1237   RenderTask task;
1238   try
1239   {
1240     RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction();
1241     (void) func;
1242   }
1243   catch (Dali::DaliException& e)
1244   {
1245     DALI_TEST_PRINT_ASSERT( e );
1246     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1247   }
1248   END_TEST;
1249 }
1250
1251
1252 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorP(void)
1253 {
1254   TestApplication application;
1255   tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor ");
1256
1257   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1258   RenderTask renderTask = taskList.CreateTask();
1259   Actor mappingActor = Actor::New();
1260   renderTask.SetScreenToFrameBufferMappingActor(mappingActor);
1261
1262   DALI_TEST_EQUALS( mappingActor, renderTask.GetScreenToFrameBufferMappingActor(), TEST_LOCATION );
1263   END_TEST;
1264 }
1265
1266
1267 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActorN(void)
1268 {
1269   TestApplication application;
1270   tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1271
1272   RenderTask task;
1273   try
1274   {
1275     Actor mappingActor;
1276     task.SetScreenToFrameBufferMappingActor(mappingActor);
1277   }
1278   catch (Dali::DaliException& e)
1279   {
1280     DALI_TEST_PRINT_ASSERT( e );
1281     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1282   }
1283   END_TEST;
1284 }
1285
1286 int UtcDaliRenderTaskGetScreenToFrameBufferMappingActor02N(void)
1287 {
1288   TestApplication application;
1289   tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor with empty task handle");
1290
1291   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1292   RenderTask renderTask = taskList.CreateTask();
1293   Actor actor;
1294   renderTask.SetScreenToFrameBufferMappingActor(actor);
1295
1296   DALI_TEST_EQUALS( (bool)renderTask.GetScreenToFrameBufferMappingActor(), false, TEST_LOCATION);
1297   END_TEST;
1298 }
1299
1300 int UtcDaliRenderTaskGetViewportP01(void)
1301 {
1302   TestApplication application;
1303
1304   tet_infoline("Testing RenderTask::GetViewport() on default task");
1305
1306   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1307   RenderTask task = taskList.GetTask( 0u );
1308   Viewport viewport = task.GetViewport();
1309
1310   // By default the viewport should match the stage width/height
1311   Vector2 stageSize = Stage::GetCurrent().GetSize();
1312   Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1313   DALI_TEST_CHECK( viewport == expectedViewport );
1314   END_TEST;
1315 }
1316
1317 int UtcDaliRenderTaskGetViewportP02(void)
1318 {
1319   TestApplication application;
1320
1321   tet_infoline("Testing RenderTask::GetViewport() on new task");
1322
1323   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1324   RenderTask task = taskList.CreateTask();
1325   Viewport viewport = task.GetViewport();
1326
1327   // By default the viewport should match the stage width/height
1328   Vector2 stageSize = Stage::GetCurrent().GetSize();
1329   Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1330   DALI_TEST_CHECK( viewport == expectedViewport );
1331   END_TEST;
1332 }
1333
1334 int UtcDaliRenderTaskGetViewportN(void)
1335 {
1336   TestApplication application;
1337
1338   tet_infoline("Testing RenderTask::GetViewport() on empty handle");
1339
1340   RenderTask task;
1341   try
1342   {
1343     Viewport viewport = task.GetViewport();
1344     (void) viewport;
1345   }
1346   catch (Dali::DaliException& e)
1347   {
1348     DALI_TEST_PRINT_ASSERT( e );
1349     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1350   }
1351   END_TEST;
1352 }
1353
1354
1355 int UtcDaliRenderTaskSetViewportP(void)
1356 {
1357   TestApplication application;
1358
1359   tet_infoline("Testing RenderTask::SetViewport()");
1360
1361   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1362
1363   RenderTask task = taskList.GetTask( 0u );
1364   Vector2 stageSize = Stage::GetCurrent().GetSize();
1365   Viewport newViewport( 0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f );
1366   task.SetViewport( newViewport );
1367
1368   // Update (viewport is a property)
1369   application.SendNotification();
1370   application.Render();
1371
1372   DALI_TEST_CHECK( task.GetViewport() == newViewport );
1373   END_TEST;
1374 }
1375
1376 int UtcDaliRenderTaskSetViewportN(void)
1377 {
1378   TestApplication application;
1379
1380   tet_infoline("Testing RenderTask::SetViewport()");
1381
1382   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1383
1384   RenderTask task;
1385   try
1386   {
1387     Vector2 stageSize = Stage::GetCurrent().GetSize();
1388     Viewport newViewport( 0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f );
1389     task.SetViewport( newViewport );
1390   }
1391   catch (Dali::DaliException& e)
1392   {
1393     DALI_TEST_PRINT_ASSERT( e );
1394     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1395   }
1396
1397   END_TEST;
1398 }
1399
1400
1401 int UtcDaliRenderTaskSetViewportPosition(void)
1402 {
1403   TestApplication application;
1404
1405   tet_infoline("Testing RenderTask::SetViewportPosition()");
1406
1407   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1408
1409   RenderTask task = taskList.GetTask( 0u );
1410
1411   Viewport viewport = task.GetViewport();
1412
1413   // By default the viewport should match the stage width/height
1414
1415   Vector2 stageSize = Stage::GetCurrent().GetSize();
1416   Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1417   DALI_TEST_CHECK( viewport == expectedViewport );
1418
1419   // 'Setter' test
1420   Vector2 newPosition(25.0f, 50.0f);
1421   task.SetViewportPosition( newPosition );
1422
1423   // Update (viewport is a property)
1424   application.SendNotification();
1425   application.Render();
1426
1427   DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1428
1429   // Set by Property test
1430   Vector2 newPosition2(32.0f, 32.0f);
1431   task.SetProperty( RenderTask::Property::VIEWPORT_POSITION, newPosition2 );
1432   DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition2, TEST_LOCATION );
1433   DALI_TEST_EQUALS( task.GetCurrentProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition, TEST_LOCATION ); // still the old position
1434
1435   // Update
1436   application.SendNotification();
1437   application.Render();
1438
1439   DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition2, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1440   DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition2, TEST_LOCATION );
1441   DALI_TEST_EQUALS( task.GetCurrentProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition2, TEST_LOCATION );
1442
1443   Vector2 newPosition3(64.0f, 0.0f);
1444   Animation animation = Animation::New(1.0f);
1445   animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_POSITION ), newPosition3, AlphaFunction::LINEAR );
1446   animation.Play();
1447
1448   DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1449   DALI_TEST_EQUALS( task.GetCurrentProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition2, TEST_LOCATION );
1450
1451   // Perform 1000ms worth of updates at which point animation should have completed.
1452   Wait(application, 1000);
1453   DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1454   DALI_TEST_EQUALS( task.GetCurrentProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1455   DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1456
1457   // Create another animation which animates by a certain value
1458   const Vector2 newPosition4( 75.0f, 45.0f );
1459   const Vector2 relativePosition( newPosition4 - newPosition3 );
1460   animation = Animation::New( 1.0f );
1461   animation.AnimateBy( Property( task, RenderTask::Property::VIEWPORT_POSITION ), relativePosition );
1462   animation.Play();
1463
1464   DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition4, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1465   DALI_TEST_EQUALS( task.GetCurrentProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition3, TEST_LOCATION );
1466
1467   // Perform 1000ms worth of updates at which point animation should have completed.
1468   Wait(application, 1000);
1469   DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition4, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1470   DALI_TEST_EQUALS( task.GetCurrentProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition4, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1471   DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition4, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1472
1473   END_TEST;
1474 }
1475
1476 int UtcDaliRenderTaskSetViewportSize(void)
1477 {
1478   TestApplication application;
1479
1480   tet_infoline("Testing RenderTask::SetViewportSize()");
1481
1482   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1483
1484   RenderTask task = taskList.GetTask( 0u );
1485
1486   Viewport viewport = task.GetViewport();
1487
1488   // By default the viewport should match the stage width/height
1489
1490   Vector2 stageSize = Stage::GetCurrent().GetSize();
1491   Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height );
1492   DALI_TEST_CHECK( viewport == expectedViewport );
1493
1494   Vector2 newSize(128.0f, 64.0f);
1495   task.SetViewportSize( newSize );
1496
1497   // Update (viewport is a property)
1498   application.SendNotification();
1499   application.Render();
1500
1501   DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1502
1503   // Set by Property test
1504   Vector2 newSize2(50.0f, 50.0f);
1505   task.SetProperty( RenderTask::Property::VIEWPORT_SIZE, newSize2 );
1506   DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE ), newSize2, TEST_LOCATION );
1507   DALI_TEST_EQUALS( task.GetCurrentProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE ), newSize, TEST_LOCATION ); // still the old position
1508
1509   // Update
1510   application.SendNotification();
1511   application.Render();
1512
1513   DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize2, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1514   DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE ), newSize2, TEST_LOCATION );
1515   DALI_TEST_EQUALS( task.GetCurrentProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE ), newSize2, TEST_LOCATION );
1516
1517   Vector2 newSize3(10.0f, 10.0f);
1518   Animation animation = Animation::New(1.0f);
1519   animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_SIZE ), newSize3, AlphaFunction::LINEAR );
1520   animation.Play();
1521
1522   DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE  ), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1523   DALI_TEST_EQUALS( task.GetCurrentProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE ), newSize2, TEST_LOCATION );
1524
1525   // Perform 1000ms worth of updates at which point animation should have completed.
1526   Wait(application, 1000);
1527   DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1528   DALI_TEST_EQUALS( task.GetCurrentProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE ), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1529   DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE  ), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1530
1531   // Create another animation which animates by a certain value
1532   const Vector2 newSize4( 75.0f, 45.0f );
1533   const Vector2 relativeSize( newSize4 - newSize3 );
1534   animation = Animation::New( 1.0f );
1535   animation.AnimateBy( Property( task, RenderTask::Property::VIEWPORT_SIZE ), relativeSize );
1536   animation.Play();
1537
1538   DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE ), newSize4, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1539   DALI_TEST_EQUALS( task.GetCurrentProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE ), newSize3, TEST_LOCATION );
1540
1541   // Perform 1000ms worth of updates at which point animation should have completed.
1542   Wait(application, 1000);
1543   DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize4, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1544   DALI_TEST_EQUALS( task.GetCurrentProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE ), newSize4, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1545   DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE ), newSize4, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1546
1547   END_TEST;
1548 }
1549
1550 int UtcDaliRenderTaskSetClearColorP(void)
1551 {
1552   TestApplication application;
1553
1554   tet_infoline("Testing RenderTask::SetClearColor()");
1555
1556   Vector4 testColor( 1.0f, 2.0f, 3.0f, 4.0f );
1557   Vector4 testColor2( 5.0f, 6.0f, 7.0f, 8.0f );
1558
1559   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1560
1561   RenderTask task = taskList.GetTask( 0u );
1562   DALI_TEST_CHECK( task.GetClearColor() != testColor );
1563
1564   task.SetClearColor( testColor );
1565
1566   // Wait a frame.
1567   Wait(application);
1568
1569   DALI_TEST_EQUALS( task.GetClearColor(), testColor, TEST_LOCATION );
1570
1571   task.SetProperty( RenderTask::Property::CLEAR_COLOR, testColor2 );
1572   DALI_TEST_EQUALS( task.GetProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR ), testColor2, TEST_LOCATION );
1573   DALI_TEST_EQUALS( task.GetCurrentProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR ), testColor, TEST_LOCATION ); // still the old color
1574
1575   // Wait a frame.
1576   Wait(application);
1577
1578   DALI_TEST_EQUALS( task.GetClearColor(), testColor2, TEST_LOCATION );
1579   DALI_TEST_EQUALS( task.GetProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR ), testColor2, TEST_LOCATION );
1580   DALI_TEST_EQUALS( task.GetCurrentProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR ), testColor2, TEST_LOCATION );
1581
1582   Vector4 newColor3(10.0f, 10.0f, 20.0f, 30.0f);
1583   Animation animation = Animation::New(1.0f);
1584   animation.AnimateTo( Property( task, RenderTask::Property::CLEAR_COLOR ), newColor3, AlphaFunction::LINEAR );
1585   animation.Play();
1586
1587   DALI_TEST_EQUALS( task.GetProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR  ), newColor3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1588   DALI_TEST_EQUALS( task.GetCurrentProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR ), testColor2, TEST_LOCATION );
1589
1590   // Perform 1000ms worth of updates at which point animation should have completed.
1591   Wait(application, 1000);
1592   DALI_TEST_EQUALS( task.GetCurrentProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR ), newColor3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1593   DALI_TEST_EQUALS( task.GetProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR  ), newColor3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
1594
1595   // Create another animation which animates by a certain value
1596   const Vector4 newColor4( 0.45f, 0.35f, 0.25f, 0.1f );
1597   const Vector4 relativeColor( newColor4 - newColor3 );
1598   animation = Animation::New( 1.0f );
1599   animation.AnimateBy( Property( task, RenderTask::Property::CLEAR_COLOR ), relativeColor );
1600   animation.Play();
1601
1602   DALI_TEST_EQUALS( task.GetProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR ), newColor4, Math::MACHINE_EPSILON_10, TEST_LOCATION );
1603   DALI_TEST_EQUALS( task.GetCurrentProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR ), newColor3, Math::MACHINE_EPSILON_10, TEST_LOCATION );
1604
1605   // Perform 1000ms worth of updates at which point animation should have completed.
1606   Wait(application, 1000);
1607   DALI_TEST_EQUALS( task.GetCurrentProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR ), newColor4, Math::MACHINE_EPSILON_10, TEST_LOCATION );
1608   DALI_TEST_EQUALS( task.GetProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR ), newColor4, Math::MACHINE_EPSILON_10, TEST_LOCATION );
1609
1610   END_TEST;
1611 }
1612
1613 int UtcDaliRenderTaskSetClearColorN(void)
1614 {
1615   TestApplication application;
1616
1617   tet_infoline("Testing RenderTask::SetClearColor() on empty handle");
1618
1619   RenderTask task;
1620   try
1621   {
1622     task.SetClearColor( Vector4::ZERO );
1623   }
1624   catch (Dali::DaliException& e)
1625   {
1626     DALI_TEST_PRINT_ASSERT( e );
1627     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1628   }
1629   END_TEST;
1630 }
1631
1632 int UtcDaliRenderTaskGetClearColorP(void)
1633 {
1634   TestApplication application;
1635
1636   tet_infoline("Testing RenderTask::GetClearColor()");
1637
1638   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1639   RenderTask task = taskList.GetTask( 0u );
1640   DALI_TEST_EQUALS( task.GetClearColor(), RenderTask::DEFAULT_CLEAR_COLOR, TEST_LOCATION );
1641   END_TEST;
1642 }
1643
1644 int UtcDaliRenderTaskGetClearColorN(void)
1645 {
1646   TestApplication application;
1647
1648   tet_infoline("Testing RenderTask::GetClearColor()");
1649
1650   RenderTask task;
1651   try
1652   {
1653     Vector4 color = task.GetClearColor();
1654     (void) color;
1655   }
1656   catch (Dali::DaliException& e)
1657   {
1658     DALI_TEST_PRINT_ASSERT( e );
1659     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1660   }
1661   END_TEST;
1662 }
1663
1664 int UtcDaliRenderTaskSetClearEnabledP(void)
1665 {
1666   TestApplication application;
1667
1668   tet_infoline("Testing RenderTask::SetClearEnabled()");
1669
1670   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1671
1672   RenderTask task = taskList.GetTask( 0u );
1673   DALI_TEST_CHECK( !task.GetClearEnabled() ); // defaults to false
1674
1675   task.SetClearEnabled( true );
1676   DALI_TEST_EQUALS( task.GetClearEnabled(), true, TEST_LOCATION );
1677
1678   task.SetClearEnabled( false );
1679   DALI_TEST_EQUALS( task.GetClearEnabled(), false, TEST_LOCATION );
1680   END_TEST;
1681 }
1682
1683 int UtcDaliRenderTaskSetClearEnabledN(void)
1684 {
1685   TestApplication application;
1686
1687   tet_infoline("Testing RenderTask::SetClearEnabled() with empty handle");
1688
1689   RenderTask task;
1690   try
1691   {
1692     task.SetClearEnabled(true);
1693   }
1694   catch (Dali::DaliException& e)
1695   {
1696     DALI_TEST_PRINT_ASSERT( e );
1697     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1698   }
1699   END_TEST;
1700 }
1701
1702 int UtcDaliRenderTaskGetClearEnabledP(void)
1703 {
1704   TestApplication application;
1705
1706   tet_infoline("Testing RenderTask::GetClearEnabled()");
1707
1708   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1709
1710   RenderTask task = taskList.GetTask( 0u );
1711   DALI_TEST_CHECK( !task.GetClearEnabled() ); // defaults to false
1712   END_TEST;
1713 }
1714
1715
1716 int UtcDaliRenderTaskGetClearEnabledN(void)
1717 {
1718   TestApplication application;
1719
1720   tet_infoline("Testing RenderTask::GetClearEnabled() with empty handle");
1721
1722   RenderTask task;
1723   try
1724   {
1725     bool x = task.GetClearEnabled();
1726     (void) x;
1727   }
1728   catch (Dali::DaliException& e)
1729   {
1730     DALI_TEST_PRINT_ASSERT( e );
1731     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1732   }
1733   END_TEST;
1734 }
1735
1736 int UtcDaliRenderTaskSetCullModeP(void)
1737 {
1738   TestApplication application;
1739
1740   tet_infoline("Testing RenderTask::SetCullMode()");
1741
1742   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1743   RenderTask task = taskList.GetTask( 0u );
1744   DALI_TEST_EQUALS( task.GetCullMode(), true, TEST_LOCATION );
1745
1746   task.SetCullMode( false );
1747
1748   DALI_TEST_EQUALS( task.GetCullMode(), false, TEST_LOCATION );
1749
1750   END_TEST;
1751 }
1752
1753 int UtcDaliRenderTaskSetCullModeN(void)
1754 {
1755   TestApplication application;
1756
1757   tet_infoline("Testing RenderTask::SetCullMode() on empty handle");
1758
1759   RenderTask task;
1760   try
1761   {
1762     task.SetCullMode( false );
1763   }
1764   catch (Dali::DaliException& e)
1765   {
1766     DALI_TEST_PRINT_ASSERT( e );
1767     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1768   }
1769   END_TEST;
1770 }
1771
1772 int UtcDaliRenderTaskGetCullModeP(void)
1773 {
1774   TestApplication application;
1775
1776   tet_infoline("Testing RenderTask::GetCullMode()");
1777
1778   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1779   RenderTask task = taskList.GetTask( 0u );
1780   DALI_TEST_EQUALS( task.GetCullMode(), true, TEST_LOCATION );
1781   END_TEST;
1782 }
1783
1784 int UtcDaliRenderTaskGetCullModeN(void)
1785 {
1786   TestApplication application;
1787
1788   tet_infoline("Testing RenderTask::GetCullMode() with empty handle");
1789
1790   RenderTask task;
1791   try
1792   {
1793     bool x = task.GetCullMode();
1794     (void) x;
1795   }
1796   catch (Dali::DaliException& e)
1797   {
1798     DALI_TEST_PRINT_ASSERT( e );
1799     DALI_TEST_ASSERT(e, "RenderTask handle is empty", TEST_LOCATION);
1800   }
1801   END_TEST;
1802 }
1803
1804
1805 int UtcDaliRenderTaskSetRefreshRate(void)
1806 {
1807   TestApplication application;
1808
1809   tet_infoline("Testing RenderTask::SetRefreshRate()");
1810
1811   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1812
1813   // By default tasks will be processed every frame
1814   RenderTask task = taskList.GetTask( 0u );
1815   DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1816
1817   task.SetRefreshRate( 2u ); // every-other frame
1818   DALI_TEST_CHECK( 2u == task.GetRefreshRate() );
1819
1820   task.SetRefreshRate( RenderTask::REFRESH_ALWAYS );
1821   DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1822   END_TEST;
1823 }
1824
1825 int UtcDaliRenderTaskGetRefreshRate(void)
1826 {
1827   TestApplication application;
1828
1829   tet_infoline("Testing RenderTask::GetRefreshRate()");
1830
1831   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1832
1833   // By default tasks will be processed every frame
1834   RenderTask task = taskList.GetTask( 0u );
1835   DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() );
1836
1837   RenderTask newTask = taskList.CreateTask();
1838   DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == newTask.GetRefreshRate() );
1839   END_TEST;
1840 }
1841
1842 int UtcDaliRenderTaskSignalFinished(void)
1843 {
1844   TestApplication application;
1845
1846   tet_infoline("Testing RenderTask::SignalFinished()");
1847
1848   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1849   TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
1850
1851   CameraActor offscreenCameraActor = CameraActor::New();
1852
1853   Stage::GetCurrent().Add( offscreenCameraActor );
1854
1855   BufferImage image = BufferImage::New( 10, 10 );
1856   image.Update();
1857   Actor rootActor = CreateRenderableActor( image );
1858   rootActor.SetSize( 10, 10 );
1859   Stage::GetCurrent().Add( rootActor );
1860
1861   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
1862   NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
1863   FrameBufferImage frameBufferImage = FrameBufferImage::New( *testNativeImagePtr.Get() );
1864
1865   RenderTask newTask = taskList.CreateTask();
1866   newTask.SetCameraActor( offscreenCameraActor );
1867   newTask.SetSourceActor( rootActor );
1868   newTask.SetInputEnabled( false );
1869   newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
1870   newTask.SetClearEnabled( true );
1871   newTask.SetExclusive( true );
1872   newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
1873   newTask.SetTargetFrameBuffer( frameBufferImage );
1874   newTask.SetProperty( RenderTask::Property::REQUIRES_SYNC, true );
1875
1876   bool finished = false;
1877   RenderTaskFinished renderTaskFinished( finished );
1878   newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1879
1880   // Flush the queue and render.
1881   application.SendNotification();
1882
1883   // 1 render to process render task, then wait for sync before finished msg is sent
1884   // from update to the event thread.
1885
1886   application.Render();
1887   application.SendNotification();
1888   DALI_TEST_CHECK( !finished );
1889
1890   Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
1891   DALI_TEST_CHECK( lastSyncObj != NULL );
1892
1893   application.Render();
1894   DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
1895   application.SendNotification();
1896   DALI_TEST_CHECK( !finished );
1897
1898   application.Render();
1899   DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
1900   application.SendNotification();
1901   DALI_TEST_CHECK( ! finished );
1902
1903   sync.SetObjectSynced( lastSyncObj, true );
1904
1905   application.Render();
1906   application.SendNotification();
1907   DALI_TEST_CHECK( !finished );
1908
1909   application.Render();
1910   application.SendNotification();
1911   DALI_TEST_CHECK( finished );
1912
1913   DALI_TEST_EQUALS( application.GetUpdateStatus(), 0, TEST_LOCATION );
1914   END_TEST;
1915 }
1916
1917
1918 int UtcDaliRenderTaskContinuous01(void)
1919 {
1920   TestApplication application;
1921
1922   tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not staged)\nPOST:continuous renders, no Finished signal");
1923
1924   // SETUP AN OFFSCREEN RENDER TASK
1925   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1926   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1927   drawTrace.Enable(true);
1928
1929   Actor rootActor = Actor::New();
1930   Stage::GetCurrent().Add( rootActor );
1931
1932   CameraActor offscreenCameraActor = CameraActor::New( Size( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT ) );
1933   Stage::GetCurrent().Add( offscreenCameraActor );
1934
1935   Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
1936
1937   RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1938   bool finished = false;
1939   RenderTaskFinished renderTaskFinished( finished );
1940   application.SendNotification();
1941
1942   // START PROCESS/RENDER                     Input,    Expected  Input, Expected, KeepUpdating
1943   DALI_TEST_CHECK( UpdateRender(application,  drawTrace, false,   finished, false, false, __LINE__ ) );
1944   application.GetPlatform().ClearReadyResources();
1945
1946   // ADD SOURCE ACTOR TO STAGE - expect continuous renders to start, no finished signal
1947   Stage::GetCurrent().Add(secondRootActor);
1948   application.SendNotification();
1949
1950   // CONTINUE PROCESS/RENDER                  Input,    Expected  Input,    Expected
1951   DALI_TEST_CHECK( UpdateRender(application,  drawTrace, true,    finished, false, false, __LINE__ ) );
1952   END_TEST;
1953 }
1954
1955
1956 int UtcDaliRenderTaskContinuous02(void)
1957 {
1958   TestApplication application;
1959
1960   tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not visible)\nPOST:continuous renders, no Finished signal");
1961
1962   // SETUP AN OFFSCREEN RENDER TASK
1963   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1964   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1965   drawTrace.Enable(true);
1966
1967   Actor rootActor = Actor::New();
1968   Stage::GetCurrent().Add( rootActor );
1969
1970   CameraActor offscreenCameraActor = CameraActor::New( Size( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT ) );
1971   Stage::GetCurrent().Add( offscreenCameraActor );
1972
1973   Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
1974   Stage::GetCurrent().Add(secondRootActor);
1975   secondRootActor.SetVisible(false);
1976
1977   RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
1978   bool finished = false;
1979   RenderTaskFinished renderTaskFinished( finished );
1980   newTask.FinishedSignal().Connect( &application, renderTaskFinished );
1981   application.SendNotification();
1982
1983   // START PROCESS/RENDER                    Input,    Expected  Input,    Expected, KeepUpdating
1984   DALI_TEST_CHECK( UpdateRender(application, drawTrace, false,   finished, false, false, __LINE__ ) );
1985   application.GetPlatform().ClearReadyResources();
1986
1987   // MAKE SOURCE ACTOR VISIBLE - expect continuous renders to start, no finished signal
1988   secondRootActor.SetVisible(true);
1989   application.SendNotification();
1990
1991   // CONTINUE PROCESS/RENDER                 Input,    Expected  Input,    Expected
1992   DALI_TEST_CHECK( UpdateRender(application, drawTrace, true,    finished, false, false, __LINE__ ) );
1993   END_TEST;
1994 }
1995
1996 int UtcDaliRenderTaskContinuous03(void)
1997 {
1998   TestApplication application;
1999
2000   tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (camera actor not staged)\nPOST:continuous renders, no Finished signal");
2001
2002   // SETUP AN OFFSCREEN RENDER TASK
2003   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2004   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2005   drawTrace.Enable(true);
2006
2007   Actor rootActor = Actor::New();
2008   Stage::GetCurrent().Add( rootActor );
2009
2010   CameraActor offscreenCameraActor = CameraActor::New( Size( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT ) );
2011   Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2012   Stage::GetCurrent().Add(secondRootActor);
2013
2014   RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2015   bool finished = false;
2016   RenderTaskFinished renderTaskFinished( finished );
2017   newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2018   application.SendNotification();
2019
2020   // START PROCESS/RENDER                    Input,    Expected  Input,    Expected
2021   DALI_TEST_CHECK( UpdateRender(application, drawTrace, false,   finished, false, false, __LINE__ ) );
2022   application.GetPlatform().ClearReadyResources();
2023
2024   // ADD CAMERA ACTOR TO STAGE - expect continuous renders to start, no finished signal
2025   Stage::GetCurrent().Add( offscreenCameraActor );
2026   application.SendNotification();
2027
2028   // CONTINUE PROCESS/RENDER                 Input,    Expected  Input,    Expected
2029   DALI_TEST_CHECK( UpdateRender(application, drawTrace, true,    finished, false, false, __LINE__ ) );
2030   END_TEST;
2031 }
2032
2033
2034 int UtcDaliRenderTaskContinuous04(void)
2035 {
2036   TestApplication application;
2037
2038   tet_infoline("Testing RenderTask Render Continuous using loaded image");
2039
2040   // SETUP AN OFFSCREEN RENDER TASK
2041   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2042   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2043   drawTrace.Enable(true);
2044
2045   Actor rootActor = Actor::New();
2046   Stage::GetCurrent().Add( rootActor );
2047
2048   CameraActor offscreenCameraActor = CameraActor::New( Size( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT ) );
2049   Stage::GetCurrent().Add( offscreenCameraActor );
2050   Actor secondRootActor = CreateRenderableActorFailed(application, "aFile.jpg");
2051   Stage::GetCurrent().Add(secondRootActor);
2052
2053   RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2054   bool finished = false;
2055   RenderTaskFinished renderTaskFinished( finished );
2056   newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2057   application.SendNotification();
2058
2059   // START PROCESS/RENDER                    Input,    Expected  Input,    Expected
2060   DALI_TEST_CHECK( UpdateRender(application, drawTrace, true,   finished, false, false, __LINE__ ) );
2061   END_TEST;
2062 }
2063
2064 int UtcDaliRenderTaskOnce01(void)
2065 {
2066   TestApplication application;
2067
2068   tet_infoline("Testing RenderTask Render Once GlSync, using loaded image");
2069
2070   // SETUP AN OFFSCREEN RENDER TASK
2071   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2072   TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2073   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2074   drawTrace.Enable(true);
2075
2076   Actor rootActor = Actor::New();
2077   Stage::GetCurrent().Add( rootActor );
2078
2079   CameraActor offscreenCameraActor = CameraActor::New( Size( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT ) );
2080   Stage::GetCurrent().Add( offscreenCameraActor );
2081   Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2082
2083   Stage::GetCurrent().Add(secondRootActor);
2084
2085   RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
2086   bool finished = false;
2087   RenderTaskFinished renderTaskFinished( finished );
2088   newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2089   application.SendNotification();
2090
2091   DALI_TEST_CHECK( UpdateRender(application, drawTrace, true,   finished, false, true, __LINE__  ) );
2092
2093   Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2094   DALI_TEST_CHECK( lastSyncObj != NULL );
2095   sync.SetObjectSynced( lastSyncObj, true );
2096
2097   DALI_TEST_CHECK( UpdateRender(application, drawTrace, false,   finished, false, true, __LINE__  ) );
2098   DALI_TEST_CHECK( UpdateRender(application, drawTrace, false,   finished, true, false, __LINE__  ) );
2099   END_TEST;
2100 }
2101
2102 int UtcDaliRenderTaskOnce02(void)
2103 {
2104   TestApplication application;
2105
2106   tet_infoline("Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loaded image.\n");
2107
2108   // SETUP AN OFFSCREEN RENDER TASK
2109   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2110   TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2111   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2112   drawTrace.Enable(true);
2113
2114   Actor rootActor = Actor::New();
2115   Stage::GetCurrent().Add( rootActor );
2116
2117   CameraActor offscreenCameraActor = CameraActor::New( Size( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT ) );
2118   Stage::GetCurrent().Add( offscreenCameraActor );
2119
2120   Shader shader = CreateShader();
2121   Image image = CreateResourceImage(application, "aFile.jpg");
2122   TextureSet textureSet = CreateTextureSet( image );
2123
2124   Geometry geometry = CreateQuadGeometry();
2125   Renderer renderer = Renderer::New(geometry, shader);
2126   renderer.SetTextures( textureSet );
2127   Actor secondRootActor = Actor::New();
2128   secondRootActor.AddRenderer(renderer);
2129   secondRootActor.SetSize(100, 100);
2130   Stage::GetCurrent().Add(secondRootActor);
2131
2132   RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
2133   bool finished = false;
2134   RenderTaskFinished renderTaskFinished( finished );
2135   newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2136   application.SendNotification();
2137
2138   DALI_TEST_CHECK( UpdateRender(application, drawTrace, true,   finished, false, true, __LINE__  ) );
2139
2140   Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2141   DALI_TEST_CHECK( lastSyncObj != NULL );
2142   sync.SetObjectSynced( lastSyncObj, true );
2143
2144   DALI_TEST_CHECK( UpdateRender(application, drawTrace, false,   finished, false, true, __LINE__  ) );
2145   DALI_TEST_CHECK( UpdateRender(application, drawTrace, false,   finished, true, false, __LINE__  ) );
2146
2147    END_TEST;
2148 }
2149
2150 int UtcDaliRenderTaskOnce03(void)
2151 {
2152   TestApplication application;
2153
2154   tet_infoline("Testing RenderTask Render Once GlSync, using loaded image. Switch from render always after ready to render once\n");
2155
2156   // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2157   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2158   TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2159   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2160   drawTrace.Enable(true);
2161
2162   Actor rootActor = Actor::New();
2163   Stage::GetCurrent().Add( rootActor );
2164
2165   CameraActor offscreenCameraActor = CameraActor::New( Size( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT ) );
2166   Stage::GetCurrent().Add( offscreenCameraActor );
2167   Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2168   Stage::GetCurrent().Add(secondRootActor);
2169
2170   RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2171   bool finished = false;
2172   RenderTaskFinished renderTaskFinished( finished );
2173   newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2174   application.SendNotification();
2175
2176   DALI_TEST_CHECK( UpdateRender(application, drawTrace, true,    finished, false, false, __LINE__ ) );
2177
2178   newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2179   application.SendNotification();
2180
2181   DALI_TEST_CHECK( UpdateRender(application, drawTrace, true,   finished, false, true, __LINE__  ) );
2182
2183   Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2184   DALI_TEST_CHECK( lastSyncObj != NULL );
2185   sync.SetObjectSynced( lastSyncObj, true );
2186
2187   DALI_TEST_CHECK( UpdateRender(application, drawTrace, false,   finished, false, true, __LINE__  ) );
2188   DALI_TEST_CHECK( UpdateRender(application, drawTrace, false,   finished, true, false, __LINE__  ) );
2189
2190   END_TEST;
2191 }
2192
2193
2194 int UtcDaliRenderTaskOnce04(void)
2195 {
2196   TestApplication application;
2197   tet_infoline("Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loaded image.\n"
2198                "Switch from render always after ready to render once\n"
2199               );
2200
2201   // SETUP AN OFFSCREEN RENDER TASK
2202   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2203   TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2204   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2205   drawTrace.Enable(true);
2206
2207   Actor rootActor = Actor::New();
2208   Stage::GetCurrent().Add( rootActor );
2209
2210   CameraActor offscreenCameraActor = CameraActor::New( Size( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT ) );
2211   Stage::GetCurrent().Add( offscreenCameraActor );
2212
2213   Shader shader = CreateShader();
2214   Image image = CreateResourceImage(application, "aFile.jpg");
2215   TextureSet textureSet = CreateTextureSet( image );
2216
2217   Geometry geometry = CreateQuadGeometry();
2218   Renderer renderer = Renderer::New(geometry, shader);
2219   renderer.SetTextures( textureSet );
2220   Actor secondRootActor = Actor::New();
2221   secondRootActor.AddRenderer(renderer);
2222   secondRootActor.SetSize(100, 100);
2223   Stage::GetCurrent().Add(secondRootActor);
2224
2225   RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true);
2226   bool finished = false;
2227   RenderTaskFinished renderTaskFinished( finished );
2228   newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2229   application.SendNotification();
2230
2231   DALI_TEST_CHECK( UpdateRender(application, drawTrace, true,    finished, false, false, __LINE__ ) );
2232
2233   newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2234   application.SendNotification();
2235
2236   DALI_TEST_CHECK( UpdateRender(application, drawTrace, true,   finished, false, true, __LINE__  ) );
2237
2238   Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2239   DALI_TEST_CHECK( lastSyncObj != NULL );
2240   sync.SetObjectSynced( lastSyncObj, true );
2241
2242   DALI_TEST_CHECK( UpdateRender(application, drawTrace, false,   finished, false, true, __LINE__  ) );
2243   DALI_TEST_CHECK( UpdateRender(application, drawTrace, false,   finished, true, false, __LINE__  ) );
2244
2245   END_TEST;
2246 }
2247
2248 int UtcDaliRenderTaskOnceNoSync01(void)
2249 {
2250   TestApplication application;
2251
2252   tet_infoline("Testing RenderTask Render Once, \nPRE: Resources ready\nPOST: Finished signal sent once only");
2253
2254   // SETUP AN OFFSCREEN RENDER TASK
2255   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2256   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2257   drawTrace.Enable(true);
2258
2259   Actor rootActor = Actor::New();
2260   Stage::GetCurrent().Add( rootActor );
2261
2262   CameraActor offscreenCameraActor = CameraActor::New( Size( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT ) );
2263   Stage::GetCurrent().Add( offscreenCameraActor );
2264   Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2265   Stage::GetCurrent().Add(secondRootActor);
2266
2267   RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2268   bool finished = false;
2269   RenderTaskFinished renderTaskFinished( finished );
2270   newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2271   application.SendNotification();
2272
2273   DALI_TEST_CHECK( UpdateRender(application, drawTrace, true,    finished, false, true, __LINE__ ) );
2274   DALI_TEST_CHECK( UpdateRender(application, drawTrace, false,   finished, true, false, __LINE__ ) );
2275   END_TEST;
2276 }
2277
2278 int UtcDaliRenderTaskOnceNoSync02(void)
2279 {
2280   TestApplication application;
2281
2282   tet_infoline("Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loaded image.\n"
2283                "PRE: Resources ready\nPOST: Finished signal sent once only");
2284   // SETUP AN OFFSCREEN RENDER TASK
2285   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2286   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2287   drawTrace.Enable(true);
2288
2289   Actor rootActor = Actor::New();
2290   Stage::GetCurrent().Add( rootActor );
2291
2292   CameraActor offscreenCameraActor = CameraActor::New( Size( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT ) );
2293   Stage::GetCurrent().Add( offscreenCameraActor );
2294
2295   Shader shader = CreateShader();
2296   Image image = CreateResourceImage(application, "aFile.jpg");
2297   TextureSet textureSet = CreateTextureSet( image );
2298
2299   Geometry geometry = CreateQuadGeometry();
2300   Renderer renderer = Renderer::New(geometry, shader);
2301   renderer.SetTextures( textureSet );
2302   Actor secondRootActor = Actor::New();
2303   secondRootActor.AddRenderer(renderer);
2304   secondRootActor.SetSize(100, 100);
2305   Stage::GetCurrent().Add(secondRootActor);
2306
2307   RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2308   bool finished = false;
2309   RenderTaskFinished renderTaskFinished( finished );
2310   newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2311   application.SendNotification();
2312
2313   DALI_TEST_CHECK( UpdateRender(application, drawTrace, true,    finished, false, true, __LINE__ ) );
2314   application.GetPlatform().ClearReadyResources();
2315   DALI_TEST_CHECK( UpdateRender(application, drawTrace, false,   finished, true, false, __LINE__ ) );
2316
2317   END_TEST;
2318 }
2319
2320 int UtcDaliRenderTaskOnceNoSync03(void)
2321 {
2322   TestApplication application;
2323
2324   tet_infoline("Testing RenderTask Render Once, using loaded image. Switch from render always after ready to render once\n"
2325                "PRE: Render task ready, Image loaded\n"
2326                "POST: Finished signal sent only once");
2327
2328   // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2329   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2330   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2331   drawTrace.Enable(true);
2332
2333   Actor rootActor = Actor::New();
2334   Stage::GetCurrent().Add( rootActor );
2335
2336   CameraActor offscreenCameraActor = CameraActor::New( Size( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT ) );
2337   Stage::GetCurrent().Add( offscreenCameraActor );
2338   Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2339   Stage::GetCurrent().Add(secondRootActor);
2340
2341   RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2342   bool finished = false;
2343   RenderTaskFinished renderTaskFinished( finished );
2344   newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2345   application.SendNotification();
2346
2347   DALI_TEST_CHECK( UpdateRender(application, drawTrace, true,    finished, false, false, __LINE__ ) );
2348
2349   newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2350   application.SendNotification(); //         Input,    Expected  Input,    Expected
2351   DALI_TEST_CHECK( UpdateRender(application, drawTrace, true,    finished, false, true, __LINE__ ) );
2352   DALI_TEST_CHECK( UpdateRender(application, drawTrace, false,   finished, true, false, __LINE__ ) );
2353   END_TEST;
2354 }
2355
2356 int UtcDaliRenderTaskOnceNoSync04(void)
2357 {
2358   TestApplication application;
2359
2360   tet_infoline("Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loading image.\n"
2361                "Switch from render always after ready to render once\n"
2362                "PRE: Render task ready, Image not loaded\n"
2363                "POST: Finished signal sent only once");
2364
2365   // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2366   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2367   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2368   drawTrace.Enable(true);
2369
2370   Actor rootActor = Actor::New();
2371   Stage::GetCurrent().Add( rootActor );
2372
2373   CameraActor offscreenCameraActor = CameraActor::New( Size( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT ) );
2374   Stage::GetCurrent().Add( offscreenCameraActor );
2375
2376   Shader shader = CreateShader();
2377   Image image = CreateResourceImage(application, "aFile.jpg");
2378   TextureSet textureSet = CreateTextureSet( image );
2379
2380   Geometry geometry = CreateQuadGeometry();
2381   Renderer renderer = Renderer::New(geometry, shader);
2382   renderer.SetTextures( textureSet );
2383   Actor secondRootActor = Actor::New();
2384   secondRootActor.AddRenderer(renderer);
2385   secondRootActor.SetSize(100, 100);
2386   Stage::GetCurrent().Add(secondRootActor);
2387
2388
2389   RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2390   bool finished = false;
2391   RenderTaskFinished renderTaskFinished( finished );
2392   newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2393   application.SendNotification();
2394
2395   DALI_TEST_CHECK( UpdateRender(application, drawTrace, true,    finished, false, false, __LINE__ ) );
2396   TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2397   Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2398   DALI_TEST_CHECK( lastSyncObj == NULL );
2399
2400   newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2401   application.SendNotification(); //         Input,    Expected  Input,    Expected
2402   DALI_TEST_CHECK( UpdateRender(application, drawTrace, true,    finished, false, true, __LINE__ ) );
2403   DALI_TEST_CHECK( UpdateRender(application, drawTrace, false,   finished, true, false, __LINE__ ) );
2404
2405   lastSyncObj = sync.GetLastSyncObject();
2406   DALI_TEST_CHECK( lastSyncObj == NULL );
2407
2408   END_TEST;
2409 }
2410
2411 int UtcDaliRenderTaskOnceNoSync05(void)
2412 {
2413   TestApplication application;
2414
2415   tet_infoline("Testing RenderTask Render Once\n"
2416                "SetRefreshRate(ONCE), resource load failed, completes render task.\n"
2417                "PRE: resources failed to load\n"
2418                "POST: No finished signal sent.");
2419
2420   // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2421   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2422   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2423   drawTrace.Enable(true);
2424
2425   Actor rootActor = Actor::New();
2426   Stage::GetCurrent().Add( rootActor );
2427
2428   CameraActor offscreenCameraActor = CameraActor::New( Size( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT ) );
2429   Stage::GetCurrent().Add( offscreenCameraActor );
2430   Actor secondRootActor = CreateRenderableActorFailed(application, "aFile.jpg");
2431   Stage::GetCurrent().Add(secondRootActor);
2432
2433   RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false);
2434   bool finished = false;
2435   RenderTaskFinished renderTaskFinished( finished );
2436   newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2437   application.SendNotification();
2438
2439   // START PROCESS/RENDER                    Input,     Expected  Input,    Expected
2440   DALI_TEST_CHECK( UpdateRender(application, drawTrace, true,    finished, false, false, __LINE__ ) );
2441
2442   // CHANGE TO RENDER ONCE,
2443   newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
2444   DALI_TEST_CHECK( UpdateRender(application, drawTrace, true,    finished, false, false, __LINE__ ) );
2445
2446   END_TEST;
2447 }
2448
2449
2450
2451 int UtcDaliRenderTaskOnceChain01(void)
2452 {
2453   TestApplication application;
2454
2455   tet_infoline("Testing RenderTask Render Once Chained render tasks\n"
2456                "SetRefreshRate(ONCE), resource load completes, both render tasks render.\n"
2457                "PRE: resources ready\n"
2458                "POST: 2 finished signals sent.");
2459
2460   // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
2461   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2462   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
2463   drawTrace.Enable(true);
2464
2465   Actor defaultRootActor = Actor::New(); // Root for default RT
2466   Stage::GetCurrent().Add( defaultRootActor );
2467
2468   CameraActor offscreenCameraActor = CameraActor::New( Size( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT ) );
2469   Stage::GetCurrent().Add( offscreenCameraActor );
2470   Actor firstRootActor = CreateRenderableActorSuccess(application, "aFile.jpg");
2471   Stage::GetCurrent().Add(firstRootActor);
2472
2473   // first render task
2474   RenderTask firstTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, firstRootActor, RenderTask::REFRESH_ONCE, false);
2475   bool firstFinished = false;
2476   RenderTaskFinished renderTask1Finished( firstFinished );
2477   firstTask.FinishedSignal().Connect( &application, renderTask1Finished );
2478
2479   // Second render task
2480   FrameBufferImage fbo = firstTask.GetTargetFrameBuffer();
2481   Actor secondRootActor = CreateRenderableActor( fbo );
2482   Stage::GetCurrent().Add(secondRootActor);
2483   RenderTask secondTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
2484   bool secondFinished = false;
2485   RenderTaskFinished renderTask2Finished( secondFinished );
2486   secondTask.FinishedSignal().Connect( &application, renderTask2Finished );
2487
2488   application.SendNotification();
2489
2490   //Both render tasks are executed.
2491   DALI_TEST_CHECK( UpdateRender(application, drawTrace, true,  firstFinished, false, true, __LINE__ ) );
2492   DALI_TEST_CHECK( firstFinished == false );
2493   DALI_TEST_CHECK( secondFinished == false );
2494
2495   //Nothing else to render and both render task should have finished now
2496   DALI_TEST_CHECK( UpdateRender(application, drawTrace, false,  firstFinished, true, false, __LINE__ ) );
2497   DALI_TEST_CHECK( firstFinished == true );
2498   DALI_TEST_CHECK( secondFinished == true );
2499
2500   END_TEST;
2501 }
2502
2503 int UtcDaliRenderTaskProperties(void)
2504 {
2505   TestApplication application;
2506
2507   RenderTask task = Stage::GetCurrent().GetRenderTaskList().CreateTask();
2508
2509   Property::IndexContainer indices;
2510   task.GetPropertyIndices( indices );
2511   DALI_TEST_CHECK( indices.Size() );
2512   DALI_TEST_EQUALS( indices.Size(), task.GetPropertyCount(), TEST_LOCATION );
2513   END_TEST;
2514 }
2515
2516 int UtcDaliRenderTaskSetScreenToFrameBufferMappingActor(void)
2517 {
2518   TestApplication application;
2519   tet_infoline("Testing RenderTask::SetScreenToFrameBufferMappingActor ");
2520
2521   Stage stage = Stage::GetCurrent();
2522   Size stageSize = stage.GetSize();
2523   Actor mappingActor = Actor::New();
2524   Vector2 scale( 0.6f, 0.75f);
2525   Vector2 offset( stageSize.x*0.1f, stageSize.y*0.15f);
2526   mappingActor.SetSize( stageSize * scale );
2527   mappingActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2528   mappingActor.SetPosition( offset.x, offset.y );
2529   stage.Add( mappingActor );
2530
2531   Actor offscreenActor = Actor::New();
2532   offscreenActor.SetSize( stageSize );
2533   offscreenActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2534   stage.Add( offscreenActor );
2535
2536   RenderTaskList taskList = stage.GetRenderTaskList();
2537   RenderTask renderTask = taskList.CreateTask();
2538   FrameBufferImage frameBufferImage =  FrameBufferImage::New(stageSize.width*scale.x, stageSize.height*scale.y, Pixel::A8);
2539   renderTask.SetSourceActor( offscreenActor );
2540   renderTask.SetExclusive( true );
2541   renderTask.SetInputEnabled( true );
2542   renderTask.SetTargetFrameBuffer( frameBufferImage );
2543   renderTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
2544   renderTask.SetScreenToFrameBufferMappingActor( mappingActor );
2545   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2546
2547   // Render and notify
2548   application.SendNotification();
2549   application.Render();
2550   application.Render();
2551   application.SendNotification();
2552
2553   Vector2 screenCoordinates( stageSize.x * 0.05f, stageSize.y * 0.05f );
2554   Dali::HitTestAlgorithm::Results results;
2555   DALI_TEST_CHECK( !results.actor );
2556   DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
2557   // miss expected, results not changed
2558   DALI_TEST_CHECK( false == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
2559   DALI_TEST_CHECK( !results.actor );
2560   DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
2561
2562   screenCoordinates.x = stageSize.x * 0.265f;
2563   screenCoordinates.y = stageSize.y * 0.33f;
2564   results.actor = Actor();
2565   results.actorCoordinates = Vector2::ZERO;
2566   // hit expected, results changed
2567   DALI_TEST_CHECK( true == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
2568   DALI_TEST_CHECK( results.actor  == offscreenActor );
2569   DALI_TEST_EQUALS( (screenCoordinates-offset)/scale , results.actorCoordinates, 0.1f, TEST_LOCATION );
2570
2571   screenCoordinates.x = stageSize.x * 0.435f;
2572   screenCoordinates.y = stageSize.y * 0.52f;
2573   // hit expected, results changed
2574   DALI_TEST_CHECK( true == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
2575   DALI_TEST_CHECK( results.actor  == offscreenActor );
2576   const Vector2 expectedCoordinates = (screenCoordinates-offset)/scale;
2577   DALI_TEST_EQUALS( expectedCoordinates , results.actorCoordinates, 0.1f, TEST_LOCATION );
2578
2579   screenCoordinates.x = stageSize.x * 0.65f;
2580   screenCoordinates.y = stageSize.y * 0.95f;
2581   // miss expected, results not changed
2582   DALI_TEST_CHECK( false == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
2583   DALI_TEST_CHECK( results.actor  == offscreenActor );
2584   DALI_TEST_EQUALS( expectedCoordinates , results.actorCoordinates, 0.1f, TEST_LOCATION );
2585   END_TEST;
2586 }
2587
2588 int UtcDaliRenderTaskFinishInvisibleSourceActor(void)
2589 {
2590   TestApplication application;
2591
2592   tet_infoline("Testing RenderTask::FinishInvisibleSourceActor()");
2593
2594   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2595   TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
2596
2597   CameraActor offscreenCameraActor = CameraActor::New();
2598
2599   Stage::GetCurrent().Add( offscreenCameraActor );
2600
2601   BufferImage image = BufferImage::New( 10, 10 );
2602   Actor rootActor = CreateRenderableActor( image );
2603   rootActor.SetSize( 10, 10 );
2604   rootActor.SetVisible(false);
2605   Stage::GetCurrent().Add( rootActor );
2606
2607   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
2608   NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
2609   FrameBufferImage frameBufferImage = FrameBufferImage::New( *testNativeImagePtr.Get() );
2610
2611   // Flush all outstanding messages
2612   application.SendNotification();
2613   application.Render();
2614
2615   RenderTask newTask = taskList.CreateTask();
2616   newTask.SetCameraActor( offscreenCameraActor );
2617   newTask.SetSourceActor( rootActor );
2618   newTask.SetInputEnabled( false );
2619   newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
2620   newTask.SetClearEnabled( true );
2621   newTask.SetExclusive( true );
2622   newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
2623   newTask.SetTargetFrameBuffer( frameBufferImage );
2624   newTask.SetProperty( RenderTask::Property::REQUIRES_SYNC, true );
2625
2626   // Framebuffer doesn't actually get created until Connected, i.e. by previous line
2627
2628   bool finished = false;
2629   RenderTaskFinished renderTaskFinished( finished );
2630   newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2631
2632   // Flush the queue and render.
2633   application.SendNotification();
2634
2635   // 1 render to process render task, then wait for sync before finished msg is sent
2636   // from update to the event thread.
2637
2638   application.Render();
2639   application.SendNotification();
2640   DALI_TEST_CHECK( !finished );
2641
2642   Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
2643   DALI_TEST_CHECK( lastSyncObj != NULL );
2644
2645   application.Render();
2646   DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
2647   application.SendNotification();
2648   DALI_TEST_CHECK( !finished );
2649
2650   application.Render();
2651   DALI_TEST_EQUALS( (Integration::KeepUpdating::Reasons)(application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
2652   application.SendNotification();
2653   DALI_TEST_CHECK( ! finished );
2654
2655   sync.SetObjectSynced( lastSyncObj, true );
2656
2657   application.Render();
2658   application.SendNotification();
2659   DALI_TEST_CHECK( !finished );
2660
2661   application.Render();
2662   application.SendNotification();
2663   DALI_TEST_CHECK( finished );
2664   finished = false;
2665
2666   application.Render(); // Double check no more finished signal
2667   application.SendNotification();
2668   DALI_TEST_CHECK( ! finished );
2669
2670   END_TEST;
2671 }
2672
2673 int UtcDaliRenderTaskFinishMissingImage(void)
2674 {
2675   TestApplication application;
2676
2677   // Previously we had bugs where not having a resource ID would cause render-tasks to wait forever
2678   tet_infoline("Testing RenderTask::SignalFinished() when an Actor has no Image set");
2679
2680   Stage stage = Stage::GetCurrent();
2681
2682   BufferImage image = BufferImage::New( 10, 10 );
2683   Actor rootActor = CreateRenderableActor( image );
2684   rootActor.SetSize( 10, 10 );
2685   stage.Add( rootActor );
2686
2687   Actor actorWithMissingImage = CreateRenderableActor( Image() );
2688   actorWithMissingImage.SetSize( 10, 10 );
2689   stage.Add( actorWithMissingImage );
2690
2691   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
2692   RenderTask newTask = taskList.CreateTask();
2693   newTask.SetInputEnabled( false );
2694   newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
2695   newTask.SetClearEnabled( true );
2696   newTask.SetExclusive( true );
2697   newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
2698
2699   bool finished = false;
2700   RenderTaskFinished renderTaskFinished( finished );
2701   newTask.FinishedSignal().Connect( &application, renderTaskFinished );
2702
2703   // 1 render to process render task, then 1 before finished msg is sent from update to the event thread.
2704   application.SendNotification();
2705   application.Render();
2706   application.Render();
2707
2708   application.SendNotification();
2709   DALI_TEST_CHECK( finished );
2710
2711   END_TEST;
2712 }
2713
2714 int UtcDaliRenderTaskWorldToViewport(void)
2715 {
2716   TestApplication application( 400u, 400u ); // square surface
2717
2718   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
2719
2720   Actor actor = Actor::New();
2721   actor.SetSize(100.0f, 100.0f);
2722   actor.SetPosition( Vector3(0.0, 0.0, 0.0) );
2723
2724   actor.SetParentOrigin( Vector3(0.5, 0.5, 0.5) );
2725   actor.SetAnchorPoint( Vector3(0.5, 0.5, 0.5) );
2726
2727   Stage::GetCurrent().Add(actor);
2728
2729   application.SendNotification();
2730   application.Render();
2731   application.SendNotification();
2732
2733   RenderTask task = taskList.GetTask( 0u );
2734
2735   CameraActor camera = task.GetCameraActor();
2736
2737   Vector2 screenSize = task.GetCurrentViewportSize();
2738
2739   float screenX = 0.0;
2740   float screenY = 0.0;
2741
2742   bool ok = task.WorldToViewport(actor.GetCurrentWorldPosition(), screenX, screenY);
2743   DALI_TEST_CHECK(ok == true);
2744
2745   DALI_TEST_EQUALS(screenX, screenSize.x/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
2746   DALI_TEST_EQUALS(screenY, screenSize.y/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
2747
2748   Actor actor2 = Actor::New();
2749   float actor2Size = 100.f;
2750   actor2.SetSize( actor2Size, actor2Size );
2751   actor2.SetPosition( Vector3(0.0, 0.0, 0.0) );
2752   actor2.SetParentOrigin( Vector3(0.5, 0.5, 0.0) );
2753   actor2.SetAnchorPoint( Vector3(0.5, 0.5, 0.0) );
2754   Stage::GetCurrent().Add( actor2 );
2755   actor2.Add(actor);
2756   actor.SetParentOrigin( Vector3(0,0,0) );
2757
2758   application.SendNotification();
2759   application.Render();
2760   application.SendNotification();
2761
2762   ok = task.WorldToViewport(actor.GetCurrentWorldPosition(), screenX, screenY);
2763   DALI_TEST_CHECK(ok == true);
2764
2765   DALI_TEST_EQUALS(screenX, screenSize.x/2 - actor2Size/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
2766   DALI_TEST_EQUALS(screenY, screenSize.y/2 - actor2Size/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
2767
2768   END_TEST;
2769 }
2770
2771
2772 int UtcDaliRenderTaskViewportToLocal(void)
2773 {
2774   TestApplication application;
2775   Actor actor = Actor::New();
2776   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2777   actor.SetSize(100.0f, 100.0f);
2778   actor.SetPosition(10.0f, 10.0f);
2779   Stage::GetCurrent().Add(actor);
2780
2781   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
2782   RenderTask task = taskList.GetTask( 0u );
2783
2784   // flush the queue and render once
2785   application.SendNotification();
2786   application.Render();
2787   application.SendNotification();
2788   application.Render();
2789
2790   float localX;
2791   float localY;
2792
2793   float rtLocalX;
2794   float rtLocalY;
2795
2796   float screenX = 50.0f;
2797   float screenY = 50.0f;
2798
2799   DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, screenX, screenY) );
2800
2801   DALI_TEST_CHECK( task.ViewportToLocal(actor, screenX, screenY, rtLocalX, rtLocalY ) );
2802
2803   DALI_TEST_EQUALS(localX, rtLocalX, 0.01f, TEST_LOCATION);
2804   DALI_TEST_EQUALS(localY, rtLocalY, 0.01f, TEST_LOCATION);
2805
2806   END_TEST;
2807
2808 }
2809
2810 int UtcDaliRenderTaskRequiresSync(void)
2811 {
2812   TestApplication application;
2813   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
2814
2815   RenderTask newTask = taskList.CreateTask();
2816   newTask.SetProperty( RenderTask::Property::REQUIRES_SYNC, false );
2817
2818   DALI_TEST_EQUALS( newTask.GetProperty< bool >( RenderTask::Property::REQUIRES_SYNC ), false, TEST_LOCATION );
2819   DALI_TEST_EQUALS( newTask.GetCurrentProperty< bool >( RenderTask::Property::REQUIRES_SYNC ), false, TEST_LOCATION );
2820
2821   newTask.SetProperty( RenderTask::Property::REQUIRES_SYNC, true );
2822
2823   DALI_TEST_EQUALS( newTask.GetProperty< bool >( RenderTask::Property::REQUIRES_SYNC ), true, TEST_LOCATION );
2824   DALI_TEST_EQUALS( newTask.GetCurrentProperty< bool >( RenderTask::Property::REQUIRES_SYNC ), true, TEST_LOCATION );
2825
2826   END_TEST;
2827 }