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