2 * Copyright (c) 2017 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.
19 #include <dali/devel-api/actors/actor-devel.h>
21 #include <dali/public-api/dali-core.h>
22 #include <dali/devel-api/images/texture-set-image.h>
23 #include <dali/devel-api/object/handle-devel.h>
28 #include <dali-test-suite-utils.h>
29 #include <test-trace-call-stack.h>
30 #include <mesh-builder.h>
34 namespace // unnamed namespace
37 const BlendFactor::Type DEFAULT_BLEND_FACTOR_SRC_RGB( BlendFactor::SRC_ALPHA );
38 const BlendFactor::Type DEFAULT_BLEND_FACTOR_DEST_RGB( BlendFactor::ONE_MINUS_SRC_ALPHA );
39 const BlendFactor::Type DEFAULT_BLEND_FACTOR_SRC_ALPHA( BlendFactor::ONE );
40 const BlendFactor::Type DEFAULT_BLEND_FACTOR_DEST_ALPHA( BlendFactor::ONE_MINUS_SRC_ALPHA );
42 const BlendEquation::Type DEFAULT_BLEND_EQUATION_RGB( BlendEquation::ADD );
43 const BlendEquation::Type DEFAULT_BLEND_EQUATION_ALPHA( BlendEquation::ADD );
46 * @brief Get GL stencil test enumeration value as a string.
47 * @return The string representation of the value of GL_STENCIL_TEST
49 std::string GetStencilTestString(void)
51 std::stringstream stream;
52 stream << GL_STENCIL_TEST;
57 * @brief Get GL depth test enumeration value as a string.
58 * @return The string representation of the value of GL_DEPTH_TEST
60 std::string GetDepthTestString(void)
62 std::stringstream stream;
63 stream << GL_DEPTH_TEST;
67 void ResetDebugAndFlush( TestApplication& application, TraceCallStack& glEnableDisableStack, TraceCallStack& glStencilFunctionStack )
69 glEnableDisableStack.Reset();
70 glStencilFunctionStack.Reset();
71 application.SendNotification();
75 void TestConstraintNoBlue( Vector4& current, const PropertyInputContainer& inputs )
80 } // unnamed namespace
82 void renderer_test_startup(void)
84 test_return_value = TET_UNDEF;
87 void renderer_test_cleanup(void)
89 test_return_value = TET_PASS;
93 int UtcDaliRendererNew01(void)
95 TestApplication application;
97 Geometry geometry = CreateQuadGeometry();
98 Shader shader = CreateShader();
99 Renderer renderer = Renderer::New(geometry, shader);
101 DALI_TEST_EQUALS( (bool)renderer, true, TEST_LOCATION );
105 int UtcDaliRendererNew02(void)
107 TestApplication application;
109 DALI_TEST_EQUALS( (bool)renderer, false, TEST_LOCATION );
113 int UtcDaliRendererCopyConstructor(void)
115 TestApplication application;
117 Geometry geometry = CreateQuadGeometry();
118 Shader shader = CreateShader();
119 Renderer renderer = Renderer::New(geometry, shader);
121 Renderer rendererCopy( renderer );
122 DALI_TEST_EQUALS( (bool)rendererCopy, true, TEST_LOCATION );
127 int UtcDaliRendererAssignmentOperator(void)
129 TestApplication application;
131 Geometry geometry = CreateQuadGeometry();
132 Shader shader = CreateShader();
133 Renderer renderer = Renderer::New(geometry, shader);
136 DALI_TEST_EQUALS( (bool)renderer2, false, TEST_LOCATION );
138 renderer2 = renderer;
139 DALI_TEST_EQUALS( (bool)renderer2, true, TEST_LOCATION );
143 int UtcDaliRendererDownCast01(void)
145 TestApplication application;
147 Geometry geometry = CreateQuadGeometry();
148 Shader shader = CreateShader();
149 Renderer renderer = Renderer::New(geometry, shader);
151 BaseHandle handle(renderer);
152 Renderer renderer2 = Renderer::DownCast(handle);
153 DALI_TEST_EQUALS( (bool)renderer2, true, TEST_LOCATION );
157 int UtcDaliRendererDownCast02(void)
159 TestApplication application;
161 Handle handle = Handle::New(); // Create a custom object
162 Renderer renderer = Renderer::DownCast(handle);
163 DALI_TEST_EQUALS( (bool)renderer, false, TEST_LOCATION );
167 int UtcDaliRendererSetGetGeometry(void)
169 TestApplication application;
170 tet_infoline( "Test SetGeometry, GetGeometry" );
172 Geometry geometry1 = CreateQuadGeometry();
173 Geometry geometry2 = CreateQuadGeometry();
175 Shader shader = CreateShader();
176 Renderer renderer = Renderer::New(geometry1, shader);
177 Actor actor = Actor::New();
178 actor.AddRenderer(renderer);
179 actor.SetSize(400, 400);
180 Stage::GetCurrent().Add(actor);
182 application.SendNotification();
183 application.Render(0);
184 DALI_TEST_EQUALS( renderer.GetGeometry(), geometry1, TEST_LOCATION );
186 // Set geometry2 to the renderer
187 renderer.SetGeometry( geometry2 );
189 application.SendNotification();
190 application.Render(0);
191 DALI_TEST_EQUALS( renderer.GetGeometry(), geometry2, TEST_LOCATION );
196 int UtcDaliRendererSetGetShader(void)
198 TestApplication application;
199 tet_infoline( "Test SetShader, GetShader" );
201 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
202 glAbstraction.EnableCullFaceCallTrace(true);
204 Shader shader1 = CreateShader();
205 shader1.RegisterProperty( "uFadeColor", Color::RED );
207 Shader shader2 = CreateShader();
208 shader2.RegisterProperty( "uFadeColor", Color::GREEN );
210 Geometry geometry = CreateQuadGeometry();
211 Renderer renderer = Renderer::New(geometry, shader1);
212 Actor actor = Actor::New();
213 actor.AddRenderer(renderer);
214 actor.SetSize(400, 400);
215 Stage::GetCurrent().Add(actor);
217 TestGlAbstraction& gl = application.GetGlAbstraction();
218 application.SendNotification();
219 application.Render(0);
221 // Expect that the first shaders's fade color property is accessed
222 Vector4 actualValue(Vector4::ZERO);
223 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
224 DALI_TEST_EQUALS( actualValue, Color::RED, TEST_LOCATION );
226 DALI_TEST_EQUALS( renderer.GetShader(), shader1, TEST_LOCATION );
228 // set the second shader to the renderer
229 renderer.SetShader( shader2 );
231 application.SendNotification();
232 application.Render(0);
234 // Expect that the second shader's fade color property is accessed
235 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
236 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
238 DALI_TEST_EQUALS( renderer.GetShader(), shader2, TEST_LOCATION );
243 int UtcDaliRendererSetGetDepthIndex(void)
245 TestApplication application;
247 tet_infoline("Test SetDepthIndex, GetDepthIndex");
249 Shader shader = CreateShader();
250 Geometry geometry = CreateQuadGeometry();
251 Renderer renderer = Renderer::New(geometry, shader);
252 Actor actor = Actor::New();
253 actor.AddRenderer(renderer);
254 actor.SetSize(400, 400);
255 Stage::GetCurrent().Add(actor);
257 application.SendNotification();
258 application.Render(0);
259 DALI_TEST_EQUALS( renderer.GetProperty<int>(Renderer::Property::DEPTH_INDEX), 0, TEST_LOCATION );
261 renderer.SetProperty( Renderer::Property::DEPTH_INDEX, 1 );
263 application.SendNotification();
264 application.Render(0);
265 DALI_TEST_EQUALS( renderer.GetProperty<int>(Renderer::Property::DEPTH_INDEX), 1, TEST_LOCATION );
267 renderer.SetProperty( Renderer::Property::DEPTH_INDEX, 10 );
269 application.SendNotification();
270 application.Render(0);
271 DALI_TEST_EQUALS( renderer.GetProperty<int>(Renderer::Property::DEPTH_INDEX), 10, TEST_LOCATION );
276 int UtcDaliRendererSetGetFaceCullingMode(void)
278 TestApplication application;
280 tet_infoline("Test SetFaceCullingMode(cullingMode)");
281 Geometry geometry = CreateQuadGeometry();
282 Shader shader = CreateShader();
283 Renderer renderer = Renderer::New( geometry, shader );
285 Actor actor = Actor::New();
286 actor.AddRenderer(renderer);
287 actor.SetSize(400, 400);
288 Stage::GetCurrent().Add(actor);
290 // By default, none of the faces should be culled
291 unsigned int cullFace = renderer.GetProperty<int>( Renderer::Property::FACE_CULLING_MODE );
292 DALI_TEST_CHECK( static_cast< FaceCullingMode::Type >( cullFace ) == FaceCullingMode::NONE );
294 TestGlAbstraction& gl = application.GetGlAbstraction();
295 TraceCallStack& cullFaceStack = gl.GetCullFaceTrace();
296 gl.EnableCullFaceCallTrace(true);
299 cullFaceStack.Reset();
300 renderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::FRONT_AND_BACK );
301 application.SendNotification();
302 application.Render();
304 DALI_TEST_EQUALS( cullFaceStack.CountMethod( "CullFace" ), 1, TEST_LOCATION );
306 std::ostringstream cullModeString;
307 cullModeString << GL_FRONT_AND_BACK;
309 DALI_TEST_CHECK( cullFaceStack.FindMethodAndParams( "CullFace", cullModeString.str() ) );
310 cullFace = renderer.GetProperty<int>( Renderer::Property::FACE_CULLING_MODE );
311 DALI_TEST_CHECK( static_cast< FaceCullingMode::Type >( cullFace ) == FaceCullingMode::FRONT_AND_BACK );
315 cullFaceStack.Reset();
316 renderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::BACK );
317 application.SendNotification();
318 application.Render();
320 DALI_TEST_EQUALS( cullFaceStack.CountMethod( "CullFace" ), 1, TEST_LOCATION );
322 std::ostringstream cullModeString;
323 cullModeString << GL_BACK;
325 DALI_TEST_CHECK( cullFaceStack.FindMethodAndParams( "CullFace", cullModeString.str() ) );
326 cullFace = renderer.GetProperty<int>( Renderer::Property::FACE_CULLING_MODE );
327 DALI_TEST_CHECK( static_cast< FaceCullingMode::Type >( cullFace ) == FaceCullingMode::BACK );
331 cullFaceStack.Reset();
332 renderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::FRONT );
333 application.SendNotification();
334 application.Render();
336 DALI_TEST_EQUALS( cullFaceStack.CountMethod( "CullFace" ), 1, TEST_LOCATION );
338 std::ostringstream cullModeString;
339 cullModeString << GL_FRONT;
341 DALI_TEST_CHECK( cullFaceStack.FindMethodAndParams( "CullFace", cullModeString.str() ) );
342 cullFace = renderer.GetProperty<int>( Renderer::Property::FACE_CULLING_MODE );
343 DALI_TEST_CHECK( static_cast< FaceCullingMode::Type >( cullFace ) == FaceCullingMode::FRONT );
347 cullFaceStack.Reset();
348 renderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::NONE );
349 application.SendNotification();
350 application.Render();
352 DALI_TEST_EQUALS( cullFaceStack.CountMethod( "CullFace" ), 0, TEST_LOCATION );
353 cullFace = renderer.GetProperty<int>( Renderer::Property::FACE_CULLING_MODE );
354 DALI_TEST_CHECK( static_cast< FaceCullingMode::Type >( cullFace ) == FaceCullingMode::NONE );
360 int UtcDaliRendererBlendOptions01(void)
362 TestApplication application;
364 tet_infoline("Test BLEND_FACTOR properties ");
366 Geometry geometry = CreateQuadGeometry();
367 Shader shader = CreateShader();
368 Renderer renderer = Renderer::New( geometry, shader );
370 Actor actor = Actor::New();
371 // set a transparent actor color so that blending is enabled
372 actor.SetOpacity( 0.5f );
373 actor.AddRenderer(renderer);
374 actor.SetSize(400, 400);
375 Stage::GetCurrent().Add(actor);
377 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::ONE_MINUS_SRC_COLOR );
378 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::SRC_ALPHA_SATURATE );
379 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE_MINUS_SRC_COLOR );
380 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::SRC_ALPHA_SATURATE );
382 // Test that Set was successful:
383 int srcFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
384 int destFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
385 int srcFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
386 int destFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
388 DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_SRC_COLOR, srcFactorRgb, TEST_LOCATION );
389 DALI_TEST_EQUALS( (int)BlendFactor::SRC_ALPHA_SATURATE, destFactorRgb, TEST_LOCATION );
390 DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_SRC_COLOR, srcFactorAlpha, TEST_LOCATION );
391 DALI_TEST_EQUALS( (int)BlendFactor::SRC_ALPHA_SATURATE, destFactorAlpha, TEST_LOCATION );
393 application.SendNotification();
394 application.Render();
396 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
398 DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_SRC_COLOR, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION );
399 DALI_TEST_EQUALS( (GLenum)GL_SRC_ALPHA_SATURATE, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION );
400 DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_SRC_COLOR, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION );
401 DALI_TEST_EQUALS( (GLenum)GL_SRC_ALPHA_SATURATE, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION );
406 int UtcDaliRendererBlendOptions02(void)
408 TestApplication application;
410 tet_infoline("Test BLEND_FACTOR properties ");
412 Geometry geometry = CreateQuadGeometry();
413 Shader shader = CreateShader();
414 Renderer renderer = Renderer::New( geometry, shader );
416 Actor actor = Actor::New();
417 actor.SetOpacity( 0.5f ); // enable blending
418 actor.AddRenderer(renderer);
419 actor.SetSize(400, 400);
420 Stage::GetCurrent().Add(actor);
422 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::CONSTANT_COLOR );
423 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ONE_MINUS_CONSTANT_COLOR );
424 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::CONSTANT_ALPHA );
425 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ONE_MINUS_CONSTANT_ALPHA );
427 // Test that Set was successful:
429 int srcFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
430 int destFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
431 int srcFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
432 int destFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
434 DALI_TEST_EQUALS( (int)BlendFactor::CONSTANT_COLOR, srcFactorRgb, TEST_LOCATION );
435 DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_CONSTANT_COLOR, destFactorRgb, TEST_LOCATION );
436 DALI_TEST_EQUALS( (int)BlendFactor::CONSTANT_ALPHA, srcFactorAlpha, TEST_LOCATION );
437 DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_CONSTANT_ALPHA, destFactorAlpha, TEST_LOCATION );
440 application.SendNotification();
441 application.Render();
443 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
444 DALI_TEST_EQUALS( (GLenum)GL_CONSTANT_COLOR, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION );
445 DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_CONSTANT_COLOR, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION );
446 DALI_TEST_EQUALS( (GLenum)GL_CONSTANT_ALPHA, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION );
447 DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_CONSTANT_ALPHA, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION );
452 int UtcDaliRendererBlendOptions03(void)
454 TestApplication application;
456 tet_infoline("Test GetBlendEquation() defaults ");
458 Geometry geometry = CreateQuadGeometry();
459 Shader shader = CreateShader();
460 Renderer renderer = Renderer::New( geometry, shader );
462 Actor actor = Actor::New();
463 actor.AddRenderer(renderer);
464 actor.SetSize(400, 400);
465 Stage::GetCurrent().Add(actor);
467 // Test the defaults as documented in blending.h
468 int equationRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_EQUATION_RGB );
469 int equationAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_EQUATION_ALPHA );
471 DALI_TEST_EQUALS( (int)BlendEquation::ADD, equationRgb, TEST_LOCATION );
472 DALI_TEST_EQUALS( (int)BlendEquation::ADD, equationAlpha, TEST_LOCATION );
477 int UtcDaliRendererBlendOptions04(void)
479 TestApplication application;
481 tet_infoline("Test SetBlendEquation() ");
483 Geometry geometry = CreateQuadGeometry();
484 Shader shader = CreateShader();
485 Renderer renderer = Renderer::New( geometry, shader );
487 Actor actor = Actor::New();
488 actor.SetOpacity( 0.1f );
489 actor.AddRenderer(renderer);
490 actor.SetSize(400, 400);
491 Stage::GetCurrent().Add(actor);
493 // Test the single blending equation setting
495 renderer.SetProperty( Renderer::Property::BLEND_EQUATION_RGB, BlendEquation::REVERSE_SUBTRACT );
496 int equationRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_EQUATION_RGB );
497 DALI_TEST_EQUALS( (int)BlendEquation::REVERSE_SUBTRACT, equationRgb, TEST_LOCATION );
500 renderer.SetProperty( Renderer::Property::BLEND_EQUATION_RGB, BlendEquation::REVERSE_SUBTRACT );
501 renderer.SetProperty( Renderer::Property::BLEND_EQUATION_ALPHA, BlendEquation::REVERSE_SUBTRACT );
503 // Test that Set was successful
505 int equationRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_EQUATION_RGB );
506 int equationAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_EQUATION_ALPHA );
507 DALI_TEST_EQUALS( (int)BlendEquation::REVERSE_SUBTRACT, equationRgb, TEST_LOCATION );
508 DALI_TEST_EQUALS( (int)BlendEquation::REVERSE_SUBTRACT, equationAlpha, TEST_LOCATION );
511 // Render & check GL commands
512 application.SendNotification();
513 application.Render();
515 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
516 DALI_TEST_EQUALS( (GLenum)GL_FUNC_REVERSE_SUBTRACT, glAbstraction.GetLastBlendEquationRgb(), TEST_LOCATION );
517 DALI_TEST_EQUALS( (GLenum)GL_FUNC_REVERSE_SUBTRACT, glAbstraction.GetLastBlendEquationAlpha(), TEST_LOCATION );
522 int UtcDaliRendererSetBlendMode01(void)
524 TestApplication application;
526 tet_infoline("Test setting the blend mode to on with an opaque color renders with blending enabled");
528 Geometry geometry = CreateQuadGeometry();
529 Shader shader = CreateShader();
530 Renderer renderer = Renderer::New( geometry, shader );
532 Actor actor = Actor::New();
533 actor.SetOpacity( 0.98f );
534 actor.AddRenderer(renderer);
535 actor.SetSize(400, 400);
536 Stage::GetCurrent().Add(actor);
538 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON);
540 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
541 glAbstraction.EnableEnableDisableCallTrace(true);
543 application.SendNotification();
544 application.Render();
546 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
547 std::ostringstream blendStr;
548 blendStr << GL_BLEND;
549 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
554 int UtcDaliRendererSetBlendMode02(void)
556 TestApplication application;
558 tet_infoline("Test setting the blend mode to off with a transparent color renders with blending disabled (and not enabled)");
560 Geometry geometry = CreateQuadGeometry();
561 Shader shader = CreateShader();
562 Renderer renderer = Renderer::New( geometry, shader );
564 Actor actor = Actor::New();
565 actor.SetOpacity( 0.15f );
566 actor.AddRenderer(renderer);
567 actor.SetSize(400, 400);
568 Stage::GetCurrent().Add(actor);
570 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::OFF);
572 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
573 glAbstraction.EnableEnableDisableCallTrace(true);
575 application.SendNotification();
576 application.Render();
578 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
579 std::ostringstream blendStr;
580 blendStr << GL_BLEND;
581 DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
586 int UtcDaliRendererSetBlendMode03(void)
588 TestApplication application;
590 tet_infoline("Test setting the blend mode to auto with a transparent color renders with blending enabled");
592 Geometry geometry = CreateQuadGeometry();
593 Shader shader = CreateShader();
594 Renderer renderer = Renderer::New( geometry, shader );
596 Actor actor = Actor::New();
597 actor.SetOpacity( 0.75f );
598 actor.AddRenderer(renderer);
599 actor.SetSize(400, 400);
600 Stage::GetCurrent().Add(actor);
602 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO);
604 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
605 glAbstraction.EnableEnableDisableCallTrace(true);
607 application.SendNotification();
608 application.Render();
610 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
611 std::ostringstream blendStr;
612 blendStr << GL_BLEND;
613 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
618 int UtcDaliRendererSetBlendMode04(void)
620 TestApplication application;
622 tet_infoline("Test setting the blend mode to auto with an opaque color renders with blending disabled");
624 Geometry geometry = CreateQuadGeometry();
625 Shader shader = CreateShader();
626 Renderer renderer = Renderer::New( geometry, shader );
628 Actor actor = Actor::New();
629 actor.AddRenderer(renderer);
630 actor.SetSize(400, 400);
631 Stage::GetCurrent().Add(actor);
633 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO);
635 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
636 glAbstraction.EnableEnableDisableCallTrace(true);
638 application.SendNotification();
639 application.Render();
641 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
642 std::ostringstream blendStr;
643 blendStr << GL_BLEND;
644 DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
649 int UtcDaliRendererSetBlendMode04b(void)
651 TestApplication application;
653 tet_infoline("Test setting the blend mode to auto with a transparent actor color renders with blending enabled");
655 Geometry geometry = CreateQuadGeometry();
656 Shader shader = CreateShader();
657 Renderer renderer = Renderer::New( geometry, shader );
659 Actor actor = Actor::New();
660 actor.AddRenderer(renderer);
661 actor.SetSize(400, 400);
662 actor.SetColor( Vector4(1.0f, 0.0f, 1.0f, 0.5f) );
663 Stage::GetCurrent().Add(actor);
665 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO);
667 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
668 glAbstraction.EnableEnableDisableCallTrace(true);
670 application.SendNotification();
671 application.Render();
673 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
674 std::ostringstream blendStr;
675 blendStr << GL_BLEND;
676 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
681 int UtcDaliRendererSetBlendMode04c(void)
683 TestApplication application;
685 tet_infoline("Test setting the blend mode to auto with an opaque opaque actor color renders with blending disabled");
687 Geometry geometry = CreateQuadGeometry();
688 Shader shader = CreateShader();
689 Renderer renderer = Renderer::New( geometry, shader );
691 Actor actor = Actor::New();
692 actor.AddRenderer(renderer);
693 actor.SetSize(400, 400);
694 actor.SetColor( Color::MAGENTA );
695 Stage::GetCurrent().Add(actor);
697 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO);
699 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
700 glAbstraction.EnableEnableDisableCallTrace(true);
702 application.SendNotification();
703 application.Render();
705 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
706 std::ostringstream blendStr;
707 blendStr << GL_BLEND;
708 DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
713 int UtcDaliRendererSetBlendMode05(void)
715 TestApplication application;
717 tet_infoline("Test setting the blend mode to auto with an opaque color and an image with an alpha channel renders with blending enabled");
719 Geometry geometry = CreateQuadGeometry();
720 BufferImage image = BufferImage::New( 40, 40, Pixel::RGBA8888 );
722 Shader shader = CreateShader();
723 TextureSet textureSet = CreateTextureSet( image );
724 Renderer renderer = Renderer::New( geometry, shader );
725 renderer.SetTextures( textureSet );
727 Actor actor = Actor::New();
728 actor.AddRenderer(renderer);
729 actor.SetSize(400, 400);
730 Stage::GetCurrent().Add(actor);
732 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO);
734 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
735 glAbstraction.EnableEnableDisableCallTrace(true);
737 application.SendNotification();
738 application.Render();
740 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
741 std::ostringstream blendStr;
742 blendStr << GL_BLEND;
743 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
748 int UtcDaliRendererSetBlendMode06(void)
750 TestApplication application;
751 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");
753 Geometry geometry = CreateQuadGeometry();
754 Shader shader = Shader::New( "vertexSrc", "fragmentSrc", Shader::Hint::OUTPUT_IS_TRANSPARENT );
756 Renderer renderer = Renderer::New( geometry, shader );
758 Actor actor = Actor::New();
759 actor.AddRenderer(renderer);
760 actor.SetSize(400, 400);
761 Stage::GetCurrent().Add(actor);
763 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO);
765 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
766 glAbstraction.EnableEnableDisableCallTrace(true);
768 application.SendNotification();
769 application.Render();
771 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
772 std::ostringstream blendStr;
773 blendStr << GL_BLEND;
774 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
779 int UtcDaliRendererSetBlendMode07(void)
781 TestApplication application;
782 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");
784 Geometry geometry = CreateQuadGeometry();
785 Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
787 BufferImage image = BufferImage::New( 50, 50, Pixel::RGB888 );
788 TextureSet textureSet = CreateTextureSet( image );
789 Renderer renderer = Renderer::New( geometry, shader );
790 renderer.SetTextures( textureSet );
792 Actor actor = Actor::New();
793 actor.AddRenderer(renderer);
794 actor.SetSize(400, 400);
795 Stage::GetCurrent().Add(actor);
797 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO);
799 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
800 glAbstraction.EnableEnableDisableCallTrace(true);
802 application.SendNotification();
803 application.Render();
805 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
806 DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", "GL_BLEND" ) );
811 int UtcDaliRendererGetBlendMode(void)
813 TestApplication application;
815 tet_infoline("Test GetBlendMode()");
817 Geometry geometry = CreateQuadGeometry();
818 Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
819 Renderer renderer = Renderer::New( geometry, shader );
822 unsigned int mode = renderer.GetProperty<int>( Renderer::Property::BLEND_MODE );
823 DALI_TEST_EQUALS( static_cast< BlendMode::Type >( mode ), BlendMode::AUTO, TEST_LOCATION );
826 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON );
827 mode = renderer.GetProperty<int>( Renderer::Property::BLEND_MODE );
828 DALI_TEST_EQUALS( static_cast< BlendMode::Type >( mode ), BlendMode::ON, TEST_LOCATION );
831 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::OFF );
832 mode = renderer.GetProperty<int>( Renderer::Property::BLEND_MODE );
833 DALI_TEST_EQUALS( static_cast< BlendMode::Type >( mode ), BlendMode::OFF, TEST_LOCATION );
838 int UtcDaliRendererSetBlendColor(void)
840 TestApplication application;
842 tet_infoline("Test SetBlendColor(color)");
844 Geometry geometry = CreateQuadGeometry();
845 Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
846 TextureSet textureSet = TextureSet::New();
847 BufferImage image = BufferImage::New( 50, 50, Pixel::RGBA8888 );
848 TextureSetImage( textureSet, 0u, image );
849 Renderer renderer = Renderer::New( geometry, shader );
850 renderer.SetTextures( textureSet );
852 Actor actor = Actor::New();
853 actor.AddRenderer(renderer);
854 actor.SetSize(400, 400);
855 Stage::GetCurrent().Add(actor);
857 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
859 renderer.SetProperty( Renderer::Property::BLEND_COLOR, Color::TRANSPARENT );
860 application.SendNotification();
861 application.Render();
862 DALI_TEST_EQUALS( glAbstraction.GetLastBlendColor(), Color::TRANSPARENT, TEST_LOCATION );
864 renderer.SetProperty( Renderer::Property::BLEND_COLOR, Color::MAGENTA );
865 application.SendNotification();
866 application.Render();
867 DALI_TEST_EQUALS( glAbstraction.GetLastBlendColor(), Color::MAGENTA, TEST_LOCATION );
869 Vector4 color( 0.1f, 0.2f, 0.3f, 0.4f );
870 renderer.SetProperty( Renderer::Property::BLEND_COLOR, color );
871 application.SendNotification();
872 application.Render();
873 DALI_TEST_EQUALS( glAbstraction.GetLastBlendColor(), color, TEST_LOCATION );
878 int UtcDaliRendererGetBlendColor(void)
880 TestApplication application;
882 tet_infoline("Test GetBlendColor()");
884 Geometry geometry = CreateQuadGeometry();
885 Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
886 Renderer renderer = Renderer::New( geometry, shader );
888 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>( Renderer::Property::BLEND_COLOR ), Color::TRANSPARENT, TEST_LOCATION );
890 renderer.SetProperty( Renderer::Property::BLEND_COLOR, Color::MAGENTA );
891 application.SendNotification();
892 application.Render();
893 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>( Renderer::Property::BLEND_COLOR ), Color::MAGENTA, TEST_LOCATION );
895 Vector4 color( 0.1f, 0.2f, 0.3f, 0.4f );
896 renderer.SetProperty( Renderer::Property::BLEND_COLOR, color );
897 application.SendNotification();
898 application.Render();
899 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>( Renderer::Property::BLEND_COLOR ), color, TEST_LOCATION );
904 int UtcDaliRendererPreMultipledAlpha(void)
906 TestApplication application;
908 tet_infoline("Test BLEND_PRE_MULTIPLIED_ALPHA property");
910 Geometry geometry = CreateQuadGeometry();
911 Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
912 Renderer renderer = Renderer::New( geometry, shader );
914 Actor actor = Actor::New();
915 actor.AddRenderer(renderer);
916 actor.SetSize(400, 400);
917 actor.SetColor( Vector4(1.0f, 0.0f, 1.0f, 0.5f) );
918 Stage::GetCurrent().Add(actor);
920 Property::Value value = renderer.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
921 bool preMultipliedAlpha;
922 DALI_TEST_CHECK( value.Get( preMultipliedAlpha ) );
923 DALI_TEST_CHECK( !preMultipliedAlpha );
925 int srcFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
926 int destFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
927 int srcFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
928 int destFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
930 DALI_TEST_EQUALS( (int)DEFAULT_BLEND_FACTOR_SRC_RGB, srcFactorRgb, TEST_LOCATION );
931 DALI_TEST_EQUALS( (int)DEFAULT_BLEND_FACTOR_DEST_RGB, destFactorRgb, TEST_LOCATION );
932 DALI_TEST_EQUALS( (int)DEFAULT_BLEND_FACTOR_SRC_ALPHA, srcFactorAlpha, TEST_LOCATION );
933 DALI_TEST_EQUALS( (int)DEFAULT_BLEND_FACTOR_DEST_ALPHA, destFactorAlpha, TEST_LOCATION );
935 application.SendNotification();
936 application.Render();
938 Vector4 actualValue(Vector4::ZERO);
939 TestGlAbstraction& gl = application.GetGlAbstraction();
940 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uColor", actualValue ) );
941 DALI_TEST_EQUALS( actualValue, Vector4(1.0f, 0.0f, 1.0f, 0.5f), TEST_LOCATION );
943 renderer.SetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true);
945 application.SendNotification();
946 application.Render();
948 value = renderer.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
949 DALI_TEST_CHECK( value.Get( preMultipliedAlpha ) );
950 DALI_TEST_CHECK( preMultipliedAlpha );
952 srcFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
953 destFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
954 srcFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
955 destFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
957 DALI_TEST_EQUALS( (int)BlendFactor::ONE, srcFactorRgb, TEST_LOCATION );
958 DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorRgb, TEST_LOCATION );
959 DALI_TEST_EQUALS( (int)BlendFactor::ONE, srcFactorAlpha, TEST_LOCATION );
960 DALI_TEST_EQUALS( (int)BlendFactor::ONE, destFactorAlpha, TEST_LOCATION );
962 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uColor", actualValue ) );
963 DALI_TEST_EQUALS( actualValue, Vector4(0.5f, 0.0f, 0.5f, 0.5f), TEST_LOCATION );
968 int UtcDaliRendererConstraint01(void)
970 TestApplication application;
972 tet_infoline("Test that a non-uniform renderer property can be constrained");
974 Shader shader = Shader::New("VertexSource", "FragmentSource");
975 Geometry geometry = CreateQuadGeometry();
976 Renderer renderer = Renderer::New( geometry, shader );
978 Actor actor = Actor::New();
979 actor.AddRenderer(renderer);
980 actor.SetSize(400, 400);
981 Stage::GetCurrent().Add(actor);
983 Vector4 initialColor = Color::WHITE;
984 Property::Index colorIndex = renderer.RegisterProperty( "uFadeColor", initialColor );
986 application.SendNotification();
987 application.Render(0);
988 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
991 Constraint constraint = Constraint::New<Vector4>( renderer, colorIndex, TestConstraintNoBlue );
993 application.SendNotification();
994 application.Render(0);
996 // Expect no blue component in either buffer - yellow
997 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector4 >( renderer, colorIndex ), Color::YELLOW, TEST_LOCATION );
998 application.Render(0);
999 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector4 >( renderer, colorIndex ), Color::YELLOW, TEST_LOCATION );
1001 renderer.RemoveConstraints();
1002 renderer.SetProperty(colorIndex, Color::WHITE );
1003 application.SendNotification();
1004 application.Render(0);
1005 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector4 >( renderer, colorIndex ), Color::WHITE, TEST_LOCATION );
1010 int UtcDaliRendererConstraint02(void)
1012 TestApplication application;
1014 tet_infoline("Test that a uniform map renderer property can be constrained");
1016 Shader shader = Shader::New("VertexSource", "FragmentSource");
1017 Geometry geometry = CreateQuadGeometry();
1018 Renderer renderer = Renderer::New( geometry, shader );
1020 Actor actor = Actor::New();
1021 actor.AddRenderer(renderer);
1022 actor.SetSize(400, 400);
1023 Stage::GetCurrent().Add(actor);
1024 application.SendNotification();
1025 application.Render(0);
1027 Vector4 initialColor = Color::WHITE;
1028 Property::Index colorIndex = renderer.RegisterProperty( "uFadeColor", initialColor );
1030 TestGlAbstraction& gl = application.GetGlAbstraction();
1032 application.SendNotification();
1033 application.Render(0);
1035 Vector4 actualValue(Vector4::ZERO);
1036 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1037 DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
1040 Constraint constraint = Constraint::New<Vector4>( renderer, colorIndex, TestConstraintNoBlue );
1042 application.SendNotification();
1043 application.Render(0);
1045 // Expect no blue component in either buffer - yellow
1046 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1047 DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
1049 application.Render(0);
1050 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1051 DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
1053 renderer.RemoveConstraints();
1054 renderer.SetProperty(colorIndex, Color::WHITE );
1055 application.SendNotification();
1056 application.Render(0);
1058 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1059 DALI_TEST_EQUALS( actualValue, Color::WHITE, TEST_LOCATION );
1064 int UtcDaliRendererAnimatedProperty01(void)
1066 TestApplication application;
1068 tet_infoline("Test that a non-uniform renderer property can be animated");
1070 Shader shader = Shader::New("VertexSource", "FragmentSource");
1071 Geometry geometry = CreateQuadGeometry();
1072 Renderer renderer = Renderer::New( geometry, shader );
1074 Actor actor = Actor::New();
1075 actor.AddRenderer(renderer);
1076 actor.SetSize(400, 400);
1077 Stage::GetCurrent().Add(actor);
1079 Vector4 initialColor = Color::WHITE;
1080 Property::Index colorIndex = renderer.RegisterProperty( "uFadeColor", initialColor );
1082 application.SendNotification();
1083 application.Render(0);
1084 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
1086 Animation animation = Animation::New(1.0f);
1087 KeyFrames keyFrames = KeyFrames::New();
1088 keyFrames.Add(0.0f, initialColor);
1089 keyFrames.Add(1.0f, Color::TRANSPARENT);
1090 animation.AnimateBetween( Property( renderer, colorIndex ), keyFrames );
1093 application.SendNotification();
1094 application.Render(500);
1096 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector4 >( renderer, colorIndex ), Color::WHITE * 0.5f, TEST_LOCATION );
1098 application.Render(500);
1100 DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector4 >( renderer, colorIndex ), Color::TRANSPARENT, TEST_LOCATION );
1105 int UtcDaliRendererAnimatedProperty02(void)
1107 TestApplication application;
1109 tet_infoline("Test that a uniform map renderer property can be animated");
1111 Shader shader = Shader::New("VertexSource", "FragmentSource");
1112 Geometry geometry = CreateQuadGeometry();
1113 Renderer renderer = Renderer::New( geometry, shader );
1115 Actor actor = Actor::New();
1116 actor.AddRenderer(renderer);
1117 actor.SetSize(400, 400);
1118 Stage::GetCurrent().Add(actor);
1119 application.SendNotification();
1120 application.Render(0);
1122 Vector4 initialColor = Color::WHITE;
1123 Property::Index colorIndex = renderer.RegisterProperty( "uFadeColor", initialColor );
1125 TestGlAbstraction& gl = application.GetGlAbstraction();
1127 application.SendNotification();
1128 application.Render(0);
1130 Vector4 actualValue(Vector4::ZERO);
1131 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1132 DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
1134 Animation animation = Animation::New(1.0f);
1135 KeyFrames keyFrames = KeyFrames::New();
1136 keyFrames.Add(0.0f, initialColor);
1137 keyFrames.Add(1.0f, Color::TRANSPARENT);
1138 animation.AnimateBetween( Property( renderer, colorIndex ), keyFrames );
1141 application.SendNotification();
1142 application.Render(500);
1144 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1145 DALI_TEST_EQUALS( actualValue, Color::WHITE * 0.5f, TEST_LOCATION );
1147 application.Render(500);
1148 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1149 DALI_TEST_EQUALS( actualValue, Color::TRANSPARENT, TEST_LOCATION );
1154 int UtcDaliRendererUniformMapPrecendence01(void)
1156 TestApplication application;
1158 tet_infoline("Test the uniform map precedence is applied properly");
1160 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1162 Shader shader = Shader::New("VertexSource", "FragmentSource");
1163 TextureSet textureSet = CreateTextureSet( image );
1165 Geometry geometry = CreateQuadGeometry();
1166 Renderer renderer = Renderer::New( geometry, shader );
1167 renderer.SetTextures( textureSet );
1169 Actor actor = Actor::New();
1170 actor.AddRenderer(renderer);
1171 actor.SetSize(400, 400);
1172 Stage::GetCurrent().Add(actor);
1173 application.SendNotification();
1174 application.Render(0);
1176 renderer.RegisterProperty( "uFadeColor", Color::RED );
1177 actor.RegisterProperty( "uFadeColor", Color::GREEN );
1178 Property::Index shaderFadeColorIndex = shader.RegisterProperty( "uFadeColor", Color::MAGENTA );
1180 TestGlAbstraction& gl = application.GetGlAbstraction();
1182 application.SendNotification();
1183 application.Render(0);
1185 // Expect that the actor's fade color property is accessed
1186 Vector4 actualValue(Vector4::ZERO);
1187 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1188 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1190 // Animate shader's fade color property. Should be no change to uniform
1191 Animation animation = Animation::New(1.0f);
1192 KeyFrames keyFrames = KeyFrames::New();
1193 keyFrames.Add(0.0f, Color::WHITE);
1194 keyFrames.Add(1.0f, Color::TRANSPARENT);
1195 animation.AnimateBetween( Property( shader, shaderFadeColorIndex ), keyFrames );
1198 application.SendNotification();
1199 application.Render(500);
1201 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1202 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1204 application.Render(500);
1205 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1206 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1211 int UtcDaliRendererUniformMapPrecendence02(void)
1213 TestApplication application;
1215 tet_infoline("Test the uniform map precedence is applied properly");
1217 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1219 Shader shader = Shader::New("VertexSource", "FragmentSource");
1220 TextureSet textureSet = CreateTextureSet( image );
1222 Geometry geometry = CreateQuadGeometry();
1223 Renderer renderer = Renderer::New( geometry, shader );
1224 renderer.SetTextures( textureSet );
1226 Actor actor = Actor::New();
1227 actor.AddRenderer(renderer);
1228 actor.SetSize(400, 400);
1229 Stage::GetCurrent().Add(actor);
1230 application.SendNotification();
1231 application.Render(0);
1233 // Don't add property / uniform map to renderer
1234 actor.RegisterProperty( "uFadeColor", Color::GREEN );
1235 Property::Index shaderFadeColorIndex = shader.RegisterProperty( "uFadeColor", Color::BLUE );
1237 TestGlAbstraction& gl = application.GetGlAbstraction();
1239 application.SendNotification();
1240 application.Render(0);
1242 // Expect that the actor's fade color property is accessed
1243 Vector4 actualValue(Vector4::ZERO);
1244 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1245 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1247 // Animate texture set's fade color property. Should be no change to uniform
1248 Animation animation = Animation::New(1.0f);
1249 KeyFrames keyFrames = KeyFrames::New();
1250 keyFrames.Add(0.0f, Color::WHITE);
1251 keyFrames.Add(1.0f, Color::TRANSPARENT);
1252 animation.AnimateBetween( Property( shader, shaderFadeColorIndex ), keyFrames );
1255 application.SendNotification();
1256 application.Render(500);
1258 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1259 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1261 application.Render(500);
1262 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1263 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1269 int UtcDaliRendererUniformMapPrecendence03(void)
1271 TestApplication application;
1273 tet_infoline("Test the uniform map precedence is applied properly");
1275 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1277 Shader shader = Shader::New("VertexSource", "FragmentSource");
1278 TextureSet textureSet = CreateTextureSet( image );
1280 Geometry geometry = CreateQuadGeometry();
1281 Renderer renderer = Renderer::New( geometry, shader );
1282 renderer.SetTextures( textureSet );
1284 Actor actor = Actor::New();
1285 actor.AddRenderer(renderer);
1286 actor.SetSize(400, 400);
1287 Stage::GetCurrent().Add(actor);
1288 application.SendNotification();
1289 application.Render(0);
1291 // Don't add property / uniform map to renderer or actor
1292 shader.RegisterProperty( "uFadeColor", Color::BLACK );
1294 TestGlAbstraction& gl = application.GetGlAbstraction();
1296 application.SendNotification();
1297 application.Render(0);
1299 // Expect that the shader's fade color property is accessed
1300 Vector4 actualValue(Vector4::ZERO);
1301 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1302 DALI_TEST_EQUALS( actualValue, Color::BLACK, TEST_LOCATION );
1307 int UtcDaliRendererUniformMapMultipleUniforms01(void)
1309 TestApplication application;
1311 tet_infoline("Test the uniform maps are collected from all objects (same type)");
1313 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1315 Shader shader = Shader::New("VertexSource", "FragmentSource");
1316 TextureSet textureSet = CreateTextureSet( image );
1318 Geometry geometry = CreateQuadGeometry();
1319 Renderer renderer = Renderer::New( geometry, shader );
1320 renderer.SetTextures( textureSet );
1322 Actor actor = Actor::New();
1323 actor.AddRenderer(renderer);
1324 actor.SetSize(400, 400);
1325 Stage::GetCurrent().Add(actor);
1326 application.SendNotification();
1327 application.Render(0);
1329 renderer.RegisterProperty( "uUniform1", Color::RED );
1330 actor.RegisterProperty( "uUniform2", Color::GREEN );
1331 shader.RegisterProperty( "uUniform3", Color::MAGENTA );
1333 TestGlAbstraction& gl = application.GetGlAbstraction();
1335 application.SendNotification();
1336 application.Render(0);
1338 // Expect that each of the object's uniforms are set
1339 Vector4 uniform1Value(Vector4::ZERO);
1340 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform1", uniform1Value ) );
1341 DALI_TEST_EQUALS( uniform1Value, Color::RED, TEST_LOCATION );
1343 Vector4 uniform2Value(Vector4::ZERO);
1344 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform2", uniform2Value ) );
1345 DALI_TEST_EQUALS( uniform2Value, Color::GREEN, TEST_LOCATION );
1347 Vector4 uniform3Value(Vector4::ZERO);
1348 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform3", uniform3Value ) );
1349 DALI_TEST_EQUALS( uniform3Value, Color::MAGENTA, TEST_LOCATION );
1354 int UtcDaliRendererUniformMapMultipleUniforms02(void)
1356 TestApplication application;
1358 tet_infoline("Test the uniform maps are collected from all objects (different types)");
1360 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1362 Shader shader = Shader::New("VertexSource", "FragmentSource");
1363 TextureSet textureSet = CreateTextureSet( image );
1365 Geometry geometry = CreateQuadGeometry();
1366 Renderer renderer = Renderer::New( geometry, shader );
1367 renderer.SetTextures( textureSet );
1369 Actor actor = Actor::New();
1370 actor.AddRenderer(renderer);
1371 actor.SetSize(400, 400);
1372 Stage::GetCurrent().Add(actor);
1373 application.SendNotification();
1374 application.Render(0);
1376 Property::Value value1(Color::RED);
1377 renderer.RegisterProperty( "uFadeColor", value1 );
1379 Property::Value value2(1.0f);
1380 actor.RegisterProperty( "uFadeProgress", value2 );
1382 Property::Value value3(Matrix3::IDENTITY);
1383 shader.RegisterProperty( "uANormalMatrix", value3 );
1385 TestGlAbstraction& gl = application.GetGlAbstraction();
1387 application.SendNotification();
1388 application.Render(0);
1390 // Expect that each of the object's uniforms are set
1391 Vector4 uniform1Value(Vector4::ZERO);
1392 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", uniform1Value ) );
1393 DALI_TEST_EQUALS( uniform1Value, value1.Get<Vector4>(), TEST_LOCATION );
1395 float uniform2Value(0.0f);
1396 DALI_TEST_CHECK( gl.GetUniformValue<float>( "uFadeProgress", uniform2Value ) );
1397 DALI_TEST_EQUALS( uniform2Value, value2.Get<float>(), TEST_LOCATION );
1399 Matrix3 uniform3Value;
1400 DALI_TEST_CHECK( gl.GetUniformValue<Matrix3>( "uANormalMatrix", uniform3Value ) );
1401 DALI_TEST_EQUALS( uniform3Value, value3.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 Geometry geometry = CreateQuadGeometry();
1414 Actor actor0 = Actor::New();
1415 actor0.SetAnchorPoint(AnchorPoint::CENTER);
1416 actor0.SetParentOrigin(AnchorPoint::CENTER);
1417 actor0.SetPosition(0.0f,0.0f);
1418 Image image0 = BufferImage::New( 64, 64, Pixel::RGB888 );
1419 TextureSet textureSet0 = CreateTextureSet( image0 );
1420 Renderer renderer0 = Renderer::New( geometry, shader );
1421 renderer0.SetTextures( textureSet0 );
1422 actor0.AddRenderer(renderer0);
1423 actor0.SetSize(1, 1);
1424 Stage::GetCurrent().Add(actor0);
1425 application.SendNotification();
1426 application.Render(0);
1428 Actor actor1 = Actor::New();
1429 actor1.SetAnchorPoint(AnchorPoint::CENTER);
1430 actor1.SetParentOrigin(AnchorPoint::CENTER);
1431 actor1.SetPosition(0.0f,0.0f);
1432 Image image1= BufferImage::New( 64, 64, Pixel::RGB888 );
1433 TextureSet textureSet1 = CreateTextureSet( image1 );
1434 Renderer renderer1 = Renderer::New( geometry, shader );
1435 renderer1.SetTextures( textureSet1 );
1436 actor1.AddRenderer(renderer1);
1437 actor1.SetSize(1, 1);
1438 Stage::GetCurrent().Add(actor1);
1439 application.SendNotification();
1440 application.Render(0);
1442 Actor actor2 = Actor::New();
1443 actor2.SetAnchorPoint(AnchorPoint::CENTER);
1444 actor2.SetParentOrigin(AnchorPoint::CENTER);
1445 actor2.SetPosition(0.0f,0.0f);
1446 Image image2= BufferImage::New( 64, 64, Pixel::RGB888 );
1447 TextureSet textureSet2 = CreateTextureSet( image2 );
1448 Renderer renderer2 = Renderer::New( geometry, shader );
1449 renderer2.SetTextures( textureSet2 );
1450 actor2.AddRenderer(renderer2);
1451 actor2.SetSize(1, 1);
1452 Stage::GetCurrent().Add(actor2);
1453 application.SendNotification();
1454 application.Render(0);
1456 Actor actor3 = Actor::New();
1457 actor3.SetAnchorPoint(AnchorPoint::CENTER);
1458 actor3.SetParentOrigin(AnchorPoint::CENTER);
1459 actor3.SetPosition(0.0f,0.0f);
1460 Image image3 = BufferImage::New( 64, 64, Pixel::RGB888 );
1461 TextureSet textureSet3 = CreateTextureSet( image3 );
1462 Renderer renderer3 = Renderer::New( geometry, shader );
1463 renderer3.SetTextures( textureSet3 );
1464 actor3.AddRenderer(renderer3);
1465 actor3.SetSize(1, 1);
1466 Stage::GetCurrent().Add(actor3);
1467 application.SendNotification();
1468 application.Render(0);
1471 * Create the following hierarchy:
1484 * Expected rendering order : actor2 - actor1 - actor0 - actor3
1489 application.SendNotification();
1490 application.Render(0);
1492 TestGlAbstraction& gl = application.GetGlAbstraction();
1493 gl.EnableTextureCallTrace(true);
1494 application.SendNotification();
1495 application.Render(0);
1497 int textureBindIndex[4];
1498 for( unsigned int i(0); i<4; ++i )
1500 std::stringstream params;
1501 params << GL_TEXTURE_2D<<", "<<i+1;
1502 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
1505 //Check that actor1 has been rendered after actor2
1506 DALI_TEST_GREATER( textureBindIndex[1], textureBindIndex[2], TEST_LOCATION );
1508 //Check that actor0 has been rendered after actor1
1509 DALI_TEST_GREATER( textureBindIndex[0], textureBindIndex[1], TEST_LOCATION );
1511 //Check that actor3 has been rendered after actor0
1512 DALI_TEST_GREATER( textureBindIndex[3], textureBindIndex[0], TEST_LOCATION );
1517 int UtcDaliRendererRenderOrder2DLayerMultipleRenderers(void)
1519 TestApplication application;
1520 tet_infoline("Test the rendering order in a 2D layer is correct using multiple renderers per actor");
1523 * Creates the following hierarchy:
1525 * actor0------------------------>actor1
1529 * renderer0 renderer1 renderer2 renderer3 renderer4 renderer5
1531 * renderer0 has depth index 2
1532 * renderer1 has depth index 0
1533 * renderer2 has depth index 1
1535 * renderer3 has depth index 1
1536 * renderer4 has depth index 0
1537 * renderer5 has depth index -1
1539 * Expected rendering order: renderer1 - renderer2 - renderer0 - renderer5 - renderer4 - renderer3
1542 Shader shader = Shader::New("VertexSource", "FragmentSource");
1543 Geometry geometry = CreateQuadGeometry();
1545 Actor actor0 = Actor::New();
1546 actor0.SetAnchorPoint(AnchorPoint::CENTER);
1547 actor0.SetParentOrigin(AnchorPoint::CENTER);
1548 actor0.SetPosition(0.0f,0.0f);
1549 actor0.SetSize(1, 1);
1550 Stage::GetCurrent().Add(actor0);
1552 Actor actor1 = Actor::New();
1553 actor1.SetAnchorPoint(AnchorPoint::CENTER);
1554 actor1.SetParentOrigin(AnchorPoint::CENTER);
1555 actor1.SetPosition(0.0f,0.0f);
1556 actor1.SetSize(1, 1);
1560 Image image0 = BufferImage::New( 64, 64, Pixel::RGB888 );
1561 TextureSet textureSet0 = CreateTextureSet( image0 );
1562 Renderer renderer0 = Renderer::New( geometry, shader );
1563 renderer0.SetTextures( textureSet0 );
1564 renderer0.SetProperty( Renderer::Property::DEPTH_INDEX, 2 );
1565 actor0.AddRenderer(renderer0);
1566 application.SendNotification();
1567 application.Render(0);
1570 Image image1= BufferImage::New( 64, 64, Pixel::RGB888 );
1571 TextureSet textureSet1 = CreateTextureSet( image1 );
1572 Renderer renderer1 = Renderer::New( geometry, shader );
1573 renderer1.SetTextures( textureSet1 );
1574 renderer1.SetProperty( Renderer::Property::DEPTH_INDEX, 0 );
1575 actor0.AddRenderer(renderer1);
1576 application.SendNotification();
1577 application.Render(0);
1580 Image image2= BufferImage::New( 64, 64, Pixel::RGB888 );
1581 TextureSet textureSet2 = CreateTextureSet( image2 );
1582 Renderer renderer2 = Renderer::New( geometry, shader );
1583 renderer2.SetTextures( textureSet2 );
1584 renderer2.SetProperty( Renderer::Property::DEPTH_INDEX, 1 );
1585 actor0.AddRenderer(renderer2);
1586 application.SendNotification();
1587 application.Render(0);
1590 Image image3 = BufferImage::New( 64, 64, Pixel::RGB888 );
1591 TextureSet textureSet3 = CreateTextureSet( image3 );
1592 Renderer renderer3 = Renderer::New( geometry, shader );
1593 renderer3.SetTextures( textureSet3 );
1594 renderer3.SetProperty( Renderer::Property::DEPTH_INDEX, 1 );
1595 actor1.AddRenderer(renderer3);
1596 application.SendNotification();
1597 application.Render(0);
1600 Image image4= BufferImage::New( 64, 64, Pixel::RGB888 );
1601 TextureSet textureSet4 = CreateTextureSet( image4 );
1602 Renderer renderer4 = Renderer::New( geometry, shader );
1603 renderer4.SetTextures( textureSet4 );
1604 renderer4.SetProperty( Renderer::Property::DEPTH_INDEX, 0 );
1605 actor1.AddRenderer(renderer4);
1606 application.SendNotification();
1607 application.Render(0);
1610 Image image5= BufferImage::New( 64, 64, Pixel::RGB888 );
1611 TextureSet textureSet5 = CreateTextureSet( image5 );
1612 Renderer renderer5 = Renderer::New( geometry, shader );
1613 renderer5.SetTextures( textureSet5 );
1614 renderer5.SetProperty( Renderer::Property::DEPTH_INDEX, -1 );
1615 actor1.AddRenderer(renderer5);
1616 application.SendNotification();
1617 application.Render(0);
1620 TestGlAbstraction& gl = application.GetGlAbstraction();
1621 gl.EnableTextureCallTrace(true);
1622 application.SendNotification();
1623 application.Render(0);
1625 int textureBindIndex[6];
1626 for( unsigned int i(0); i<6; ++i )
1628 std::stringstream params;
1629 params << GL_TEXTURE_2D<<", "<<i+1;
1630 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
1633 //Check that renderer3 has been rendered after renderer4
1634 DALI_TEST_GREATER( textureBindIndex[3], textureBindIndex[4], TEST_LOCATION );
1636 //Check that renderer0 has been rendered after renderer2
1637 DALI_TEST_GREATER( textureBindIndex[4], textureBindIndex[5], TEST_LOCATION );
1639 //Check that renderer0 has been rendered after renderer2
1640 DALI_TEST_GREATER( textureBindIndex[5], textureBindIndex[0], TEST_LOCATION );
1642 //Check that renderer0 has been rendered after renderer2
1643 DALI_TEST_GREATER( textureBindIndex[0], textureBindIndex[2], TEST_LOCATION );
1645 //Check that renderer2 has been rendered after renderer1
1646 DALI_TEST_GREATER( textureBindIndex[2], textureBindIndex[1], TEST_LOCATION );
1651 int UtcDaliRendererRenderOrder2DLayerSiblingOrder(void)
1653 TestApplication application;
1654 tet_infoline("Test the rendering order in a 2D layer is correct using sibling order");
1657 * Creates the following hierarchy:
1665 * actor0 (SIBLING_ORDER:1) actor1 (SIBLING_ORDER:0)
1669 * renderer0 renderer1 actor2 renderer2 renderer3 renderer4
1674 * actor0 has sibling order 1
1675 * actor1 has sibling order 0
1676 * actor2 has sibling order 0
1678 * renderer0 has depth index 2
1679 * renderer1 has depth index 0
1681 * renderer2 has depth index 0
1682 * renderer3 has depth index 1
1683 * renderer4 has depth index 2
1685 * renderer5 has depth index -1
1687 * Expected rendering order: renderer2 - renderer3 - renderer4 - renderer1 - renderer0 - renderer5
1690 Shader shader = Shader::New("VertexSource", "FragmentSource");
1691 Geometry geometry = CreateQuadGeometry();
1693 Actor actor0 = Actor::New();
1694 actor0.SetAnchorPoint(AnchorPoint::CENTER);
1695 actor0.SetParentOrigin(AnchorPoint::CENTER);
1696 actor0.SetPosition(0.0f,0.0f);
1697 actor0.SetSize(1, 1);
1698 actor0.SetProperty( Dali::DevelActor::Property::SIBLING_ORDER, 1 );
1699 DALI_TEST_EQUALS( actor0.GetProperty<int>( Dali::DevelActor::Property::SIBLING_ORDER), 1, TEST_LOCATION );
1700 Stage::GetCurrent().Add(actor0);
1702 Actor actor1 = Actor::New();
1703 actor1.SetAnchorPoint(AnchorPoint::CENTER);
1704 actor1.SetParentOrigin(AnchorPoint::CENTER);
1705 actor1.SetPosition(0.0f,0.0f);
1706 actor1.SetSize(1, 1);
1707 DALI_TEST_EQUALS( actor1.GetProperty<int>( Dali::DevelActor::Property::SIBLING_ORDER), 0, TEST_LOCATION );
1708 Stage::GetCurrent().Add(actor1);
1710 Actor actor2 = Actor::New();
1711 actor2.SetAnchorPoint(AnchorPoint::CENTER);
1712 actor2.SetParentOrigin(AnchorPoint::CENTER);
1713 actor2.SetPosition(0.0f,0.0f);
1714 actor2.SetSize(1, 1);
1715 DALI_TEST_EQUALS( actor1.GetProperty<int>( Dali::DevelActor::Property::SIBLING_ORDER), 0, TEST_LOCATION );
1719 Image image0 = BufferImage::New( 64, 64, Pixel::RGB888 );
1720 TextureSet textureSet0 = CreateTextureSet( image0 );
1721 Renderer renderer0 = Renderer::New( geometry, shader );
1722 renderer0.SetTextures( textureSet0 );
1723 renderer0.SetProperty( Renderer::Property::DEPTH_INDEX, 2 );
1724 actor0.AddRenderer(renderer0);
1725 application.SendNotification();
1726 application.Render(0);
1729 Image image1= BufferImage::New( 64, 64, Pixel::RGB888 );
1730 TextureSet textureSet1 = CreateTextureSet( image1 );
1731 Renderer renderer1 = Renderer::New( geometry, shader );
1732 renderer1.SetTextures( textureSet1 );
1733 renderer1.SetProperty( Renderer::Property::DEPTH_INDEX, 0 );
1734 actor0.AddRenderer(renderer1);
1735 application.SendNotification();
1736 application.Render(0);
1739 Image image2= BufferImage::New( 64, 64, Pixel::RGB888 );
1740 TextureSet textureSet2 = CreateTextureSet( image2 );
1741 Renderer renderer2 = Renderer::New( geometry, shader );
1742 renderer2.SetTextures( textureSet2 );
1743 renderer2.SetProperty( Renderer::Property::DEPTH_INDEX, 0 );
1744 actor1.AddRenderer(renderer2);
1745 application.SendNotification();
1746 application.Render(0);
1749 Image image3 = BufferImage::New( 64, 64, Pixel::RGB888 );
1750 TextureSet textureSet3 = CreateTextureSet( image3 );
1751 Renderer renderer3 = Renderer::New( geometry, shader );
1752 renderer3.SetTextures( textureSet3 );
1753 renderer3.SetProperty( Renderer::Property::DEPTH_INDEX, 1 );
1754 actor1.AddRenderer(renderer3);
1755 application.SendNotification();
1756 application.Render(0);
1759 Image image4= BufferImage::New( 64, 64, Pixel::RGB888 );
1760 TextureSet textureSet4 = CreateTextureSet( image4 );
1761 Renderer renderer4 = Renderer::New( geometry, shader );
1762 renderer4.SetTextures( textureSet4 );
1763 renderer4.SetProperty( Renderer::Property::DEPTH_INDEX, 2 );
1764 actor1.AddRenderer(renderer4);
1765 application.SendNotification();
1766 application.Render(0);
1769 Image image5= BufferImage::New( 64, 64, Pixel::RGB888 );
1770 TextureSet textureSet5 = CreateTextureSet( image5 );
1771 Renderer renderer5 = Renderer::New( geometry, shader );
1772 renderer5.SetTextures( textureSet5 );
1773 renderer5.SetProperty( Renderer::Property::DEPTH_INDEX, -1 );
1774 actor2.AddRenderer(renderer5);
1775 application.SendNotification();
1776 application.Render(0);
1779 TestGlAbstraction& gl = application.GetGlAbstraction();
1780 gl.EnableTextureCallTrace(true);
1781 application.SendNotification();
1782 application.Render(0);
1784 int textureBindIndex[6];
1785 for( unsigned int i(0); i<6; ++i )
1787 std::stringstream params;
1788 params << GL_TEXTURE_2D<<", "<<i+1;
1789 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
1792 DALI_TEST_EQUALS( textureBindIndex[2], 0, TEST_LOCATION );
1793 DALI_TEST_EQUALS( textureBindIndex[3], 1, TEST_LOCATION );
1794 DALI_TEST_EQUALS( textureBindIndex[4], 2, TEST_LOCATION );
1795 DALI_TEST_EQUALS( textureBindIndex[1], 3, TEST_LOCATION );
1796 DALI_TEST_EQUALS( textureBindIndex[0], 4, TEST_LOCATION );
1797 DALI_TEST_EQUALS( textureBindIndex[5], 5, TEST_LOCATION );
1799 //Change sibling order of actor1
1800 //New Expected rendering order: renderer1 - renderer0 - renderer2 - renderer3 - renderer4 - renderer5
1801 actor1.SetProperty( Dali::DevelActor::Property::SIBLING_ORDER, 2 );
1803 gl.GetTextureTrace().Reset();
1804 application.SendNotification();
1805 application.Render(0);
1807 for( unsigned int i(0); i<6; ++i )
1809 std::stringstream params;
1810 params << GL_TEXTURE_2D<<", "<<i+1;
1811 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
1814 DALI_TEST_EQUALS( textureBindIndex[1], 0, TEST_LOCATION );
1815 DALI_TEST_EQUALS( textureBindIndex[0], 1, TEST_LOCATION );
1816 DALI_TEST_EQUALS( textureBindIndex[2], 2, TEST_LOCATION );
1817 DALI_TEST_EQUALS( textureBindIndex[3], 3, TEST_LOCATION );
1818 DALI_TEST_EQUALS( textureBindIndex[4], 4, TEST_LOCATION );
1819 DALI_TEST_EQUALS( textureBindIndex[5], 5, TEST_LOCATION );
1824 int UtcDaliRendererRenderOrder2DLayerOverlay(void)
1826 TestApplication application;
1827 tet_infoline("Test the rendering order in a 2D layer is correct for overlays");
1829 Shader shader = Shader::New("VertexSource", "FragmentSource");
1830 Geometry geometry = CreateQuadGeometry();
1832 Actor actor0 = Actor::New();
1833 actor0.SetAnchorPoint(AnchorPoint::CENTER);
1834 actor0.SetParentOrigin(AnchorPoint::CENTER);
1835 Image image0 = BufferImage::New( 64, 64, Pixel::RGB888 );
1836 TextureSet textureSet0 = CreateTextureSet( image0 );
1837 Renderer renderer0 = Renderer::New( geometry, shader );
1838 renderer0.SetTextures( textureSet0 );
1839 actor0.AddRenderer(renderer0);
1840 actor0.SetPosition(0.0f,0.0f);
1841 actor0.SetSize(100, 100);
1842 Stage::GetCurrent().Add(actor0);
1843 actor0.SetDrawMode( DrawMode::OVERLAY_2D );
1844 application.SendNotification();
1845 application.Render(0);
1847 Actor actor1 = Actor::New();
1848 actor1.SetAnchorPoint(AnchorPoint::CENTER);
1849 actor1.SetParentOrigin(AnchorPoint::CENTER);
1850 Image image1= BufferImage::New( 64, 64, Pixel::RGB888 );
1851 TextureSet textureSet1 = CreateTextureSet( image1 );
1852 Renderer renderer1 = Renderer::New( geometry, shader );
1853 renderer1.SetTextures( textureSet1 );
1854 actor1.SetPosition(0.0f,0.0f);
1855 actor1.AddRenderer(renderer1);
1856 actor1.SetSize(100, 100);
1857 Stage::GetCurrent().Add(actor1);
1858 actor1.SetDrawMode( DrawMode::OVERLAY_2D );
1859 application.SendNotification();
1860 application.Render(0);
1862 Actor actor2 = Actor::New();
1863 actor2.SetAnchorPoint(AnchorPoint::CENTER);
1864 actor2.SetParentOrigin(AnchorPoint::CENTER);
1865 Image image2= BufferImage::New( 64, 64, Pixel::RGB888 );
1866 TextureSet textureSet2 = CreateTextureSet( image2 );
1867 Renderer renderer2 = Renderer::New( geometry, shader );
1868 renderer2.SetTextures( textureSet2 );
1869 actor2.AddRenderer(renderer2);
1870 actor2.SetPosition(0.0f,0.0f);
1871 actor2.SetSize(100, 100);
1872 Stage::GetCurrent().Add(actor2);
1873 application.SendNotification();
1874 application.Render(0);
1876 Actor actor3 = Actor::New();
1877 actor3.SetAnchorPoint(AnchorPoint::CENTER);
1878 actor3.SetParentOrigin(AnchorPoint::CENTER);
1879 Image image3 = BufferImage::New( 64, 64, Pixel::RGB888 );
1880 TextureSet textureSet3 = CreateTextureSet( image3 );
1881 Renderer renderer3 = Renderer::New( geometry, shader );
1882 renderer3.SetTextures( textureSet3 );
1883 actor3.SetPosition(0.0f,0.0f);
1884 actor3.AddRenderer(renderer3);
1885 actor3.SetSize(100, 100);
1886 Stage::GetCurrent().Add(actor3);
1887 actor3.SetDrawMode( DrawMode::OVERLAY_2D );
1888 application.SendNotification();
1889 application.Render(0);
1891 Actor actor4 = Actor::New();
1892 actor4.SetAnchorPoint(AnchorPoint::CENTER);
1893 actor4.SetParentOrigin(AnchorPoint::CENTER);
1894 Image image4 = BufferImage::New( 64, 64, Pixel::RGB888 );
1895 TextureSet textureSet4 = CreateTextureSet( image4 );
1896 Renderer renderer4 = Renderer::New( geometry, shader );
1897 renderer4.SetTextures( textureSet4 );
1898 actor4.AddRenderer(renderer4);
1899 actor4.SetPosition(0.0f,0.0f);
1900 actor4.SetSize(100, 100);
1901 Stage::GetCurrent().Add(actor4);
1902 application.SendNotification();
1903 application.Render(0);
1906 * Create the following hierarchy:
1913 * (Overlay) (Regular actor)
1923 * Expected rendering order : actor2 - actor4 - actor1 - actor0 - actor3
1925 Stage::GetCurrent().Add( actor2 );
1930 application.SendNotification();
1931 application.Render(0);
1933 TestGlAbstraction& gl = application.GetGlAbstraction();
1934 gl.EnableTextureCallTrace(true);
1935 application.SendNotification();
1936 application.Render(0);
1938 int textureBindIndex[5];
1939 for( unsigned int i(0); i<5; ++i )
1941 std::stringstream params;
1942 params << GL_TEXTURE_2D<<", "<<i+1;
1943 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
1946 //Check that actor4 has been rendered after actor2
1947 DALI_TEST_GREATER( textureBindIndex[4], textureBindIndex[2], TEST_LOCATION );
1949 //Check that actor1 has been rendered after actor4
1950 DALI_TEST_GREATER( textureBindIndex[1], textureBindIndex[4], TEST_LOCATION );
1952 //Check that actor0 has been rendered after actor1
1953 DALI_TEST_GREATER( textureBindIndex[0], textureBindIndex[1], TEST_LOCATION );
1955 //Check that actor3 has been rendered after actor0
1956 DALI_TEST_GREATER( textureBindIndex[3], textureBindIndex[0], TEST_LOCATION );
1961 int UtcDaliRendererSetIndexRange(void)
1965 "attribute vec2 aPosition;\n"
1968 " gl_Position = aPosition;\n"
1974 " gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0)\n"
1978 TestApplication application;
1979 tet_infoline("Test setting the range of indices to draw");
1981 TestGlAbstraction& gl = application.GetGlAbstraction();
1982 gl.EnableDrawCallTrace( true );
1984 Actor actor = Actor::New();
1985 actor.SetSize( 100, 100 );
1988 Geometry geometry = Geometry::New();
1989 geometry.SetType( Geometry::LINE_LOOP );
1991 // --------------------------------------------------------------------------
1993 unsigned short indices[] = { 0, 2, 4, 6, 8, // offset = 0, count = 5
1994 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, // offset = 5, count = 10
1995 1, 3, 5, 7, 9, 1 }; // offset = 15, count = 6 // line strip
1997 // --------------------------------------------------------------------------
2006 { Vector2( 0.0f, 1.00f) }, { Vector2( 0.0f, -1.00f) },
2007 { Vector2( -0.95f, 0.31f) }, { Vector2( 0.59f, 0.81f) },
2008 { Vector2( -0.59f, -0.81f) }, { Vector2( -0.95f, -0.31f) },
2009 { Vector2( 0.59f, -0.81f) }, { Vector2( 0.95f, -0.31f) },
2010 { Vector2( 0.95f, 0.31f) }, { Vector2( -0.59f, 0.81f) },
2012 Property::Map vertexFormat;
2013 vertexFormat["aPosition"] = Property::VECTOR2;
2014 PropertyBuffer vertexBuffer = PropertyBuffer::New( vertexFormat );
2015 vertexBuffer.SetData( shapes, sizeof(shapes)/sizeof(shapes[0]));
2017 // --------------------------------------------------------------------------
2018 geometry.SetIndexBuffer( indices, sizeof(indices)/sizeof(indices[0]) );
2019 geometry.AddVertexBuffer( vertexBuffer );
2022 Shader shader = Shader::New( vertexShader,fragmentShader );
2023 Renderer renderer = Renderer::New( geometry, shader );
2024 actor.AddRenderer( renderer );
2026 Stage stage = Stage::GetCurrent();
2031 // LINE_LOOP, first 0, count 5
2033 renderer.SetIndexRange( 0, 5 );
2034 application.SendNotification();
2035 application.Render();
2036 sprintf( buffer, "%u, 5, %u, indices", GL_LINE_LOOP, GL_UNSIGNED_SHORT );
2037 bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
2038 DALI_TEST_CHECK( result );
2041 // LINE_LOOP, first 5, count 10
2043 renderer.SetIndexRange( 5, 10 );
2044 sprintf( buffer, "%u, 10, %u, indices", GL_LINE_LOOP, GL_UNSIGNED_SHORT );
2045 application.SendNotification();
2046 application.Render();
2047 bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
2048 DALI_TEST_CHECK( result );
2051 // LINE_STRIP, first 15, count 6
2053 renderer.SetIndexRange( 15, 6 );
2054 geometry.SetType( Geometry::LINE_STRIP );
2055 sprintf( buffer, "%u, 6, %u, indices", GL_LINE_STRIP, GL_UNSIGNED_SHORT );
2056 application.SendNotification();
2057 application.Render();
2058 bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
2059 DALI_TEST_CHECK( result );
2062 // Index out of bounds
2064 renderer.SetIndexRange( 15, 30 );
2065 geometry.SetType( Geometry::LINE_STRIP );
2066 sprintf( buffer, "%u, 6, %u, indices", GL_LINE_STRIP, GL_UNSIGNED_SHORT );
2067 application.SendNotification();
2068 application.Render();
2069 bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
2070 DALI_TEST_CHECK( result );
2073 // drawing whole buffer starting from 15 ( last valid primitive )
2075 renderer.SetIndexRange( 15, 0 );
2076 geometry.SetType( Geometry::LINE_STRIP );
2077 sprintf( buffer, "%u, 6, %u, indices", GL_LINE_STRIP, GL_UNSIGNED_SHORT );
2078 application.SendNotification();
2079 application.Render();
2080 bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
2081 DALI_TEST_CHECK( result );
2088 int UtcDaliRendererSetDepthFunction(void)
2090 TestApplication application;
2092 tet_infoline("Test setting the depth function");
2094 Geometry geometry = CreateQuadGeometry();
2095 Shader shader = CreateShader();
2096 Renderer renderer = Renderer::New( geometry, shader );
2098 Actor actor = Actor::New();
2099 actor.AddRenderer(renderer);
2100 actor.SetSize(400, 400);
2101 Stage stage = Stage::GetCurrent();
2102 stage.GetRootLayer().SetBehavior( Layer::LAYER_3D );
2105 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2106 glAbstraction.EnableEnableDisableCallTrace(true);
2107 glAbstraction.EnableDepthFunctionCallTrace(true);
2109 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2110 TraceCallStack& glDepthFunctionStack = glAbstraction.GetDepthFunctionTrace();
2112 std::ostringstream depthTestStr;
2113 depthTestStr << GL_DEPTH_TEST;
2117 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::NEVER);
2119 glEnableDisableStack.Reset();
2120 glDepthFunctionStack.Reset();
2121 application.SendNotification();
2122 application.Render();
2124 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", depthTestStr.str().c_str() ) );
2125 std::ostringstream depthFunctionStr;
2126 depthFunctionStr << GL_NEVER;
2127 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2132 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::ALWAYS);
2134 glDepthFunctionStack.Reset();
2135 application.SendNotification();
2136 application.Render();
2138 std::ostringstream depthFunctionStr;
2139 depthFunctionStr << GL_ALWAYS;
2140 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2145 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::LESS);
2147 glDepthFunctionStack.Reset();
2148 application.SendNotification();
2149 application.Render();
2151 std::ostringstream depthFunctionStr;
2152 depthFunctionStr << GL_LESS;
2153 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2158 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::GREATER);
2160 glDepthFunctionStack.Reset();
2161 application.SendNotification();
2162 application.Render();
2164 std::ostringstream depthFunctionStr;
2165 depthFunctionStr << GL_GREATER;
2166 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2171 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::EQUAL);
2173 glDepthFunctionStack.Reset();
2174 application.SendNotification();
2175 application.Render();
2177 std::ostringstream depthFunctionStr;
2178 depthFunctionStr << GL_EQUAL;
2179 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2184 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::NOT_EQUAL);
2186 glDepthFunctionStack.Reset();
2187 application.SendNotification();
2188 application.Render();
2190 std::ostringstream depthFunctionStr;
2191 depthFunctionStr << GL_NOTEQUAL;
2192 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2197 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::LESS_EQUAL);
2199 glDepthFunctionStack.Reset();
2200 application.SendNotification();
2201 application.Render();
2203 std::ostringstream depthFunctionStr;
2204 depthFunctionStr << GL_LEQUAL;
2205 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2210 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::GREATER_EQUAL);
2212 glDepthFunctionStack.Reset();
2213 application.SendNotification();
2214 application.Render();
2216 std::ostringstream depthFunctionStr;
2217 depthFunctionStr << GL_GEQUAL;
2218 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2225 * @brief This templatized function checks an enumeration property is setting and getting correctly.
2226 * The checks performed are as follows:
2227 * - Check the initial/default value.
2228 * - Set a different value via enum.
2229 * - Check it was set.
2230 * - Set a different value via string.
2231 * - Check it was set.
2233 template< typename T >
2234 void CheckEnumerationProperty( Renderer& renderer, Property::Index propertyIndex, T initialValue, T firstCheckEnumeration, T secondCheckEnumeration, std::string secondCheckString )
2236 DALI_TEST_CHECK( renderer.GetProperty<int>( propertyIndex ) == static_cast<int>( initialValue ) );
2237 DALI_TEST_CHECK( DevelHandle::GetCurrentProperty< int >( renderer, propertyIndex ) == static_cast<int>( initialValue ) );
2238 renderer.SetProperty( propertyIndex, firstCheckEnumeration );
2239 DALI_TEST_CHECK( renderer.GetProperty<int>( propertyIndex ) == static_cast<int>( firstCheckEnumeration ) );
2240 DALI_TEST_CHECK( DevelHandle::GetCurrentProperty< int >( renderer, propertyIndex ) == static_cast<int>( firstCheckEnumeration ) );
2241 renderer.SetProperty( propertyIndex, secondCheckString );
2242 DALI_TEST_CHECK( renderer.GetProperty<int>( propertyIndex ) == static_cast<int>( secondCheckEnumeration ) );
2243 DALI_TEST_CHECK( DevelHandle::GetCurrentProperty< int >( renderer, propertyIndex ) == static_cast<int>( secondCheckEnumeration ) );
2246 int UtcDaliRendererEnumProperties(void)
2248 TestApplication application;
2249 tet_infoline( "Test Renderer enumeration properties can be set with both integer and string values" );
2251 Geometry geometry = CreateQuadGeometry();
2252 Shader shader = CreateShader();
2253 Renderer renderer = Renderer::New( geometry, shader );
2256 * Here we use a templatized function to perform several checks on each enumeration property.
2257 * @see CheckEnumerationProperty for details of the checks performed.
2260 CheckEnumerationProperty< FaceCullingMode::Type >( renderer, Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::NONE, FaceCullingMode::FRONT, FaceCullingMode::BACK, "BACK" );
2261 CheckEnumerationProperty< BlendMode::Type >( renderer, Renderer::Property::BLEND_MODE, BlendMode::AUTO, BlendMode::OFF, BlendMode::ON, "ON" );
2262 CheckEnumerationProperty< BlendEquation::Type >( renderer, Renderer::Property::BLEND_EQUATION_RGB, BlendEquation::ADD, BlendEquation::SUBTRACT, BlendEquation::REVERSE_SUBTRACT, "REVERSE_SUBTRACT" );
2263 CheckEnumerationProperty< BlendEquation::Type >( renderer, Renderer::Property::BLEND_EQUATION_ALPHA, BlendEquation::ADD, BlendEquation::SUBTRACT, BlendEquation::REVERSE_SUBTRACT, "REVERSE_SUBTRACT" );
2264 CheckEnumerationProperty< BlendFactor::Type >( renderer, Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::SRC_ALPHA, BlendFactor::ONE, BlendFactor::SRC_COLOR, "SRC_COLOR" );
2265 CheckEnumerationProperty< BlendFactor::Type >( renderer, Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::SRC_COLOR, "SRC_COLOR" );
2266 CheckEnumerationProperty< BlendFactor::Type >( renderer, Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::SRC_COLOR, "SRC_COLOR" );
2267 CheckEnumerationProperty< BlendFactor::Type >( renderer, Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::SRC_COLOR, "SRC_COLOR" );
2268 CheckEnumerationProperty< DepthWriteMode::Type >( renderer, Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::AUTO, DepthWriteMode::OFF, DepthWriteMode::ON, "ON" );
2269 CheckEnumerationProperty< DepthFunction::Type >( renderer, Renderer::Property::DEPTH_FUNCTION, DepthFunction::LESS, DepthFunction::ALWAYS, DepthFunction::GREATER, "GREATER" );
2270 CheckEnumerationProperty< DepthTestMode::Type >( renderer, Renderer::Property::DEPTH_TEST_MODE, DepthTestMode::AUTO, DepthTestMode::OFF, DepthTestMode::ON, "ON" );
2271 CheckEnumerationProperty< StencilFunction::Type >( renderer, Renderer::Property::STENCIL_FUNCTION, StencilFunction::ALWAYS, StencilFunction::LESS, StencilFunction::EQUAL, "EQUAL" );
2272 CheckEnumerationProperty< RenderMode::Type >( renderer, Renderer::Property::RENDER_MODE, RenderMode::AUTO, RenderMode::NONE, RenderMode::STENCIL, "STENCIL" );
2273 CheckEnumerationProperty< StencilOperation::Type >( renderer, Renderer::Property::STENCIL_OPERATION_ON_FAIL, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT" );
2274 CheckEnumerationProperty< StencilOperation::Type >( renderer, Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT" );
2275 CheckEnumerationProperty< StencilOperation::Type >( renderer, Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT" );
2280 Renderer RendererTestFixture( TestApplication& application )
2282 Geometry geometry = CreateQuadGeometry();
2283 Shader shader = CreateShader();
2284 Renderer renderer = Renderer::New( geometry, shader );
2286 Actor actor = Actor::New();
2287 actor.AddRenderer( renderer );
2288 actor.SetSize( 400.0f, 400.0f );
2289 Stage stage = Stage::GetCurrent();
2290 stage.GetRootLayer().SetBehavior( Layer::LAYER_3D );
2296 int UtcDaliRendererSetDepthTestMode(void)
2298 TestApplication application;
2299 tet_infoline("Test setting the DepthTestMode");
2301 Renderer renderer = RendererTestFixture( application );
2302 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2303 glAbstraction.EnableEnableDisableCallTrace( true );
2304 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2306 glEnableDisableStack.Reset();
2307 application.SendNotification();
2308 application.Render();
2310 // Check depth-test is enabled by default.
2311 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetDepthTestString() ) );
2312 DALI_TEST_CHECK( !glEnableDisableStack.FindMethodAndParams( "Disable", GetDepthTestString() ) );
2314 // Turn off depth-testing. We want to check if the depth buffer has been disabled, so we need to turn off depth-write as well for this case.
2315 renderer.SetProperty( Renderer::Property::DEPTH_TEST_MODE, DepthTestMode::OFF );
2316 renderer.SetProperty( Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::OFF );
2318 glEnableDisableStack.Reset();
2319 application.SendNotification();
2320 application.Render();
2322 // Check the depth buffer was disabled.
2323 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Disable", GetDepthTestString() ) );
2325 // Turn on automatic mode depth-testing.
2326 // Layer behavior is currently set to LAYER_3D so AUTO should enable depth-testing.
2327 renderer.SetProperty( Renderer::Property::DEPTH_TEST_MODE, DepthTestMode::AUTO );
2329 glEnableDisableStack.Reset();
2330 application.SendNotification();
2331 application.Render();
2333 // Check depth-test is now enabled.
2334 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetDepthTestString() ) );
2335 DALI_TEST_CHECK( !glEnableDisableStack.FindMethodAndParams( "Disable", GetDepthTestString() ) );
2337 // Change the layer behavior to LAYER_2D.
2338 // Note this will also disable depth testing for the layer by default, we test this first.
2339 Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_2D );
2341 glEnableDisableStack.Reset();
2342 application.SendNotification();
2343 application.Render();
2345 // Check depth-test is disabled.
2346 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Disable", GetDepthTestString() ) );
2348 // Turn the layer depth-test flag back on, and confirm that depth testing is now on.
2349 Stage::GetCurrent().GetRootLayer().SetDepthTestDisabled( false );
2351 glEnableDisableStack.Reset();
2352 application.SendNotification();
2353 application.Render();
2355 // Check depth-test is *still* disabled.
2356 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetDepthTestString() ) );
2361 int UtcDaliRendererSetDepthWriteMode(void)
2363 TestApplication application;
2364 tet_infoline("Test setting the DepthWriteMode");
2366 Renderer renderer = RendererTestFixture( application );
2367 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2369 application.SendNotification();
2370 application.Render();
2372 // Check the default depth-write status first.
2373 DALI_TEST_CHECK( glAbstraction.GetLastDepthMask() );
2375 // Turn off depth-writing.
2376 renderer.SetProperty( Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::OFF );
2378 application.SendNotification();
2379 application.Render();
2381 // Check depth-write is now disabled.
2382 DALI_TEST_CHECK( !glAbstraction.GetLastDepthMask() );
2384 // Test the AUTO mode for depth-writing.
2385 // As our renderer is opaque, depth-testing should be enabled.
2386 renderer.SetProperty( Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::AUTO );
2388 application.SendNotification();
2389 application.Render();
2391 // Check depth-write is now enabled.
2392 DALI_TEST_CHECK( glAbstraction.GetLastDepthMask() );
2394 // Now make the renderer be treated as translucent by enabling blending.
2395 // The AUTO depth-write mode should turn depth-write off in this scenario.
2396 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON );
2398 application.SendNotification();
2399 application.Render();
2401 // Check depth-write is now disabled.
2402 DALI_TEST_CHECK( !glAbstraction.GetLastDepthMask() );
2407 int UtcDaliRendererCheckStencilDefaults(void)
2409 TestApplication application;
2410 tet_infoline("Test the stencil defaults");
2412 Renderer renderer = RendererTestFixture( application );
2413 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2414 glAbstraction.EnableEnableDisableCallTrace( true );
2415 glAbstraction.EnableStencilFunctionCallTrace( true );
2416 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2417 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
2419 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2421 // Check the defaults:
2422 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION ).Get<int>() ), static_cast<int>( StencilFunction::ALWAYS ), TEST_LOCATION );
2423 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION_MASK ).Get<int>() ), 0xFF, TEST_LOCATION );
2424 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION_REFERENCE ).Get<int>() ), 0x00, TEST_LOCATION );
2425 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_MASK ).Get<int>() ), 0xFF, TEST_LOCATION );
2426 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_OPERATION_ON_FAIL ).Get<int>() ), static_cast<int>( StencilOperation::KEEP ), TEST_LOCATION );
2427 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL ).Get<int>() ), static_cast<int>( StencilOperation::KEEP ), TEST_LOCATION );
2428 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_PASS ).Get<int>() ), static_cast<int>( StencilOperation::KEEP ), TEST_LOCATION );
2433 int UtcDaliRendererSetRenderModeToUseStencilBuffer(void)
2435 TestApplication application;
2436 tet_infoline("Test setting the RenderMode to use the stencil buffer");
2438 Renderer renderer = RendererTestFixture( application );
2439 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2440 glAbstraction.EnableEnableDisableCallTrace( true );
2441 glAbstraction.EnableStencilFunctionCallTrace( true );
2442 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2443 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
2445 // Set the StencilFunction to something other than the default, to confirm it is set as a property,
2446 // but NO GL call has been made while the RenderMode is set to not use the stencil buffer.
2447 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::NONE );
2448 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2450 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION, StencilFunction::NEVER );
2451 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION ).Get<int>() ), static_cast<int>( StencilFunction::NEVER ), TEST_LOCATION );
2453 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2454 std::string methodString( "StencilFunc" );
2455 DALI_TEST_CHECK( !glStencilFunctionStack.FindMethod( methodString ) );
2457 // Test the other RenderModes that will not enable the stencil buffer.
2458 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::AUTO );
2459 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2460 DALI_TEST_CHECK( !glStencilFunctionStack.FindMethod( methodString ) );
2462 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
2463 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2464 DALI_TEST_CHECK( !glStencilFunctionStack.FindMethod( methodString ) );
2466 // Now set the RenderMode to modes that will use the stencil buffer, and check the StencilFunction has changed.
2467 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL );
2468 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2470 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetStencilTestString() ) );
2471 DALI_TEST_CHECK( glStencilFunctionStack.FindMethod( methodString ) );
2473 // Test the COLOR_STENCIL RenderMode as it also enables the stencil buffer.
2474 // First set a mode to turn off the stencil buffer, so the enable is required.
2475 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
2476 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2477 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR_STENCIL );
2478 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2480 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetStencilTestString() ) );
2481 DALI_TEST_CHECK( glStencilFunctionStack.FindMethod( methodString ) );
2486 // Helper function for the SetRenderModeToUseColorBuffer test.
2487 void CheckRenderModeColorMask( TestApplication& application, Renderer& renderer, RenderMode::Type renderMode, bool expectedValue )
2489 // Set the RenderMode property to a value that should not allow color buffer writes.
2490 renderer.SetProperty( Renderer::Property::RENDER_MODE, renderMode );
2491 application.SendNotification();
2492 application.Render();
2494 // Check if ColorMask has been called, and that the values are correct.
2495 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2496 const TestGlAbstraction::ColorMaskParams& colorMaskParams( glAbstraction.GetColorMaskParams() );
2498 DALI_TEST_EQUALS<bool>( colorMaskParams.red, expectedValue, TEST_LOCATION );
2499 DALI_TEST_EQUALS<bool>( colorMaskParams.green, expectedValue, TEST_LOCATION );
2500 DALI_TEST_EQUALS<bool>( colorMaskParams.blue, expectedValue, TEST_LOCATION );
2501 DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, expectedValue, TEST_LOCATION );
2504 int UtcDaliRendererSetRenderModeToUseColorBuffer(void)
2506 TestApplication application;
2507 tet_infoline("Test setting the RenderMode to use the color buffer");
2509 Renderer renderer = RendererTestFixture( application );
2511 // Set the RenderMode property to a value that should not allow color buffer writes.
2512 // Then check if ColorMask has been called, and that the values are correct.
2513 CheckRenderModeColorMask( application, renderer, RenderMode::AUTO, true );
2514 CheckRenderModeColorMask( application, renderer, RenderMode::NONE, false );
2515 CheckRenderModeColorMask( application, renderer, RenderMode::COLOR, true );
2516 CheckRenderModeColorMask( application, renderer, RenderMode::STENCIL, false );
2517 CheckRenderModeColorMask( application, renderer, RenderMode::COLOR_STENCIL, true );
2522 int UtcDaliRendererSetStencilFunction(void)
2524 TestApplication application;
2525 tet_infoline("Test setting the StencilFunction");
2527 Renderer renderer = RendererTestFixture( application );
2528 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2529 glAbstraction.EnableEnableDisableCallTrace( true );
2530 glAbstraction.EnableStencilFunctionCallTrace( true );
2531 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2532 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
2534 // RenderMode must use the stencil for StencilFunction to operate.
2535 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL );
2536 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2539 * Lookup table for testing StencilFunction.
2540 * Note: This MUST be in the same order as the Dali::StencilFunction enum.
2542 const int StencilFunctionLookupTable[] = {
2551 }; const int StencilFunctionLookupTableCount = sizeof( StencilFunctionLookupTable ) / sizeof( StencilFunctionLookupTable[0] );
2554 * Loop through all types of StencilFunction, checking:
2555 * - The value is cached (set in event thread side)
2556 * - Causes "glStencilFunc" to be called
2557 * - Checks the correct parameters to "glStencilFunc" were used
2559 std::string nonChangingParameters = "0, 255";
2560 std::string methodString( "StencilFunc" );
2561 for( int i = 0; i < StencilFunctionLookupTableCount; ++i )
2563 // Set the property.
2564 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION, static_cast<Dali::StencilFunction::Type>( i ) );
2566 // Check GetProperty returns the same value.
2567 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION ).Get<int>() ), i, TEST_LOCATION );
2569 // Reset the trace debug.
2570 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2572 // Check the function is called and the parameters are correct.
2573 std::stringstream parameterStream;
2574 parameterStream << StencilFunctionLookupTable[ i ] << ", " << nonChangingParameters;
2576 DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterStream.str() ) );
2579 // Change the Function Reference only and check the behavior is correct:
2580 // 170 is 0xaa in hex / 10101010 in binary (every other bit set).
2581 int testValueReference = 170;
2582 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION_REFERENCE, testValueReference );
2584 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION_REFERENCE ).Get<int>() ), testValueReference, TEST_LOCATION );
2586 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2588 std::stringstream parameterStream;
2589 parameterStream << StencilFunctionLookupTable[ StencilOperation::DECREMENT_WRAP ] << ", " << testValueReference << ", 255";
2591 DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterStream.str() ) );
2594 // Change the Function Mask only and check the behavior is correct:
2595 // 85 is 0x55 in hex / 01010101 in binary (every other bit set).
2596 int testValueMask = 85;
2597 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION_MASK, testValueMask );
2599 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION_MASK ).Get<int>() ), testValueMask, TEST_LOCATION );
2601 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2603 // Clear the stringstream.
2604 parameterStream.str( std::string() );
2605 parameterStream << StencilFunctionLookupTable[ StencilOperation::DECREMENT_WRAP ] << ", " << testValueReference << ", " << testValueMask;
2607 DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterStream.str() ) );
2612 int UtcDaliRendererSetStencilOperation(void)
2614 TestApplication application;
2615 tet_infoline("Test setting the StencilOperation");
2617 Renderer renderer = RendererTestFixture( application );
2618 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2619 glAbstraction.EnableEnableDisableCallTrace( true );
2620 glAbstraction.EnableStencilFunctionCallTrace( true );
2621 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2622 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
2624 // RenderMode must use the stencil for StencilOperation to operate.
2625 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL );
2628 * Lookup table for testing StencilOperation.
2629 * Note: This MUST be in the same order as the Dali::StencilOperation enum.
2631 const int StencilOperationLookupTable[] = {
2640 }; const int StencilOperationLookupTableCount = sizeof( StencilOperationLookupTable ) / sizeof( StencilOperationLookupTable[0] );
2642 // Set all 3 StencilOperation properties to a default.
2643 renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_FAIL, StencilOperation::ZERO );
2644 renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, StencilOperation::ZERO );
2645 renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, StencilOperation::ZERO );
2647 // Set our expected parameter list to the equivalent result.
2648 int parameters[] = { StencilOperationLookupTable[ StencilOperation::ZERO ], StencilOperationLookupTable[ StencilOperation::ZERO ], StencilOperationLookupTable[ StencilOperation::ZERO ] };
2650 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2653 * Loop through all types of StencilOperation, checking:
2654 * - The value is cached (set in event thread side)
2655 * - Causes "glStencilFunc" to be called
2656 * - Checks the correct parameters to "glStencilFunc" were used
2657 * - Checks the above for all 3 parameter placements of StencilOperation ( OnFail, OnZFail, OnPass )
2659 int stencilOperationPropertyKeys[] = { Renderer::Property::STENCIL_OPERATION_ON_FAIL, Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, Renderer::Property::STENCIL_OPERATION_ON_Z_PASS };
2660 std::string methodString( "StencilOp" );
2662 for( int parameterIndex = 0; parameterIndex < 3; ++parameterIndex )
2664 for( int i = 0; i < StencilOperationLookupTableCount; ++i )
2666 // Set the property (outer loop causes all 3 different properties to be set separately).
2667 renderer.SetProperty( stencilOperationPropertyKeys[ parameterIndex ], static_cast<Dali::StencilFunction::Type>( i ) );
2669 // Check GetProperty returns the same value.
2670 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( stencilOperationPropertyKeys[ parameterIndex ] ).Get<int>() ), i, TEST_LOCATION );
2672 // Reset the trace debug.
2673 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2675 // Check the function is called and the parameters are correct.
2676 // Set the expected parameter value at its correct index (only)
2677 parameters[ parameterIndex ] = StencilOperationLookupTable[ i ];
2679 // Build the parameter list.
2680 std::stringstream parameterStream;
2681 for( int parameterBuild = 0; parameterBuild < 3; ++parameterBuild )
2683 parameterStream << parameters[ parameterBuild ];
2684 // Comma-separate the parameters.
2685 if( parameterBuild < 2 )
2687 parameterStream << ", ";
2691 // Check the function was called and the parameters were correct.
2692 DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterStream.str() ) );
2699 int UtcDaliRendererSetStencilMask(void)
2701 TestApplication application;
2702 tet_infoline("Test setting the StencilMask");
2704 Renderer renderer = RendererTestFixture( application );
2705 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2706 glAbstraction.EnableEnableDisableCallTrace( true );
2707 glAbstraction.EnableStencilFunctionCallTrace( true );
2708 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2709 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
2711 // RenderMode must use the stencil for StencilMask to operate.
2712 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL );
2714 // Set the StencilMask property to a value.
2715 renderer.SetProperty( Renderer::Property::STENCIL_MASK, 0x00 );
2717 // Check GetProperty returns the same value.
2718 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_MASK ).Get<int>() ), 0x00, TEST_LOCATION );
2720 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2722 std::string methodString( "StencilMask" );
2723 std::string parameterString = "0";
2725 // Check the function was called and the parameters were correct.
2726 DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterString ) );
2728 // Set the StencilMask property to another value to ensure it has changed.
2729 renderer.SetProperty( Renderer::Property::STENCIL_MASK, 0xFF );
2731 // Check GetProperty returns the same value.
2732 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_MASK ).Get<int>() ), 0xFF, TEST_LOCATION );
2734 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2736 parameterString = "255";
2738 // Check the function was called and the parameters were correct.
2739 DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterString ) );
2744 int UtcDaliRendererWrongNumberOfTextures(void)
2746 TestApplication application;
2747 tet_infoline("Test renderer does render even if number of textures is different than active samplers in the shader");
2749 //Create a TextureSet with 4 textures (One more texture in the texture set than active samplers)
2750 //@note Shaders in the test suit have 3 active samplers. See TestGlAbstraction::GetActiveUniform()
2751 Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 64u, 64u );
2752 TextureSet textureSet = CreateTextureSet();
2753 textureSet.SetTexture(0, texture );
2754 textureSet.SetTexture(1, texture );
2755 textureSet.SetTexture(2, texture );
2756 textureSet.SetTexture(3, texture );
2757 Shader shader = Shader::New("VertexSource", "FragmentSource");
2758 Geometry geometry = CreateQuadGeometry();
2759 Renderer renderer = Renderer::New( geometry, shader );
2760 renderer.SetTextures( textureSet );
2762 Actor actor= Actor::New();
2763 actor.AddRenderer(renderer);
2764 actor.SetPosition(0.0f,0.0f);
2765 actor.SetSize(100, 100);
2766 Stage::GetCurrent().Add(actor);
2768 TestGlAbstraction& gl = application.GetGlAbstraction();
2769 TraceCallStack& drawTrace = gl.GetDrawTrace();
2771 drawTrace.Enable(true);
2773 application.SendNotification();
2774 application.Render(0);
2776 //Test we do the drawcall when TextureSet has more textures than there are active samplers in the shader
2777 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION );
2779 //Create a TextureSet with 1 texture (two more active samplers than texture in the texture set)
2780 //@note Shaders in the test suit have 3 active samplers. See TestGlAbstraction::GetActiveUniform()
2781 textureSet = CreateTextureSet();
2782 renderer.SetTextures( textureSet );
2783 textureSet.SetTexture(0, texture );
2785 application.SendNotification();
2786 application.Render(0);
2788 //Test we do the drawcall when TextureSet has less textures than there are active samplers in the shader.
2789 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION );