2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <dali/public-api/dali-core.h>
19 #include <dali-test-suite-utils.h>
25 #include <mesh-builder.h>
29 void TestConstraintNoBlue( Vector4& current, const PropertyInputContainer& inputs )
35 void renderer_test_startup(void)
37 test_return_value = TET_UNDEF;
40 void renderer_test_cleanup(void)
42 test_return_value = TET_PASS;
46 int UtcDaliRendererNew01(void)
48 TestApplication application;
50 Geometry geometry = CreateQuadGeometry();
51 Shader shader = CreateShader();
52 Renderer renderer = Renderer::New(geometry, shader);
54 DALI_TEST_EQUALS( (bool)renderer, true, TEST_LOCATION );
58 int UtcDaliRendererNew02(void)
60 TestApplication application;
62 DALI_TEST_EQUALS( (bool)renderer, false, TEST_LOCATION );
66 int UtcDaliRendererCopyConstructor(void)
68 TestApplication application;
70 Geometry geometry = CreateQuadGeometry();
71 Shader shader = CreateShader();
72 Renderer renderer = Renderer::New(geometry, shader);
74 Renderer rendererCopy( renderer );
75 DALI_TEST_EQUALS( (bool)rendererCopy, true, TEST_LOCATION );
80 int UtcDaliRendererAssignmentOperator(void)
82 TestApplication application;
84 Geometry geometry = CreateQuadGeometry();
85 Shader shader = CreateShader();
86 Renderer renderer = Renderer::New(geometry, shader);
89 DALI_TEST_EQUALS( (bool)renderer2, false, TEST_LOCATION );
92 DALI_TEST_EQUALS( (bool)renderer2, true, TEST_LOCATION );
96 int UtcDaliRendererDownCast01(void)
98 TestApplication application;
100 Geometry geometry = CreateQuadGeometry();
101 Shader shader = CreateShader();
102 Renderer renderer = Renderer::New(geometry, shader);
104 BaseHandle handle(renderer);
105 Renderer renderer2 = Renderer::DownCast(handle);
106 DALI_TEST_EQUALS( (bool)renderer2, true, TEST_LOCATION );
110 int UtcDaliRendererDownCast02(void)
112 TestApplication application;
114 Handle handle = Handle::New(); // Create a custom object
115 Renderer renderer = Renderer::DownCast(handle);
116 DALI_TEST_EQUALS( (bool)renderer, false, TEST_LOCATION );
120 int UtcDaliRendererSetGetGeometry(void)
122 TestApplication application;
123 tet_infoline( "Test SetGeometry, GetGeometry" );
125 Geometry geometry1 = CreateQuadGeometry();
126 Geometry geometry2 = CreateQuadGeometry();
128 Shader shader = CreateShader();
129 Renderer renderer = Renderer::New(geometry1, shader);
130 Actor actor = Actor::New();
131 actor.AddRenderer(renderer);
132 actor.SetSize(400, 400);
133 Stage::GetCurrent().Add(actor);
135 application.SendNotification();
136 application.Render(0);
137 DALI_TEST_EQUALS( renderer.GetGeometry(), geometry1, TEST_LOCATION );
139 // Set geometry2 to the renderer
140 renderer.SetGeometry( geometry2 );
142 application.SendNotification();
143 application.Render(0);
144 DALI_TEST_EQUALS( renderer.GetGeometry(), geometry2, TEST_LOCATION );
149 int UtcDaliRendererSetGetShader(void)
151 TestApplication application;
152 tet_infoline( "Test SetShader, GetShader" );
154 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
155 glAbstraction.EnableCullFaceCallTrace(true);
157 Shader shader1 = CreateShader();
158 shader1.RegisterProperty( "uFadeColor", Color::RED );
160 Shader shader2 = CreateShader();
161 shader2.RegisterProperty( "uFadeColor", Color::GREEN );
163 Geometry geometry = CreateQuadGeometry();
164 Renderer renderer = Renderer::New(geometry, shader1);
165 Actor actor = Actor::New();
166 actor.AddRenderer(renderer);
167 actor.SetSize(400, 400);
168 Stage::GetCurrent().Add(actor);
170 TestGlAbstraction& gl = application.GetGlAbstraction();
171 application.SendNotification();
172 application.Render(0);
174 // Expect that the first shaders's fade color property is accessed
175 Vector4 actualValue(Vector4::ZERO);
176 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
177 DALI_TEST_EQUALS( actualValue, Color::RED, TEST_LOCATION );
179 DALI_TEST_EQUALS( renderer.GetShader(), shader1, TEST_LOCATION );
181 // set the second shader to the renderer
182 renderer.SetShader( shader2 );
184 application.SendNotification();
185 application.Render(0);
187 // Expect that the second shader's fade color property is accessed
188 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
189 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
191 DALI_TEST_EQUALS( renderer.GetShader(), shader2, TEST_LOCATION );
196 int UtcDaliRendererSetGetDepthIndex(void)
198 TestApplication application;
200 tet_infoline("Test SetDepthIndex, GetDepthIndex");
202 Shader shader = CreateShader();
203 Geometry geometry = CreateQuadGeometry();
204 Renderer renderer = Renderer::New(geometry, shader);
205 Actor actor = Actor::New();
206 actor.AddRenderer(renderer);
207 actor.SetSize(400, 400);
208 Stage::GetCurrent().Add(actor);
210 application.SendNotification();
211 application.Render(0);
212 DALI_TEST_EQUALS( renderer.GetProperty<int>(Renderer::Property::DEPTH_INDEX), 0, TEST_LOCATION );
214 renderer.SetProperty( Renderer::Property::DEPTH_INDEX, 1 );
216 application.SendNotification();
217 application.Render(0);
218 DALI_TEST_EQUALS( renderer.GetProperty<int>(Renderer::Property::DEPTH_INDEX), 1, TEST_LOCATION );
220 renderer.SetProperty( Renderer::Property::DEPTH_INDEX, 10 );
222 application.SendNotification();
223 application.Render(0);
224 DALI_TEST_EQUALS( renderer.GetProperty<int>(Renderer::Property::DEPTH_INDEX), 10, TEST_LOCATION );
229 int UtcDaliRendererSetGetFaceCullingMode(void)
231 TestApplication application;
233 tet_infoline("Test SetFaceCullingMode(cullingMode)");
234 Geometry geometry = CreateQuadGeometry();
235 Shader shader = CreateShader();
236 Renderer renderer = Renderer::New( geometry, shader );
238 Actor actor = Actor::New();
239 actor.AddRenderer(renderer);
240 actor.SetSize(400, 400);
241 Stage::GetCurrent().Add(actor);
243 // By default, none of the faces should be culled
244 unsigned int cullFace = renderer.GetProperty<int>( Renderer::Property::FACE_CULLING_MODE );
245 DALI_TEST_CHECK( static_cast< Dali::Renderer::FaceCullingMode >( cullFace ) == Renderer::NONE );
247 TestGlAbstraction& gl = application.GetGlAbstraction();
248 TraceCallStack& cullFaceStack = gl.GetCullFaceTrace();
249 gl.EnableCullFaceCallTrace(true);
252 cullFaceStack.Reset();
253 renderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, Renderer::CULL_BACK_AND_FRONT );
254 application.SendNotification();
255 application.Render();
257 DALI_TEST_EQUALS( cullFaceStack.CountMethod( "CullFace" ), 1, TEST_LOCATION );
259 std::ostringstream cullModeString;
260 cullModeString << GL_FRONT_AND_BACK;
262 DALI_TEST_CHECK( cullFaceStack.FindMethodAndParams( "CullFace", cullModeString.str() ) );
263 cullFace = renderer.GetProperty<int>( Renderer::Property::FACE_CULLING_MODE );
264 DALI_TEST_CHECK( static_cast< Dali::Renderer::FaceCullingMode >( cullFace ) == Renderer::CULL_BACK_AND_FRONT);
268 cullFaceStack.Reset();
269 renderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, Renderer::CULL_BACK );
270 application.SendNotification();
271 application.Render();
273 DALI_TEST_EQUALS( cullFaceStack.CountMethod( "CullFace" ), 1, TEST_LOCATION );
275 std::ostringstream cullModeString;
276 cullModeString << GL_BACK;
278 DALI_TEST_CHECK( cullFaceStack.FindMethodAndParams( "CullFace", cullModeString.str() ) );
279 cullFace = renderer.GetProperty<int>( Renderer::Property::FACE_CULLING_MODE );
280 DALI_TEST_CHECK( static_cast< Dali::Renderer::FaceCullingMode >( cullFace ) == Renderer::CULL_BACK );
284 cullFaceStack.Reset();
285 renderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, Renderer::CULL_FRONT );
286 application.SendNotification();
287 application.Render();
289 DALI_TEST_EQUALS( cullFaceStack.CountMethod( "CullFace" ), 1, TEST_LOCATION );
291 std::ostringstream cullModeString;
292 cullModeString << GL_FRONT;
294 DALI_TEST_CHECK( cullFaceStack.FindMethodAndParams( "CullFace", cullModeString.str() ) );
295 cullFace = renderer.GetProperty<int>( Renderer::Property::FACE_CULLING_MODE );
296 DALI_TEST_CHECK( static_cast< Dali::Renderer::FaceCullingMode >( cullFace ) == Renderer::CULL_FRONT );
300 cullFaceStack.Reset();
301 renderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, Renderer::NONE );
302 application.SendNotification();
303 application.Render();
305 DALI_TEST_EQUALS( cullFaceStack.CountMethod( "CullFace" ), 0, TEST_LOCATION );
306 cullFace = renderer.GetProperty<int>( Renderer::Property::FACE_CULLING_MODE );
307 DALI_TEST_CHECK( static_cast< Dali::Renderer::FaceCullingMode >( cullFace ) == Renderer::NONE );
313 int UtcDaliRendererBlendingOptions01(void)
315 TestApplication application;
317 tet_infoline("Test SetBlendFunc(src, dest) ");
319 Geometry geometry = CreateQuadGeometry();
320 Shader shader = CreateShader();
321 Renderer renderer = Renderer::New( geometry, shader );
323 Actor actor = Actor::New();
324 // set a transparent actor color so that blending is enabled
325 actor.SetOpacity( 0.5f );
326 actor.AddRenderer(renderer);
327 actor.SetSize(400, 400);
328 Stage::GetCurrent().Add(actor);
330 renderer.SetBlendFunc(BlendingFactor::ONE_MINUS_SRC_COLOR, BlendingFactor::SRC_ALPHA_SATURATE);
332 // Test that Set was successful:
333 BlendingFactor::Type srcFactorRgb( BlendingFactor::ZERO );
334 BlendingFactor::Type destFactorRgb( BlendingFactor::ZERO );
335 BlendingFactor::Type srcFactorAlpha( BlendingFactor::ZERO );
336 BlendingFactor::Type destFactorAlpha( BlendingFactor::ZERO );
337 renderer.GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
339 DALI_TEST_EQUALS( BlendingFactor::ONE_MINUS_SRC_COLOR, srcFactorRgb, TEST_LOCATION );
340 DALI_TEST_EQUALS( BlendingFactor::SRC_ALPHA_SATURATE, destFactorRgb, TEST_LOCATION );
341 DALI_TEST_EQUALS( BlendingFactor::ONE_MINUS_SRC_COLOR, srcFactorAlpha, TEST_LOCATION );
342 DALI_TEST_EQUALS( BlendingFactor::SRC_ALPHA_SATURATE, destFactorAlpha, TEST_LOCATION );
344 application.SendNotification();
345 application.Render();
347 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
349 DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_SRC_COLOR, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION );
350 DALI_TEST_EQUALS( (GLenum)GL_SRC_ALPHA_SATURATE, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION );
351 DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_SRC_COLOR, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION );
352 DALI_TEST_EQUALS( (GLenum)GL_SRC_ALPHA_SATURATE, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION );
357 int UtcDaliRendererBlendingOptions02(void)
359 TestApplication application;
361 tet_infoline("Test SetBlendFunc(srcRgb, destRgb, srcAlpha, destAlpha) ");
363 Geometry geometry = CreateQuadGeometry();
364 Shader shader = CreateShader();
365 Renderer renderer = Renderer::New( geometry, shader );
367 Actor actor = Actor::New();
368 actor.SetOpacity( 0.5f ); // enable blending
369 actor.AddRenderer(renderer);
370 actor.SetSize(400, 400);
371 Stage::GetCurrent().Add(actor);
373 renderer.SetBlendFunc( BlendingFactor::CONSTANT_COLOR, BlendingFactor::ONE_MINUS_CONSTANT_COLOR,
374 BlendingFactor::CONSTANT_ALPHA, BlendingFactor::ONE_MINUS_CONSTANT_ALPHA );
376 // Test that Set was successful:
378 BlendingFactor::Type srcFactorRgb( BlendingFactor::ZERO );
379 BlendingFactor::Type destFactorRgb( BlendingFactor::ZERO );
380 BlendingFactor::Type srcFactorAlpha( BlendingFactor::ZERO );
381 BlendingFactor::Type destFactorAlpha( BlendingFactor::ZERO );
382 renderer.GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
384 DALI_TEST_EQUALS( BlendingFactor::CONSTANT_COLOR, srcFactorRgb, TEST_LOCATION );
385 DALI_TEST_EQUALS( BlendingFactor::ONE_MINUS_CONSTANT_COLOR, destFactorRgb, TEST_LOCATION );
386 DALI_TEST_EQUALS( BlendingFactor::CONSTANT_ALPHA, srcFactorAlpha, TEST_LOCATION );
387 DALI_TEST_EQUALS( BlendingFactor::ONE_MINUS_CONSTANT_ALPHA, destFactorAlpha, TEST_LOCATION );
390 application.SendNotification();
391 application.Render();
393 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
394 DALI_TEST_EQUALS( (GLenum)GL_CONSTANT_COLOR, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION );
395 DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_CONSTANT_COLOR, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION );
396 DALI_TEST_EQUALS( (GLenum)GL_CONSTANT_ALPHA, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION );
397 DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_CONSTANT_ALPHA, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION );
402 int UtcDaliRendererBlendingOptions03(void)
404 TestApplication application;
406 tet_infoline("Test GetBlendEquation() defaults ");
408 Geometry geometry = CreateQuadGeometry();
409 Shader shader = CreateShader();
410 Renderer renderer = Renderer::New( geometry, shader );
412 Actor actor = Actor::New();
413 actor.AddRenderer(renderer);
414 actor.SetSize(400, 400);
415 Stage::GetCurrent().Add(actor);
417 // Test the defaults as documented in blending.h
418 BlendingEquation::Type equationRgb( BlendingEquation::SUBTRACT );
419 BlendingEquation::Type equationAlpha( BlendingEquation::SUBTRACT );
420 renderer.GetBlendEquation( equationRgb, equationAlpha );
421 DALI_TEST_EQUALS( BlendingEquation::ADD, equationRgb, TEST_LOCATION );
422 DALI_TEST_EQUALS( BlendingEquation::ADD, equationAlpha, TEST_LOCATION );
427 int UtcDaliRendererBlendingOptions04(void)
429 TestApplication application;
431 tet_infoline("Test SetBlendEquation() ");
433 Geometry geometry = CreateQuadGeometry();
434 Shader shader = CreateShader();
435 Renderer renderer = Renderer::New( geometry, shader );
437 Actor actor = Actor::New();
438 actor.SetOpacity( 0.1f );
439 actor.AddRenderer(renderer);
440 actor.SetSize(400, 400);
441 Stage::GetCurrent().Add(actor);
443 // Test the single blending equation setting
445 renderer.SetBlendEquation( BlendingEquation::REVERSE_SUBTRACT );
446 BlendingEquation::Type equationRgba( BlendingEquation::SUBTRACT );
447 renderer.GetBlendEquation( equationRgba, equationRgba );
448 DALI_TEST_EQUALS( BlendingEquation::REVERSE_SUBTRACT, equationRgba, TEST_LOCATION );
451 renderer.SetBlendEquation( BlendingEquation::REVERSE_SUBTRACT, BlendingEquation::REVERSE_SUBTRACT );
453 // Test that Set was successful
455 BlendingEquation::Type equationRgb( BlendingEquation::SUBTRACT );
456 BlendingEquation::Type equationAlpha( BlendingEquation::SUBTRACT );
457 renderer.GetBlendEquation( equationRgb, equationAlpha );
458 DALI_TEST_EQUALS( BlendingEquation::REVERSE_SUBTRACT, equationRgb, TEST_LOCATION );
459 DALI_TEST_EQUALS( BlendingEquation::REVERSE_SUBTRACT, equationAlpha, TEST_LOCATION );
462 // Render & check GL commands
463 application.SendNotification();
464 application.Render();
466 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
467 DALI_TEST_EQUALS( (GLenum)GL_FUNC_REVERSE_SUBTRACT, glAbstraction.GetLastBlendEquationRgb(), TEST_LOCATION );
468 DALI_TEST_EQUALS( (GLenum)GL_FUNC_REVERSE_SUBTRACT, glAbstraction.GetLastBlendEquationAlpha(), TEST_LOCATION );
473 int UtcDaliRendererSetBlendMode01(void)
475 TestApplication application;
477 tet_infoline("Test setting the blend mode to on with an opaque color renders with blending enabled");
479 Geometry geometry = CreateQuadGeometry();
480 Shader shader = CreateShader();
481 Renderer renderer = Renderer::New( geometry, shader );
483 Actor actor = Actor::New();
484 actor.SetOpacity( 0.98f );
485 actor.AddRenderer(renderer);
486 actor.SetSize(400, 400);
487 Stage::GetCurrent().Add(actor);
489 renderer.SetProperty( Renderer::Property::BLENDING_MODE, BlendingMode::ON);
491 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
492 glAbstraction.EnableEnableDisableCallTrace(true);
494 application.SendNotification();
495 application.Render();
497 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
498 std::ostringstream blendStr;
499 blendStr << GL_BLEND;
500 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
505 int UtcDaliRendererSetBlendMode02(void)
507 TestApplication application;
509 tet_infoline("Test setting the blend mode to off with a transparent color renders with blending disabled (and not enabled)");
511 Geometry geometry = CreateQuadGeometry();
512 Shader shader = CreateShader();
513 Renderer renderer = Renderer::New( geometry, shader );
515 Actor actor = Actor::New();
516 actor.SetOpacity( 0.15f );
517 actor.AddRenderer(renderer);
518 actor.SetSize(400, 400);
519 Stage::GetCurrent().Add(actor);
521 renderer.SetProperty( Renderer::Property::BLENDING_MODE, BlendingMode::OFF);
523 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
524 glAbstraction.EnableEnableDisableCallTrace(true);
526 application.SendNotification();
527 application.Render();
529 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
530 std::ostringstream blendStr;
531 blendStr << GL_BLEND;
532 DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
537 int UtcDaliRendererSetBlendMode03(void)
539 TestApplication application;
541 tet_infoline("Test setting the blend mode to auto with a transparent color renders with blending enabled");
543 Geometry geometry = CreateQuadGeometry();
544 Shader shader = CreateShader();
545 Renderer renderer = Renderer::New( geometry, shader );
547 Actor actor = Actor::New();
548 actor.SetOpacity( 0.75f );
549 actor.AddRenderer(renderer);
550 actor.SetSize(400, 400);
551 Stage::GetCurrent().Add(actor);
553 renderer.SetProperty( Renderer::Property::BLENDING_MODE, BlendingMode::AUTO);
555 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
556 glAbstraction.EnableEnableDisableCallTrace(true);
558 application.SendNotification();
559 application.Render();
561 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
562 std::ostringstream blendStr;
563 blendStr << GL_BLEND;
564 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
569 int UtcDaliRendererSetBlendMode04(void)
571 TestApplication application;
573 tet_infoline("Test setting the blend mode to auto with an opaque color renders with blending disabled");
575 Geometry geometry = CreateQuadGeometry();
576 Shader shader = CreateShader();
577 Renderer renderer = Renderer::New( geometry, shader );
579 Actor actor = Actor::New();
580 actor.AddRenderer(renderer);
581 actor.SetSize(400, 400);
582 Stage::GetCurrent().Add(actor);
584 renderer.SetProperty( Renderer::Property::BLENDING_MODE, BlendingMode::AUTO);
586 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
587 glAbstraction.EnableEnableDisableCallTrace(true);
589 application.SendNotification();
590 application.Render();
592 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
593 std::ostringstream blendStr;
594 blendStr << GL_BLEND;
595 DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
600 int UtcDaliRendererSetBlendMode04b(void)
602 TestApplication application;
604 tet_infoline("Test setting the blend mode to auto with a transparent actor color renders with blending enabled");
606 Geometry geometry = CreateQuadGeometry();
607 Shader shader = CreateShader();
608 Renderer renderer = Renderer::New( geometry, shader );
610 Actor actor = Actor::New();
611 actor.AddRenderer(renderer);
612 actor.SetSize(400, 400);
613 actor.SetColor( Vector4(1.0f, 0.0f, 1.0f, 0.5f) );
614 Stage::GetCurrent().Add(actor);
616 renderer.SetProperty( Renderer::Property::BLENDING_MODE, BlendingMode::AUTO);
618 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
619 glAbstraction.EnableEnableDisableCallTrace(true);
621 application.SendNotification();
622 application.Render();
624 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
625 std::ostringstream blendStr;
626 blendStr << GL_BLEND;
627 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
632 int UtcDaliRendererSetBlendMode04c(void)
634 TestApplication application;
636 tet_infoline("Test setting the blend mode to auto with an opaque opaque actor color renders with blending disabled");
638 Geometry geometry = CreateQuadGeometry();
639 Shader shader = CreateShader();
640 Renderer renderer = Renderer::New( geometry, shader );
642 Actor actor = Actor::New();
643 actor.AddRenderer(renderer);
644 actor.SetSize(400, 400);
645 actor.SetColor( Color::MAGENTA );
646 Stage::GetCurrent().Add(actor);
648 renderer.SetProperty( Renderer::Property::BLENDING_MODE, BlendingMode::AUTO);
650 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
651 glAbstraction.EnableEnableDisableCallTrace(true);
653 application.SendNotification();
654 application.Render();
656 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
657 std::ostringstream blendStr;
658 blendStr << GL_BLEND;
659 DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
664 int UtcDaliRendererSetBlendMode05(void)
666 TestApplication application;
668 tet_infoline("Test setting the blend mode to auto with an opaque color and an image with an alpha channel renders with blending enabled");
670 Geometry geometry = CreateQuadGeometry();
671 BufferImage image = BufferImage::New( 40, 40, Pixel::RGBA8888 );
673 Shader shader = CreateShader();
674 TextureSet textureSet = CreateTextureSet( image );
675 Renderer renderer = Renderer::New( geometry, shader );
676 renderer.SetTextures( textureSet );
678 Actor actor = Actor::New();
679 actor.AddRenderer(renderer);
680 actor.SetSize(400, 400);
681 Stage::GetCurrent().Add(actor);
683 renderer.SetProperty( Renderer::Property::BLENDING_MODE, BlendingMode::AUTO);
685 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
686 glAbstraction.EnableEnableDisableCallTrace(true);
688 application.SendNotification();
689 application.Render();
691 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
692 std::ostringstream blendStr;
693 blendStr << GL_BLEND;
694 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
699 int UtcDaliRendererSetBlendMode06(void)
701 TestApplication application;
702 tet_infoline("Test setting the blend mode to auto with an opaque color and an image without an alpha channel and a shader with the hint OUTPUT_IS_TRANSPARENT renders with blending enabled");
704 Geometry geometry = CreateQuadGeometry();
705 Shader shader = Shader::New( "vertexSrc", "fragmentSrc", Shader::HINT_OUTPUT_IS_TRANSPARENT );
707 Renderer renderer = Renderer::New( geometry, shader );
709 Actor actor = Actor::New();
710 actor.AddRenderer(renderer);
711 actor.SetSize(400, 400);
712 Stage::GetCurrent().Add(actor);
714 renderer.SetProperty( Renderer::Property::BLENDING_MODE, BlendingMode::AUTO);
716 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
717 glAbstraction.EnableEnableDisableCallTrace(true);
719 application.SendNotification();
720 application.Render();
722 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
723 std::ostringstream blendStr;
724 blendStr << GL_BLEND;
725 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
730 int UtcDaliRendererSetBlendMode07(void)
732 TestApplication application;
733 tet_infoline("Test setting the blend mode to auto with an opaque color and an image without an alpha channel and a shader with the hint OUTPUT_IS_OPAQUE renders with blending disabled");
735 Geometry geometry = CreateQuadGeometry();
736 Shader shader = Shader::New( "vertexSrc", "fragmentSrc", Shader::HINT_OUTPUT_IS_OPAQUE );
738 BufferImage image = BufferImage::New( 50, 50, Pixel::RGB888 );
739 TextureSet textureSet = CreateTextureSet( image );
740 Renderer renderer = Renderer::New( geometry, shader );
741 renderer.SetTextures( textureSet );
743 Actor actor = Actor::New();
744 actor.AddRenderer(renderer);
745 actor.SetSize(400, 400);
746 Stage::GetCurrent().Add(actor);
748 renderer.SetProperty( Renderer::Property::BLENDING_MODE, BlendingMode::AUTO);
750 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
751 glAbstraction.EnableEnableDisableCallTrace(true);
753 application.SendNotification();
754 application.Render();
756 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
757 DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", "GL_BLEND" ) );
762 int UtcDaliRendererGetBlendMode(void)
764 TestApplication application;
766 tet_infoline("Test GetBlendMode()");
768 Geometry geometry = CreateQuadGeometry();
769 Shader shader = Shader::New( "vertexSrc", "fragmentSrc", Shader::HINT_OUTPUT_IS_OPAQUE );
770 Renderer renderer = Renderer::New( geometry, shader );
773 unsigned int mode = renderer.GetProperty<int>( Renderer::Property::BLENDING_MODE );
774 DALI_TEST_EQUALS( static_cast< BlendingMode::Type >( mode ), BlendingMode::AUTO, TEST_LOCATION );
777 renderer.SetProperty( Renderer::Property::BLENDING_MODE, BlendingMode::ON );
778 mode = renderer.GetProperty<int>( Renderer::Property::BLENDING_MODE );
779 DALI_TEST_EQUALS( static_cast< BlendingMode::Type >( mode ), BlendingMode::ON, TEST_LOCATION );
782 renderer.SetProperty( Renderer::Property::BLENDING_MODE, BlendingMode::OFF );
783 mode = renderer.GetProperty<int>( Renderer::Property::BLENDING_MODE );
784 DALI_TEST_EQUALS( static_cast< BlendingMode::Type >( mode ), BlendingMode::OFF, TEST_LOCATION );
789 int UtcDaliRendererSetBlendColor(void)
791 TestApplication application;
793 tet_infoline("Test SetBlendColor(color)");
795 Geometry geometry = CreateQuadGeometry();
796 Shader shader = Shader::New( "vertexSrc", "fragmentSrc", Shader::HINT_OUTPUT_IS_OPAQUE );
797 TextureSet textureSet = TextureSet::New();
798 BufferImage image = BufferImage::New( 50, 50, Pixel::RGBA8888 );
799 textureSet.SetImage( 0u, image );
800 Renderer renderer = Renderer::New( geometry, shader );
801 renderer.SetTextures( textureSet );
803 Actor actor = Actor::New();
804 actor.AddRenderer(renderer);
805 actor.SetSize(400, 400);
806 Stage::GetCurrent().Add(actor);
808 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
810 renderer.SetProperty( Renderer::Property::BLENDING_COLOR, Color::TRANSPARENT );
811 application.SendNotification();
812 application.Render();
813 DALI_TEST_EQUALS( glAbstraction.GetLastBlendColor(), Color::TRANSPARENT, TEST_LOCATION );
815 renderer.SetProperty( Renderer::Property::BLENDING_COLOR, Color::MAGENTA );
816 application.SendNotification();
817 application.Render();
818 DALI_TEST_EQUALS( glAbstraction.GetLastBlendColor(), Color::MAGENTA, TEST_LOCATION );
820 Vector4 color( 0.1f, 0.2f, 0.3f, 0.4f );
821 renderer.SetProperty( Renderer::Property::BLENDING_COLOR, color );
822 application.SendNotification();
823 application.Render();
824 DALI_TEST_EQUALS( glAbstraction.GetLastBlendColor(), color, TEST_LOCATION );
829 int UtcDaliRendererGetBlendColor(void)
831 TestApplication application;
833 tet_infoline("Test GetBlendColor()");
835 Geometry geometry = CreateQuadGeometry();
836 Shader shader = Shader::New( "vertexSrc", "fragmentSrc", Shader::HINT_OUTPUT_IS_OPAQUE );
837 Renderer renderer = Renderer::New( geometry, shader );
839 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>( Renderer::Property::BLENDING_COLOR ), Color::TRANSPARENT, TEST_LOCATION );
841 renderer.SetProperty( Renderer::Property::BLENDING_COLOR, Color::MAGENTA );
842 application.SendNotification();
843 application.Render();
844 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>( Renderer::Property::BLENDING_COLOR ), Color::MAGENTA, TEST_LOCATION );
846 Vector4 color( 0.1f, 0.2f, 0.3f, 0.4f );
847 renderer.SetProperty( Renderer::Property::BLENDING_COLOR, color );
848 application.SendNotification();
849 application.Render();
850 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>( Renderer::Property::BLENDING_COLOR ), color, TEST_LOCATION );
855 int UtcDaliRendererPreMultipledAlpha(void)
857 TestApplication application;
859 tet_infoline("Test BLEND_PRE_MULTIPLIED_ALPHA property");
861 Geometry geometry = CreateQuadGeometry();
862 Shader shader = Shader::New( "vertexSrc", "fragmentSrc", Shader::HINT_OUTPUT_IS_OPAQUE );
863 Renderer renderer = Renderer::New( geometry, shader );
865 Actor actor = Actor::New();
866 actor.AddRenderer(renderer);
867 actor.SetSize(400, 400);
868 actor.SetColor( Vector4(1.0f, 0.0f, 1.0f, 0.5f) );
869 Stage::GetCurrent().Add(actor);
871 Property::Value value = renderer.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
872 bool preMultipliedAlpha;
873 DALI_TEST_CHECK( value.Get( preMultipliedAlpha ) );
874 DALI_TEST_CHECK( !preMultipliedAlpha );
876 BlendingFactor::Type srcFactorRgb( BlendingFactor::ZERO );
877 BlendingFactor::Type destFactorRgb( BlendingFactor::ZERO );
878 BlendingFactor::Type srcFactorAlpha( BlendingFactor::ZERO );
879 BlendingFactor::Type destFactorAlpha( BlendingFactor::ZERO );
880 renderer.GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
881 DALI_TEST_EQUALS( DEFAULT_BLENDING_SRC_FACTOR_RGB, srcFactorRgb, TEST_LOCATION );
882 DALI_TEST_EQUALS( DEFAULT_BLENDING_DEST_FACTOR_RGB, destFactorRgb, TEST_LOCATION );
883 DALI_TEST_EQUALS( DEFAULT_BLENDING_SRC_FACTOR_ALPHA, srcFactorAlpha, TEST_LOCATION );
884 DALI_TEST_EQUALS( DEFAULT_BLENDING_DEST_FACTOR_ALPHA, destFactorAlpha, TEST_LOCATION );
886 application.SendNotification();
887 application.Render();
889 Vector4 actualValue(Vector4::ZERO);
890 TestGlAbstraction& gl = application.GetGlAbstraction();
891 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uColor", actualValue ) );
892 DALI_TEST_EQUALS( actualValue, Vector4(1.0f, 0.0f, 1.0f, 0.5f), TEST_LOCATION );
894 renderer.SetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true);
896 application.SendNotification();
897 application.Render();
899 value = renderer.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
900 DALI_TEST_CHECK( value.Get( preMultipliedAlpha ) );
901 DALI_TEST_CHECK( preMultipliedAlpha );
903 renderer.GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
904 DALI_TEST_EQUALS( BlendingFactor::ONE, srcFactorRgb, TEST_LOCATION );
905 DALI_TEST_EQUALS( BlendingFactor::ONE_MINUS_SRC_ALPHA, destFactorRgb, TEST_LOCATION );
906 DALI_TEST_EQUALS( BlendingFactor::ONE, srcFactorAlpha, TEST_LOCATION );
907 DALI_TEST_EQUALS( BlendingFactor::ONE, destFactorAlpha, TEST_LOCATION );
909 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uColor", actualValue ) );
910 DALI_TEST_EQUALS( actualValue, Vector4(0.5f, 0.0f, 0.5f, 0.5f), TEST_LOCATION );
915 int UtcDaliRendererConstraint01(void)
917 TestApplication application;
919 tet_infoline("Test that a non-uniform renderer property can be constrained");
921 Shader shader = Shader::New("VertexSource", "FragmentSource");
922 Geometry geometry = CreateQuadGeometry();
923 Renderer renderer = Renderer::New( geometry, shader );
925 Actor actor = Actor::New();
926 actor.AddRenderer(renderer);
927 actor.SetSize(400, 400);
928 Stage::GetCurrent().Add(actor);
930 Vector4 initialColor = Color::WHITE;
931 Property::Index colorIndex = renderer.RegisterProperty( "uFadeColor", initialColor );
933 application.SendNotification();
934 application.Render(0);
935 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
938 Constraint constraint = Constraint::New<Vector4>( renderer, colorIndex, TestConstraintNoBlue );
940 application.SendNotification();
941 application.Render(0);
943 // Expect no blue component in either buffer - yellow
944 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION );
945 application.Render(0);
946 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION );
948 renderer.RemoveConstraints();
949 renderer.SetProperty(colorIndex, Color::WHITE );
950 application.SendNotification();
951 application.Render(0);
952 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), Color::WHITE, TEST_LOCATION );
957 int UtcDaliRendererConstraint02(void)
959 TestApplication application;
961 tet_infoline("Test that a uniform map renderer property can be constrained");
963 Shader shader = Shader::New("VertexSource", "FragmentSource");
964 Geometry geometry = CreateQuadGeometry();
965 Renderer renderer = Renderer::New( geometry, shader );
967 Actor actor = Actor::New();
968 actor.AddRenderer(renderer);
969 actor.SetSize(400, 400);
970 Stage::GetCurrent().Add(actor);
971 application.SendNotification();
972 application.Render(0);
974 Vector4 initialColor = Color::WHITE;
975 Property::Index colorIndex = renderer.RegisterProperty( "uFadeColor", initialColor );
977 TestGlAbstraction& gl = application.GetGlAbstraction();
979 application.SendNotification();
980 application.Render(0);
982 Vector4 actualValue(Vector4::ZERO);
983 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
984 DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
987 Constraint constraint = Constraint::New<Vector4>( renderer, colorIndex, TestConstraintNoBlue );
989 application.SendNotification();
990 application.Render(0);
992 // Expect no blue component in either buffer - yellow
993 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
994 DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
996 application.Render(0);
997 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
998 DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
1000 renderer.RemoveConstraints();
1001 renderer.SetProperty(colorIndex, Color::WHITE );
1002 application.SendNotification();
1003 application.Render(0);
1005 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1006 DALI_TEST_EQUALS( actualValue, Color::WHITE, TEST_LOCATION );
1013 int UtcDaliRendererAnimatedProperty01(void)
1015 TestApplication application;
1017 tet_infoline("Test that a non-uniform renderer property can be animated");
1019 Shader shader = Shader::New("VertexSource", "FragmentSource");
1020 Geometry geometry = CreateQuadGeometry();
1021 Renderer renderer = Renderer::New( geometry, shader );
1023 Actor actor = Actor::New();
1024 actor.AddRenderer(renderer);
1025 actor.SetSize(400, 400);
1026 Stage::GetCurrent().Add(actor);
1028 Vector4 initialColor = Color::WHITE;
1029 Property::Index colorIndex = renderer.RegisterProperty( "uFadeColor", initialColor );
1031 application.SendNotification();
1032 application.Render(0);
1033 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
1035 Animation animation = Animation::New(1.0f);
1036 KeyFrames keyFrames = KeyFrames::New();
1037 keyFrames.Add(0.0f, initialColor);
1038 keyFrames.Add(1.0f, Color::TRANSPARENT);
1039 animation.AnimateBetween( Property( renderer, colorIndex ), keyFrames );
1042 application.SendNotification();
1043 application.Render(500);
1045 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), Color::WHITE * 0.5f, TEST_LOCATION );
1047 application.Render(500);
1049 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), Color::TRANSPARENT, TEST_LOCATION );
1054 int UtcDaliRendererAnimatedProperty02(void)
1056 TestApplication application;
1058 tet_infoline("Test that a uniform map renderer property can be animated");
1060 Shader shader = Shader::New("VertexSource", "FragmentSource");
1061 Geometry geometry = CreateQuadGeometry();
1062 Renderer renderer = Renderer::New( geometry, shader );
1064 Actor actor = Actor::New();
1065 actor.AddRenderer(renderer);
1066 actor.SetSize(400, 400);
1067 Stage::GetCurrent().Add(actor);
1068 application.SendNotification();
1069 application.Render(0);
1071 Vector4 initialColor = Color::WHITE;
1072 Property::Index colorIndex = renderer.RegisterProperty( "uFadeColor", initialColor );
1074 TestGlAbstraction& gl = application.GetGlAbstraction();
1076 application.SendNotification();
1077 application.Render(0);
1079 Vector4 actualValue(Vector4::ZERO);
1080 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1081 DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
1083 Animation animation = Animation::New(1.0f);
1084 KeyFrames keyFrames = KeyFrames::New();
1085 keyFrames.Add(0.0f, initialColor);
1086 keyFrames.Add(1.0f, Color::TRANSPARENT);
1087 animation.AnimateBetween( Property( renderer, colorIndex ), keyFrames );
1090 application.SendNotification();
1091 application.Render(500);
1093 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1094 DALI_TEST_EQUALS( actualValue, Color::WHITE * 0.5f, TEST_LOCATION );
1096 application.Render(500);
1097 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1098 DALI_TEST_EQUALS( actualValue, Color::TRANSPARENT, TEST_LOCATION );
1106 int UtcDaliRendererUniformMapPrecendence01(void)
1108 TestApplication application;
1110 tet_infoline("Test the uniform map precedence is applied properly");
1112 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1114 Shader shader = Shader::New("VertexSource", "FragmentSource");
1115 TextureSet textureSet = CreateTextureSet( image );
1117 PropertyBuffer vertexBuffer = CreatePropertyBuffer();
1118 Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
1119 Renderer renderer = Renderer::New( geometry, shader );
1120 renderer.SetTextures( textureSet );
1122 Actor actor = Actor::New();
1123 actor.AddRenderer(renderer);
1124 actor.SetSize(400, 400);
1125 Stage::GetCurrent().Add(actor);
1126 application.SendNotification();
1127 application.Render(0);
1129 renderer.RegisterProperty( "uFadeColor", Color::RED );
1131 actor.RegisterProperty( "uFadeColor", Color::GREEN );
1133 Property::Index textureSetFadeColorIndex = textureSet.RegisterProperty( "uFadeColor", Color::BLUE );
1135 shader.RegisterProperty( "uFadeColor", Color::MAGENTA );
1137 TestGlAbstraction& gl = application.GetGlAbstraction();
1139 application.SendNotification();
1140 application.Render(0);
1142 // Expect that the actor's fade color property is accessed
1143 Vector4 actualValue(Vector4::ZERO);
1144 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1145 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1147 // Animate texture set's fade color property. Should be no change to uniform
1148 Animation animation = Animation::New(1.0f);
1149 KeyFrames keyFrames = KeyFrames::New();
1150 keyFrames.Add(0.0f, Color::WHITE);
1151 keyFrames.Add(1.0f, Color::TRANSPARENT);
1152 animation.AnimateBetween( Property( textureSet, textureSetFadeColorIndex ), keyFrames );
1155 application.SendNotification();
1156 application.Render(500);
1158 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1159 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1161 application.Render(500);
1162 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1163 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1168 int UtcDaliRendererUniformMapPrecendence02(void)
1170 TestApplication application;
1172 tet_infoline("Test the uniform map precedence is applied properly");
1174 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1176 Shader shader = Shader::New("VertexSource", "FragmentSource");
1177 TextureSet textureSet = CreateTextureSet( image );
1179 PropertyBuffer vertexBuffer = CreatePropertyBuffer();
1180 Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
1181 Renderer renderer = Renderer::New( geometry, shader );
1182 renderer.SetTextures( textureSet );
1184 Actor actor = Actor::New();
1185 actor.AddRenderer(renderer);
1186 actor.SetSize(400, 400);
1187 Stage::GetCurrent().Add(actor);
1188 application.SendNotification();
1189 application.Render(0);
1191 // Don't add property / uniform map to renderer
1193 actor.RegisterProperty( "uFadeColor", Color::GREEN );
1195 Property::Index textureSetFadeColorIndex = textureSet.RegisterProperty( "uFadeColor", Color::BLUE );
1197 shader.RegisterProperty( "uFadeColor", Color::MAGENTA );
1200 TestGlAbstraction& gl = application.GetGlAbstraction();
1202 application.SendNotification();
1203 application.Render(0);
1205 // Expect that the actor's fade color property is accessed
1206 Vector4 actualValue(Vector4::ZERO);
1207 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1208 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1210 // Animate texture set's fade color property. Should be no change to uniform
1211 Animation animation = Animation::New(1.0f);
1212 KeyFrames keyFrames = KeyFrames::New();
1213 keyFrames.Add(0.0f, Color::WHITE);
1214 keyFrames.Add(1.0f, Color::TRANSPARENT);
1215 animation.AnimateBetween( Property( textureSet, textureSetFadeColorIndex ), keyFrames );
1218 application.SendNotification();
1219 application.Render(500);
1221 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1222 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1224 application.Render(500);
1225 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1226 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1232 int UtcDaliRendererUniformMapPrecendence03(void)
1234 TestApplication application;
1236 tet_infoline("Test the uniform map precedence is applied properly");
1238 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1240 Shader shader = Shader::New("VertexSource", "FragmentSource");
1241 TextureSet textureSet = CreateTextureSet( image );
1243 PropertyBuffer vertexBuffer = CreatePropertyBuffer();
1244 Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
1245 Renderer renderer = Renderer::New( geometry, shader );
1246 renderer.SetTextures( textureSet );
1248 Actor actor = Actor::New();
1249 actor.AddRenderer(renderer);
1250 actor.SetSize(400, 400);
1251 Stage::GetCurrent().Add(actor);
1252 application.SendNotification();
1253 application.Render(0);
1255 // Don't add property / uniform map to renderer or actor
1257 textureSet.RegisterProperty( "uFadeColor", Color::BLUE );
1259 Property::Index shaderFadeColorIndex = shader.RegisterProperty( "uFadeColor", Color::BLACK );
1261 TestGlAbstraction& gl = application.GetGlAbstraction();
1263 application.SendNotification();
1264 application.Render(0);
1266 // Expect that the texture set's fade color property is accessed
1267 Vector4 actualValue(Vector4::ZERO);
1268 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1269 DALI_TEST_EQUALS( actualValue, Color::BLUE, TEST_LOCATION );
1271 // Animate geometry's fade color property. Should be no change to uniform
1272 Animation animation = Animation::New(1.0f);
1273 KeyFrames keyFrames = KeyFrames::New();
1274 keyFrames.Add(0.0f, Color::WHITE);
1275 keyFrames.Add(1.0f, Color::TRANSPARENT);
1276 animation.AnimateBetween( Property( shader, shaderFadeColorIndex ), keyFrames );
1279 application.SendNotification();
1280 application.Render(500);
1282 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1283 DALI_TEST_EQUALS( actualValue, Color::BLUE, TEST_LOCATION );
1285 application.Render(500);
1286 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1287 DALI_TEST_EQUALS( actualValue, Color::BLUE, TEST_LOCATION );
1292 int UtcDaliRendererUniformMapMultipleUniforms01(void)
1294 TestApplication application;
1296 tet_infoline("Test the uniform maps are collected from all objects (same type)");
1298 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1300 Shader shader = Shader::New("VertexSource", "FragmentSource");
1301 TextureSet textureSet = CreateTextureSet( image );
1303 PropertyBuffer vertexBuffer = CreatePropertyBuffer();
1304 Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
1305 Renderer renderer = Renderer::New( geometry, shader );
1306 renderer.SetTextures( textureSet );
1308 Actor actor = Actor::New();
1309 actor.AddRenderer(renderer);
1310 actor.SetSize(400, 400);
1311 Stage::GetCurrent().Add(actor);
1312 application.SendNotification();
1313 application.Render(0);
1315 renderer.RegisterProperty( "uUniform1", Color::RED );
1316 actor.RegisterProperty( "uUniform2", Color::GREEN );
1317 textureSet.RegisterProperty( "uUniform3", Color::BLUE );
1318 shader.RegisterProperty( "uUniform4", Color::MAGENTA );
1320 TestGlAbstraction& gl = application.GetGlAbstraction();
1322 application.SendNotification();
1323 application.Render(0);
1325 // Expect that each of the object's uniforms are set
1326 Vector4 uniform1Value(Vector4::ZERO);
1327 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform1", uniform1Value ) );
1328 DALI_TEST_EQUALS( uniform1Value, Color::RED, TEST_LOCATION );
1330 Vector4 uniform2Value(Vector4::ZERO);
1331 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform2", uniform2Value ) );
1332 DALI_TEST_EQUALS( uniform2Value, Color::GREEN, TEST_LOCATION );
1334 Vector4 uniform3Value(Vector4::ZERO);
1335 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform3", uniform3Value ) );
1336 DALI_TEST_EQUALS( uniform3Value, Color::BLUE, TEST_LOCATION );
1338 Vector4 uniform4Value(Vector4::ZERO);
1339 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform4", uniform4Value ) );
1340 DALI_TEST_EQUALS( uniform4Value, Color::MAGENTA, TEST_LOCATION );
1345 int UtcDaliRendererUniformMapMultipleUniforms02(void)
1347 TestApplication application;
1349 tet_infoline("Test the uniform maps are collected from all objects (different types)");
1351 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1353 Shader shader = Shader::New("VertexSource", "FragmentSource");
1354 TextureSet textureSet = CreateTextureSet( image );
1356 PropertyBuffer vertexBuffer = CreatePropertyBuffer();
1357 Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
1358 Renderer renderer = Renderer::New( geometry, shader );
1359 renderer.SetTextures( textureSet );
1361 Actor actor = Actor::New();
1362 actor.AddRenderer(renderer);
1363 actor.SetSize(400, 400);
1364 Stage::GetCurrent().Add(actor);
1365 application.SendNotification();
1366 application.Render(0);
1368 Property::Value value1(Color::RED);
1369 renderer.RegisterProperty( "uFadeColor", value1 );
1371 Property::Value value2(1.0f);
1372 actor.RegisterProperty( "uFadeProgress", value2 );
1374 Property::Value value3(Vector3(0.5f, 0.5f, 1.0f));
1375 textureSet.RegisterProperty( "uFadePosition", value3);
1377 Property::Value value5(Matrix3::IDENTITY);
1378 shader.RegisterProperty( "uANormalMatrix", value5 );
1380 TestGlAbstraction& gl = application.GetGlAbstraction();
1382 application.SendNotification();
1383 application.Render(0);
1385 // Expect that each of the object's uniforms are set
1386 Vector4 uniform1Value(Vector4::ZERO);
1387 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", uniform1Value ) );
1388 DALI_TEST_EQUALS( uniform1Value, value1.Get<Vector4>(), TEST_LOCATION );
1390 float uniform2Value(0.0f);
1391 DALI_TEST_CHECK( gl.GetUniformValue<float>( "uFadeProgress", uniform2Value ) );
1392 DALI_TEST_EQUALS( uniform2Value, value2.Get<float>(), TEST_LOCATION );
1394 Vector3 uniform3Value(Vector3::ZERO);
1395 DALI_TEST_CHECK( gl.GetUniformValue<Vector3>( "uFadePosition", uniform3Value ) );
1396 DALI_TEST_EQUALS( uniform3Value, value3.Get<Vector3>(), TEST_LOCATION );
1398 Matrix3 uniform5Value;
1399 DALI_TEST_CHECK( gl.GetUniformValue<Matrix3>( "uANormalMatrix", uniform5Value ) );
1400 DALI_TEST_EQUALS( uniform5Value, value5.Get<Matrix3>(), TEST_LOCATION );
1406 int UtcDaliRendererRenderOrder2DLayer(void)
1408 TestApplication application;
1409 tet_infoline("Test the rendering order in a 2D layer is correct");
1411 Shader shader = Shader::New("VertexSource", "FragmentSource");
1412 PropertyBuffer vertexBuffer = CreatePropertyBuffer();
1413 Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
1415 Actor actor0 = Actor::New();
1416 actor0.SetAnchorPoint(AnchorPoint::CENTER);
1417 actor0.SetParentOrigin(AnchorPoint::CENTER);
1418 actor0.SetPosition(0.0f,0.0f);
1419 Image image0 = BufferImage::New( 64, 64, Pixel::RGB888 );
1420 TextureSet textureSet0 = CreateTextureSet( image0 );
1421 Renderer renderer0 = Renderer::New( geometry, shader );
1422 renderer0.SetTextures( textureSet0 );
1423 actor0.AddRenderer(renderer0);
1424 actor0.SetSize(1, 1);
1425 Stage::GetCurrent().Add(actor0);
1426 application.SendNotification();
1427 application.Render(0);
1429 Actor actor1 = Actor::New();
1430 actor1.SetAnchorPoint(AnchorPoint::CENTER);
1431 actor1.SetParentOrigin(AnchorPoint::CENTER);
1432 actor1.SetPosition(0.0f,0.0f);
1433 Image image1= BufferImage::New( 64, 64, Pixel::RGB888 );
1434 TextureSet textureSet1 = CreateTextureSet( image1 );
1435 Renderer renderer1 = Renderer::New( geometry, shader );
1436 renderer1.SetTextures( textureSet1 );
1437 actor1.AddRenderer(renderer1);
1438 actor1.SetSize(1, 1);
1439 Stage::GetCurrent().Add(actor1);
1440 application.SendNotification();
1441 application.Render(0);
1443 Actor actor2 = Actor::New();
1444 actor2.SetAnchorPoint(AnchorPoint::CENTER);
1445 actor2.SetParentOrigin(AnchorPoint::CENTER);
1446 actor2.SetPosition(0.0f,0.0f);
1447 Image image2= BufferImage::New( 64, 64, Pixel::RGB888 );
1448 TextureSet textureSet2 = CreateTextureSet( image2 );
1449 Renderer renderer2 = Renderer::New( geometry, shader );
1450 renderer2.SetTextures( textureSet2 );
1451 actor2.AddRenderer(renderer2);
1452 actor2.SetSize(1, 1);
1453 Stage::GetCurrent().Add(actor2);
1454 application.SendNotification();
1455 application.Render(0);
1457 Actor actor3 = Actor::New();
1458 actor3.SetAnchorPoint(AnchorPoint::CENTER);
1459 actor3.SetParentOrigin(AnchorPoint::CENTER);
1460 actor3.SetPosition(0.0f,0.0f);
1461 Image image3 = BufferImage::New( 64, 64, Pixel::RGB888 );
1462 TextureSet textureSet3 = CreateTextureSet( image3 );
1463 Renderer renderer3 = Renderer::New( geometry, shader );
1464 renderer3.SetTextures( textureSet3 );
1465 actor3.AddRenderer(renderer3);
1466 actor3.SetSize(1, 1);
1467 Stage::GetCurrent().Add(actor3);
1468 application.SendNotification();
1469 application.Render(0);
1472 * Create the following hierarchy:
1485 * Expected rendering order : actor2 - actor1 - actor0 - actor3
1490 application.SendNotification();
1491 application.Render(0);
1493 TestGlAbstraction& gl = application.GetGlAbstraction();
1494 gl.EnableTextureCallTrace(true);
1495 application.SendNotification();
1496 application.Render(0);
1498 int textureBindIndex[4];
1499 for( unsigned int i(0); i<4; ++i )
1501 std::stringstream params;
1502 params << GL_TEXTURE_2D<<", "<<i+1;
1503 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
1506 //Check that actor1 has been rendered after actor2
1507 DALI_TEST_GREATER( textureBindIndex[1], textureBindIndex[2], TEST_LOCATION );
1509 //Check that actor0 has been rendered after actor1
1510 DALI_TEST_GREATER( textureBindIndex[0], textureBindIndex[1], TEST_LOCATION );
1512 //Check that actor3 has been rendered after actor0
1513 DALI_TEST_GREATER( textureBindIndex[3], textureBindIndex[0], TEST_LOCATION );
1518 int UtcDaliRendererRenderOrder2DLayerMultipleRenderers(void)
1520 TestApplication application;
1521 tet_infoline("Test the rendering order in a 2D layer is correct using multiple renderers per actor");
1524 * Creates the following hierarchy:
1526 * actor0------------------------>actor1
1530 * renderer0 renderer1 renderer2 renderer3 renderer4 renderer5
1532 * renderer0 has depth index 2
1533 * renderer1 has depth index 0
1534 * renderer2 has depth index 1
1536 * renderer3 has depth index 1
1537 * renderer4 has depth index 0
1538 * renderer5 has depth index -1
1540 * Expected rendering order: renderer1 - renderer2 - renderer0 - renderer5 - renderer4 - renderer3
1543 Shader shader = Shader::New("VertexSource", "FragmentSource");
1544 PropertyBuffer vertexBuffer = CreatePropertyBuffer();
1545 Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
1547 Actor actor0 = Actor::New();
1548 actor0.SetAnchorPoint(AnchorPoint::CENTER);
1549 actor0.SetParentOrigin(AnchorPoint::CENTER);
1550 actor0.SetPosition(0.0f,0.0f);
1551 actor0.SetSize(1, 1);
1552 Stage::GetCurrent().Add(actor0);
1554 Actor actor1 = Actor::New();
1555 actor1.SetAnchorPoint(AnchorPoint::CENTER);
1556 actor1.SetParentOrigin(AnchorPoint::CENTER);
1557 actor1.SetPosition(0.0f,0.0f);
1558 actor1.SetSize(1, 1);
1562 Image image0 = BufferImage::New( 64, 64, Pixel::RGB888 );
1563 TextureSet textureSet0 = CreateTextureSet( image0 );
1564 Renderer renderer0 = Renderer::New( geometry, shader );
1565 renderer0.SetTextures( textureSet0 );
1566 renderer0.SetProperty( Renderer::Property::DEPTH_INDEX, 2 );
1567 actor0.AddRenderer(renderer0);
1568 application.SendNotification();
1569 application.Render(0);
1572 Image image1= BufferImage::New( 64, 64, Pixel::RGB888 );
1573 TextureSet textureSet1 = CreateTextureSet( image1 );
1574 Renderer renderer1 = Renderer::New( geometry, shader );
1575 renderer1.SetTextures( textureSet1 );
1576 renderer1.SetProperty( Renderer::Property::DEPTH_INDEX, 0 );
1577 actor0.AddRenderer(renderer1);
1578 application.SendNotification();
1579 application.Render(0);
1582 Image image2= BufferImage::New( 64, 64, Pixel::RGB888 );
1583 TextureSet textureSet2 = CreateTextureSet( image2 );
1584 Renderer renderer2 = Renderer::New( geometry, shader );
1585 renderer2.SetTextures( textureSet2 );
1586 renderer2.SetProperty( Renderer::Property::DEPTH_INDEX, 1 );
1587 actor0.AddRenderer(renderer2);
1588 application.SendNotification();
1589 application.Render(0);
1592 Image image3 = BufferImage::New( 64, 64, Pixel::RGB888 );
1593 TextureSet textureSet3 = CreateTextureSet( image3 );
1594 Renderer renderer3 = Renderer::New( geometry, shader );
1595 renderer3.SetTextures( textureSet3 );
1596 renderer3.SetProperty( Renderer::Property::DEPTH_INDEX, 1 );
1597 actor1.AddRenderer(renderer3);
1598 application.SendNotification();
1599 application.Render(0);
1602 Image image4= BufferImage::New( 64, 64, Pixel::RGB888 );
1603 TextureSet textureSet4 = CreateTextureSet( image4 );
1604 Renderer renderer4 = Renderer::New( geometry, shader );
1605 renderer4.SetTextures( textureSet4 );
1606 renderer4.SetProperty( Renderer::Property::DEPTH_INDEX, 0 );
1607 actor1.AddRenderer(renderer4);
1608 application.SendNotification();
1609 application.Render(0);
1612 Image image5= BufferImage::New( 64, 64, Pixel::RGB888 );
1613 TextureSet textureSet5 = CreateTextureSet( image5 );
1614 Renderer renderer5 = Renderer::New( geometry, shader );
1615 renderer5.SetTextures( textureSet5 );
1616 renderer5.SetProperty( Renderer::Property::DEPTH_INDEX, -1 );
1617 actor1.AddRenderer(renderer5);
1618 application.SendNotification();
1619 application.Render(0);
1622 TestGlAbstraction& gl = application.GetGlAbstraction();
1623 gl.EnableTextureCallTrace(true);
1624 application.SendNotification();
1625 application.Render(0);
1627 int textureBindIndex[6];
1628 for( unsigned int i(0); i<6; ++i )
1630 std::stringstream params;
1631 params << GL_TEXTURE_2D<<", "<<i+1;
1632 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
1635 //Check that renderer3 has been rendered after renderer4
1636 DALI_TEST_GREATER( textureBindIndex[3], textureBindIndex[4], TEST_LOCATION );
1638 //Check that renderer0 has been rendered after renderer2
1639 DALI_TEST_GREATER( textureBindIndex[4], textureBindIndex[5], TEST_LOCATION );
1641 //Check that renderer0 has been rendered after renderer2
1642 DALI_TEST_GREATER( textureBindIndex[5], textureBindIndex[0], TEST_LOCATION );
1644 //Check that renderer0 has been rendered after renderer2
1645 DALI_TEST_GREATER( textureBindIndex[0], textureBindIndex[2], TEST_LOCATION );
1647 //Check that renderer2 has been rendered after renderer1
1648 DALI_TEST_GREATER( textureBindIndex[2], textureBindIndex[1], TEST_LOCATION );
1653 int UtcDaliRendererRenderOrder2DLayerOverlay(void)
1655 TestApplication application;
1656 tet_infoline("Test the rendering order in a 2D layer is correct for overlays");
1658 Shader shader = Shader::New("VertexSource", "FragmentSource");
1659 PropertyBuffer vertexBuffer = CreatePropertyBuffer();
1660 Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
1662 Actor actor0 = Actor::New();
1663 actor0.SetAnchorPoint(AnchorPoint::CENTER);
1664 actor0.SetParentOrigin(AnchorPoint::CENTER);
1665 Image image0 = BufferImage::New( 64, 64, Pixel::RGB888 );
1666 TextureSet textureSet0 = CreateTextureSet( image0 );
1667 Renderer renderer0 = Renderer::New( geometry, shader );
1668 renderer0.SetTextures( textureSet0 );
1669 actor0.AddRenderer(renderer0);
1670 actor0.SetPosition(0.0f,0.0f);
1671 actor0.SetSize(100, 100);
1672 Stage::GetCurrent().Add(actor0);
1673 actor0.SetDrawMode( DrawMode::OVERLAY_2D );
1674 application.SendNotification();
1675 application.Render(0);
1677 Actor actor1 = Actor::New();
1678 actor1.SetAnchorPoint(AnchorPoint::CENTER);
1679 actor1.SetParentOrigin(AnchorPoint::CENTER);
1680 Image image1= BufferImage::New( 64, 64, Pixel::RGB888 );
1681 TextureSet textureSet1 = CreateTextureSet( image1 );
1682 Renderer renderer1 = Renderer::New( geometry, shader );
1683 renderer1.SetTextures( textureSet1 );
1684 actor1.SetPosition(0.0f,0.0f);
1685 actor1.AddRenderer(renderer1);
1686 actor1.SetSize(100, 100);
1687 Stage::GetCurrent().Add(actor1);
1688 actor1.SetDrawMode( DrawMode::OVERLAY_2D );
1689 application.SendNotification();
1690 application.Render(0);
1692 Actor actor2 = Actor::New();
1693 actor2.SetAnchorPoint(AnchorPoint::CENTER);
1694 actor2.SetParentOrigin(AnchorPoint::CENTER);
1695 Image image2= BufferImage::New( 64, 64, Pixel::RGB888 );
1696 TextureSet textureSet2 = CreateTextureSet( image2 );
1697 Renderer renderer2 = Renderer::New( geometry, shader );
1698 renderer2.SetTextures( textureSet2 );
1699 actor2.AddRenderer(renderer2);
1700 actor2.SetPosition(0.0f,0.0f);
1701 actor2.SetSize(100, 100);
1702 Stage::GetCurrent().Add(actor2);
1703 application.SendNotification();
1704 application.Render(0);
1706 Actor actor3 = Actor::New();
1707 actor3.SetAnchorPoint(AnchorPoint::CENTER);
1708 actor3.SetParentOrigin(AnchorPoint::CENTER);
1709 Image image3 = BufferImage::New( 64, 64, Pixel::RGB888 );
1710 TextureSet textureSet3 = CreateTextureSet( image3 );
1711 Renderer renderer3 = Renderer::New( geometry, shader );
1712 renderer3.SetTextures( textureSet3 );
1713 actor3.SetPosition(0.0f,0.0f);
1714 actor3.AddRenderer(renderer3);
1715 actor3.SetSize(100, 100);
1716 Stage::GetCurrent().Add(actor3);
1717 actor3.SetDrawMode( DrawMode::OVERLAY_2D );
1718 application.SendNotification();
1719 application.Render(0);
1721 Actor actor4 = Actor::New();
1722 actor4.SetAnchorPoint(AnchorPoint::CENTER);
1723 actor4.SetParentOrigin(AnchorPoint::CENTER);
1724 Image image4 = BufferImage::New( 64, 64, Pixel::RGB888 );
1725 TextureSet textureSet4 = CreateTextureSet( image4 );
1726 Renderer renderer4 = Renderer::New( geometry, shader );
1727 renderer4.SetTextures( textureSet4 );
1728 actor4.AddRenderer(renderer4);
1729 actor4.SetPosition(0.0f,0.0f);
1730 actor4.SetSize(100, 100);
1731 Stage::GetCurrent().Add(actor4);
1732 application.SendNotification();
1733 application.Render(0);
1736 * Create the following hierarchy:
1743 * (Overlay) (Regular actor)
1753 * Expected rendering order : actor2 - actor4 - actor1 - actor0 - actor3
1755 Stage::GetCurrent().Add( actor2 );
1760 application.SendNotification();
1761 application.Render(0);
1763 TestGlAbstraction& gl = application.GetGlAbstraction();
1764 gl.EnableTextureCallTrace(true);
1765 application.SendNotification();
1766 application.Render(0);
1768 int textureBindIndex[5];
1769 for( unsigned int i(0); i<5; ++i )
1771 std::stringstream params;
1772 params << GL_TEXTURE_2D<<", "<<i+1;
1773 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
1776 //Check that actor4 has been rendered after actor2
1777 DALI_TEST_GREATER( textureBindIndex[4], textureBindIndex[2], TEST_LOCATION );
1779 //Check that actor1 has been rendered after actor4
1780 DALI_TEST_GREATER( textureBindIndex[1], textureBindIndex[4], TEST_LOCATION );
1782 //Check that actor0 has been rendered after actor1
1783 DALI_TEST_GREATER( textureBindIndex[0], textureBindIndex[1], TEST_LOCATION );
1785 //Check that actor3 has been rendered after actor0
1786 DALI_TEST_GREATER( textureBindIndex[3], textureBindIndex[0], TEST_LOCATION );
1791 int UtcDaliRendererSetIndexRange(void)
1795 "attribute vec2 aPosition;\n"
1798 " gl_Position = aPosition;\n"
1804 " gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0)\n"
1808 TestApplication application;
1809 tet_infoline("Test setting the range of indices to draw");
1811 TestGlAbstraction& gl = application.GetGlAbstraction();
1812 gl.EnableDrawCallTrace( true );
1814 Actor actor = Actor::New();
1815 actor.SetSize( 100, 100 );
1818 Geometry geometry = Geometry::New();
1819 geometry.SetGeometryType( Geometry::LINE_LOOP );
1821 // --------------------------------------------------------------------------
1823 unsigned short indices[] = { 0, 2, 4, 6, 8, // offset = 0, count = 5
1824 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, // offset = 5, count = 10
1825 1, 3, 5, 7, 9, 1 }; // offset = 15, count = 6 // line strip
1827 // --------------------------------------------------------------------------
1836 { Vector2( 0.0f, 1.00f) }, { Vector2( 0.0f, -1.00f) },
1837 { Vector2( -0.95f, 0.31f) }, { Vector2( 0.59f, 0.81f) },
1838 { Vector2( -0.59f, -0.81f) }, { Vector2( -0.95f, -0.31f) },
1839 { Vector2( 0.59f, -0.81f) }, { Vector2( 0.95f, -0.31f) },
1840 { Vector2( 0.95f, 0.31f) }, { Vector2( -0.59f, 0.81f) },
1842 Property::Map vertexFormat;
1843 vertexFormat["aPosition"] = Property::VECTOR2;
1844 PropertyBuffer vertexBuffer = PropertyBuffer::New( vertexFormat );
1845 vertexBuffer.SetData( shapes, sizeof(shapes)/sizeof(shapes[0]));
1847 // --------------------------------------------------------------------------
1848 geometry.SetIndexBuffer( indices, sizeof(indices)/sizeof(indices[0]) );
1849 geometry.AddVertexBuffer( vertexBuffer );
1852 Shader shader = Shader::New( vertexShader,fragmentShader );
1853 Renderer renderer = Renderer::New( geometry, shader );
1854 actor.AddRenderer( renderer );
1856 Stage stage = Stage::GetCurrent();
1861 // LINE_LOOP, first 0, count 5
1863 renderer.SetIndexRange( 0, 5 );
1864 application.SendNotification();
1865 application.Render();
1866 sprintf( buffer, "%u, 5, %u, indices", GL_LINE_LOOP, GL_UNSIGNED_SHORT );
1867 bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
1868 DALI_TEST_CHECK( result );
1871 // LINE_LOOP, first 5, count 10
1873 renderer.SetIndexRange( 5, 10 );
1874 sprintf( buffer, "%u, 10, %u, indices", GL_LINE_LOOP, GL_UNSIGNED_SHORT );
1875 application.SendNotification();
1876 application.Render();
1877 bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
1878 DALI_TEST_CHECK( result );
1881 // LINE_STRIP, first 15, count 6
1883 renderer.SetIndexRange( 15, 6 );
1884 geometry.SetGeometryType( Geometry::LINE_STRIP );
1885 sprintf( buffer, "%u, 6, %u, indices", GL_LINE_STRIP, GL_UNSIGNED_SHORT );
1886 application.SendNotification();
1887 application.Render();
1888 bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
1889 DALI_TEST_CHECK( result );