2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali/public-api/dali-core.h>
23 #include <dali-test-suite-utils.h>
27 void utc_dali_internal_image_culling_startup(void)
29 test_return_value = TET_UNDEF;
32 void utc_dali_internal_image_culling_cleanup(void)
34 test_return_value = TET_PASS;
42 #define NUM_ROWS_PER_PANE 3
43 #define NUM_COLS_PER_PANE 3
44 const unsigned int TEXTURE_ID_OFFSET = 23;
46 Image LoadImage( TestApplication& application, GLuint textureId, int width, int height )
49 char* filename = NULL;
50 int numChars = asprintf(&filename, "image%u.png", textureId );
54 const Vector2 closestImageSize( width, height );
55 application.GetPlatform().SetClosestImageSize(closestImageSize);
57 image = Image::New( filename, Image::Immediate, Image::Never );
60 DALI_TEST_CHECK(image);
61 application.SendNotification();
62 application.Render(16);
64 std::vector<GLuint> ids;
65 ids.push_back( textureId );
66 application.GetGlAbstraction().SetNextTextureIds( ids );
68 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true );
69 Integration::ResourcePointer resource(bitmap);
70 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
71 DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
72 Integration::ResourceRequest* request = application.GetPlatform().GetRequest();
73 DALI_TEST_CHECK( request != NULL );
76 application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, resource);
78 application.SendNotification();
79 application.Render(16);
80 application.GetPlatform().ClearReadyResources();
81 application.GetPlatform().DiscardRequest();
82 application.SendNotification();
83 application.Render(16);
88 ImageActor CreateOnStageActor(TestApplication& application, Image image, int width, int height, bool testDraw)
90 ImageActor imageActor = ImageActor::New(image);
91 Stage::GetCurrent().Add(imageActor);
93 imageActor.SetParentOrigin(ParentOrigin::CENTER);
94 application.SendNotification();
95 application.Render(16);
96 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
97 TraceCallStack& textureTrace = glAbstraction.GetTextureTrace();
98 TraceCallStack& drawTrace = glAbstraction.GetDrawTrace();
102 DALI_TEST_CHECK( drawTrace.FindMethod( "DrawArrays" ) );
103 DALI_TEST_CHECK( textureTrace.FindMethod( "BindTexture" ) );
104 const std::vector<GLuint>& textures = glAbstraction.GetBoundTextures(GL_TEXTURE0);
105 DALI_TEST_CHECK( textures.size() > 0 );
106 if( textures.size() > 0 )
108 DALI_TEST_CHECK( textures[0] == 23 );
115 void TestImageInside( TestApplication& application, int width, int height )
117 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
118 TraceCallStack& textureTrace = glAbstraction.GetTextureTrace();
119 textureTrace.Enable(true);
120 TraceCallStack& drawTrace = glAbstraction.GetDrawTrace();
121 drawTrace.Enable(true);
123 Image image = LoadImage( application, 23, width, height );
125 ImageActor imageActor = CreateOnStageActor(application, image, width, height, true);
126 imageActor.SetPosition(0.0f, 0.0f, 0.0f);
128 Vector3 imageSize = imageActor.GetCurrentSize();
129 DALI_TEST_EQUALS( imageSize, Vector3(width, height, std::min(width, height)), TEST_LOCATION);
132 imageActor.SetParentOrigin(ParentOrigin::TOP_LEFT);
133 application.SendNotification();
134 application.Render(16);
135 DALI_TEST_CHECK( drawTrace.FindMethod( "DrawArrays" ) );
138 imageActor.SetParentOrigin(ParentOrigin::TOP_RIGHT);
139 application.SendNotification();
140 application.Render(16);
141 DALI_TEST_CHECK( drawTrace.FindMethod( "DrawArrays" ) );
144 imageActor.SetParentOrigin(ParentOrigin::BOTTOM_RIGHT);
145 application.SendNotification();
146 application.Render(16);
147 DALI_TEST_CHECK( drawTrace.FindMethod( "DrawArrays" ) );
150 imageActor.SetParentOrigin(ParentOrigin::BOTTOM_LEFT);
151 application.SendNotification();
152 application.Render(16);
153 DALI_TEST_CHECK( drawTrace.FindMethod( "DrawArrays" ) );
157 bool RepositionActor(TestApplication& application, Actor actor, float x, float y, bool inside)
159 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
162 actor.SetPosition( x, y, 0.0f);
163 application.SendNotification();
164 application.Render(16);
166 bool found = drawTrace.FindMethod( "DrawArrays" );
167 return (inside && found) || (!inside && !found);
171 void RepositionActorWithAngle(TestApplication& application, Actor actor, float x, float y, float angle, bool inside)
173 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
176 actor.SetPosition( x, y, 0.0f);
177 actor.SetRotation( Degree(angle), Vector3::ZAXIS );
178 application.SendNotification();
179 application.Render(16);
182 bool found = drawTrace.FindMethod( "DrawArrays" );
183 if( ! found ) tet_printf( "Not drawn: Position:(%3.0f, %3.0f)\n", x, y );
184 DALI_TEST_CHECK( found );
188 bool found = drawTrace.FindMethod( "DrawArrays" );
189 if( found ) tet_printf( "Drawn when not needed: Position:(%3.0f, %3.0f)\n", x, y );
190 DALI_TEST_CHECK( ! found );
194 void RepositionActorOutside(TestApplication& application, Actor actor, float x, float y, bool drawn )
196 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
199 actor.SetPosition( x, y, 0.0f);
200 application.SendNotification();
201 application.Render(16);
204 bool found = drawTrace.FindMethod( "DrawArrays" );
205 if( ! found ) tet_printf( "Not drawn: Position:(%3.0f, %3.0f)\n", x, y );
206 DALI_TEST_CHECK( found );
210 bool found = drawTrace.FindMethod( "DrawArrays" );
211 if( found ) tet_printf( "Drawn unnecessarily: Position:(%3.0f, %3.0f)\n", x, y );
212 DALI_TEST_CHECK( ! found );
217 void SphereTestImageAtBoundary( TestApplication& application, int width, int height )
219 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
220 TraceCallStack& textureTrace = glAbstraction.GetTextureTrace();
221 textureTrace.Enable(true);
222 TraceCallStack& drawTrace = glAbstraction.GetDrawTrace();
223 drawTrace.Enable(true);
225 Vector2 stageSize = Stage::GetCurrent().GetSize();
227 Image image = LoadImage(application, 23, width, height);
228 ImageActor imageActor = CreateOnStageActor(application, image, width, height, true);
230 Vector3 imageSize = imageActor.GetCurrentSize();
231 DALI_TEST_EQUALS( imageSize, Vector3(width, height, std::min(width, height)), TEST_LOCATION);
234 float radius = imageSize.Length() * 0.5f; // Radius of bounding box
235 tet_printf("Testing Stage Size: (%3.0f, %3.0f) image size:(%3.0f, %3.0f) := radius=%3.0f\n",
236 stageSize.x, stageSize.y, imageSize.x, imageSize.y, radius);
238 for( int i=0; i<=radius; i++ )
240 float x1 = -stageSize.x/2.0f - i;
241 float x2 = stageSize.x/2.0f + i;
242 float y1 = -stageSize.y/2.0f - i;
243 float y2 = stageSize.y/2.0f + i;
245 //tet_printf("Testing i=%d\n",i);
247 // Test paths marked with dots
250 // . \_ | within radius
255 for( int j=-10; j<=10; j++ )
257 float x = ((stageSize.x+2*radius)/21.0f) * j;
258 float y = ((stageSize.y+2*radius)/21.0f) * j;
260 RepositionActor( application, imageActor, x1, y, true );
261 RepositionActor( application, imageActor, x2, y, true );
262 RepositionActor( application, imageActor, x, y1, true );
263 RepositionActor( application, imageActor, x, y2, true );
268 void OBBTestImageAtBoundary( TestApplication& application, int width, int height )
270 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
271 TraceCallStack& textureTrace = glAbstraction.GetTextureTrace();
272 textureTrace.Enable(true);
273 TraceCallStack& drawTrace = glAbstraction.GetDrawTrace();
274 drawTrace.Enable(true);
276 Vector2 stageSize = Stage::GetCurrent().GetSize();
278 Image image = LoadImage(application, 23, width, height);
279 ImageActor imageActor = CreateOnStageActor(application, image, width, height, true);
281 Vector3 imageSize = imageActor.GetCurrentSize();
282 DALI_TEST_EQUALS( imageSize, Vector3(width, height, std::min(width, height)), TEST_LOCATION);
285 tet_printf("Testing Stage Size: (%3.0f, %3.0f) image size:(%3.0f, %3.0f) \n",
286 stageSize.x, stageSize.y, imageSize.x, imageSize.y);
288 int successCount = 0;
290 for( int i=0; i<100; i++ )
292 float x1 = -stageSize.x/2.0f - imageSize.x*i/200.0f;
293 float x2 = stageSize.x/2.0f + imageSize.x*i/200.0f;
294 float y1 = -stageSize.y/2.0f - imageSize.y*i/200.0f;
295 float y2 = stageSize.y/2.0f + imageSize.y*i/200.0f;
297 //tet_printf("Testing i=%d\n",i);
299 // Test paths marked with dots
302 // . \_ | within radius
307 for( int j=-10; j<=10; j++ )
309 float x = ((stageSize.x+imageSize.x/2.0f)/21.0f) * j;
310 float y = ((stageSize.y+imageSize.y/2.0f)/21.0f) * j;
312 if(RepositionActor( application, imageActor, x1, y, true )) successCount++;
313 if(RepositionActor( application, imageActor, x2, y, true )) successCount++;
314 if(RepositionActor( application, imageActor, x, y1, true )) successCount++;
315 if(RepositionActor( application, imageActor, x, y2, true )) successCount++;
320 DALI_TEST_EQUALS(successCount, totalCount, TEST_LOCATION);
321 tet_printf( "Test succeeded with %d passes out of %d tests\n", successCount, totalCount);
325 void SphereTestImageOutsideBoundary( TestApplication& application, int width, int height )
327 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
328 TraceCallStack& textureTrace = glAbstraction.GetTextureTrace();
329 textureTrace.Enable(true);
330 TraceCallStack& drawTrace = glAbstraction.GetDrawTrace();
331 drawTrace.Enable(true);
333 Vector2 stageSize = Stage::GetCurrent().GetSize();
335 Image image = LoadImage( application, 23, width, height );
337 ImageActor imageActor = CreateOnStageActor(application, image, width, height, true);
338 Vector3 imageSize = imageActor.GetCurrentSize();
339 DALI_TEST_EQUALS( imageSize, Vector3(width, height, std::min(width, height)), TEST_LOCATION);
342 float radius = imageSize.Length() * 0.5f; // Radius of bounding box
343 tet_printf("Testing Stage Size: (%3.0f, %3.0f) image size:(%3.0f, %3.0f) := radius=%3.0f\n",
344 stageSize.x, stageSize.y, imageSize.x, imageSize.y, radius);
346 for( int i=0; i<100; i++ )
349 float x1 = -stageSize.x/2.0f - imageSize.x*i/200.0f;
350 float x2 = stageSize.x/2.0f + imageSize.x*i/200.0f;
351 float y1 = -stageSize.y/2.0f - imageSize.y*i/200.0f;
352 float y2 = stageSize.y/2.0f + imageSize.y*i/200.0f;
355 //tet_printf("Testing i=%d\n",i);
356 for( int j=-10; j<=10; j++ )
358 float x = (stageSize.x/17.0f) * j; // use larger intervals to test more area
359 float y = (stageSize.y/17.0f) * j;
361 RepositionActor( application, imageActor, x1, y, false );
362 RepositionActor( application, imageActor, x2, y, false );
363 RepositionActor( application, imageActor, x, y1, false );
364 RepositionActor( application, imageActor, x, y2, false );
369 void OBBTestImageOutsideBoundary( TestApplication& application, int width, int height )
371 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
372 TraceCallStack& textureTrace = glAbstraction.GetTextureTrace();
373 textureTrace.Enable(true);
374 TraceCallStack& drawTrace = glAbstraction.GetDrawTrace();
375 drawTrace.Enable(true);
377 Vector2 stageSize = Stage::GetCurrent().GetSize();
379 Image image = LoadImage( application, 23, width, height );
381 ImageActor imageActor = CreateOnStageActor(application, image, width, height, true);
382 Vector3 imageSize = imageActor.GetCurrentSize();
383 DALI_TEST_EQUALS( imageSize, Vector3(width, height, std::min(width, height)), TEST_LOCATION);
386 tet_printf("Testing Stage Size: (%3.0f, %3.0f) image size:(%3.0f, %3.0f)\n",
387 stageSize.x, stageSize.y, imageSize.x, imageSize.y);
392 for( int i=0; i<=100; i++ )
394 float x1 = -stageSize.x/2.0f - imageSize.x * (1.5f + i/100.0f);
395 float x2 = stageSize.x/2.0f + imageSize.x * (1.5f + i/100.0f);
396 float y1 = -stageSize.y/2.0f - imageSize.y * (1.5f + i/100.0f);
397 float y2 = stageSize.y/2.0f + imageSize.y * (1.5f + i/100.0f);
399 for( int j=-10; j<=10; j++ )
401 float x = (stageSize.x/17.0f) * j; // use larger intervals to test more area
402 float y = (stageSize.y/17.0f) * j;
404 if(RepositionActor( application, imageActor, x1, y, false )) successCount++;
405 if(RepositionActor( application, imageActor, x2, y, false )) successCount++;
406 if(RepositionActor( application, imageActor, x, y1, false )) successCount++;
407 if(RepositionActor( application, imageActor, x, y2, false )) successCount++;
411 DALI_TEST_EQUALS(successCount, totalCount, TEST_LOCATION);
412 tet_printf( "Test succeeded with %d passes out of %d tests\n", successCount, totalCount);
415 void TestPlaneOfImages(TestApplication& application, float z)
417 Vector2 stageSize = Stage::GetCurrent().GetSize();
418 Vector2 imageSize = stageSize/3.0f;
420 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
421 TraceCallStack& textureTrace = glAbstraction.GetTextureTrace();
422 TraceCallStack& drawTrace = glAbstraction.GetDrawTrace();
424 // Create a grid of 9 x 9 actors; only the central 3x3 are in viewport
426 ActorContainer actors;
427 for( int i = 0; i < NUM_ROWS*NUM_COLS; i++ )
429 GLuint textureId = TEXTURE_ID_OFFSET+i;
430 Image image = LoadImage( application, textureId, imageSize.x, imageSize.y );
431 ImageActor imageActor = CreateOnStageActor(application, image, imageSize.x, imageSize.y, false );
432 actors.push_back(imageActor);
434 application.SendNotification();
435 application.Render(16);
438 textureTrace.Reset();
439 drawTrace.Enable(true);
440 textureTrace.Enable(true);
441 application.GetGlAbstraction().ClearBoundTextures();
443 for( int row=0; row<NUM_ROWS; row++)
445 for( int col=0; col<NUM_COLS; col++)
447 // col: 0 1 2 | 3 4 5 | 6 7 8
449 // -4/3 -1 -2/3 -1/3 0 1/3 |2/3 1 4/3
452 // NUM_COLS = 9 NUM_COLS_PER_PANE = 3 (A pane is stage sized)
454 // NUM_COLS / NUM_COLS_PER_PANE => number of panes
455 // 3 per pane, splits into -1/3, 0, +1/3
456 // number of lh planes * number of cols per plane
457 // Center column maps to zero, index of center column = num_cols / 2 rounded down
458 // index - that and divide by number of cols per pane.
459 // 0 1 2 3 4 5 6 7 8 9 10 11 12
460 float xOffset = (int)(col - (NUM_COLS/2));
461 float yOffset = (int)(row - (NUM_ROWS/2));
462 float x = stageSize.x*xOffset / (float)(NUM_COLS_PER_PANE);
463 float y = stageSize.y*yOffset / (float)(NUM_ROWS_PER_PANE);
464 actors[row*NUM_COLS+col].SetPosition( x, y, z );
468 application.SendNotification();
469 application.Render(16);
471 DALI_TEST_CHECK( drawTrace.FindMethod( "DrawArrays" ) );
473 typedef std::vector<GLuint> TexVec;
474 const TexVec& textures = glAbstraction.GetBoundTextures(GL_TEXTURE0);
475 DALI_TEST_CHECK( textures.size() >= NUM_ROWS_PER_PANE * NUM_COLS_PER_PANE );
476 if( textures.size() > 0 )
479 int expectedCount = 0;
480 for(unsigned int row=0; row<NUM_ROWS; row++)
482 for(unsigned int col=0; col<NUM_ROWS; col++)
484 Vector3 pos = actors[row*NUM_COLS+col].GetCurrentPosition();
485 if( -stageSize.x/2.0f <= pos.x && pos.x <= stageSize.x/2.0f &&
486 -stageSize.y/2.0f <= pos.y && pos.y <= stageSize.y/2.0f )
489 GLuint texId = (row*NUM_COLS+col)+TEXTURE_ID_OFFSET;
491 for(TexVec::const_iterator iter = textures.begin(); iter != textures.end(); iter++)
501 tet_printf("Number of expected draws: %u\n", expectedCount);
502 DALI_TEST_EQUALS(foundCount, expectedCount, TEST_LOCATION);
504 int numDrawCalls = drawTrace.CountMethod("DrawArrays");
505 DALI_TEST_CHECK( numDrawCalls >= NUM_ROWS_PER_PANE * NUM_COLS_PER_PANE );
507 tet_printf("Number of bound textures: %u\n", textures.size());
508 tet_printf("Number of draw calls: %d\n", numDrawCalls);
513 int UtcDaliImageCulling_Inside01(void)
515 tet_infoline( "Testing that 80x80 image positioned inside the stage is drawn\n");
517 TestApplication application;
519 TestImageInside(application, 80, 80);
524 int UtcDaliImageCulling_Inside02(void)
526 tet_infoline( "Testing that 120x40 image positioned inside the stage is drawn\n");
528 TestApplication application;
530 TestImageInside(application, 120, 40);
535 int UtcDaliImageCulling_Inside03(void)
537 tet_infoline( "Testing that 40x120 image positioned inside the stage is drawn\n");
539 TestApplication application;
541 TestImageInside(application, 40, 120);
546 int UtcDaliImageCulling_Inside04(void)
548 tet_infoline( "Testing that 500x2 image positioned inside the stage is drawn\n");
549 TestApplication application;
550 TestImageInside(application, 500, 2);
554 int UtcDaliImageCulling_Inside05(void)
556 tet_infoline( "Testing that 2x500 image positioned inside the stage is drawn\n");
557 TestApplication application;
558 TestImageInside(application, 2, 500);
563 int UtcDaliImageCulling_WithinBoundary01(void)
565 tet_infoline("Test that 80x80 image positioned outside the stage but with bounding box intersecting the stage is drawn\n");
567 TestApplication application;
568 OBBTestImageAtBoundary( application, 80, 80);
571 int UtcDaliImageCulling_WithinBoundary02(void)
573 tet_infoline("Test that 120x40 image positioned outside the stage but with bounding box intersecting the stage is drawn\n");
575 TestApplication application;
576 OBBTestImageAtBoundary( application, 120, 40 );
579 int UtcDaliImageCulling_WithinBoundary03(void)
581 tet_infoline("Test that 40x120 image positioned outside the stage but with bounding box intersecting the stage is drawn\n");
583 TestApplication application;
584 OBBTestImageAtBoundary( application, 40, 120);
588 int UtcDaliImageCulling_WithinBoundary04(void)
590 tet_infoline("Test that 500x2 images positioned outside the stage but with bounding box intersecting the stage is drawn\n");
592 TestApplication application;
593 OBBTestImageAtBoundary( application, 500, 2 );
597 int UtcDaliImageCulling_WithinBoundary05(void)
599 tet_infoline("Test that 2x500 images positioned outside the stage but with bounding box intersecting the stage is drawn\n");
601 TestApplication application;
602 OBBTestImageAtBoundary( application, 2, 500 );
606 int UtcDaliImageCulling_OutsideBoundary01(void)
608 tet_infoline("Test that 80x80 image positioned outside the stage by more than 2 times\n"
609 "the radius of the bounding circle is not drawn\n");
611 TestApplication application;
612 OBBTestImageOutsideBoundary( application, 80, 80 );
616 int UtcDaliImageCulling_OutsideBoundary02(void)
618 tet_infoline("Test that 120x40 image positioned outside the stage by more than 2 times\n"
619 "the radius of the bounding circle is not drawn\n");
621 TestApplication application;
622 OBBTestImageOutsideBoundary( application, 120, 40 );
625 int UtcDaliImageCulling_OutsideBoundary03(void)
627 tet_infoline("Test that 40x120 image positioned outside the stage by more than 2 times\n"
628 "the radius of the bounding circle is not drawn\n");
630 TestApplication application;
631 OBBTestImageOutsideBoundary( application, 40, 120 );
635 int UtcDaliImageCulling_OutsideBoundary04(void)
637 tet_infoline("Test that 500x2 image positioned outside the stage by more than 2 times\n"
638 "the radius of the bounding circle is not drawn\n");
640 TestApplication application;
641 OBBTestImageOutsideBoundary( application, 500, 2 );
645 int UtcDaliImageCulling_OutsideBoundary05(void)
647 tet_infoline("Test that 2x500 image positioned outside the stage by more than 2 times\n"
648 "the radius of the bounding circle is not drawn\n");
650 TestApplication application;
651 OBBTestImageOutsideBoundary( application, 2, 500 );
655 int UtcDaliImageCulling_OutsideIntersect01(void)
657 TestApplication application;
659 tet_infoline("Test that actors positioned outside the stage with bounding boxes also\n"
660 "outside the stage but intersecting it are still drawn");
662 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
663 TraceCallStack& textureTrace = glAbstraction.GetTextureTrace();
664 textureTrace.Enable(true);
665 TraceCallStack& drawTrace = glAbstraction.GetDrawTrace();
666 drawTrace.Enable(true);
667 Vector2 stageSize = Stage::GetCurrent().GetSize();
669 float width = stageSize.x*5.0f;
670 float height = stageSize.y*0.2f;
671 Image image = LoadImage( application, 23, width, height);
672 ImageActor imageActor = CreateOnStageActor(application, image, width, height, true);
674 RepositionActor( application, imageActor, stageSize.x*1.2f, 0.0f, true);
675 RepositionActor( application, imageActor, stageSize.x*1.2f, -stageSize.y*0.55f, true);
676 RepositionActor( application, imageActor, stageSize.x*1.2f, stageSize.y*0.55f, true);
680 int UtcDaliImageCulling_OutsideIntersect02(void)
682 TestApplication application;
684 tet_infoline("Test that actors positioned outside the stage with bounding boxes also\n"
685 "outside the stage that cross planes are not drawn");
687 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
688 TraceCallStack& textureTrace = glAbstraction.GetTextureTrace();
689 textureTrace.Enable(true);
690 TraceCallStack& drawTrace = glAbstraction.GetDrawTrace();
691 drawTrace.Enable(true);
692 Vector2 stageSize = Stage::GetCurrent().GetSize();
694 float width = stageSize.x*5.0f;
695 float height = stageSize.y*0.2f;
696 Image image = LoadImage( application, 23, width, height);
697 ImageActor imageActor = CreateOnStageActor(application, image, width, height, true);
699 RepositionActor( application, imageActor, stageSize.x*10.0f, stageSize.y*0.5f, false);
700 RepositionActor( application, imageActor, -stageSize.x*10.0f, stageSize.y*0.5f, false);
701 RepositionActor( application, imageActor, stageSize.x*10.0f, -stageSize.y*0.5f, false);
702 RepositionActor( application, imageActor, -stageSize.x*10.0f, -stageSize.y*0.5f, false);
706 int UtcDaliImageCulling_OutsideIntersect03(void)
708 TestApplication application;
710 tet_infoline("Test that image actor larger than the stage, positioned outside the stage \n"
711 "with bounding boxes also outside the stage but intersecting it is still drawn\n");
713 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
714 TraceCallStack& textureTrace = glAbstraction.GetTextureTrace();
715 textureTrace.Enable(true);
716 TraceCallStack& drawTrace = glAbstraction.GetDrawTrace();
717 drawTrace.Enable(true);
718 Vector2 stageSize = Stage::GetCurrent().GetSize();
720 // Try an actor bigger than the stage, with center outside stage
721 float width = stageSize.x*5.0f;
722 float height = stageSize.y*5.0f;
723 Image image = LoadImage( application, 23, width, height);
724 ImageActor imageActor = CreateOnStageActor(application, image, width, height, true);
726 RepositionActor( application, imageActor, stageSize.x*1.2f, 0.0f, true);
727 RepositionActor( application, imageActor, stageSize.x*1.2f, -stageSize.y*1.1f, true);
728 RepositionActor( application, imageActor, stageSize.x*1.2f, stageSize.y*1.1f, true);
733 int UtcDaliImageCulling_OutsideIntersect04(void)
735 TestApplication application;
737 tet_infoline("Test that image actors positioned outside the stage, with bounding boxes\n"
738 "also outside the stage but intersecting it, and angled at 45 degrees to\n"
739 "the corners are still drawn\n");
741 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
742 TraceCallStack& textureTrace = glAbstraction.GetTextureTrace();
743 textureTrace.Enable(true);
744 TraceCallStack& drawTrace = glAbstraction.GetDrawTrace();
745 drawTrace.Enable(true);
746 Vector2 stageSize = Stage::GetCurrent().GetSize();
748 // Test image at 45 degrees outside corners of stage
749 float width = 400.0f;
750 float height = 200.0f;
751 Image image = LoadImage( application, 23, width, height);
752 ImageActor imageActor = CreateOnStageActor(application, image, width, height, true);
754 RepositionActorWithAngle( application, imageActor, -stageSize.x*0.55f, -stageSize.y*0.55, 135.0f, true);
755 RepositionActorWithAngle( application, imageActor, -stageSize.x*0.55f, stageSize.y*0.55, 225.0f, true);
756 RepositionActorWithAngle( application, imageActor, stageSize.x*0.55f, -stageSize.y*0.55, 45.0f, true);
757 RepositionActorWithAngle( application, imageActor, stageSize.x*0.55f, stageSize.y*0.55, 315.0f, true);
762 int UtcDaliImageCulling_Plane01(void)
764 tet_infoline("Test that a set of image actors with different images are drawn appropriately");
766 TestApplication application;
768 TestPlaneOfImages(application, 0.0f);
772 int UtcDaliImageCulling_Plane02(void)
774 tet_infoline("Test that a set of image actors with different images are drawn appropriately");
776 TestApplication application;
778 TestPlaneOfImages(application, 100.0f);
782 int UtcDaliImageCulling_Plane03(void)
784 tet_infoline("Test that a set of image actors with different images are drawn appropriately");
786 TestApplication application;
788 TestPlaneOfImages(application, -100.0f);
792 int UtcDaliImageCulling_Plane04(void)
794 tet_infoline("Test that a set of image actors with different images are drawn appropriately");
796 TestApplication application;
798 TestPlaneOfImages(application, -200.0f);
802 int UtcDaliImageCulling_Disable(void)
804 tet_infoline("Test that culling can be disabled");
806 TestApplication application;
807 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
808 TraceCallStack& textureTrace = glAbstraction.GetTextureTrace();
809 textureTrace.Enable(true);
810 TraceCallStack& drawTrace = glAbstraction.GetDrawTrace();
811 drawTrace.Enable(true);
813 Vector2 stageSize = Stage::GetCurrent().GetSize();
816 Image image = LoadImage( application, 23, width, height );
818 ImageActor imageActor = CreateOnStageActor(application, image, width, height, true);
819 Vector3 imageSize = imageActor.GetCurrentSize();
820 DALI_TEST_EQUALS( imageSize, Vector3(width, height, std::min(width, height)), TEST_LOCATION);
824 tet_infoline("Setting cull mode to false\n");
825 Stage::GetCurrent().GetRenderTaskList().GetTask(0).SetCullMode(false);
827 float x1 = -stageSize.x - imageSize.x;
828 float x2 = stageSize.x + imageSize.x;
829 float y1 = -stageSize.y - imageSize.y;
830 float y2 = stageSize.y + imageSize.y;
832 // Positioning actors outside stage, with no culling, they should still be drawn.
833 RepositionActorOutside( application, imageActor, x1, y1, true );
834 RepositionActorOutside( application, imageActor, x2, y1, true );
835 RepositionActorOutside( application, imageActor, x1, y2, true );
836 RepositionActorOutside( application, imageActor, x2, y2, true );
838 tet_infoline("Setting cull mode to true\n");
839 Stage::GetCurrent().GetRenderTaskList().GetTask(0).SetCullMode(true);
841 RepositionActorOutside( application, imageActor, x1, y1, false );
842 RepositionActorOutside( application, imageActor, x2, y1, false );
843 RepositionActorOutside( application, imageActor, x1, y2, false );
844 RepositionActorOutside( application, imageActor, x2, y2, false );