2 * Copyright (c) 2016 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/public-api/dali-core.h>
20 #include <dali/devel-api/images/texture-set-image.h>
25 #include <dali-test-suite-utils.h>
26 #include <test-trace-call-stack.h>
27 #include <mesh-builder.h>
31 namespace // unnamed namespace
34 const BlendFactor::Type DEFAULT_BLEND_FACTOR_SRC_RGB( BlendFactor::SRC_ALPHA );
35 const BlendFactor::Type DEFAULT_BLEND_FACTOR_DEST_RGB( BlendFactor::ONE_MINUS_SRC_ALPHA );
36 const BlendFactor::Type DEFAULT_BLEND_FACTOR_SRC_ALPHA( BlendFactor::ONE );
37 const BlendFactor::Type DEFAULT_BLEND_FACTOR_DEST_ALPHA( BlendFactor::ONE_MINUS_SRC_ALPHA );
39 const BlendEquation::Type DEFAULT_BLEND_EQUATION_RGB( BlendEquation::ADD );
40 const BlendEquation::Type DEFAULT_BLEND_EQUATION_ALPHA( BlendEquation::ADD );
43 * @brief Get GL stencil test enumeration value as a string.
44 * @return The string representation of the value of GL_STENCIL_TEST
46 std::string GetStencilTestString(void)
48 std::stringstream stream;
49 stream << GL_STENCIL_TEST;
53 void ResetDebugAndFlush( TestApplication& application, TraceCallStack& glEnableDisableStack, TraceCallStack& glStencilFunctionStack )
55 glEnableDisableStack.Reset();
56 glStencilFunctionStack.Reset();
57 application.SendNotification();
61 void TestConstraintNoBlue( Vector4& current, const PropertyInputContainer& inputs )
66 } // unnamed namespace
68 void renderer_test_startup(void)
70 test_return_value = TET_UNDEF;
73 void renderer_test_cleanup(void)
75 test_return_value = TET_PASS;
79 int UtcDaliRendererNew01(void)
81 TestApplication application;
83 Geometry geometry = CreateQuadGeometry();
84 Shader shader = CreateShader();
85 Renderer renderer = Renderer::New(geometry, shader);
87 DALI_TEST_EQUALS( (bool)renderer, true, TEST_LOCATION );
91 int UtcDaliRendererNew02(void)
93 TestApplication application;
95 DALI_TEST_EQUALS( (bool)renderer, false, TEST_LOCATION );
99 int UtcDaliRendererCopyConstructor(void)
101 TestApplication application;
103 Geometry geometry = CreateQuadGeometry();
104 Shader shader = CreateShader();
105 Renderer renderer = Renderer::New(geometry, shader);
107 Renderer rendererCopy( renderer );
108 DALI_TEST_EQUALS( (bool)rendererCopy, true, TEST_LOCATION );
113 int UtcDaliRendererAssignmentOperator(void)
115 TestApplication application;
117 Geometry geometry = CreateQuadGeometry();
118 Shader shader = CreateShader();
119 Renderer renderer = Renderer::New(geometry, shader);
122 DALI_TEST_EQUALS( (bool)renderer2, false, TEST_LOCATION );
124 renderer2 = renderer;
125 DALI_TEST_EQUALS( (bool)renderer2, true, TEST_LOCATION );
129 int UtcDaliRendererDownCast01(void)
131 TestApplication application;
133 Geometry geometry = CreateQuadGeometry();
134 Shader shader = CreateShader();
135 Renderer renderer = Renderer::New(geometry, shader);
137 BaseHandle handle(renderer);
138 Renderer renderer2 = Renderer::DownCast(handle);
139 DALI_TEST_EQUALS( (bool)renderer2, true, TEST_LOCATION );
143 int UtcDaliRendererDownCast02(void)
145 TestApplication application;
147 Handle handle = Handle::New(); // Create a custom object
148 Renderer renderer = Renderer::DownCast(handle);
149 DALI_TEST_EQUALS( (bool)renderer, false, TEST_LOCATION );
153 int UtcDaliRendererSetGetGeometry(void)
155 TestApplication application;
156 tet_infoline( "Test SetGeometry, GetGeometry" );
158 Geometry geometry1 = CreateQuadGeometry();
159 Geometry geometry2 = CreateQuadGeometry();
161 Shader shader = CreateShader();
162 Renderer renderer = Renderer::New(geometry1, shader);
163 Actor actor = Actor::New();
164 actor.AddRenderer(renderer);
165 actor.SetSize(400, 400);
166 Stage::GetCurrent().Add(actor);
168 application.SendNotification();
169 application.Render(0);
170 DALI_TEST_EQUALS( renderer.GetGeometry(), geometry1, TEST_LOCATION );
172 // Set geometry2 to the renderer
173 renderer.SetGeometry( geometry2 );
175 application.SendNotification();
176 application.Render(0);
177 DALI_TEST_EQUALS( renderer.GetGeometry(), geometry2, TEST_LOCATION );
182 int UtcDaliRendererSetGetShader(void)
184 TestApplication application;
185 tet_infoline( "Test SetShader, GetShader" );
187 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
188 glAbstraction.EnableCullFaceCallTrace(true);
190 Shader shader1 = CreateShader();
191 shader1.RegisterProperty( "uFadeColor", Color::RED );
193 Shader shader2 = CreateShader();
194 shader2.RegisterProperty( "uFadeColor", Color::GREEN );
196 Geometry geometry = CreateQuadGeometry();
197 Renderer renderer = Renderer::New(geometry, shader1);
198 Actor actor = Actor::New();
199 actor.AddRenderer(renderer);
200 actor.SetSize(400, 400);
201 Stage::GetCurrent().Add(actor);
203 TestGlAbstraction& gl = application.GetGlAbstraction();
204 application.SendNotification();
205 application.Render(0);
207 // Expect that the first shaders's fade color property is accessed
208 Vector4 actualValue(Vector4::ZERO);
209 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
210 DALI_TEST_EQUALS( actualValue, Color::RED, TEST_LOCATION );
212 DALI_TEST_EQUALS( renderer.GetShader(), shader1, TEST_LOCATION );
214 // set the second shader to the renderer
215 renderer.SetShader( shader2 );
217 application.SendNotification();
218 application.Render(0);
220 // Expect that the second shader's fade color property is accessed
221 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
222 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
224 DALI_TEST_EQUALS( renderer.GetShader(), shader2, TEST_LOCATION );
229 int UtcDaliRendererSetGetDepthIndex(void)
231 TestApplication application;
233 tet_infoline("Test SetDepthIndex, GetDepthIndex");
235 Shader shader = CreateShader();
236 Geometry geometry = CreateQuadGeometry();
237 Renderer renderer = Renderer::New(geometry, shader);
238 Actor actor = Actor::New();
239 actor.AddRenderer(renderer);
240 actor.SetSize(400, 400);
241 Stage::GetCurrent().Add(actor);
243 application.SendNotification();
244 application.Render(0);
245 DALI_TEST_EQUALS( renderer.GetProperty<int>(Renderer::Property::DEPTH_INDEX), 0, TEST_LOCATION );
247 renderer.SetProperty( Renderer::Property::DEPTH_INDEX, 1 );
249 application.SendNotification();
250 application.Render(0);
251 DALI_TEST_EQUALS( renderer.GetProperty<int>(Renderer::Property::DEPTH_INDEX), 1, TEST_LOCATION );
253 renderer.SetProperty( Renderer::Property::DEPTH_INDEX, 10 );
255 application.SendNotification();
256 application.Render(0);
257 DALI_TEST_EQUALS( renderer.GetProperty<int>(Renderer::Property::DEPTH_INDEX), 10, TEST_LOCATION );
262 int UtcDaliRendererSetGetFaceCullingMode(void)
264 TestApplication application;
266 tet_infoline("Test SetFaceCullingMode(cullingMode)");
267 Geometry geometry = CreateQuadGeometry();
268 Shader shader = CreateShader();
269 Renderer renderer = Renderer::New( geometry, shader );
271 Actor actor = Actor::New();
272 actor.AddRenderer(renderer);
273 actor.SetSize(400, 400);
274 Stage::GetCurrent().Add(actor);
276 // By default, none of the faces should be culled
277 unsigned int cullFace = renderer.GetProperty<int>( Renderer::Property::FACE_CULLING_MODE );
278 DALI_TEST_CHECK( static_cast< FaceCullingMode::Type >( cullFace ) == FaceCullingMode::NONE );
280 TestGlAbstraction& gl = application.GetGlAbstraction();
281 TraceCallStack& cullFaceStack = gl.GetCullFaceTrace();
282 gl.EnableCullFaceCallTrace(true);
285 cullFaceStack.Reset();
286 renderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::FRONT_AND_BACK );
287 application.SendNotification();
288 application.Render();
290 DALI_TEST_EQUALS( cullFaceStack.CountMethod( "CullFace" ), 1, TEST_LOCATION );
292 std::ostringstream cullModeString;
293 cullModeString << GL_FRONT_AND_BACK;
295 DALI_TEST_CHECK( cullFaceStack.FindMethodAndParams( "CullFace", cullModeString.str() ) );
296 cullFace = renderer.GetProperty<int>( Renderer::Property::FACE_CULLING_MODE );
297 DALI_TEST_CHECK( static_cast< FaceCullingMode::Type >( cullFace ) == FaceCullingMode::FRONT_AND_BACK );
301 cullFaceStack.Reset();
302 renderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::BACK );
303 application.SendNotification();
304 application.Render();
306 DALI_TEST_EQUALS( cullFaceStack.CountMethod( "CullFace" ), 1, TEST_LOCATION );
308 std::ostringstream cullModeString;
309 cullModeString << GL_BACK;
311 DALI_TEST_CHECK( cullFaceStack.FindMethodAndParams( "CullFace", cullModeString.str() ) );
312 cullFace = renderer.GetProperty<int>( Renderer::Property::FACE_CULLING_MODE );
313 DALI_TEST_CHECK( static_cast< FaceCullingMode::Type >( cullFace ) == FaceCullingMode::BACK );
317 cullFaceStack.Reset();
318 renderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::FRONT );
319 application.SendNotification();
320 application.Render();
322 DALI_TEST_EQUALS( cullFaceStack.CountMethod( "CullFace" ), 1, TEST_LOCATION );
324 std::ostringstream cullModeString;
325 cullModeString << GL_FRONT;
327 DALI_TEST_CHECK( cullFaceStack.FindMethodAndParams( "CullFace", cullModeString.str() ) );
328 cullFace = renderer.GetProperty<int>( Renderer::Property::FACE_CULLING_MODE );
329 DALI_TEST_CHECK( static_cast< FaceCullingMode::Type >( cullFace ) == FaceCullingMode::FRONT );
333 cullFaceStack.Reset();
334 renderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::NONE );
335 application.SendNotification();
336 application.Render();
338 DALI_TEST_EQUALS( cullFaceStack.CountMethod( "CullFace" ), 0, TEST_LOCATION );
339 cullFace = renderer.GetProperty<int>( Renderer::Property::FACE_CULLING_MODE );
340 DALI_TEST_CHECK( static_cast< FaceCullingMode::Type >( cullFace ) == FaceCullingMode::NONE );
346 int UtcDaliRendererBlendOptions01(void)
348 TestApplication application;
350 tet_infoline("Test BLEND_FACTOR properties ");
352 Geometry geometry = CreateQuadGeometry();
353 Shader shader = CreateShader();
354 Renderer renderer = Renderer::New( geometry, shader );
356 Actor actor = Actor::New();
357 // set a transparent actor color so that blending is enabled
358 actor.SetOpacity( 0.5f );
359 actor.AddRenderer(renderer);
360 actor.SetSize(400, 400);
361 Stage::GetCurrent().Add(actor);
363 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::ONE_MINUS_SRC_COLOR );
364 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::SRC_ALPHA_SATURATE );
365 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE_MINUS_SRC_COLOR );
366 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::SRC_ALPHA_SATURATE );
368 // Test that Set was successful:
369 int srcFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
370 int destFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
371 int srcFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
372 int destFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
374 DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_SRC_COLOR, srcFactorRgb, TEST_LOCATION );
375 DALI_TEST_EQUALS( (int)BlendFactor::SRC_ALPHA_SATURATE, destFactorRgb, TEST_LOCATION );
376 DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_SRC_COLOR, srcFactorAlpha, TEST_LOCATION );
377 DALI_TEST_EQUALS( (int)BlendFactor::SRC_ALPHA_SATURATE, destFactorAlpha, TEST_LOCATION );
379 application.SendNotification();
380 application.Render();
382 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
384 DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_SRC_COLOR, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION );
385 DALI_TEST_EQUALS( (GLenum)GL_SRC_ALPHA_SATURATE, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION );
386 DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_SRC_COLOR, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION );
387 DALI_TEST_EQUALS( (GLenum)GL_SRC_ALPHA_SATURATE, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION );
392 int UtcDaliRendererBlendOptions02(void)
394 TestApplication application;
396 tet_infoline("Test BLEND_FACTOR properties ");
398 Geometry geometry = CreateQuadGeometry();
399 Shader shader = CreateShader();
400 Renderer renderer = Renderer::New( geometry, shader );
402 Actor actor = Actor::New();
403 actor.SetOpacity( 0.5f ); // enable blending
404 actor.AddRenderer(renderer);
405 actor.SetSize(400, 400);
406 Stage::GetCurrent().Add(actor);
408 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::CONSTANT_COLOR );
409 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ONE_MINUS_CONSTANT_COLOR );
410 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::CONSTANT_ALPHA );
411 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ONE_MINUS_CONSTANT_ALPHA );
413 // Test that Set was successful:
415 int srcFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
416 int destFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
417 int srcFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
418 int destFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
420 DALI_TEST_EQUALS( (int)BlendFactor::CONSTANT_COLOR, srcFactorRgb, TEST_LOCATION );
421 DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_CONSTANT_COLOR, destFactorRgb, TEST_LOCATION );
422 DALI_TEST_EQUALS( (int)BlendFactor::CONSTANT_ALPHA, srcFactorAlpha, TEST_LOCATION );
423 DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_CONSTANT_ALPHA, destFactorAlpha, TEST_LOCATION );
426 application.SendNotification();
427 application.Render();
429 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
430 DALI_TEST_EQUALS( (GLenum)GL_CONSTANT_COLOR, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION );
431 DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_CONSTANT_COLOR, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION );
432 DALI_TEST_EQUALS( (GLenum)GL_CONSTANT_ALPHA, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION );
433 DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_CONSTANT_ALPHA, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION );
438 int UtcDaliRendererBlendOptions03(void)
440 TestApplication application;
442 tet_infoline("Test GetBlendEquation() defaults ");
444 Geometry geometry = CreateQuadGeometry();
445 Shader shader = CreateShader();
446 Renderer renderer = Renderer::New( geometry, shader );
448 Actor actor = Actor::New();
449 actor.AddRenderer(renderer);
450 actor.SetSize(400, 400);
451 Stage::GetCurrent().Add(actor);
453 // Test the defaults as documented in blending.h
454 int equationRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_EQUATION_RGB );
455 int equationAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_EQUATION_ALPHA );
457 DALI_TEST_EQUALS( (int)BlendEquation::ADD, equationRgb, TEST_LOCATION );
458 DALI_TEST_EQUALS( (int)BlendEquation::ADD, equationAlpha, TEST_LOCATION );
463 int UtcDaliRendererBlendOptions04(void)
465 TestApplication application;
467 tet_infoline("Test SetBlendEquation() ");
469 Geometry geometry = CreateQuadGeometry();
470 Shader shader = CreateShader();
471 Renderer renderer = Renderer::New( geometry, shader );
473 Actor actor = Actor::New();
474 actor.SetOpacity( 0.1f );
475 actor.AddRenderer(renderer);
476 actor.SetSize(400, 400);
477 Stage::GetCurrent().Add(actor);
479 // Test the single blending equation setting
481 renderer.SetProperty( Renderer::Property::BLEND_EQUATION_RGB, BlendEquation::REVERSE_SUBTRACT );
482 int equationRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_EQUATION_RGB );
483 DALI_TEST_EQUALS( (int)BlendEquation::REVERSE_SUBTRACT, equationRgb, TEST_LOCATION );
486 renderer.SetProperty( Renderer::Property::BLEND_EQUATION_RGB, BlendEquation::REVERSE_SUBTRACT );
487 renderer.SetProperty( Renderer::Property::BLEND_EQUATION_ALPHA, BlendEquation::REVERSE_SUBTRACT );
489 // Test that Set was successful
491 int equationRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_EQUATION_RGB );
492 int equationAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_EQUATION_ALPHA );
493 DALI_TEST_EQUALS( (int)BlendEquation::REVERSE_SUBTRACT, equationRgb, TEST_LOCATION );
494 DALI_TEST_EQUALS( (int)BlendEquation::REVERSE_SUBTRACT, equationAlpha, TEST_LOCATION );
497 // Render & check GL commands
498 application.SendNotification();
499 application.Render();
501 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
502 DALI_TEST_EQUALS( (GLenum)GL_FUNC_REVERSE_SUBTRACT, glAbstraction.GetLastBlendEquationRgb(), TEST_LOCATION );
503 DALI_TEST_EQUALS( (GLenum)GL_FUNC_REVERSE_SUBTRACT, glAbstraction.GetLastBlendEquationAlpha(), TEST_LOCATION );
508 int UtcDaliRendererSetBlendMode01(void)
510 TestApplication application;
512 tet_infoline("Test setting the blend mode to on with an opaque color renders with blending enabled");
514 Geometry geometry = CreateQuadGeometry();
515 Shader shader = CreateShader();
516 Renderer renderer = Renderer::New( geometry, shader );
518 Actor actor = Actor::New();
519 actor.SetOpacity( 0.98f );
520 actor.AddRenderer(renderer);
521 actor.SetSize(400, 400);
522 Stage::GetCurrent().Add(actor);
524 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON);
526 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
527 glAbstraction.EnableEnableDisableCallTrace(true);
529 application.SendNotification();
530 application.Render();
532 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
533 std::ostringstream blendStr;
534 blendStr << GL_BLEND;
535 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
540 int UtcDaliRendererSetBlendMode02(void)
542 TestApplication application;
544 tet_infoline("Test setting the blend mode to off with a transparent color renders with blending disabled (and not enabled)");
546 Geometry geometry = CreateQuadGeometry();
547 Shader shader = CreateShader();
548 Renderer renderer = Renderer::New( geometry, shader );
550 Actor actor = Actor::New();
551 actor.SetOpacity( 0.15f );
552 actor.AddRenderer(renderer);
553 actor.SetSize(400, 400);
554 Stage::GetCurrent().Add(actor);
556 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::OFF);
558 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
559 glAbstraction.EnableEnableDisableCallTrace(true);
561 application.SendNotification();
562 application.Render();
564 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
565 std::ostringstream blendStr;
566 blendStr << GL_BLEND;
567 DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
572 int UtcDaliRendererSetBlendMode03(void)
574 TestApplication application;
576 tet_infoline("Test setting the blend mode to auto with a transparent color renders with blending enabled");
578 Geometry geometry = CreateQuadGeometry();
579 Shader shader = CreateShader();
580 Renderer renderer = Renderer::New( geometry, shader );
582 Actor actor = Actor::New();
583 actor.SetOpacity( 0.75f );
584 actor.AddRenderer(renderer);
585 actor.SetSize(400, 400);
586 Stage::GetCurrent().Add(actor);
588 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO);
590 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
591 glAbstraction.EnableEnableDisableCallTrace(true);
593 application.SendNotification();
594 application.Render();
596 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
597 std::ostringstream blendStr;
598 blendStr << GL_BLEND;
599 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
604 int UtcDaliRendererSetBlendMode04(void)
606 TestApplication application;
608 tet_infoline("Test setting the blend mode to auto with an opaque color renders with blending disabled");
610 Geometry geometry = CreateQuadGeometry();
611 Shader shader = CreateShader();
612 Renderer renderer = Renderer::New( geometry, shader );
614 Actor actor = Actor::New();
615 actor.AddRenderer(renderer);
616 actor.SetSize(400, 400);
617 Stage::GetCurrent().Add(actor);
619 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO);
621 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
622 glAbstraction.EnableEnableDisableCallTrace(true);
624 application.SendNotification();
625 application.Render();
627 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
628 std::ostringstream blendStr;
629 blendStr << GL_BLEND;
630 DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
635 int UtcDaliRendererSetBlendMode04b(void)
637 TestApplication application;
639 tet_infoline("Test setting the blend mode to auto with a transparent actor color renders with blending enabled");
641 Geometry geometry = CreateQuadGeometry();
642 Shader shader = CreateShader();
643 Renderer renderer = Renderer::New( geometry, shader );
645 Actor actor = Actor::New();
646 actor.AddRenderer(renderer);
647 actor.SetSize(400, 400);
648 actor.SetColor( Vector4(1.0f, 0.0f, 1.0f, 0.5f) );
649 Stage::GetCurrent().Add(actor);
651 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO);
653 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
654 glAbstraction.EnableEnableDisableCallTrace(true);
656 application.SendNotification();
657 application.Render();
659 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
660 std::ostringstream blendStr;
661 blendStr << GL_BLEND;
662 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
667 int UtcDaliRendererSetBlendMode04c(void)
669 TestApplication application;
671 tet_infoline("Test setting the blend mode to auto with an opaque opaque actor color renders with blending disabled");
673 Geometry geometry = CreateQuadGeometry();
674 Shader shader = CreateShader();
675 Renderer renderer = Renderer::New( geometry, shader );
677 Actor actor = Actor::New();
678 actor.AddRenderer(renderer);
679 actor.SetSize(400, 400);
680 actor.SetColor( Color::MAGENTA );
681 Stage::GetCurrent().Add(actor);
683 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO);
685 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
686 glAbstraction.EnableEnableDisableCallTrace(true);
688 application.SendNotification();
689 application.Render();
691 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
692 std::ostringstream blendStr;
693 blendStr << GL_BLEND;
694 DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
699 int UtcDaliRendererSetBlendMode05(void)
701 TestApplication application;
703 tet_infoline("Test setting the blend mode to auto with an opaque color and an image with an alpha channel renders with blending enabled");
705 Geometry geometry = CreateQuadGeometry();
706 BufferImage image = BufferImage::New( 40, 40, Pixel::RGBA8888 );
708 Shader shader = CreateShader();
709 TextureSet textureSet = CreateTextureSet( image );
710 Renderer renderer = Renderer::New( geometry, shader );
711 renderer.SetTextures( textureSet );
713 Actor actor = Actor::New();
714 actor.AddRenderer(renderer);
715 actor.SetSize(400, 400);
716 Stage::GetCurrent().Add(actor);
718 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO);
720 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
721 glAbstraction.EnableEnableDisableCallTrace(true);
723 application.SendNotification();
724 application.Render();
726 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
727 std::ostringstream blendStr;
728 blendStr << GL_BLEND;
729 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
734 int UtcDaliRendererSetBlendMode06(void)
736 TestApplication application;
737 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");
739 Geometry geometry = CreateQuadGeometry();
740 Shader shader = Shader::New( "vertexSrc", "fragmentSrc", Shader::Hint::OUTPUT_IS_TRANSPARENT );
742 Renderer renderer = Renderer::New( geometry, shader );
744 Actor actor = Actor::New();
745 actor.AddRenderer(renderer);
746 actor.SetSize(400, 400);
747 Stage::GetCurrent().Add(actor);
749 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO);
751 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
752 glAbstraction.EnableEnableDisableCallTrace(true);
754 application.SendNotification();
755 application.Render();
757 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
758 std::ostringstream blendStr;
759 blendStr << GL_BLEND;
760 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
765 int UtcDaliRendererSetBlendMode07(void)
767 TestApplication application;
768 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");
770 Geometry geometry = CreateQuadGeometry();
771 Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
773 BufferImage image = BufferImage::New( 50, 50, Pixel::RGB888 );
774 TextureSet textureSet = CreateTextureSet( image );
775 Renderer renderer = Renderer::New( geometry, shader );
776 renderer.SetTextures( textureSet );
778 Actor actor = Actor::New();
779 actor.AddRenderer(renderer);
780 actor.SetSize(400, 400);
781 Stage::GetCurrent().Add(actor);
783 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO);
785 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
786 glAbstraction.EnableEnableDisableCallTrace(true);
788 application.SendNotification();
789 application.Render();
791 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
792 DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", "GL_BLEND" ) );
797 int UtcDaliRendererGetBlendMode(void)
799 TestApplication application;
801 tet_infoline("Test GetBlendMode()");
803 Geometry geometry = CreateQuadGeometry();
804 Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
805 Renderer renderer = Renderer::New( geometry, shader );
808 unsigned int mode = renderer.GetProperty<int>( Renderer::Property::BLEND_MODE );
809 DALI_TEST_EQUALS( static_cast< BlendMode::Type >( mode ), BlendMode::AUTO, TEST_LOCATION );
812 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON );
813 mode = renderer.GetProperty<int>( Renderer::Property::BLEND_MODE );
814 DALI_TEST_EQUALS( static_cast< BlendMode::Type >( mode ), BlendMode::ON, TEST_LOCATION );
817 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::OFF );
818 mode = renderer.GetProperty<int>( Renderer::Property::BLEND_MODE );
819 DALI_TEST_EQUALS( static_cast< BlendMode::Type >( mode ), BlendMode::OFF, TEST_LOCATION );
824 int UtcDaliRendererSetBlendColor(void)
826 TestApplication application;
828 tet_infoline("Test SetBlendColor(color)");
830 Geometry geometry = CreateQuadGeometry();
831 Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
832 TextureSet textureSet = TextureSet::New();
833 BufferImage image = BufferImage::New( 50, 50, Pixel::RGBA8888 );
834 TextureSetImage( textureSet, 0u, image );
835 Renderer renderer = Renderer::New( geometry, shader );
836 renderer.SetTextures( textureSet );
838 Actor actor = Actor::New();
839 actor.AddRenderer(renderer);
840 actor.SetSize(400, 400);
841 Stage::GetCurrent().Add(actor);
843 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
845 renderer.SetProperty( Renderer::Property::BLEND_COLOR, Color::TRANSPARENT );
846 application.SendNotification();
847 application.Render();
848 DALI_TEST_EQUALS( glAbstraction.GetLastBlendColor(), Color::TRANSPARENT, TEST_LOCATION );
850 renderer.SetProperty( Renderer::Property::BLEND_COLOR, Color::MAGENTA );
851 application.SendNotification();
852 application.Render();
853 DALI_TEST_EQUALS( glAbstraction.GetLastBlendColor(), Color::MAGENTA, TEST_LOCATION );
855 Vector4 color( 0.1f, 0.2f, 0.3f, 0.4f );
856 renderer.SetProperty( Renderer::Property::BLEND_COLOR, color );
857 application.SendNotification();
858 application.Render();
859 DALI_TEST_EQUALS( glAbstraction.GetLastBlendColor(), color, TEST_LOCATION );
864 int UtcDaliRendererGetBlendColor(void)
866 TestApplication application;
868 tet_infoline("Test GetBlendColor()");
870 Geometry geometry = CreateQuadGeometry();
871 Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
872 Renderer renderer = Renderer::New( geometry, shader );
874 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>( Renderer::Property::BLEND_COLOR ), Color::TRANSPARENT, TEST_LOCATION );
876 renderer.SetProperty( Renderer::Property::BLEND_COLOR, Color::MAGENTA );
877 application.SendNotification();
878 application.Render();
879 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>( Renderer::Property::BLEND_COLOR ), Color::MAGENTA, TEST_LOCATION );
881 Vector4 color( 0.1f, 0.2f, 0.3f, 0.4f );
882 renderer.SetProperty( Renderer::Property::BLEND_COLOR, color );
883 application.SendNotification();
884 application.Render();
885 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>( Renderer::Property::BLEND_COLOR ), color, TEST_LOCATION );
890 int UtcDaliRendererPreMultipledAlpha(void)
892 TestApplication application;
894 tet_infoline("Test BLEND_PRE_MULTIPLIED_ALPHA property");
896 Geometry geometry = CreateQuadGeometry();
897 Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
898 Renderer renderer = Renderer::New( geometry, shader );
900 Actor actor = Actor::New();
901 actor.AddRenderer(renderer);
902 actor.SetSize(400, 400);
903 actor.SetColor( Vector4(1.0f, 0.0f, 1.0f, 0.5f) );
904 Stage::GetCurrent().Add(actor);
906 Property::Value value = renderer.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
907 bool preMultipliedAlpha;
908 DALI_TEST_CHECK( value.Get( preMultipliedAlpha ) );
909 DALI_TEST_CHECK( !preMultipliedAlpha );
911 int srcFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
912 int destFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
913 int srcFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
914 int destFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
916 DALI_TEST_EQUALS( (int)DEFAULT_BLEND_FACTOR_SRC_RGB, srcFactorRgb, TEST_LOCATION );
917 DALI_TEST_EQUALS( (int)DEFAULT_BLEND_FACTOR_DEST_RGB, destFactorRgb, TEST_LOCATION );
918 DALI_TEST_EQUALS( (int)DEFAULT_BLEND_FACTOR_SRC_ALPHA, srcFactorAlpha, TEST_LOCATION );
919 DALI_TEST_EQUALS( (int)DEFAULT_BLEND_FACTOR_DEST_ALPHA, destFactorAlpha, TEST_LOCATION );
921 application.SendNotification();
922 application.Render();
924 Vector4 actualValue(Vector4::ZERO);
925 TestGlAbstraction& gl = application.GetGlAbstraction();
926 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uColor", actualValue ) );
927 DALI_TEST_EQUALS( actualValue, Vector4(1.0f, 0.0f, 1.0f, 0.5f), TEST_LOCATION );
929 renderer.SetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true);
931 application.SendNotification();
932 application.Render();
934 value = renderer.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
935 DALI_TEST_CHECK( value.Get( preMultipliedAlpha ) );
936 DALI_TEST_CHECK( preMultipliedAlpha );
938 srcFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
939 destFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
940 srcFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
941 destFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
943 DALI_TEST_EQUALS( (int)BlendFactor::ONE, srcFactorRgb, TEST_LOCATION );
944 DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorRgb, TEST_LOCATION );
945 DALI_TEST_EQUALS( (int)BlendFactor::ONE, srcFactorAlpha, TEST_LOCATION );
946 DALI_TEST_EQUALS( (int)BlendFactor::ONE, destFactorAlpha, TEST_LOCATION );
948 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uColor", actualValue ) );
949 DALI_TEST_EQUALS( actualValue, Vector4(0.5f, 0.0f, 0.5f, 0.5f), TEST_LOCATION );
954 int UtcDaliRendererConstraint01(void)
956 TestApplication application;
958 tet_infoline("Test that a non-uniform renderer property can be constrained");
960 Shader shader = Shader::New("VertexSource", "FragmentSource");
961 Geometry geometry = CreateQuadGeometry();
962 Renderer renderer = Renderer::New( geometry, shader );
964 Actor actor = Actor::New();
965 actor.AddRenderer(renderer);
966 actor.SetSize(400, 400);
967 Stage::GetCurrent().Add(actor);
969 Vector4 initialColor = Color::WHITE;
970 Property::Index colorIndex = renderer.RegisterProperty( "uFadeColor", initialColor );
972 application.SendNotification();
973 application.Render(0);
974 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
977 Constraint constraint = Constraint::New<Vector4>( renderer, colorIndex, TestConstraintNoBlue );
979 application.SendNotification();
980 application.Render(0);
982 // Expect no blue component in either buffer - yellow
983 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION );
984 application.Render(0);
985 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION );
987 renderer.RemoveConstraints();
988 renderer.SetProperty(colorIndex, Color::WHITE );
989 application.SendNotification();
990 application.Render(0);
991 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), Color::WHITE, TEST_LOCATION );
996 int UtcDaliRendererConstraint02(void)
998 TestApplication application;
1000 tet_infoline("Test that a uniform map renderer property can be constrained");
1002 Shader shader = Shader::New("VertexSource", "FragmentSource");
1003 Geometry geometry = CreateQuadGeometry();
1004 Renderer renderer = Renderer::New( geometry, shader );
1006 Actor actor = Actor::New();
1007 actor.AddRenderer(renderer);
1008 actor.SetSize(400, 400);
1009 Stage::GetCurrent().Add(actor);
1010 application.SendNotification();
1011 application.Render(0);
1013 Vector4 initialColor = Color::WHITE;
1014 Property::Index colorIndex = renderer.RegisterProperty( "uFadeColor", initialColor );
1016 TestGlAbstraction& gl = application.GetGlAbstraction();
1018 application.SendNotification();
1019 application.Render(0);
1021 Vector4 actualValue(Vector4::ZERO);
1022 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1023 DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
1026 Constraint constraint = Constraint::New<Vector4>( renderer, colorIndex, TestConstraintNoBlue );
1028 application.SendNotification();
1029 application.Render(0);
1031 // Expect no blue component in either buffer - yellow
1032 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1033 DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
1035 application.Render(0);
1036 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1037 DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
1039 renderer.RemoveConstraints();
1040 renderer.SetProperty(colorIndex, Color::WHITE );
1041 application.SendNotification();
1042 application.Render(0);
1044 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1045 DALI_TEST_EQUALS( actualValue, Color::WHITE, TEST_LOCATION );
1052 int UtcDaliRendererAnimatedProperty01(void)
1054 TestApplication application;
1056 tet_infoline("Test that a non-uniform renderer property can be animated");
1058 Shader shader = Shader::New("VertexSource", "FragmentSource");
1059 Geometry geometry = CreateQuadGeometry();
1060 Renderer renderer = Renderer::New( geometry, shader );
1062 Actor actor = Actor::New();
1063 actor.AddRenderer(renderer);
1064 actor.SetSize(400, 400);
1065 Stage::GetCurrent().Add(actor);
1067 Vector4 initialColor = Color::WHITE;
1068 Property::Index colorIndex = renderer.RegisterProperty( "uFadeColor", initialColor );
1070 application.SendNotification();
1071 application.Render(0);
1072 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
1074 Animation animation = Animation::New(1.0f);
1075 KeyFrames keyFrames = KeyFrames::New();
1076 keyFrames.Add(0.0f, initialColor);
1077 keyFrames.Add(1.0f, Color::TRANSPARENT);
1078 animation.AnimateBetween( Property( renderer, colorIndex ), keyFrames );
1081 application.SendNotification();
1082 application.Render(500);
1084 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), Color::WHITE * 0.5f, TEST_LOCATION );
1086 application.Render(500);
1088 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), Color::TRANSPARENT, TEST_LOCATION );
1093 int UtcDaliRendererAnimatedProperty02(void)
1095 TestApplication application;
1097 tet_infoline("Test that a uniform map renderer property can be animated");
1099 Shader shader = Shader::New("VertexSource", "FragmentSource");
1100 Geometry geometry = CreateQuadGeometry();
1101 Renderer renderer = Renderer::New( geometry, shader );
1103 Actor actor = Actor::New();
1104 actor.AddRenderer(renderer);
1105 actor.SetSize(400, 400);
1106 Stage::GetCurrent().Add(actor);
1107 application.SendNotification();
1108 application.Render(0);
1110 Vector4 initialColor = Color::WHITE;
1111 Property::Index colorIndex = renderer.RegisterProperty( "uFadeColor", initialColor );
1113 TestGlAbstraction& gl = application.GetGlAbstraction();
1115 application.SendNotification();
1116 application.Render(0);
1118 Vector4 actualValue(Vector4::ZERO);
1119 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1120 DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
1122 Animation animation = Animation::New(1.0f);
1123 KeyFrames keyFrames = KeyFrames::New();
1124 keyFrames.Add(0.0f, initialColor);
1125 keyFrames.Add(1.0f, Color::TRANSPARENT);
1126 animation.AnimateBetween( Property( renderer, colorIndex ), keyFrames );
1129 application.SendNotification();
1130 application.Render(500);
1132 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1133 DALI_TEST_EQUALS( actualValue, Color::WHITE * 0.5f, TEST_LOCATION );
1135 application.Render(500);
1136 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1137 DALI_TEST_EQUALS( actualValue, Color::TRANSPARENT, TEST_LOCATION );
1142 int UtcDaliRendererUniformMapPrecendence01(void)
1144 TestApplication application;
1146 tet_infoline("Test the uniform map precedence is applied properly");
1148 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1150 Shader shader = Shader::New("VertexSource", "FragmentSource");
1151 TextureSet textureSet = CreateTextureSet( image );
1153 Geometry geometry = CreateQuadGeometry();
1154 Renderer renderer = Renderer::New( geometry, shader );
1155 renderer.SetTextures( textureSet );
1157 Actor actor = Actor::New();
1158 actor.AddRenderer(renderer);
1159 actor.SetSize(400, 400);
1160 Stage::GetCurrent().Add(actor);
1161 application.SendNotification();
1162 application.Render(0);
1164 renderer.RegisterProperty( "uFadeColor", Color::RED );
1165 actor.RegisterProperty( "uFadeColor", Color::GREEN );
1166 Property::Index shaderFadeColorIndex = shader.RegisterProperty( "uFadeColor", Color::MAGENTA );
1168 TestGlAbstraction& gl = application.GetGlAbstraction();
1170 application.SendNotification();
1171 application.Render(0);
1173 // Expect that the actor's fade color property is accessed
1174 Vector4 actualValue(Vector4::ZERO);
1175 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1176 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1178 // Animate shader's fade color property. Should be no change to uniform
1179 Animation animation = Animation::New(1.0f);
1180 KeyFrames keyFrames = KeyFrames::New();
1181 keyFrames.Add(0.0f, Color::WHITE);
1182 keyFrames.Add(1.0f, Color::TRANSPARENT);
1183 animation.AnimateBetween( Property( shader, shaderFadeColorIndex ), keyFrames );
1186 application.SendNotification();
1187 application.Render(500);
1189 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1190 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1192 application.Render(500);
1193 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1194 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1199 int UtcDaliRendererUniformMapPrecendence02(void)
1201 TestApplication application;
1203 tet_infoline("Test the uniform map precedence is applied properly");
1205 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1207 Shader shader = Shader::New("VertexSource", "FragmentSource");
1208 TextureSet textureSet = CreateTextureSet( image );
1210 Geometry geometry = CreateQuadGeometry();
1211 Renderer renderer = Renderer::New( geometry, shader );
1212 renderer.SetTextures( textureSet );
1214 Actor actor = Actor::New();
1215 actor.AddRenderer(renderer);
1216 actor.SetSize(400, 400);
1217 Stage::GetCurrent().Add(actor);
1218 application.SendNotification();
1219 application.Render(0);
1221 // Don't add property / uniform map to renderer
1222 actor.RegisterProperty( "uFadeColor", Color::GREEN );
1223 Property::Index shaderFadeColorIndex = shader.RegisterProperty( "uFadeColor", Color::BLUE );
1225 TestGlAbstraction& gl = application.GetGlAbstraction();
1227 application.SendNotification();
1228 application.Render(0);
1230 // Expect that the actor's fade color property is accessed
1231 Vector4 actualValue(Vector4::ZERO);
1232 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1233 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1235 // Animate texture set's fade color property. Should be no change to uniform
1236 Animation animation = Animation::New(1.0f);
1237 KeyFrames keyFrames = KeyFrames::New();
1238 keyFrames.Add(0.0f, Color::WHITE);
1239 keyFrames.Add(1.0f, Color::TRANSPARENT);
1240 animation.AnimateBetween( Property( shader, shaderFadeColorIndex ), keyFrames );
1243 application.SendNotification();
1244 application.Render(500);
1246 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1247 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1249 application.Render(500);
1250 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1251 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1257 int UtcDaliRendererUniformMapPrecendence03(void)
1259 TestApplication application;
1261 tet_infoline("Test the uniform map precedence is applied properly");
1263 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1265 Shader shader = Shader::New("VertexSource", "FragmentSource");
1266 TextureSet textureSet = CreateTextureSet( image );
1268 Geometry geometry = CreateQuadGeometry();
1269 Renderer renderer = Renderer::New( geometry, shader );
1270 renderer.SetTextures( textureSet );
1272 Actor actor = Actor::New();
1273 actor.AddRenderer(renderer);
1274 actor.SetSize(400, 400);
1275 Stage::GetCurrent().Add(actor);
1276 application.SendNotification();
1277 application.Render(0);
1279 // Don't add property / uniform map to renderer or actor
1280 shader.RegisterProperty( "uFadeColor", Color::BLACK );
1282 TestGlAbstraction& gl = application.GetGlAbstraction();
1284 application.SendNotification();
1285 application.Render(0);
1287 // Expect that the shader's fade color property is accessed
1288 Vector4 actualValue(Vector4::ZERO);
1289 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1290 DALI_TEST_EQUALS( actualValue, Color::BLACK, TEST_LOCATION );
1295 int UtcDaliRendererUniformMapMultipleUniforms01(void)
1297 TestApplication application;
1299 tet_infoline("Test the uniform maps are collected from all objects (same type)");
1301 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1303 Shader shader = Shader::New("VertexSource", "FragmentSource");
1304 TextureSet textureSet = CreateTextureSet( image );
1306 Geometry geometry = CreateQuadGeometry();
1307 Renderer renderer = Renderer::New( geometry, shader );
1308 renderer.SetTextures( textureSet );
1310 Actor actor = Actor::New();
1311 actor.AddRenderer(renderer);
1312 actor.SetSize(400, 400);
1313 Stage::GetCurrent().Add(actor);
1314 application.SendNotification();
1315 application.Render(0);
1317 renderer.RegisterProperty( "uUniform1", Color::RED );
1318 actor.RegisterProperty( "uUniform2", Color::GREEN );
1319 shader.RegisterProperty( "uUniform3", Color::MAGENTA );
1321 TestGlAbstraction& gl = application.GetGlAbstraction();
1323 application.SendNotification();
1324 application.Render(0);
1326 // Expect that each of the object's uniforms are set
1327 Vector4 uniform1Value(Vector4::ZERO);
1328 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform1", uniform1Value ) );
1329 DALI_TEST_EQUALS( uniform1Value, Color::RED, TEST_LOCATION );
1331 Vector4 uniform2Value(Vector4::ZERO);
1332 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform2", uniform2Value ) );
1333 DALI_TEST_EQUALS( uniform2Value, Color::GREEN, TEST_LOCATION );
1335 Vector4 uniform3Value(Vector4::ZERO);
1336 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform3", uniform3Value ) );
1337 DALI_TEST_EQUALS( uniform3Value, Color::MAGENTA, TEST_LOCATION );
1342 int UtcDaliRendererUniformMapMultipleUniforms02(void)
1344 TestApplication application;
1346 tet_infoline("Test the uniform maps are collected from all objects (different types)");
1348 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1350 Shader shader = Shader::New("VertexSource", "FragmentSource");
1351 TextureSet textureSet = CreateTextureSet( image );
1353 Geometry geometry = CreateQuadGeometry();
1354 Renderer renderer = Renderer::New( geometry, shader );
1355 renderer.SetTextures( textureSet );
1357 Actor actor = Actor::New();
1358 actor.AddRenderer(renderer);
1359 actor.SetSize(400, 400);
1360 Stage::GetCurrent().Add(actor);
1361 application.SendNotification();
1362 application.Render(0);
1364 Property::Value value1(Color::RED);
1365 renderer.RegisterProperty( "uFadeColor", value1 );
1367 Property::Value value2(1.0f);
1368 actor.RegisterProperty( "uFadeProgress", value2 );
1370 Property::Value value3(Matrix3::IDENTITY);
1371 shader.RegisterProperty( "uANormalMatrix", value3 );
1373 TestGlAbstraction& gl = application.GetGlAbstraction();
1375 application.SendNotification();
1376 application.Render(0);
1378 // Expect that each of the object's uniforms are set
1379 Vector4 uniform1Value(Vector4::ZERO);
1380 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", uniform1Value ) );
1381 DALI_TEST_EQUALS( uniform1Value, value1.Get<Vector4>(), TEST_LOCATION );
1383 float uniform2Value(0.0f);
1384 DALI_TEST_CHECK( gl.GetUniformValue<float>( "uFadeProgress", uniform2Value ) );
1385 DALI_TEST_EQUALS( uniform2Value, value2.Get<float>(), TEST_LOCATION );
1387 Matrix3 uniform3Value;
1388 DALI_TEST_CHECK( gl.GetUniformValue<Matrix3>( "uANormalMatrix", uniform3Value ) );
1389 DALI_TEST_EQUALS( uniform3Value, value3.Get<Matrix3>(), TEST_LOCATION );
1395 int UtcDaliRendererRenderOrder2DLayer(void)
1397 TestApplication application;
1398 tet_infoline("Test the rendering order in a 2D layer is correct");
1400 Shader shader = Shader::New("VertexSource", "FragmentSource");
1401 Geometry geometry = CreateQuadGeometry();
1403 Actor actor0 = Actor::New();
1404 actor0.SetAnchorPoint(AnchorPoint::CENTER);
1405 actor0.SetParentOrigin(AnchorPoint::CENTER);
1406 actor0.SetPosition(0.0f,0.0f);
1407 Image image0 = BufferImage::New( 64, 64, Pixel::RGB888 );
1408 TextureSet textureSet0 = CreateTextureSet( image0 );
1409 Renderer renderer0 = Renderer::New( geometry, shader );
1410 renderer0.SetTextures( textureSet0 );
1411 actor0.AddRenderer(renderer0);
1412 actor0.SetSize(1, 1);
1413 Stage::GetCurrent().Add(actor0);
1414 application.SendNotification();
1415 application.Render(0);
1417 Actor actor1 = Actor::New();
1418 actor1.SetAnchorPoint(AnchorPoint::CENTER);
1419 actor1.SetParentOrigin(AnchorPoint::CENTER);
1420 actor1.SetPosition(0.0f,0.0f);
1421 Image image1= BufferImage::New( 64, 64, Pixel::RGB888 );
1422 TextureSet textureSet1 = CreateTextureSet( image1 );
1423 Renderer renderer1 = Renderer::New( geometry, shader );
1424 renderer1.SetTextures( textureSet1 );
1425 actor1.AddRenderer(renderer1);
1426 actor1.SetSize(1, 1);
1427 Stage::GetCurrent().Add(actor1);
1428 application.SendNotification();
1429 application.Render(0);
1431 Actor actor2 = Actor::New();
1432 actor2.SetAnchorPoint(AnchorPoint::CENTER);
1433 actor2.SetParentOrigin(AnchorPoint::CENTER);
1434 actor2.SetPosition(0.0f,0.0f);
1435 Image image2= BufferImage::New( 64, 64, Pixel::RGB888 );
1436 TextureSet textureSet2 = CreateTextureSet( image2 );
1437 Renderer renderer2 = Renderer::New( geometry, shader );
1438 renderer2.SetTextures( textureSet2 );
1439 actor2.AddRenderer(renderer2);
1440 actor2.SetSize(1, 1);
1441 Stage::GetCurrent().Add(actor2);
1442 application.SendNotification();
1443 application.Render(0);
1445 Actor actor3 = Actor::New();
1446 actor3.SetAnchorPoint(AnchorPoint::CENTER);
1447 actor3.SetParentOrigin(AnchorPoint::CENTER);
1448 actor3.SetPosition(0.0f,0.0f);
1449 Image image3 = BufferImage::New( 64, 64, Pixel::RGB888 );
1450 TextureSet textureSet3 = CreateTextureSet( image3 );
1451 Renderer renderer3 = Renderer::New( geometry, shader );
1452 renderer3.SetTextures( textureSet3 );
1453 actor3.AddRenderer(renderer3);
1454 actor3.SetSize(1, 1);
1455 Stage::GetCurrent().Add(actor3);
1456 application.SendNotification();
1457 application.Render(0);
1460 * Create the following hierarchy:
1473 * Expected rendering order : actor2 - actor1 - actor0 - actor3
1478 application.SendNotification();
1479 application.Render(0);
1481 TestGlAbstraction& gl = application.GetGlAbstraction();
1482 gl.EnableTextureCallTrace(true);
1483 application.SendNotification();
1484 application.Render(0);
1486 int textureBindIndex[4];
1487 for( unsigned int i(0); i<4; ++i )
1489 std::stringstream params;
1490 params << GL_TEXTURE_2D<<", "<<i+1;
1491 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
1494 //Check that actor1 has been rendered after actor2
1495 DALI_TEST_GREATER( textureBindIndex[1], textureBindIndex[2], TEST_LOCATION );
1497 //Check that actor0 has been rendered after actor1
1498 DALI_TEST_GREATER( textureBindIndex[0], textureBindIndex[1], TEST_LOCATION );
1500 //Check that actor3 has been rendered after actor0
1501 DALI_TEST_GREATER( textureBindIndex[3], textureBindIndex[0], TEST_LOCATION );
1506 int UtcDaliRendererRenderOrder2DLayerMultipleRenderers(void)
1508 TestApplication application;
1509 tet_infoline("Test the rendering order in a 2D layer is correct using multiple renderers per actor");
1512 * Creates the following hierarchy:
1514 * actor0------------------------>actor1
1518 * renderer0 renderer1 renderer2 renderer3 renderer4 renderer5
1520 * renderer0 has depth index 2
1521 * renderer1 has depth index 0
1522 * renderer2 has depth index 1
1524 * renderer3 has depth index 1
1525 * renderer4 has depth index 0
1526 * renderer5 has depth index -1
1528 * Expected rendering order: renderer1 - renderer2 - renderer0 - renderer5 - renderer4 - renderer3
1531 Shader shader = Shader::New("VertexSource", "FragmentSource");
1532 Geometry geometry = CreateQuadGeometry();
1534 Actor actor0 = Actor::New();
1535 actor0.SetAnchorPoint(AnchorPoint::CENTER);
1536 actor0.SetParentOrigin(AnchorPoint::CENTER);
1537 actor0.SetPosition(0.0f,0.0f);
1538 actor0.SetSize(1, 1);
1539 Stage::GetCurrent().Add(actor0);
1541 Actor actor1 = Actor::New();
1542 actor1.SetAnchorPoint(AnchorPoint::CENTER);
1543 actor1.SetParentOrigin(AnchorPoint::CENTER);
1544 actor1.SetPosition(0.0f,0.0f);
1545 actor1.SetSize(1, 1);
1549 Image image0 = BufferImage::New( 64, 64, Pixel::RGB888 );
1550 TextureSet textureSet0 = CreateTextureSet( image0 );
1551 Renderer renderer0 = Renderer::New( geometry, shader );
1552 renderer0.SetTextures( textureSet0 );
1553 renderer0.SetProperty( Renderer::Property::DEPTH_INDEX, 2 );
1554 actor0.AddRenderer(renderer0);
1555 application.SendNotification();
1556 application.Render(0);
1559 Image image1= BufferImage::New( 64, 64, Pixel::RGB888 );
1560 TextureSet textureSet1 = CreateTextureSet( image1 );
1561 Renderer renderer1 = Renderer::New( geometry, shader );
1562 renderer1.SetTextures( textureSet1 );
1563 renderer1.SetProperty( Renderer::Property::DEPTH_INDEX, 0 );
1564 actor0.AddRenderer(renderer1);
1565 application.SendNotification();
1566 application.Render(0);
1569 Image image2= BufferImage::New( 64, 64, Pixel::RGB888 );
1570 TextureSet textureSet2 = CreateTextureSet( image2 );
1571 Renderer renderer2 = Renderer::New( geometry, shader );
1572 renderer2.SetTextures( textureSet2 );
1573 renderer2.SetProperty( Renderer::Property::DEPTH_INDEX, 1 );
1574 actor0.AddRenderer(renderer2);
1575 application.SendNotification();
1576 application.Render(0);
1579 Image image3 = BufferImage::New( 64, 64, Pixel::RGB888 );
1580 TextureSet textureSet3 = CreateTextureSet( image3 );
1581 Renderer renderer3 = Renderer::New( geometry, shader );
1582 renderer3.SetTextures( textureSet3 );
1583 renderer3.SetProperty( Renderer::Property::DEPTH_INDEX, 1 );
1584 actor1.AddRenderer(renderer3);
1585 application.SendNotification();
1586 application.Render(0);
1589 Image image4= BufferImage::New( 64, 64, Pixel::RGB888 );
1590 TextureSet textureSet4 = CreateTextureSet( image4 );
1591 Renderer renderer4 = Renderer::New( geometry, shader );
1592 renderer4.SetTextures( textureSet4 );
1593 renderer4.SetProperty( Renderer::Property::DEPTH_INDEX, 0 );
1594 actor1.AddRenderer(renderer4);
1595 application.SendNotification();
1596 application.Render(0);
1599 Image image5= BufferImage::New( 64, 64, Pixel::RGB888 );
1600 TextureSet textureSet5 = CreateTextureSet( image5 );
1601 Renderer renderer5 = Renderer::New( geometry, shader );
1602 renderer5.SetTextures( textureSet5 );
1603 renderer5.SetProperty( Renderer::Property::DEPTH_INDEX, -1 );
1604 actor1.AddRenderer(renderer5);
1605 application.SendNotification();
1606 application.Render(0);
1609 TestGlAbstraction& gl = application.GetGlAbstraction();
1610 gl.EnableTextureCallTrace(true);
1611 application.SendNotification();
1612 application.Render(0);
1614 int textureBindIndex[6];
1615 for( unsigned int i(0); i<6; ++i )
1617 std::stringstream params;
1618 params << GL_TEXTURE_2D<<", "<<i+1;
1619 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
1622 //Check that renderer3 has been rendered after renderer4
1623 DALI_TEST_GREATER( textureBindIndex[3], textureBindIndex[4], TEST_LOCATION );
1625 //Check that renderer0 has been rendered after renderer2
1626 DALI_TEST_GREATER( textureBindIndex[4], textureBindIndex[5], TEST_LOCATION );
1628 //Check that renderer0 has been rendered after renderer2
1629 DALI_TEST_GREATER( textureBindIndex[5], textureBindIndex[0], TEST_LOCATION );
1631 //Check that renderer0 has been rendered after renderer2
1632 DALI_TEST_GREATER( textureBindIndex[0], textureBindIndex[2], TEST_LOCATION );
1634 //Check that renderer2 has been rendered after renderer1
1635 DALI_TEST_GREATER( textureBindIndex[2], textureBindIndex[1], TEST_LOCATION );
1640 int UtcDaliRendererRenderOrder2DLayerOverlay(void)
1642 TestApplication application;
1643 tet_infoline("Test the rendering order in a 2D layer is correct for overlays");
1645 Shader shader = Shader::New("VertexSource", "FragmentSource");
1646 Geometry geometry = CreateQuadGeometry();
1648 Actor actor0 = Actor::New();
1649 actor0.SetAnchorPoint(AnchorPoint::CENTER);
1650 actor0.SetParentOrigin(AnchorPoint::CENTER);
1651 Image image0 = BufferImage::New( 64, 64, Pixel::RGB888 );
1652 TextureSet textureSet0 = CreateTextureSet( image0 );
1653 Renderer renderer0 = Renderer::New( geometry, shader );
1654 renderer0.SetTextures( textureSet0 );
1655 actor0.AddRenderer(renderer0);
1656 actor0.SetPosition(0.0f,0.0f);
1657 actor0.SetSize(100, 100);
1658 Stage::GetCurrent().Add(actor0);
1659 actor0.SetDrawMode( DrawMode::OVERLAY_2D );
1660 application.SendNotification();
1661 application.Render(0);
1663 Actor actor1 = Actor::New();
1664 actor1.SetAnchorPoint(AnchorPoint::CENTER);
1665 actor1.SetParentOrigin(AnchorPoint::CENTER);
1666 Image image1= BufferImage::New( 64, 64, Pixel::RGB888 );
1667 TextureSet textureSet1 = CreateTextureSet( image1 );
1668 Renderer renderer1 = Renderer::New( geometry, shader );
1669 renderer1.SetTextures( textureSet1 );
1670 actor1.SetPosition(0.0f,0.0f);
1671 actor1.AddRenderer(renderer1);
1672 actor1.SetSize(100, 100);
1673 Stage::GetCurrent().Add(actor1);
1674 actor1.SetDrawMode( DrawMode::OVERLAY_2D );
1675 application.SendNotification();
1676 application.Render(0);
1678 Actor actor2 = Actor::New();
1679 actor2.SetAnchorPoint(AnchorPoint::CENTER);
1680 actor2.SetParentOrigin(AnchorPoint::CENTER);
1681 Image image2= BufferImage::New( 64, 64, Pixel::RGB888 );
1682 TextureSet textureSet2 = CreateTextureSet( image2 );
1683 Renderer renderer2 = Renderer::New( geometry, shader );
1684 renderer2.SetTextures( textureSet2 );
1685 actor2.AddRenderer(renderer2);
1686 actor2.SetPosition(0.0f,0.0f);
1687 actor2.SetSize(100, 100);
1688 Stage::GetCurrent().Add(actor2);
1689 application.SendNotification();
1690 application.Render(0);
1692 Actor actor3 = Actor::New();
1693 actor3.SetAnchorPoint(AnchorPoint::CENTER);
1694 actor3.SetParentOrigin(AnchorPoint::CENTER);
1695 Image image3 = BufferImage::New( 64, 64, Pixel::RGB888 );
1696 TextureSet textureSet3 = CreateTextureSet( image3 );
1697 Renderer renderer3 = Renderer::New( geometry, shader );
1698 renderer3.SetTextures( textureSet3 );
1699 actor3.SetPosition(0.0f,0.0f);
1700 actor3.AddRenderer(renderer3);
1701 actor3.SetSize(100, 100);
1702 Stage::GetCurrent().Add(actor3);
1703 actor3.SetDrawMode( DrawMode::OVERLAY_2D );
1704 application.SendNotification();
1705 application.Render(0);
1707 Actor actor4 = Actor::New();
1708 actor4.SetAnchorPoint(AnchorPoint::CENTER);
1709 actor4.SetParentOrigin(AnchorPoint::CENTER);
1710 Image image4 = BufferImage::New( 64, 64, Pixel::RGB888 );
1711 TextureSet textureSet4 = CreateTextureSet( image4 );
1712 Renderer renderer4 = Renderer::New( geometry, shader );
1713 renderer4.SetTextures( textureSet4 );
1714 actor4.AddRenderer(renderer4);
1715 actor4.SetPosition(0.0f,0.0f);
1716 actor4.SetSize(100, 100);
1717 Stage::GetCurrent().Add(actor4);
1718 application.SendNotification();
1719 application.Render(0);
1722 * Create the following hierarchy:
1729 * (Overlay) (Regular actor)
1739 * Expected rendering order : actor2 - actor4 - actor1 - actor0 - actor3
1741 Stage::GetCurrent().Add( actor2 );
1746 application.SendNotification();
1747 application.Render(0);
1749 TestGlAbstraction& gl = application.GetGlAbstraction();
1750 gl.EnableTextureCallTrace(true);
1751 application.SendNotification();
1752 application.Render(0);
1754 int textureBindIndex[5];
1755 for( unsigned int i(0); i<5; ++i )
1757 std::stringstream params;
1758 params << GL_TEXTURE_2D<<", "<<i+1;
1759 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
1762 //Check that actor4 has been rendered after actor2
1763 DALI_TEST_GREATER( textureBindIndex[4], textureBindIndex[2], TEST_LOCATION );
1765 //Check that actor1 has been rendered after actor4
1766 DALI_TEST_GREATER( textureBindIndex[1], textureBindIndex[4], TEST_LOCATION );
1768 //Check that actor0 has been rendered after actor1
1769 DALI_TEST_GREATER( textureBindIndex[0], textureBindIndex[1], TEST_LOCATION );
1771 //Check that actor3 has been rendered after actor0
1772 DALI_TEST_GREATER( textureBindIndex[3], textureBindIndex[0], TEST_LOCATION );
1777 int UtcDaliRendererSetIndexRange(void)
1781 "attribute vec2 aPosition;\n"
1784 " gl_Position = aPosition;\n"
1790 " gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0)\n"
1794 TestApplication application;
1795 tet_infoline("Test setting the range of indices to draw");
1797 TestGlAbstraction& gl = application.GetGlAbstraction();
1798 gl.EnableDrawCallTrace( true );
1800 Actor actor = Actor::New();
1801 actor.SetSize( 100, 100 );
1804 Geometry geometry = Geometry::New();
1805 geometry.SetType( Geometry::LINE_LOOP );
1807 // --------------------------------------------------------------------------
1809 unsigned short indices[] = { 0, 2, 4, 6, 8, // offset = 0, count = 5
1810 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, // offset = 5, count = 10
1811 1, 3, 5, 7, 9, 1 }; // offset = 15, count = 6 // line strip
1813 // --------------------------------------------------------------------------
1822 { Vector2( 0.0f, 1.00f) }, { Vector2( 0.0f, -1.00f) },
1823 { Vector2( -0.95f, 0.31f) }, { Vector2( 0.59f, 0.81f) },
1824 { Vector2( -0.59f, -0.81f) }, { Vector2( -0.95f, -0.31f) },
1825 { Vector2( 0.59f, -0.81f) }, { Vector2( 0.95f, -0.31f) },
1826 { Vector2( 0.95f, 0.31f) }, { Vector2( -0.59f, 0.81f) },
1828 Property::Map vertexFormat;
1829 vertexFormat["aPosition"] = Property::VECTOR2;
1830 PropertyBuffer vertexBuffer = PropertyBuffer::New( vertexFormat );
1831 vertexBuffer.SetData( shapes, sizeof(shapes)/sizeof(shapes[0]));
1833 // --------------------------------------------------------------------------
1834 geometry.SetIndexBuffer( indices, sizeof(indices)/sizeof(indices[0]) );
1835 geometry.AddVertexBuffer( vertexBuffer );
1838 Shader shader = Shader::New( vertexShader,fragmentShader );
1839 Renderer renderer = Renderer::New( geometry, shader );
1840 actor.AddRenderer( renderer );
1842 Stage stage = Stage::GetCurrent();
1847 // LINE_LOOP, first 0, count 5
1849 renderer.SetIndexRange( 0, 5 );
1850 application.SendNotification();
1851 application.Render();
1852 sprintf( buffer, "%u, 5, %u, indices", GL_LINE_LOOP, GL_UNSIGNED_SHORT );
1853 bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
1854 DALI_TEST_CHECK( result );
1857 // LINE_LOOP, first 5, count 10
1859 renderer.SetIndexRange( 5, 10 );
1860 sprintf( buffer, "%u, 10, %u, indices", GL_LINE_LOOP, GL_UNSIGNED_SHORT );
1861 application.SendNotification();
1862 application.Render();
1863 bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
1864 DALI_TEST_CHECK( result );
1867 // LINE_STRIP, first 15, count 6
1869 renderer.SetIndexRange( 15, 6 );
1870 geometry.SetType( Geometry::LINE_STRIP );
1871 sprintf( buffer, "%u, 6, %u, indices", GL_LINE_STRIP, GL_UNSIGNED_SHORT );
1872 application.SendNotification();
1873 application.Render();
1874 bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
1875 DALI_TEST_CHECK( result );
1878 // Index out of bounds
1880 renderer.SetIndexRange( 15, 30 );
1881 geometry.SetType( Geometry::LINE_STRIP );
1882 sprintf( buffer, "%u, 6, %u, indices", GL_LINE_STRIP, GL_UNSIGNED_SHORT );
1883 application.SendNotification();
1884 application.Render();
1885 bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
1886 DALI_TEST_CHECK( result );
1889 // drawing whole buffer starting from 15 ( last valid primitive )
1891 renderer.SetIndexRange( 15, 0 );
1892 geometry.SetType( Geometry::LINE_STRIP );
1893 sprintf( buffer, "%u, 6, %u, indices", GL_LINE_STRIP, GL_UNSIGNED_SHORT );
1894 application.SendNotification();
1895 application.Render();
1896 bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
1897 DALI_TEST_CHECK( result );
1904 int UtcDaliRendererSetDepthFunction(void)
1906 TestApplication application;
1908 tet_infoline("Test setting the depth function");
1910 Geometry geometry = CreateQuadGeometry();
1911 Shader shader = CreateShader();
1912 Renderer renderer = Renderer::New( geometry, shader );
1914 Actor actor = Actor::New();
1915 actor.AddRenderer(renderer);
1916 actor.SetSize(400, 400);
1917 Stage stage = Stage::GetCurrent();
1918 stage.GetRootLayer().SetBehavior( Layer::LAYER_3D );
1921 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
1922 glAbstraction.EnableEnableDisableCallTrace(true);
1923 glAbstraction.EnableDepthFunctionCallTrace(true);
1925 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
1926 TraceCallStack& glDepthFunctionStack = glAbstraction.GetDepthFunctionTrace();
1928 std::ostringstream depthTestStr;
1929 depthTestStr << GL_DEPTH_TEST;
1933 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::NEVER);
1935 glEnableDisableStack.Reset();
1936 glDepthFunctionStack.Reset();
1937 application.SendNotification();
1938 application.Render();
1940 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", depthTestStr.str().c_str() ) );
1941 std::ostringstream depthFunctionStr;
1942 depthFunctionStr << GL_NEVER;
1943 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
1948 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::ALWAYS);
1950 glDepthFunctionStack.Reset();
1951 application.SendNotification();
1952 application.Render();
1954 std::ostringstream depthFunctionStr;
1955 depthFunctionStr << GL_ALWAYS;
1956 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
1961 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::LESS);
1963 glDepthFunctionStack.Reset();
1964 application.SendNotification();
1965 application.Render();
1967 std::ostringstream depthFunctionStr;
1968 depthFunctionStr << GL_LESS;
1969 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
1974 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::GREATER);
1976 glDepthFunctionStack.Reset();
1977 application.SendNotification();
1978 application.Render();
1980 std::ostringstream depthFunctionStr;
1981 depthFunctionStr << GL_GREATER;
1982 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
1987 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::EQUAL);
1989 glDepthFunctionStack.Reset();
1990 application.SendNotification();
1991 application.Render();
1993 std::ostringstream depthFunctionStr;
1994 depthFunctionStr << GL_EQUAL;
1995 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2000 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::NOT_EQUAL);
2002 glDepthFunctionStack.Reset();
2003 application.SendNotification();
2004 application.Render();
2006 std::ostringstream depthFunctionStr;
2007 depthFunctionStr << GL_NOTEQUAL;
2008 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2013 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::LESS_EQUAL);
2015 glDepthFunctionStack.Reset();
2016 application.SendNotification();
2017 application.Render();
2019 std::ostringstream depthFunctionStr;
2020 depthFunctionStr << GL_LEQUAL;
2021 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2026 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::GREATER_EQUAL);
2028 glDepthFunctionStack.Reset();
2029 application.SendNotification();
2030 application.Render();
2032 std::ostringstream depthFunctionStr;
2033 depthFunctionStr << GL_GEQUAL;
2034 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2040 Renderer StencilTestFixture( TestApplication& application )
2042 Geometry geometry = CreateQuadGeometry();
2043 Shader shader = CreateShader();
2044 Renderer renderer = Renderer::New( geometry, shader );
2046 Actor actor = Actor::New();
2047 actor.AddRenderer( renderer );
2048 actor.SetSize( 400.0f, 400.0f );
2049 Stage stage = Stage::GetCurrent();
2050 stage.GetRootLayer().SetBehavior( Layer::LAYER_3D );
2056 int UtcDaliRendererCheckStencilDefaults(void)
2058 TestApplication application;
2059 tet_infoline("Test the stencil defaults");
2061 Renderer renderer = StencilTestFixture( application );
2062 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2063 glAbstraction.EnableEnableDisableCallTrace( true );
2064 glAbstraction.EnableStencilFunctionCallTrace( true );
2065 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2066 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
2068 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2070 // Check the defaults:
2071 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION ).Get<int>() ), static_cast<int>( StencilFunction::ALWAYS ), TEST_LOCATION );
2072 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION_MASK ).Get<int>() ), 0xFF, TEST_LOCATION );
2073 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION_REFERENCE ).Get<int>() ), 0x00, TEST_LOCATION );
2074 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_MASK ).Get<int>() ), 0xFF, TEST_LOCATION );
2075 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_OPERATION_ON_FAIL ).Get<int>() ), static_cast<int>( StencilOperation::KEEP ), TEST_LOCATION );
2076 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 );
2077 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 );
2082 int UtcDaliRendererSetStencilMode(void)
2084 TestApplication application;
2085 tet_infoline("Test setting the StencilMode");
2087 Renderer renderer = StencilTestFixture( application );
2088 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2089 glAbstraction.EnableEnableDisableCallTrace( true );
2090 glAbstraction.EnableStencilFunctionCallTrace( true );
2091 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2092 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
2094 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2096 // Set the StencilFunction to something other than the default, to confirm it is set as a property,
2097 // but NO GL call has been made while the StencilMode is set to OFF.
2098 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION, StencilFunction::NEVER );
2099 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION ).Get<int>() ), static_cast<int>( StencilFunction::NEVER ), TEST_LOCATION );
2100 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2102 std::string methodString( "StencilFunc" );
2103 DALI_TEST_CHECK( !glStencilFunctionStack.FindMethod( methodString ) );
2105 // Now set the StencilMode to ON and check the StencilFunction has changed.
2106 renderer.SetProperty( Renderer::Property::STENCIL_MODE, StencilMode::ON );
2107 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2109 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetStencilTestString() ) );
2110 DALI_TEST_CHECK( glStencilFunctionStack.FindMethod( methodString ) );
2115 int UtcDaliRendererSetStencilFunction(void)
2117 TestApplication application;
2118 tet_infoline("Test setting the StencilFunction");
2120 Renderer renderer = StencilTestFixture( application );
2121 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2122 glAbstraction.EnableEnableDisableCallTrace( true );
2123 glAbstraction.EnableStencilFunctionCallTrace( true );
2124 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2125 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
2127 // StencilMode must be ON for StencilFunction to operate.
2128 renderer.SetProperty( Renderer::Property::STENCIL_MODE, StencilMode::ON );
2129 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2132 * Lookup table for testing StencilFunction.
2133 * Note: This MUST be in the same order as the Dali::StencilFunction enum.
2135 const int StencilFunctionLookupTable[] = {
2144 }; const int StencilFunctionLookupTableCount = sizeof( StencilFunctionLookupTable ) / sizeof( StencilFunctionLookupTable[0] );
2147 * Loop through all types of StencilFunction, checking:
2148 * - The value is cached (set in event thread side)
2149 * - Causes "glStencilFunc" to be called
2150 * - Checks the correct parameters to "glStencilFunc" were used
2152 std::string nonChangingParameters = "0, 255";
2153 std::string methodString( "StencilFunc" );
2154 for( int i = 0; i < StencilFunctionLookupTableCount; ++i )
2156 // Set the property.
2157 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION, static_cast<Dali::StencilFunction::Type>( i ) );
2159 // Check GetProperty returns the same value.
2160 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION ).Get<int>() ), i, TEST_LOCATION );
2162 // Reset the trace debug.
2163 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2165 // Check the function is called and the parameters are correct.
2166 std::stringstream parameterStream;
2167 parameterStream << StencilFunctionLookupTable[ i ] << ", " << nonChangingParameters;
2169 DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterStream.str() ) );
2172 // Change the Function Reference only and check the behavior is correct:
2173 // 170 is 0xaa in hex / 10101010 in binary (every other bit set).
2174 int testValueReference = 170;
2175 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION_REFERENCE, testValueReference );
2177 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION_REFERENCE ).Get<int>() ), testValueReference, TEST_LOCATION );
2179 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2181 std::stringstream parameterStream;
2182 parameterStream << StencilFunctionLookupTable[ StencilOperation::DECREMENT_WRAP ] << ", " << testValueReference << ", 255";
2184 DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterStream.str() ) );
2187 // Change the Function Mask only and check the behavior is correct:
2188 // 85 is 0x55 in hex / 01010101 in binary (every other bit set).
2189 int testValueMask = 85;
2190 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION_MASK, testValueMask );
2192 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION_MASK ).Get<int>() ), testValueMask, TEST_LOCATION );
2194 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2196 // Clear the stringstream.
2197 parameterStream.str( std::string() );
2198 parameterStream << StencilFunctionLookupTable[ StencilOperation::DECREMENT_WRAP ] << ", " << testValueReference << ", " << testValueMask;
2200 DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterStream.str() ) );
2205 int UtcDaliRendererSetStencilOperation(void)
2207 TestApplication application;
2208 tet_infoline("Test setting the StencilOperation");
2210 Renderer renderer = StencilTestFixture( application );
2211 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2212 glAbstraction.EnableEnableDisableCallTrace( true );
2213 glAbstraction.EnableStencilFunctionCallTrace( true );
2214 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2215 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
2217 // StencilMode must be ON for StencilOperation to operate.
2218 renderer.SetProperty( Renderer::Property::STENCIL_MODE, StencilMode::ON );
2221 * Lookup table for testing StencilOperation.
2222 * Note: This MUST be in the same order as the Dali::StencilOperation enum.
2224 const int StencilOperationLookupTable[] = {
2233 }; const int StencilOperationLookupTableCount = sizeof( StencilOperationLookupTable ) / sizeof( StencilOperationLookupTable[0] );
2235 // Set all 3 StencilOperation properties to a default.
2236 renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_FAIL, StencilOperation::ZERO );
2237 renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, StencilOperation::ZERO );
2238 renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, StencilOperation::ZERO );
2240 // Set our expected parameter list to the equivalent result.
2241 int parameters[] = { StencilOperationLookupTable[ StencilOperation::ZERO ], StencilOperationLookupTable[ StencilOperation::ZERO ], StencilOperationLookupTable[ StencilOperation::ZERO ] };
2243 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2246 * Loop through all types of StencilOperation, checking:
2247 * - The value is cached (set in event thread side)
2248 * - Causes "glStencilFunc" to be called
2249 * - Checks the correct parameters to "glStencilFunc" were used
2250 * - Checks the above for all 3 parameter placements of StencilOperation ( OnFail, OnZFail, OnPass )
2252 int stencilOperationPropertyKeys[] = { Renderer::Property::STENCIL_OPERATION_ON_FAIL, Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, Renderer::Property::STENCIL_OPERATION_ON_Z_PASS };
2253 std::string methodString( "StencilOp" );
2255 for( int parameterIndex = 0; parameterIndex < 3; ++parameterIndex )
2257 for( int i = 0; i < StencilOperationLookupTableCount; ++i )
2259 // Set the property (outer loop causes all 3 different properties to be set separately).
2260 renderer.SetProperty( stencilOperationPropertyKeys[ parameterIndex ], static_cast<Dali::StencilFunction::Type>( i ) );
2262 // Check GetProperty returns the same value.
2263 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( stencilOperationPropertyKeys[ parameterIndex ] ).Get<int>() ), i, TEST_LOCATION );
2265 // Reset the trace debug.
2266 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2268 // Check the function is called and the parameters are correct.
2269 // Set the expected parameter value at its correct index (only)
2270 parameters[ parameterIndex ] = StencilOperationLookupTable[ i ];
2272 // Build the parameter list.
2273 std::stringstream parameterStream;
2274 for( int parameterBuild = 0; parameterBuild < 3; ++parameterBuild )
2276 parameterStream << parameters[ parameterBuild ];
2277 // Comma-separate the parameters.
2278 if( parameterBuild < 2 )
2280 parameterStream << ", ";
2284 // Check the function was called and the parameters were correct.
2285 DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterStream.str() ) );
2292 int UtcDaliRendererSetStencilMask(void)
2294 TestApplication application;
2295 tet_infoline("Test setting the StencilMask");
2297 Renderer renderer = StencilTestFixture( application );
2298 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2299 glAbstraction.EnableEnableDisableCallTrace( true );
2300 glAbstraction.EnableStencilFunctionCallTrace( true );
2301 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2302 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
2304 // StencilMode must be ON for StencilMask to operate.
2305 renderer.SetProperty( Renderer::Property::STENCIL_MODE, StencilMode::ON );
2307 // Set the StencilMask property to a value.
2308 renderer.SetProperty( Renderer::Property::STENCIL_MASK, 0x00 );
2310 // Check GetProperty returns the same value.
2311 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_MASK ).Get<int>() ), 0x00, TEST_LOCATION );
2313 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2315 std::string methodString( "StencilMask" );
2316 std::string parameterString = "0";
2318 // Check the function was called and the parameters were correct.
2319 DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterString ) );
2321 // Set the StencilMask property to another value to ensure it has changed.
2322 renderer.SetProperty( Renderer::Property::STENCIL_MASK, 0xFF );
2324 // Check GetProperty returns the same value.
2325 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_MASK ).Get<int>() ), 0xFF, TEST_LOCATION );
2327 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2329 parameterString = "255";
2331 // Check the function was called and the parameters were correct.
2332 DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterString ) );
2337 int UtcDaliRendererSetWriteToColorBuffer(void)
2339 TestApplication application;
2340 tet_infoline("Test setting the WriteToColorBuffer flag");
2342 Renderer renderer = StencilTestFixture( application );
2343 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2345 // Set the StencilMask property to a value.
2346 renderer.SetProperty( Renderer::Property::WRITE_TO_COLOR_BUFFER, false );
2348 // Check GetProperty returns the same value.
2349 DALI_TEST_CHECK( !renderer.GetProperty( Renderer::Property::WRITE_TO_COLOR_BUFFER ).Get<bool>() );
2351 application.SendNotification();
2352 application.Render();
2354 // Check if ColorMask has been called, and that the values are correct.
2355 const TestGlAbstraction::ColorMaskParams& colorMaskParams( glAbstraction.GetColorMaskParams() );
2357 DALI_TEST_EQUALS<bool>( colorMaskParams.red, false, TEST_LOCATION );
2358 DALI_TEST_EQUALS<bool>( colorMaskParams.green, false, TEST_LOCATION );
2359 DALI_TEST_EQUALS<bool>( colorMaskParams.blue, false, TEST_LOCATION );
2360 DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, false, TEST_LOCATION );
2362 // Set the StencilMask property to true.
2363 renderer.SetProperty( Renderer::Property::WRITE_TO_COLOR_BUFFER, true );
2365 // Check GetProperty returns the same value.
2366 DALI_TEST_CHECK( renderer.GetProperty( Renderer::Property::WRITE_TO_COLOR_BUFFER ).Get<bool>() );
2368 application.SendNotification();
2369 application.Render();
2371 // Check if ColorMask has been called, and that the values are correct.
2372 const TestGlAbstraction::ColorMaskParams& colorMaskParamsChanged( glAbstraction.GetColorMaskParams() );
2374 DALI_TEST_EQUALS<bool>( colorMaskParamsChanged.red, true, TEST_LOCATION );
2375 DALI_TEST_EQUALS<bool>( colorMaskParamsChanged.green, true, TEST_LOCATION );
2376 DALI_TEST_EQUALS<bool>( colorMaskParamsChanged.blue, true, TEST_LOCATION );
2377 DALI_TEST_EQUALS<bool>( colorMaskParamsChanged.alpha, true, TEST_LOCATION );