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 );
1103 int UtcDaliRendererUniformMapPrecendence01(void)
1105 TestApplication application;
1107 tet_infoline("Test the uniform map precedence is applied properly");
1109 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1111 Shader shader = Shader::New("VertexSource", "FragmentSource");
1112 TextureSet textureSet = CreateTextureSet( image );
1114 PropertyBuffer vertexBuffer = CreatePropertyBuffer();
1115 Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
1116 Renderer renderer = Renderer::New( geometry, shader );
1117 renderer.SetTextures( textureSet );
1119 Actor actor = Actor::New();
1120 actor.AddRenderer(renderer);
1121 actor.SetSize(400, 400);
1122 Stage::GetCurrent().Add(actor);
1123 application.SendNotification();
1124 application.Render(0);
1126 renderer.RegisterProperty( "uFadeColor", Color::RED );
1127 actor.RegisterProperty( "uFadeColor", Color::GREEN );
1128 Property::Index shaderFadeColorIndex = shader.RegisterProperty( "uFadeColor", Color::MAGENTA );
1130 TestGlAbstraction& gl = application.GetGlAbstraction();
1132 application.SendNotification();
1133 application.Render(0);
1135 // Expect that the actor's fade color property is accessed
1136 Vector4 actualValue(Vector4::ZERO);
1137 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1138 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1140 // Animate shader's fade color property. Should be no change to uniform
1141 Animation animation = Animation::New(1.0f);
1142 KeyFrames keyFrames = KeyFrames::New();
1143 keyFrames.Add(0.0f, Color::WHITE);
1144 keyFrames.Add(1.0f, Color::TRANSPARENT);
1145 animation.AnimateBetween( Property( shader, shaderFadeColorIndex ), keyFrames );
1148 application.SendNotification();
1149 application.Render(500);
1151 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1152 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1154 application.Render(500);
1155 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1156 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1161 int UtcDaliRendererUniformMapPrecendence02(void)
1163 TestApplication application;
1165 tet_infoline("Test the uniform map precedence is applied properly");
1167 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1169 Shader shader = Shader::New("VertexSource", "FragmentSource");
1170 TextureSet textureSet = CreateTextureSet( image );
1172 PropertyBuffer vertexBuffer = CreatePropertyBuffer();
1173 Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
1174 Renderer renderer = Renderer::New( geometry, shader );
1175 renderer.SetTextures( textureSet );
1177 Actor actor = Actor::New();
1178 actor.AddRenderer(renderer);
1179 actor.SetSize(400, 400);
1180 Stage::GetCurrent().Add(actor);
1181 application.SendNotification();
1182 application.Render(0);
1184 // Don't add property / uniform map to renderer
1185 actor.RegisterProperty( "uFadeColor", Color::GREEN );
1186 Property::Index shaderFadeColorIndex = shader.RegisterProperty( "uFadeColor", Color::BLUE );
1188 TestGlAbstraction& gl = application.GetGlAbstraction();
1190 application.SendNotification();
1191 application.Render(0);
1193 // Expect that the actor's fade color property is accessed
1194 Vector4 actualValue(Vector4::ZERO);
1195 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1196 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1198 // Animate texture set's fade color property. Should be no change to uniform
1199 Animation animation = Animation::New(1.0f);
1200 KeyFrames keyFrames = KeyFrames::New();
1201 keyFrames.Add(0.0f, Color::WHITE);
1202 keyFrames.Add(1.0f, Color::TRANSPARENT);
1203 animation.AnimateBetween( Property( shader, shaderFadeColorIndex ), keyFrames );
1206 application.SendNotification();
1207 application.Render(500);
1209 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1210 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1212 application.Render(500);
1213 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1214 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1220 int UtcDaliRendererUniformMapPrecendence03(void)
1222 TestApplication application;
1224 tet_infoline("Test the uniform map precedence is applied properly");
1226 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1228 Shader shader = Shader::New("VertexSource", "FragmentSource");
1229 TextureSet textureSet = CreateTextureSet( image );
1231 PropertyBuffer vertexBuffer = CreatePropertyBuffer();
1232 Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
1233 Renderer renderer = Renderer::New( geometry, shader );
1234 renderer.SetTextures( textureSet );
1236 Actor actor = Actor::New();
1237 actor.AddRenderer(renderer);
1238 actor.SetSize(400, 400);
1239 Stage::GetCurrent().Add(actor);
1240 application.SendNotification();
1241 application.Render(0);
1243 // Don't add property / uniform map to renderer or actor
1244 shader.RegisterProperty( "uFadeColor", Color::BLACK );
1246 TestGlAbstraction& gl = application.GetGlAbstraction();
1248 application.SendNotification();
1249 application.Render(0);
1251 // Expect that the shader's fade color property is accessed
1252 Vector4 actualValue(Vector4::ZERO);
1253 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1254 DALI_TEST_EQUALS( actualValue, Color::BLACK, TEST_LOCATION );
1259 int UtcDaliRendererUniformMapMultipleUniforms01(void)
1261 TestApplication application;
1263 tet_infoline("Test the uniform maps are collected from all objects (same type)");
1265 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1267 Shader shader = Shader::New("VertexSource", "FragmentSource");
1268 TextureSet textureSet = CreateTextureSet( image );
1270 PropertyBuffer vertexBuffer = CreatePropertyBuffer();
1271 Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
1272 Renderer renderer = Renderer::New( geometry, shader );
1273 renderer.SetTextures( textureSet );
1275 Actor actor = Actor::New();
1276 actor.AddRenderer(renderer);
1277 actor.SetSize(400, 400);
1278 Stage::GetCurrent().Add(actor);
1279 application.SendNotification();
1280 application.Render(0);
1282 renderer.RegisterProperty( "uUniform1", Color::RED );
1283 actor.RegisterProperty( "uUniform2", Color::GREEN );
1284 shader.RegisterProperty( "uUniform3", Color::MAGENTA );
1286 TestGlAbstraction& gl = application.GetGlAbstraction();
1288 application.SendNotification();
1289 application.Render(0);
1291 // Expect that each of the object's uniforms are set
1292 Vector4 uniform1Value(Vector4::ZERO);
1293 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform1", uniform1Value ) );
1294 DALI_TEST_EQUALS( uniform1Value, Color::RED, TEST_LOCATION );
1296 Vector4 uniform2Value(Vector4::ZERO);
1297 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform2", uniform2Value ) );
1298 DALI_TEST_EQUALS( uniform2Value, Color::GREEN, TEST_LOCATION );
1300 Vector4 uniform3Value(Vector4::ZERO);
1301 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform3", uniform3Value ) );
1302 DALI_TEST_EQUALS( uniform3Value, Color::MAGENTA, TEST_LOCATION );
1307 int UtcDaliRendererUniformMapMultipleUniforms02(void)
1309 TestApplication application;
1311 tet_infoline("Test the uniform maps are collected from all objects (different types)");
1313 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1315 Shader shader = Shader::New("VertexSource", "FragmentSource");
1316 TextureSet textureSet = CreateTextureSet( image );
1318 PropertyBuffer vertexBuffer = CreatePropertyBuffer();
1319 Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
1320 Renderer renderer = Renderer::New( geometry, shader );
1321 renderer.SetTextures( textureSet );
1323 Actor actor = Actor::New();
1324 actor.AddRenderer(renderer);
1325 actor.SetSize(400, 400);
1326 Stage::GetCurrent().Add(actor);
1327 application.SendNotification();
1328 application.Render(0);
1330 Property::Value value1(Color::RED);
1331 renderer.RegisterProperty( "uFadeColor", value1 );
1333 Property::Value value2(1.0f);
1334 actor.RegisterProperty( "uFadeProgress", value2 );
1336 Property::Value value3(Matrix3::IDENTITY);
1337 shader.RegisterProperty( "uANormalMatrix", value3 );
1339 TestGlAbstraction& gl = application.GetGlAbstraction();
1341 application.SendNotification();
1342 application.Render(0);
1344 // Expect that each of the object's uniforms are set
1345 Vector4 uniform1Value(Vector4::ZERO);
1346 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", uniform1Value ) );
1347 DALI_TEST_EQUALS( uniform1Value, value1.Get<Vector4>(), TEST_LOCATION );
1349 float uniform2Value(0.0f);
1350 DALI_TEST_CHECK( gl.GetUniformValue<float>( "uFadeProgress", uniform2Value ) );
1351 DALI_TEST_EQUALS( uniform2Value, value2.Get<float>(), TEST_LOCATION );
1353 Matrix3 uniform3Value;
1354 DALI_TEST_CHECK( gl.GetUniformValue<Matrix3>( "uANormalMatrix", uniform3Value ) );
1355 DALI_TEST_EQUALS( uniform3Value, value3.Get<Matrix3>(), TEST_LOCATION );
1361 int UtcDaliRendererRenderOrder2DLayer(void)
1363 TestApplication application;
1364 tet_infoline("Test the rendering order in a 2D layer is correct");
1366 Shader shader = Shader::New("VertexSource", "FragmentSource");
1367 PropertyBuffer vertexBuffer = CreatePropertyBuffer();
1368 Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
1370 Actor actor0 = Actor::New();
1371 actor0.SetAnchorPoint(AnchorPoint::CENTER);
1372 actor0.SetParentOrigin(AnchorPoint::CENTER);
1373 actor0.SetPosition(0.0f,0.0f);
1374 Image image0 = BufferImage::New( 64, 64, Pixel::RGB888 );
1375 TextureSet textureSet0 = CreateTextureSet( image0 );
1376 Renderer renderer0 = Renderer::New( geometry, shader );
1377 renderer0.SetTextures( textureSet0 );
1378 actor0.AddRenderer(renderer0);
1379 actor0.SetSize(1, 1);
1380 Stage::GetCurrent().Add(actor0);
1381 application.SendNotification();
1382 application.Render(0);
1384 Actor actor1 = Actor::New();
1385 actor1.SetAnchorPoint(AnchorPoint::CENTER);
1386 actor1.SetParentOrigin(AnchorPoint::CENTER);
1387 actor1.SetPosition(0.0f,0.0f);
1388 Image image1= BufferImage::New( 64, 64, Pixel::RGB888 );
1389 TextureSet textureSet1 = CreateTextureSet( image1 );
1390 Renderer renderer1 = Renderer::New( geometry, shader );
1391 renderer1.SetTextures( textureSet1 );
1392 actor1.AddRenderer(renderer1);
1393 actor1.SetSize(1, 1);
1394 Stage::GetCurrent().Add(actor1);
1395 application.SendNotification();
1396 application.Render(0);
1398 Actor actor2 = Actor::New();
1399 actor2.SetAnchorPoint(AnchorPoint::CENTER);
1400 actor2.SetParentOrigin(AnchorPoint::CENTER);
1401 actor2.SetPosition(0.0f,0.0f);
1402 Image image2= BufferImage::New( 64, 64, Pixel::RGB888 );
1403 TextureSet textureSet2 = CreateTextureSet( image2 );
1404 Renderer renderer2 = Renderer::New( geometry, shader );
1405 renderer2.SetTextures( textureSet2 );
1406 actor2.AddRenderer(renderer2);
1407 actor2.SetSize(1, 1);
1408 Stage::GetCurrent().Add(actor2);
1409 application.SendNotification();
1410 application.Render(0);
1412 Actor actor3 = Actor::New();
1413 actor3.SetAnchorPoint(AnchorPoint::CENTER);
1414 actor3.SetParentOrigin(AnchorPoint::CENTER);
1415 actor3.SetPosition(0.0f,0.0f);
1416 Image image3 = BufferImage::New( 64, 64, Pixel::RGB888 );
1417 TextureSet textureSet3 = CreateTextureSet( image3 );
1418 Renderer renderer3 = Renderer::New( geometry, shader );
1419 renderer3.SetTextures( textureSet3 );
1420 actor3.AddRenderer(renderer3);
1421 actor3.SetSize(1, 1);
1422 Stage::GetCurrent().Add(actor3);
1423 application.SendNotification();
1424 application.Render(0);
1427 * Create the following hierarchy:
1440 * Expected rendering order : actor2 - actor1 - actor0 - actor3
1445 application.SendNotification();
1446 application.Render(0);
1448 TestGlAbstraction& gl = application.GetGlAbstraction();
1449 gl.EnableTextureCallTrace(true);
1450 application.SendNotification();
1451 application.Render(0);
1453 int textureBindIndex[4];
1454 for( unsigned int i(0); i<4; ++i )
1456 std::stringstream params;
1457 params << GL_TEXTURE_2D<<", "<<i+1;
1458 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
1461 //Check that actor1 has been rendered after actor2
1462 DALI_TEST_GREATER( textureBindIndex[1], textureBindIndex[2], TEST_LOCATION );
1464 //Check that actor0 has been rendered after actor1
1465 DALI_TEST_GREATER( textureBindIndex[0], textureBindIndex[1], TEST_LOCATION );
1467 //Check that actor3 has been rendered after actor0
1468 DALI_TEST_GREATER( textureBindIndex[3], textureBindIndex[0], TEST_LOCATION );
1473 int UtcDaliRendererRenderOrder2DLayerMultipleRenderers(void)
1475 TestApplication application;
1476 tet_infoline("Test the rendering order in a 2D layer is correct using multiple renderers per actor");
1479 * Creates the following hierarchy:
1481 * actor0------------------------>actor1
1485 * renderer0 renderer1 renderer2 renderer3 renderer4 renderer5
1487 * renderer0 has depth index 2
1488 * renderer1 has depth index 0
1489 * renderer2 has depth index 1
1491 * renderer3 has depth index 1
1492 * renderer4 has depth index 0
1493 * renderer5 has depth index -1
1495 * Expected rendering order: renderer1 - renderer2 - renderer0 - renderer5 - renderer4 - renderer3
1498 Shader shader = Shader::New("VertexSource", "FragmentSource");
1499 PropertyBuffer vertexBuffer = CreatePropertyBuffer();
1500 Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
1502 Actor actor0 = Actor::New();
1503 actor0.SetAnchorPoint(AnchorPoint::CENTER);
1504 actor0.SetParentOrigin(AnchorPoint::CENTER);
1505 actor0.SetPosition(0.0f,0.0f);
1506 actor0.SetSize(1, 1);
1507 Stage::GetCurrent().Add(actor0);
1509 Actor actor1 = Actor::New();
1510 actor1.SetAnchorPoint(AnchorPoint::CENTER);
1511 actor1.SetParentOrigin(AnchorPoint::CENTER);
1512 actor1.SetPosition(0.0f,0.0f);
1513 actor1.SetSize(1, 1);
1517 Image image0 = BufferImage::New( 64, 64, Pixel::RGB888 );
1518 TextureSet textureSet0 = CreateTextureSet( image0 );
1519 Renderer renderer0 = Renderer::New( geometry, shader );
1520 renderer0.SetTextures( textureSet0 );
1521 renderer0.SetProperty( Renderer::Property::DEPTH_INDEX, 2 );
1522 actor0.AddRenderer(renderer0);
1523 application.SendNotification();
1524 application.Render(0);
1527 Image image1= BufferImage::New( 64, 64, Pixel::RGB888 );
1528 TextureSet textureSet1 = CreateTextureSet( image1 );
1529 Renderer renderer1 = Renderer::New( geometry, shader );
1530 renderer1.SetTextures( textureSet1 );
1531 renderer1.SetProperty( Renderer::Property::DEPTH_INDEX, 0 );
1532 actor0.AddRenderer(renderer1);
1533 application.SendNotification();
1534 application.Render(0);
1537 Image image2= BufferImage::New( 64, 64, Pixel::RGB888 );
1538 TextureSet textureSet2 = CreateTextureSet( image2 );
1539 Renderer renderer2 = Renderer::New( geometry, shader );
1540 renderer2.SetTextures( textureSet2 );
1541 renderer2.SetProperty( Renderer::Property::DEPTH_INDEX, 1 );
1542 actor0.AddRenderer(renderer2);
1543 application.SendNotification();
1544 application.Render(0);
1547 Image image3 = BufferImage::New( 64, 64, Pixel::RGB888 );
1548 TextureSet textureSet3 = CreateTextureSet( image3 );
1549 Renderer renderer3 = Renderer::New( geometry, shader );
1550 renderer3.SetTextures( textureSet3 );
1551 renderer3.SetProperty( Renderer::Property::DEPTH_INDEX, 1 );
1552 actor1.AddRenderer(renderer3);
1553 application.SendNotification();
1554 application.Render(0);
1557 Image image4= BufferImage::New( 64, 64, Pixel::RGB888 );
1558 TextureSet textureSet4 = CreateTextureSet( image4 );
1559 Renderer renderer4 = Renderer::New( geometry, shader );
1560 renderer4.SetTextures( textureSet4 );
1561 renderer4.SetProperty( Renderer::Property::DEPTH_INDEX, 0 );
1562 actor1.AddRenderer(renderer4);
1563 application.SendNotification();
1564 application.Render(0);
1567 Image image5= BufferImage::New( 64, 64, Pixel::RGB888 );
1568 TextureSet textureSet5 = CreateTextureSet( image5 );
1569 Renderer renderer5 = Renderer::New( geometry, shader );
1570 renderer5.SetTextures( textureSet5 );
1571 renderer5.SetProperty( Renderer::Property::DEPTH_INDEX, -1 );
1572 actor1.AddRenderer(renderer5);
1573 application.SendNotification();
1574 application.Render(0);
1577 TestGlAbstraction& gl = application.GetGlAbstraction();
1578 gl.EnableTextureCallTrace(true);
1579 application.SendNotification();
1580 application.Render(0);
1582 int textureBindIndex[6];
1583 for( unsigned int i(0); i<6; ++i )
1585 std::stringstream params;
1586 params << GL_TEXTURE_2D<<", "<<i+1;
1587 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
1590 //Check that renderer3 has been rendered after renderer4
1591 DALI_TEST_GREATER( textureBindIndex[3], textureBindIndex[4], TEST_LOCATION );
1593 //Check that renderer0 has been rendered after renderer2
1594 DALI_TEST_GREATER( textureBindIndex[4], textureBindIndex[5], TEST_LOCATION );
1596 //Check that renderer0 has been rendered after renderer2
1597 DALI_TEST_GREATER( textureBindIndex[5], textureBindIndex[0], TEST_LOCATION );
1599 //Check that renderer0 has been rendered after renderer2
1600 DALI_TEST_GREATER( textureBindIndex[0], textureBindIndex[2], TEST_LOCATION );
1602 //Check that renderer2 has been rendered after renderer1
1603 DALI_TEST_GREATER( textureBindIndex[2], textureBindIndex[1], TEST_LOCATION );
1608 int UtcDaliRendererRenderOrder2DLayerOverlay(void)
1610 TestApplication application;
1611 tet_infoline("Test the rendering order in a 2D layer is correct for overlays");
1613 Shader shader = Shader::New("VertexSource", "FragmentSource");
1614 PropertyBuffer vertexBuffer = CreatePropertyBuffer();
1615 Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
1617 Actor actor0 = Actor::New();
1618 actor0.SetAnchorPoint(AnchorPoint::CENTER);
1619 actor0.SetParentOrigin(AnchorPoint::CENTER);
1620 Image image0 = BufferImage::New( 64, 64, Pixel::RGB888 );
1621 TextureSet textureSet0 = CreateTextureSet( image0 );
1622 Renderer renderer0 = Renderer::New( geometry, shader );
1623 renderer0.SetTextures( textureSet0 );
1624 actor0.AddRenderer(renderer0);
1625 actor0.SetPosition(0.0f,0.0f);
1626 actor0.SetSize(100, 100);
1627 Stage::GetCurrent().Add(actor0);
1628 actor0.SetDrawMode( DrawMode::OVERLAY_2D );
1629 application.SendNotification();
1630 application.Render(0);
1632 Actor actor1 = Actor::New();
1633 actor1.SetAnchorPoint(AnchorPoint::CENTER);
1634 actor1.SetParentOrigin(AnchorPoint::CENTER);
1635 Image image1= BufferImage::New( 64, 64, Pixel::RGB888 );
1636 TextureSet textureSet1 = CreateTextureSet( image1 );
1637 Renderer renderer1 = Renderer::New( geometry, shader );
1638 renderer1.SetTextures( textureSet1 );
1639 actor1.SetPosition(0.0f,0.0f);
1640 actor1.AddRenderer(renderer1);
1641 actor1.SetSize(100, 100);
1642 Stage::GetCurrent().Add(actor1);
1643 actor1.SetDrawMode( DrawMode::OVERLAY_2D );
1644 application.SendNotification();
1645 application.Render(0);
1647 Actor actor2 = Actor::New();
1648 actor2.SetAnchorPoint(AnchorPoint::CENTER);
1649 actor2.SetParentOrigin(AnchorPoint::CENTER);
1650 Image image2= BufferImage::New( 64, 64, Pixel::RGB888 );
1651 TextureSet textureSet2 = CreateTextureSet( image2 );
1652 Renderer renderer2 = Renderer::New( geometry, shader );
1653 renderer2.SetTextures( textureSet2 );
1654 actor2.AddRenderer(renderer2);
1655 actor2.SetPosition(0.0f,0.0f);
1656 actor2.SetSize(100, 100);
1657 Stage::GetCurrent().Add(actor2);
1658 application.SendNotification();
1659 application.Render(0);
1661 Actor actor3 = Actor::New();
1662 actor3.SetAnchorPoint(AnchorPoint::CENTER);
1663 actor3.SetParentOrigin(AnchorPoint::CENTER);
1664 Image image3 = BufferImage::New( 64, 64, Pixel::RGB888 );
1665 TextureSet textureSet3 = CreateTextureSet( image3 );
1666 Renderer renderer3 = Renderer::New( geometry, shader );
1667 renderer3.SetTextures( textureSet3 );
1668 actor3.SetPosition(0.0f,0.0f);
1669 actor3.AddRenderer(renderer3);
1670 actor3.SetSize(100, 100);
1671 Stage::GetCurrent().Add(actor3);
1672 actor3.SetDrawMode( DrawMode::OVERLAY_2D );
1673 application.SendNotification();
1674 application.Render(0);
1676 Actor actor4 = Actor::New();
1677 actor4.SetAnchorPoint(AnchorPoint::CENTER);
1678 actor4.SetParentOrigin(AnchorPoint::CENTER);
1679 Image image4 = BufferImage::New( 64, 64, Pixel::RGB888 );
1680 TextureSet textureSet4 = CreateTextureSet( image4 );
1681 Renderer renderer4 = Renderer::New( geometry, shader );
1682 renderer4.SetTextures( textureSet4 );
1683 actor4.AddRenderer(renderer4);
1684 actor4.SetPosition(0.0f,0.0f);
1685 actor4.SetSize(100, 100);
1686 Stage::GetCurrent().Add(actor4);
1687 application.SendNotification();
1688 application.Render(0);
1691 * Create the following hierarchy:
1698 * (Overlay) (Regular actor)
1708 * Expected rendering order : actor2 - actor4 - actor1 - actor0 - actor3
1710 Stage::GetCurrent().Add( actor2 );
1715 application.SendNotification();
1716 application.Render(0);
1718 TestGlAbstraction& gl = application.GetGlAbstraction();
1719 gl.EnableTextureCallTrace(true);
1720 application.SendNotification();
1721 application.Render(0);
1723 int textureBindIndex[5];
1724 for( unsigned int i(0); i<5; ++i )
1726 std::stringstream params;
1727 params << GL_TEXTURE_2D<<", "<<i+1;
1728 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
1731 //Check that actor4 has been rendered after actor2
1732 DALI_TEST_GREATER( textureBindIndex[4], textureBindIndex[2], TEST_LOCATION );
1734 //Check that actor1 has been rendered after actor4
1735 DALI_TEST_GREATER( textureBindIndex[1], textureBindIndex[4], TEST_LOCATION );
1737 //Check that actor0 has been rendered after actor1
1738 DALI_TEST_GREATER( textureBindIndex[0], textureBindIndex[1], TEST_LOCATION );
1740 //Check that actor3 has been rendered after actor0
1741 DALI_TEST_GREATER( textureBindIndex[3], textureBindIndex[0], TEST_LOCATION );
1746 int UtcDaliRendererSetIndexRange(void)
1750 "attribute vec2 aPosition;\n"
1753 " gl_Position = aPosition;\n"
1759 " gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0)\n"
1763 TestApplication application;
1764 tet_infoline("Test setting the range of indices to draw");
1766 TestGlAbstraction& gl = application.GetGlAbstraction();
1767 gl.EnableDrawCallTrace( true );
1769 Actor actor = Actor::New();
1770 actor.SetSize( 100, 100 );
1773 Geometry geometry = Geometry::New();
1774 geometry.SetGeometryType( Geometry::LINE_LOOP );
1776 // --------------------------------------------------------------------------
1778 unsigned short indices[] = { 0, 2, 4, 6, 8, // offset = 0, count = 5
1779 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, // offset = 5, count = 10
1780 1, 3, 5, 7, 9, 1 }; // offset = 15, count = 6 // line strip
1782 // --------------------------------------------------------------------------
1791 { Vector2( 0.0f, 1.00f) }, { Vector2( 0.0f, -1.00f) },
1792 { Vector2( -0.95f, 0.31f) }, { Vector2( 0.59f, 0.81f) },
1793 { Vector2( -0.59f, -0.81f) }, { Vector2( -0.95f, -0.31f) },
1794 { Vector2( 0.59f, -0.81f) }, { Vector2( 0.95f, -0.31f) },
1795 { Vector2( 0.95f, 0.31f) }, { Vector2( -0.59f, 0.81f) },
1797 Property::Map vertexFormat;
1798 vertexFormat["aPosition"] = Property::VECTOR2;
1799 PropertyBuffer vertexBuffer = PropertyBuffer::New( vertexFormat );
1800 vertexBuffer.SetData( shapes, sizeof(shapes)/sizeof(shapes[0]));
1802 // --------------------------------------------------------------------------
1803 geometry.SetIndexBuffer( indices, sizeof(indices)/sizeof(indices[0]) );
1804 geometry.AddVertexBuffer( vertexBuffer );
1807 Shader shader = Shader::New( vertexShader,fragmentShader );
1808 Renderer renderer = Renderer::New( geometry, shader );
1809 actor.AddRenderer( renderer );
1811 Stage stage = Stage::GetCurrent();
1816 // LINE_LOOP, first 0, count 5
1818 renderer.SetIndexRange( 0, 5 );
1819 application.SendNotification();
1820 application.Render();
1821 sprintf( buffer, "%u, 5, %u, indices", GL_LINE_LOOP, GL_UNSIGNED_SHORT );
1822 bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
1823 DALI_TEST_CHECK( result );
1826 // LINE_LOOP, first 5, count 10
1828 renderer.SetIndexRange( 5, 10 );
1829 sprintf( buffer, "%u, 10, %u, indices", GL_LINE_LOOP, GL_UNSIGNED_SHORT );
1830 application.SendNotification();
1831 application.Render();
1832 bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
1833 DALI_TEST_CHECK( result );
1836 // LINE_STRIP, first 15, count 6
1838 renderer.SetIndexRange( 15, 6 );
1839 geometry.SetGeometryType( Geometry::LINE_STRIP );
1840 sprintf( buffer, "%u, 6, %u, indices", GL_LINE_STRIP, GL_UNSIGNED_SHORT );
1841 application.SendNotification();
1842 application.Render();
1843 bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
1844 DALI_TEST_CHECK( result );