2 * Copyright (c) 2020 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>
20 #include <dali/devel-api/rendering/renderer-devel.h>
21 #include <dali/devel-api/common/stage.h>
23 #include <dali/public-api/dali-core.h>
24 #include <dali/integration-api/render-task-list-integ.h>
29 #include <dali-test-suite-utils.h>
30 #include <test-trace-call-stack.h>
31 #include <mesh-builder.h>
35 namespace // unnamed namespace
38 const BlendFactor::Type DEFAULT_BLEND_FACTOR_SRC_RGB( BlendFactor::SRC_ALPHA );
39 const BlendFactor::Type DEFAULT_BLEND_FACTOR_DEST_RGB( BlendFactor::ONE_MINUS_SRC_ALPHA );
40 const BlendFactor::Type DEFAULT_BLEND_FACTOR_SRC_ALPHA( BlendFactor::ONE );
41 const BlendFactor::Type DEFAULT_BLEND_FACTOR_DEST_ALPHA( BlendFactor::ONE_MINUS_SRC_ALPHA );
43 const BlendEquation::Type DEFAULT_BLEND_EQUATION_RGB( BlendEquation::ADD );
44 const BlendEquation::Type DEFAULT_BLEND_EQUATION_ALPHA( BlendEquation::ADD );
47 * @brief Get GL stencil test enumeration value as a string.
48 * @return The string representation of the value of GL_STENCIL_TEST
50 std::string GetStencilTestString(void)
52 std::stringstream stream;
53 stream << GL_STENCIL_TEST;
58 * @brief Get GL depth test enumeration value as a string.
59 * @return The string representation of the value of GL_DEPTH_TEST
61 std::string GetDepthTestString(void)
63 std::stringstream stream;
64 stream << GL_DEPTH_TEST;
68 void ResetDebugAndFlush( TestApplication& application, TraceCallStack& glEnableDisableStack, TraceCallStack& glStencilFunctionStack )
70 glEnableDisableStack.Reset();
71 glStencilFunctionStack.Reset();
72 application.SendNotification();
76 void TestConstraintNoBlue( Vector4& current, const PropertyInputContainer& inputs )
81 } // unnamed namespace
83 void renderer_test_startup(void)
85 test_return_value = TET_UNDEF;
88 void renderer_test_cleanup(void)
90 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 UtcDaliRendererMoveConstructor(void)
145 TestApplication application;
147 Geometry geometry = CreateQuadGeometry();
148 Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
149 Renderer renderer = Renderer::New( geometry, shader );
150 DALI_TEST_CHECK( renderer );
151 DALI_TEST_EQUALS( 1, renderer.GetBaseObject().ReferenceCount(), TEST_LOCATION );
152 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>( Renderer::Property::BLEND_COLOR ), Color::TRANSPARENT, TEST_LOCATION );
154 renderer.SetProperty( Renderer::Property::BLEND_COLOR, Color::MAGENTA );
155 application.SendNotification();
156 application.Render();
157 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>( Renderer::Property::BLEND_COLOR ), Color::MAGENTA, TEST_LOCATION );
159 Renderer move = std::move( renderer );
160 DALI_TEST_CHECK( move );
161 DALI_TEST_EQUALS( 1, move.GetBaseObject().ReferenceCount(), TEST_LOCATION );
162 DALI_TEST_EQUALS( move.GetProperty<Vector4>( Renderer::Property::BLEND_COLOR ), Color::MAGENTA, TEST_LOCATION );
163 DALI_TEST_CHECK( !renderer );
168 int UtcDaliRendererMoveAssignment(void)
170 TestApplication application;
172 Geometry geometry = CreateQuadGeometry();
173 Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
174 Renderer renderer = Renderer::New( geometry, shader );
175 DALI_TEST_CHECK( renderer );
176 DALI_TEST_EQUALS( 1, renderer.GetBaseObject().ReferenceCount(), TEST_LOCATION );
177 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>( Renderer::Property::BLEND_COLOR ), Color::TRANSPARENT, TEST_LOCATION );
179 renderer.SetProperty( Renderer::Property::BLEND_COLOR, Color::MAGENTA );
180 application.SendNotification();
181 application.Render();
182 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>( Renderer::Property::BLEND_COLOR ), Color::MAGENTA, TEST_LOCATION );
185 move = std::move( renderer );
186 DALI_TEST_CHECK( move );
187 DALI_TEST_EQUALS( 1, move.GetBaseObject().ReferenceCount(), TEST_LOCATION );
188 DALI_TEST_EQUALS( move.GetProperty<Vector4>( Renderer::Property::BLEND_COLOR ), Color::MAGENTA, TEST_LOCATION );
189 DALI_TEST_CHECK( !renderer );
194 int UtcDaliRendererDownCast01(void)
196 TestApplication application;
198 Geometry geometry = CreateQuadGeometry();
199 Shader shader = CreateShader();
200 Renderer renderer = Renderer::New(geometry, shader);
202 BaseHandle handle(renderer);
203 Renderer renderer2 = Renderer::DownCast(handle);
204 DALI_TEST_EQUALS( (bool)renderer2, true, TEST_LOCATION );
208 int UtcDaliRendererDownCast02(void)
210 TestApplication application;
212 Handle handle = Handle::New(); // Create a custom object
213 Renderer renderer = Renderer::DownCast(handle);
214 DALI_TEST_EQUALS( (bool)renderer, false, TEST_LOCATION );
218 // using a template to auto deduce the parameter types
219 template< typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8>
220 void TEST_RENDERER_PROPERTY( P1 renderer, P2 stringName, P3 type, P4 isWriteable, P5 isAnimateable, P6 isConstraintInput, P7 enumName, P8 LOCATION )
222 DALI_TEST_EQUALS( renderer.GetPropertyName( enumName ), stringName, LOCATION );
223 DALI_TEST_EQUALS( renderer.GetPropertyIndex( stringName ), static_cast<Property::Index>(enumName), LOCATION );
224 DALI_TEST_EQUALS( renderer.GetPropertyType( enumName ), type, LOCATION );
225 DALI_TEST_EQUALS( renderer.IsPropertyWritable( enumName ), isWriteable, LOCATION );
226 DALI_TEST_EQUALS( renderer.IsPropertyAnimatable( enumName ), isAnimateable, LOCATION );
227 DALI_TEST_EQUALS( renderer.IsPropertyAConstraintInput( enumName ), isConstraintInput, LOCATION );
230 int UtcDaliRendererDefaultProperties(void)
232 TestApplication application;
233 /* from renderer-impl.cpp
234 DALI_PROPERTY( "depthIndex", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_INDEX )
235 DALI_PROPERTY( "faceCullingMode", INTEGER, true, false, false, Dali::Renderer::Property::FACE_CULLING_MODE )
236 DALI_PROPERTY( "blendMode", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_MODE )
237 DALI_PROPERTY( "blendEquationRgb", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_EQUATION_RGB )
238 DALI_PROPERTY( "blendEquationAlpha", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_EQUATION_ALPHA )
239 DALI_PROPERTY( "blendFactorSrcRgb", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_SRC_RGB )
240 DALI_PROPERTY( "blendFactorDestRgb", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_DEST_RGB )
241 DALI_PROPERTY( "blendFactorSrcAlpha", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_SRC_ALPHA )
242 DALI_PROPERTY( "blendFactorDestAlpha", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_DEST_ALPHA )
243 DALI_PROPERTY( "blendColor", VECTOR4, true, false, false, Dali::Renderer::Property::BLEND_COLOR )
244 DALI_PROPERTY( "blendPreMultipliedAlpha", BOOLEAN, true, false, false, Dali::Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA )
245 DALI_PROPERTY( "indexRangeFirst", INTEGER, true, false, false, Dali::Renderer::Property::INDEX_RANGE_FIRST )
246 DALI_PROPERTY( "indexRangeCount", INTEGER, true, false, false, Dali::Renderer::Property::INDEX_RANGE_COUNT )
247 DALI_PROPERTY( "depthWriteMode", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_WRITE_MODE )
248 DALI_PROPERTY( "depthFunction", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_FUNCTION )
249 DALI_PROPERTY( "depthTestMode", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_TEST_MODE )
250 DALI_PROPERTY( "renderMode", INTEGER, true, false, false, Dali::Renderer::Property::RENDER_MODE )
251 DALI_PROPERTY( "stencilFunction", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION )
252 DALI_PROPERTY( "stencilFunctionMask", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION_MASK )
253 DALI_PROPERTY( "stencilFunctionReference", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION_REFERENCE )
254 DALI_PROPERTY( "stencilMask", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_MASK )
255 DALI_PROPERTY( "stencilOperationOnFail", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_FAIL )
256 DALI_PROPERTY( "stencilOperationOnZFail", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL )
257 DALI_PROPERTY( "stencilOperationOnZPass", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_PASS )
258 DALI_PROPERTY( "opacity", FLOAT, true, true, true, Dali::DevelRenderer::Property::OPACITY )
259 DALI_PROPERTY( "renderingBehavior", INTEGER, true, false, false, Dali::DevelRenderer::Property::RENDERING_BEHAVIOR )
262 Geometry geometry = CreateQuadGeometry();
263 Shader shader = CreateShader();
264 Renderer renderer = Renderer::New(geometry, shader);
265 DALI_TEST_EQUALS( renderer.GetPropertyCount(), 26, TEST_LOCATION );
267 TEST_RENDERER_PROPERTY( renderer, "depthIndex", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_INDEX, TEST_LOCATION );
268 TEST_RENDERER_PROPERTY( renderer, "faceCullingMode", Property::INTEGER, true, false, false, Renderer::Property::FACE_CULLING_MODE, TEST_LOCATION );
269 TEST_RENDERER_PROPERTY( renderer, "blendMode", Property::INTEGER, true, false, false, Renderer::Property::BLEND_MODE, TEST_LOCATION );
270 TEST_RENDERER_PROPERTY( renderer, "blendEquationRgb", Property::INTEGER, true, false, false, Renderer::Property::BLEND_EQUATION_RGB, TEST_LOCATION );
271 TEST_RENDERER_PROPERTY( renderer, "blendEquationAlpha", Property::INTEGER, true, false, false, Renderer::Property::BLEND_EQUATION_ALPHA, TEST_LOCATION );
272 TEST_RENDERER_PROPERTY( renderer, "blendFactorSrcRgb", Property::INTEGER, true, false, false, Renderer::Property::BLEND_FACTOR_SRC_RGB, TEST_LOCATION );
273 TEST_RENDERER_PROPERTY( renderer, "blendFactorDestRgb", Property::INTEGER, true, false, false, Renderer::Property::BLEND_FACTOR_DEST_RGB, TEST_LOCATION );
274 TEST_RENDERER_PROPERTY( renderer, "blendFactorSrcAlpha", Property::INTEGER, true, false, false, Renderer::Property::BLEND_FACTOR_SRC_ALPHA, TEST_LOCATION );
275 TEST_RENDERER_PROPERTY( renderer, "blendFactorDestAlpha", Property::INTEGER, true, false, false, Renderer::Property::BLEND_FACTOR_DEST_ALPHA, TEST_LOCATION );
276 TEST_RENDERER_PROPERTY( renderer, "blendColor", Property::VECTOR4, true, false, false, Renderer::Property::BLEND_COLOR, TEST_LOCATION );
277 TEST_RENDERER_PROPERTY( renderer, "blendPreMultipliedAlpha", Property::BOOLEAN, true, false, false, Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, TEST_LOCATION );
278 TEST_RENDERER_PROPERTY( renderer, "indexRangeFirst", Property::INTEGER, true, false, false, Renderer::Property::INDEX_RANGE_FIRST, TEST_LOCATION );
279 TEST_RENDERER_PROPERTY( renderer, "indexRangeCount", Property::INTEGER, true, false, false, Renderer::Property::INDEX_RANGE_COUNT, TEST_LOCATION );
280 TEST_RENDERER_PROPERTY( renderer, "depthWriteMode", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_WRITE_MODE, TEST_LOCATION );
281 TEST_RENDERER_PROPERTY( renderer, "depthFunction", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_FUNCTION, TEST_LOCATION );
282 TEST_RENDERER_PROPERTY( renderer, "depthTestMode", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_TEST_MODE, TEST_LOCATION );
283 TEST_RENDERER_PROPERTY( renderer, "renderMode", Property::INTEGER, true, false, false, Renderer::Property::RENDER_MODE, TEST_LOCATION );
284 TEST_RENDERER_PROPERTY( renderer, "stencilFunction", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_FUNCTION, TEST_LOCATION );
285 TEST_RENDERER_PROPERTY( renderer, "stencilFunctionMask", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_FUNCTION_MASK, TEST_LOCATION );
286 TEST_RENDERER_PROPERTY( renderer, "stencilFunctionReference",Property::INTEGER, true, false, false, Renderer::Property::STENCIL_FUNCTION_REFERENCE, TEST_LOCATION );
287 TEST_RENDERER_PROPERTY( renderer, "stencilMask", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_MASK, TEST_LOCATION );
288 TEST_RENDERER_PROPERTY( renderer, "stencilOperationOnFail", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_OPERATION_ON_FAIL, TEST_LOCATION );
289 TEST_RENDERER_PROPERTY( renderer, "stencilOperationOnZFail", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, TEST_LOCATION );
290 TEST_RENDERER_PROPERTY( renderer, "stencilOperationOnZPass", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, TEST_LOCATION );
291 TEST_RENDERER_PROPERTY( renderer, "opacity", Property::FLOAT, true, true, true, DevelRenderer::Property::OPACITY, TEST_LOCATION );
292 TEST_RENDERER_PROPERTY( renderer, "renderingBehavior", Property::INTEGER, true, false, false, DevelRenderer::Property::RENDERING_BEHAVIOR, TEST_LOCATION );
297 int UtcDaliRendererSetGetGeometry(void)
299 TestApplication application;
300 tet_infoline( "Test SetGeometry, GetGeometry" );
302 Geometry geometry1 = CreateQuadGeometry();
303 Geometry geometry2 = CreateQuadGeometry();
305 Shader shader = CreateShader();
306 Renderer renderer = Renderer::New(geometry1, shader);
307 Actor actor = Actor::New();
308 actor.AddRenderer(renderer);
309 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
310 application.GetScene().Add(actor);
312 application.SendNotification();
313 application.Render(0);
314 DALI_TEST_EQUALS( renderer.GetGeometry(), geometry1, TEST_LOCATION );
316 // Set geometry2 to the renderer
317 renderer.SetGeometry( geometry2 );
319 application.SendNotification();
320 application.Render(0);
321 DALI_TEST_EQUALS( renderer.GetGeometry(), geometry2, TEST_LOCATION );
326 int UtcDaliRendererSetGetShader(void)
328 TestApplication application;
329 tet_infoline( "Test SetShader, GetShader" );
331 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
332 glAbstraction.EnableCullFaceCallTrace(true);
334 Shader shader1 = CreateShader();
335 shader1.RegisterProperty( "uFadeColor", Color::RED );
337 Shader shader2 = CreateShader();
338 shader2.RegisterProperty( "uFadeColor", Color::GREEN );
340 Geometry geometry = CreateQuadGeometry();
341 Renderer renderer = Renderer::New(geometry, shader1);
342 Actor actor = Actor::New();
343 actor.AddRenderer(renderer);
344 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
345 application.GetScene().Add(actor);
347 TestGlAbstraction& gl = application.GetGlAbstraction();
348 application.SendNotification();
349 application.Render(0);
351 // Expect that the first shaders's fade color property is accessed
352 Vector4 actualValue(Vector4::ZERO);
353 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
354 DALI_TEST_EQUALS( actualValue, Color::RED, TEST_LOCATION );
356 DALI_TEST_EQUALS( renderer.GetShader(), shader1, TEST_LOCATION );
358 // set the second shader to the renderer
359 renderer.SetShader( shader2 );
361 application.SendNotification();
362 application.Render(0);
364 // Expect that the second shader's fade color property is accessed
365 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
366 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
368 DALI_TEST_EQUALS( renderer.GetShader(), shader2, TEST_LOCATION );
373 int UtcDaliRendererSetGetDepthIndex(void)
375 TestApplication application;
377 tet_infoline("Test SetDepthIndex, GetDepthIndex");
379 Shader shader = CreateShader();
380 Geometry geometry = CreateQuadGeometry();
381 Renderer renderer = Renderer::New(geometry, shader);
382 Actor actor = Actor::New();
383 actor.AddRenderer(renderer);
384 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
385 application.GetScene().Add(actor);
387 application.SendNotification();
388 application.Render(0);
389 DALI_TEST_EQUALS( renderer.GetProperty<int>(Renderer::Property::DEPTH_INDEX), 0, TEST_LOCATION );
391 renderer.SetProperty( Renderer::Property::DEPTH_INDEX, 1 );
393 DALI_TEST_EQUALS( renderer.GetProperty<int>(Renderer::Property::DEPTH_INDEX), 1, TEST_LOCATION );
394 DALI_TEST_EQUALS( renderer.GetCurrentProperty<int>(Renderer::Property::DEPTH_INDEX), 0, TEST_LOCATION );
396 application.SendNotification();
397 application.Render(0);
398 DALI_TEST_EQUALS( renderer.GetCurrentProperty<int>(Renderer::Property::DEPTH_INDEX), 1, TEST_LOCATION );
400 renderer.SetProperty( Renderer::Property::DEPTH_INDEX, 10 );
402 DALI_TEST_EQUALS( renderer.GetProperty<int>(Renderer::Property::DEPTH_INDEX), 10, TEST_LOCATION );
403 DALI_TEST_EQUALS( renderer.GetCurrentProperty<int>(Renderer::Property::DEPTH_INDEX), 1, TEST_LOCATION );
405 application.SendNotification();
406 application.Render(0);
407 DALI_TEST_EQUALS( renderer.GetCurrentProperty<int>(Renderer::Property::DEPTH_INDEX), 10, TEST_LOCATION );
412 int UtcDaliRendererSetGetFaceCullingMode(void)
414 TestApplication application;
416 tet_infoline("Test SetFaceCullingMode(cullingMode)");
417 Geometry geometry = CreateQuadGeometry();
418 Shader shader = CreateShader();
419 Renderer renderer = Renderer::New( geometry, shader );
421 Actor actor = Actor::New();
422 actor.AddRenderer(renderer);
423 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
424 application.GetScene().Add(actor);
426 // By default, none of the faces should be culled
427 unsigned int cullFace = renderer.GetProperty<int>( Renderer::Property::FACE_CULLING_MODE );
428 DALI_TEST_CHECK( static_cast< FaceCullingMode::Type >( cullFace ) == FaceCullingMode::NONE );
430 TestGlAbstraction& gl = application.GetGlAbstraction();
431 TraceCallStack& cullFaceStack = gl.GetCullFaceTrace();
432 gl.EnableCullFaceCallTrace(true);
435 cullFaceStack.Reset();
436 renderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::FRONT_AND_BACK );
437 application.SendNotification();
438 application.Render();
440 DALI_TEST_EQUALS( cullFaceStack.CountMethod( "CullFace" ), 1, TEST_LOCATION );
442 std::ostringstream cullModeString;
443 cullModeString << GL_FRONT_AND_BACK;
445 DALI_TEST_CHECK( cullFaceStack.FindMethodAndParams( "CullFace", cullModeString.str() ) );
446 cullFace = renderer.GetProperty<int>( Renderer::Property::FACE_CULLING_MODE );
447 DALI_TEST_CHECK( static_cast< FaceCullingMode::Type >( cullFace ) == FaceCullingMode::FRONT_AND_BACK );
451 cullFaceStack.Reset();
452 renderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::BACK );
453 application.SendNotification();
454 application.Render();
456 DALI_TEST_EQUALS( cullFaceStack.CountMethod( "CullFace" ), 1, TEST_LOCATION );
458 std::ostringstream cullModeString;
459 cullModeString << GL_BACK;
461 DALI_TEST_CHECK( cullFaceStack.FindMethodAndParams( "CullFace", cullModeString.str() ) );
462 cullFace = renderer.GetProperty<int>( Renderer::Property::FACE_CULLING_MODE );
463 DALI_TEST_CHECK( static_cast< FaceCullingMode::Type >( cullFace ) == FaceCullingMode::BACK );
467 cullFaceStack.Reset();
468 renderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::FRONT );
469 application.SendNotification();
470 application.Render();
472 DALI_TEST_EQUALS( cullFaceStack.CountMethod( "CullFace" ), 1, TEST_LOCATION );
474 std::ostringstream cullModeString;
475 cullModeString << GL_FRONT;
477 DALI_TEST_CHECK( cullFaceStack.FindMethodAndParams( "CullFace", cullModeString.str() ) );
478 cullFace = renderer.GetProperty<int>( Renderer::Property::FACE_CULLING_MODE );
479 DALI_TEST_CHECK( static_cast< FaceCullingMode::Type >( cullFace ) == FaceCullingMode::FRONT );
483 cullFaceStack.Reset();
484 renderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::NONE );
485 application.SendNotification();
486 application.Render();
488 DALI_TEST_EQUALS( cullFaceStack.CountMethod( "CullFace" ), 0, TEST_LOCATION );
489 cullFace = renderer.GetProperty<int>( Renderer::Property::FACE_CULLING_MODE );
490 DALI_TEST_CHECK( static_cast< FaceCullingMode::Type >( cullFace ) == FaceCullingMode::NONE );
496 int UtcDaliRendererBlendOptions01(void)
498 TestApplication application;
500 tet_infoline("Test BLEND_FACTOR properties ");
502 Geometry geometry = CreateQuadGeometry();
503 Shader shader = CreateShader();
504 Renderer renderer = Renderer::New( geometry, shader );
506 Actor actor = Actor::New();
507 // set a transparent actor color so that blending is enabled
508 actor.SetProperty( Actor::Property::OPACITY, 0.5f );
509 actor.AddRenderer(renderer);
510 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
511 application.GetScene().Add(actor);
513 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::ONE_MINUS_SRC_COLOR );
514 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::SRC_ALPHA_SATURATE );
515 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE_MINUS_SRC_COLOR );
516 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::SRC_ALPHA_SATURATE );
518 // Test that Set was successful:
519 int srcFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
520 int destFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
521 int srcFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
522 int destFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
524 DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_SRC_COLOR, srcFactorRgb, TEST_LOCATION );
525 DALI_TEST_EQUALS( (int)BlendFactor::SRC_ALPHA_SATURATE, destFactorRgb, TEST_LOCATION );
526 DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_SRC_COLOR, srcFactorAlpha, TEST_LOCATION );
527 DALI_TEST_EQUALS( (int)BlendFactor::SRC_ALPHA_SATURATE, destFactorAlpha, TEST_LOCATION );
529 application.SendNotification();
530 application.Render();
532 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
534 DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_SRC_COLOR, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION );
535 DALI_TEST_EQUALS( (GLenum)GL_SRC_ALPHA_SATURATE, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION );
536 DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_SRC_COLOR, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION );
537 DALI_TEST_EQUALS( (GLenum)GL_SRC_ALPHA_SATURATE, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION );
542 int UtcDaliRendererBlendOptions02(void)
544 TestApplication application;
546 tet_infoline("Test BLEND_FACTOR properties ");
548 Geometry geometry = CreateQuadGeometry();
549 Shader shader = CreateShader();
550 Renderer renderer = Renderer::New( geometry, shader );
552 Actor actor = Actor::New();
553 actor.SetProperty( Actor::Property::OPACITY, 0.5f ); // enable blending
554 actor.AddRenderer(renderer);
555 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
556 application.GetScene().Add(actor);
558 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::CONSTANT_COLOR );
559 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ONE_MINUS_CONSTANT_COLOR );
560 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::CONSTANT_ALPHA );
561 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ONE_MINUS_CONSTANT_ALPHA );
563 // Test that Set was successful:
565 int srcFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
566 int destFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
567 int srcFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
568 int destFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
570 DALI_TEST_EQUALS( (int)BlendFactor::CONSTANT_COLOR, srcFactorRgb, TEST_LOCATION );
571 DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_CONSTANT_COLOR, destFactorRgb, TEST_LOCATION );
572 DALI_TEST_EQUALS( (int)BlendFactor::CONSTANT_ALPHA, srcFactorAlpha, TEST_LOCATION );
573 DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_CONSTANT_ALPHA, destFactorAlpha, TEST_LOCATION );
576 application.SendNotification();
577 application.Render();
579 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
580 DALI_TEST_EQUALS( (GLenum)GL_CONSTANT_COLOR, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION );
581 DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_CONSTANT_COLOR, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION );
582 DALI_TEST_EQUALS( (GLenum)GL_CONSTANT_ALPHA, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION );
583 DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_CONSTANT_ALPHA, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION );
588 int UtcDaliRendererBlendOptions03(void)
590 TestApplication application;
592 tet_infoline("Test GetBlendEquation() defaults ");
594 Geometry geometry = CreateQuadGeometry();
595 Shader shader = CreateShader();
596 Renderer renderer = Renderer::New( geometry, shader );
598 Actor actor = Actor::New();
599 actor.AddRenderer(renderer);
600 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
601 application.GetScene().Add(actor);
603 // Test the defaults as documented in blending.h
604 int equationRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_EQUATION_RGB );
605 int equationAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_EQUATION_ALPHA );
607 DALI_TEST_EQUALS( (int)BlendEquation::ADD, equationRgb, TEST_LOCATION );
608 DALI_TEST_EQUALS( (int)BlendEquation::ADD, equationAlpha, TEST_LOCATION );
613 int UtcDaliRendererBlendOptions04(void)
615 TestApplication application;
617 tet_infoline("Test SetBlendEquation() ");
619 Geometry geometry = CreateQuadGeometry();
620 Shader shader = CreateShader();
621 Renderer renderer = Renderer::New( geometry, shader );
623 Actor actor = Actor::New();
624 actor.SetProperty( Actor::Property::OPACITY, 0.1f );
625 actor.AddRenderer(renderer);
626 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
627 application.GetScene().Add(actor);
629 // Test the single blending equation setting
631 renderer.SetProperty( Renderer::Property::BLEND_EQUATION_RGB, BlendEquation::REVERSE_SUBTRACT );
632 int equationRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_EQUATION_RGB );
633 DALI_TEST_EQUALS( (int)BlendEquation::REVERSE_SUBTRACT, equationRgb, TEST_LOCATION );
636 renderer.SetProperty( Renderer::Property::BLEND_EQUATION_RGB, BlendEquation::REVERSE_SUBTRACT );
637 renderer.SetProperty( Renderer::Property::BLEND_EQUATION_ALPHA, BlendEquation::REVERSE_SUBTRACT );
639 // Test that Set was successful
641 int equationRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_EQUATION_RGB );
642 int equationAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_EQUATION_ALPHA );
643 DALI_TEST_EQUALS( (int)BlendEquation::REVERSE_SUBTRACT, equationRgb, TEST_LOCATION );
644 DALI_TEST_EQUALS( (int)BlendEquation::REVERSE_SUBTRACT, equationAlpha, TEST_LOCATION );
647 // Render & check GL commands
648 application.SendNotification();
649 application.Render();
651 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
652 DALI_TEST_EQUALS( (GLenum)GL_FUNC_REVERSE_SUBTRACT, glAbstraction.GetLastBlendEquationRgb(), TEST_LOCATION );
653 DALI_TEST_EQUALS( (GLenum)GL_FUNC_REVERSE_SUBTRACT, glAbstraction.GetLastBlendEquationAlpha(), TEST_LOCATION );
658 int UtcDaliRendererSetBlendMode01(void)
660 TestApplication application;
662 tet_infoline("Test setting the blend mode to on with an opaque color renders with blending enabled");
664 Geometry geometry = CreateQuadGeometry();
665 Shader shader = CreateShader();
666 Renderer renderer = Renderer::New( geometry, shader );
668 Actor actor = Actor::New();
669 actor.SetProperty( Actor::Property::OPACITY, 0.98f );
670 actor.AddRenderer(renderer);
671 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
672 application.GetScene().Add(actor);
674 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON);
676 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
677 glAbstraction.EnableEnableDisableCallTrace(true);
679 application.SendNotification();
680 application.Render();
682 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
683 std::ostringstream blendStr;
684 blendStr << GL_BLEND;
685 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
690 int UtcDaliRendererSetBlendMode01b(void)
692 TestApplication application;
694 tet_infoline("Test setting the blend mode to on with an transparent color renders with blending enabled");
696 Geometry geometry = CreateQuadGeometry();
697 Shader shader = CreateShader();
698 Renderer renderer = Renderer::New( geometry, shader );
700 Actor actor = Actor::New();
701 actor.SetProperty( Actor::Property::OPACITY, 0.0f );
702 actor.AddRenderer(renderer);
703 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
704 application.GetScene().Add(actor);
706 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON);
708 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
709 glAbstraction.EnableEnableDisableCallTrace(true);
710 glAbstraction.EnableDrawCallTrace( true );
712 application.SendNotification();
713 application.Render();
715 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
716 std::ostringstream blendStr;
717 blendStr << GL_BLEND;
718 DALI_TEST_CHECK( !glEnableStack.FindMethod( "Enable" ) );
720 DALI_TEST_CHECK( !glAbstraction.GetDrawTrace().FindMethod( "DrawElements" ) );
725 int UtcDaliRendererSetBlendMode02(void)
727 TestApplication application;
729 tet_infoline("Test setting the blend mode to off with a transparent color renders with blending disabled (and not enabled)");
731 Geometry geometry = CreateQuadGeometry();
732 Shader shader = CreateShader();
733 Renderer renderer = Renderer::New( geometry, shader );
735 Actor actor = Actor::New();
736 actor.SetProperty( Actor::Property::OPACITY, 0.15f );
737 actor.AddRenderer(renderer);
738 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
739 application.GetScene().Add(actor);
741 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::OFF);
743 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
744 glAbstraction.EnableEnableDisableCallTrace(true);
746 application.SendNotification();
747 application.Render();
749 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
750 std::ostringstream blendStr;
751 blendStr << GL_BLEND;
752 DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
757 int UtcDaliRendererSetBlendMode03(void)
759 TestApplication application;
761 tet_infoline("Test setting the blend mode to auto with a transparent color renders with blending enabled");
763 Geometry geometry = CreateQuadGeometry();
764 Shader shader = CreateShader();
765 Renderer renderer = Renderer::New( geometry, shader );
767 Actor actor = Actor::New();
768 actor.SetProperty( Actor::Property::OPACITY, 0.75f );
769 actor.AddRenderer(renderer);
770 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
771 application.GetScene().Add(actor);
773 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO);
775 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
776 glAbstraction.EnableEnableDisableCallTrace(true);
778 application.SendNotification();
779 application.Render();
781 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
782 std::ostringstream blendStr;
783 blendStr << GL_BLEND;
784 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
789 int UtcDaliRendererSetBlendMode04(void)
791 TestApplication application;
793 tet_infoline("Test setting the blend mode to auto with an opaque color renders with blending disabled");
795 Geometry geometry = CreateQuadGeometry();
796 Shader shader = CreateShader();
797 Renderer renderer = Renderer::New( geometry, shader );
799 Actor actor = Actor::New();
800 actor.AddRenderer(renderer);
801 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
802 application.GetScene().Add(actor);
804 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO);
806 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
807 glAbstraction.EnableEnableDisableCallTrace(true);
809 application.SendNotification();
810 application.Render();
812 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
813 std::ostringstream blendStr;
814 blendStr << GL_BLEND;
815 DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
820 int UtcDaliRendererSetBlendMode04b(void)
822 TestApplication application;
824 tet_infoline("Test setting the blend mode to auto with a transparent actor color renders with blending enabled");
826 Geometry geometry = CreateQuadGeometry();
827 Shader shader = CreateShader();
828 Renderer renderer = Renderer::New( geometry, shader );
830 Actor actor = Actor::New();
831 actor.AddRenderer(renderer);
832 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
833 actor.SetProperty( Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 0.5f) );
834 application.GetScene().Add(actor);
836 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO);
838 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
839 glAbstraction.EnableEnableDisableCallTrace(true);
841 application.SendNotification();
842 application.Render();
844 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
845 std::ostringstream blendStr;
846 blendStr << GL_BLEND;
847 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
852 int UtcDaliRendererSetBlendMode04c(void)
854 TestApplication application;
856 tet_infoline("Test setting the blend mode to auto with an opaque opaque actor color renders with blending disabled");
858 Geometry geometry = CreateQuadGeometry();
859 Shader shader = CreateShader();
860 Renderer renderer = Renderer::New( geometry, shader );
862 Actor actor = Actor::New();
863 actor.AddRenderer(renderer);
864 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
865 actor.SetProperty( Actor::Property::COLOR, Color::MAGENTA );
866 application.GetScene().Add(actor);
868 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO);
870 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
871 glAbstraction.EnableEnableDisableCallTrace(true);
873 application.SendNotification();
874 application.Render();
876 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
877 std::ostringstream blendStr;
878 blendStr << GL_BLEND;
879 DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
884 int UtcDaliRendererSetBlendMode05(void)
886 TestApplication application;
888 tet_infoline("Test setting the blend mode to auto with an opaque color and an image with an alpha channel renders with blending enabled");
890 Geometry geometry = CreateQuadGeometry();
891 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 40, 40);
893 Shader shader = CreateShader();
894 TextureSet textureSet = CreateTextureSet( image );
895 Renderer renderer = Renderer::New( geometry, shader );
896 renderer.SetTextures( textureSet );
898 Actor actor = Actor::New();
899 actor.AddRenderer(renderer);
900 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
901 application.GetScene().Add(actor);
903 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO);
905 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
906 glAbstraction.EnableEnableDisableCallTrace(true);
908 application.SendNotification();
909 application.Render();
911 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
912 std::ostringstream blendStr;
913 blendStr << GL_BLEND;
914 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
919 int UtcDaliRendererSetBlendMode06(void)
921 TestApplication application;
922 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");
924 Geometry geometry = CreateQuadGeometry();
925 Shader shader = Shader::New( "vertexSrc", "fragmentSrc", Shader::Hint::OUTPUT_IS_TRANSPARENT );
927 Renderer renderer = Renderer::New( geometry, shader );
929 Actor actor = Actor::New();
930 actor.AddRenderer(renderer);
931 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
932 application.GetScene().Add(actor);
934 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO);
936 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
937 glAbstraction.EnableEnableDisableCallTrace(true);
939 application.SendNotification();
940 application.Render();
942 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
943 std::ostringstream blendStr;
944 blendStr << GL_BLEND;
945 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
950 int UtcDaliRendererSetBlendMode07(void)
952 TestApplication application;
953 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");
955 Geometry geometry = CreateQuadGeometry();
956 Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
958 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGB888, 50, 50);
959 TextureSet textureSet = CreateTextureSet( image );
960 Renderer renderer = Renderer::New( geometry, shader );
961 renderer.SetTextures( textureSet );
963 Actor actor = Actor::New();
964 actor.AddRenderer(renderer);
965 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
966 application.GetScene().Add(actor);
968 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO);
970 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
971 glAbstraction.EnableEnableDisableCallTrace(true);
973 application.SendNotification();
974 application.Render();
976 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
977 DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", "GL_BLEND" ) );
982 int UtcDaliRendererGetBlendMode(void)
984 TestApplication application;
986 tet_infoline("Test GetBlendMode()");
988 Geometry geometry = CreateQuadGeometry();
989 Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
990 Renderer renderer = Renderer::New( geometry, shader );
993 unsigned int mode = renderer.GetProperty<int>( Renderer::Property::BLEND_MODE );
994 DALI_TEST_EQUALS( static_cast< BlendMode::Type >( mode ), BlendMode::AUTO, TEST_LOCATION );
997 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON );
998 mode = renderer.GetProperty<int>( Renderer::Property::BLEND_MODE );
999 DALI_TEST_EQUALS( static_cast< BlendMode::Type >( mode ), BlendMode::ON, TEST_LOCATION );
1002 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::OFF );
1003 mode = renderer.GetProperty<int>( Renderer::Property::BLEND_MODE );
1004 DALI_TEST_EQUALS( static_cast< BlendMode::Type >( mode ), BlendMode::OFF, TEST_LOCATION );
1009 int UtcDaliRendererSetBlendColor(void)
1011 TestApplication application;
1013 tet_infoline("Test SetBlendColor(color)");
1015 Geometry geometry = CreateQuadGeometry();
1016 Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
1017 TextureSet textureSet = TextureSet::New();
1018 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 50, 50);
1019 textureSet.SetTexture(0u, image);
1020 Renderer renderer = Renderer::New( geometry, shader );
1021 renderer.SetTextures( textureSet );
1023 Actor actor = Actor::New();
1024 actor.AddRenderer(renderer);
1025 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
1026 application.GetScene().Add(actor);
1028 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
1030 renderer.SetProperty( Renderer::Property::BLEND_COLOR, Color::TRANSPARENT );
1032 application.SendNotification();
1033 application.Render();
1035 DALI_TEST_EQUALS( renderer.GetProperty< Vector4 >(Renderer::Property::BLEND_COLOR), Color::TRANSPARENT, TEST_LOCATION );
1036 DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >(Renderer::Property::BLEND_COLOR), Color::TRANSPARENT, TEST_LOCATION );
1037 DALI_TEST_EQUALS( glAbstraction.GetLastBlendColor(), Color::TRANSPARENT, TEST_LOCATION );
1039 renderer.SetProperty( Renderer::Property::BLEND_COLOR, Color::MAGENTA );
1041 DALI_TEST_EQUALS( renderer.GetProperty< Vector4 >(Renderer::Property::BLEND_COLOR), Color::MAGENTA, TEST_LOCATION );
1042 DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >(Renderer::Property::BLEND_COLOR), Color::TRANSPARENT, TEST_LOCATION );
1044 application.SendNotification();
1045 application.Render();
1047 DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >(Renderer::Property::BLEND_COLOR), Color::MAGENTA, TEST_LOCATION );
1048 DALI_TEST_EQUALS( glAbstraction.GetLastBlendColor(), Color::MAGENTA, TEST_LOCATION );
1050 Vector4 color( 0.1f, 0.2f, 0.3f, 0.4f );
1051 renderer.SetProperty( Renderer::Property::BLEND_COLOR, color );
1052 application.SendNotification();
1053 application.Render();
1054 DALI_TEST_EQUALS( glAbstraction.GetLastBlendColor(), color, TEST_LOCATION );
1059 int UtcDaliRendererGetBlendColor(void)
1061 TestApplication application;
1063 tet_infoline("Test GetBlendColor()");
1065 Geometry geometry = CreateQuadGeometry();
1066 Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
1067 Renderer renderer = Renderer::New( geometry, shader );
1069 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>( Renderer::Property::BLEND_COLOR ), Color::TRANSPARENT, TEST_LOCATION );
1071 renderer.SetProperty( Renderer::Property::BLEND_COLOR, Color::MAGENTA );
1072 application.SendNotification();
1073 application.Render();
1074 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>( Renderer::Property::BLEND_COLOR ), Color::MAGENTA, TEST_LOCATION );
1076 Vector4 color( 0.1f, 0.2f, 0.3f, 0.4f );
1077 renderer.SetProperty( Renderer::Property::BLEND_COLOR, color );
1078 application.SendNotification();
1079 application.Render();
1080 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>( Renderer::Property::BLEND_COLOR ), color, TEST_LOCATION );
1085 int UtcDaliRendererPreMultipledAlpha(void)
1087 TestApplication application;
1089 tet_infoline("Test BLEND_PRE_MULTIPLIED_ALPHA property");
1091 Geometry geometry = CreateQuadGeometry();
1092 Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
1093 Renderer renderer = Renderer::New( geometry, shader );
1095 Actor actor = Actor::New();
1096 actor.AddRenderer(renderer);
1097 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
1098 actor.SetProperty( Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 0.5f) );
1099 application.GetScene().Add(actor);
1101 Property::Value value = renderer.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
1102 bool preMultipliedAlpha;
1103 DALI_TEST_CHECK( value.Get( preMultipliedAlpha ) );
1104 DALI_TEST_CHECK( !preMultipliedAlpha );
1106 int srcFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
1107 int destFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
1108 int srcFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
1109 int destFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
1111 DALI_TEST_EQUALS( (int)DEFAULT_BLEND_FACTOR_SRC_RGB, srcFactorRgb, TEST_LOCATION );
1112 DALI_TEST_EQUALS( (int)DEFAULT_BLEND_FACTOR_DEST_RGB, destFactorRgb, TEST_LOCATION );
1113 DALI_TEST_EQUALS( (int)DEFAULT_BLEND_FACTOR_SRC_ALPHA, srcFactorAlpha, TEST_LOCATION );
1114 DALI_TEST_EQUALS( (int)DEFAULT_BLEND_FACTOR_DEST_ALPHA, destFactorAlpha, TEST_LOCATION );
1116 application.SendNotification();
1117 application.Render();
1119 Vector4 actualValue(Vector4::ZERO);
1120 TestGlAbstraction& gl = application.GetGlAbstraction();
1121 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uColor", actualValue ) );
1122 DALI_TEST_EQUALS( actualValue, Vector4(1.0f, 0.0f, 1.0f, 0.5f), TEST_LOCATION );
1124 // Enable pre-multiplied alpha
1125 renderer.SetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true );
1127 application.SendNotification();
1128 application.Render();
1130 value = renderer.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
1131 DALI_TEST_CHECK( value.Get( preMultipliedAlpha ) );
1132 DALI_TEST_CHECK( preMultipliedAlpha );
1134 value = renderer.GetCurrentProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
1135 DALI_TEST_CHECK( value.Get( preMultipliedAlpha ) );
1136 DALI_TEST_CHECK( preMultipliedAlpha );
1138 srcFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
1139 destFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
1140 srcFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
1141 destFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
1143 DALI_TEST_EQUALS( (int)BlendFactor::ONE, srcFactorRgb, TEST_LOCATION );
1144 DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorRgb, TEST_LOCATION );
1145 DALI_TEST_EQUALS( (int)BlendFactor::ONE, srcFactorAlpha, TEST_LOCATION );
1146 DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorAlpha, TEST_LOCATION );
1148 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uColor", actualValue ) );
1149 DALI_TEST_EQUALS( actualValue, Vector4(0.5f, 0.0f, 0.5f, 0.5f), TEST_LOCATION );
1151 // Disable pre-multiplied alpha again
1152 renderer.SetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, false );
1154 application.SendNotification();
1155 application.Render();
1157 value = renderer.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
1158 DALI_TEST_CHECK( value.Get( preMultipliedAlpha ) );
1159 DALI_TEST_CHECK( !preMultipliedAlpha );
1161 value = renderer.GetCurrentProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
1162 DALI_TEST_CHECK( value.Get( preMultipliedAlpha ) );
1163 DALI_TEST_CHECK( !preMultipliedAlpha );
1165 srcFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
1166 destFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
1167 srcFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
1168 destFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
1170 DALI_TEST_EQUALS( (int)BlendFactor::SRC_ALPHA, srcFactorRgb, TEST_LOCATION );
1171 DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorRgb, TEST_LOCATION );
1172 DALI_TEST_EQUALS( (int)BlendFactor::ONE, srcFactorAlpha, TEST_LOCATION );
1173 DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorAlpha, TEST_LOCATION );
1175 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uColor", actualValue ) );
1176 DALI_TEST_EQUALS( actualValue, Vector4( 1.0f, 0.0f, 1.0f, 0.5f ), TEST_LOCATION );
1181 int UtcDaliRendererConstraint01(void)
1183 TestApplication application;
1185 tet_infoline("Test that a non-uniform renderer property can be constrained");
1187 Shader shader = Shader::New("VertexSource", "FragmentSource");
1188 Geometry geometry = CreateQuadGeometry();
1189 Renderer renderer = Renderer::New( geometry, shader );
1191 Actor actor = Actor::New();
1192 actor.AddRenderer(renderer);
1193 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
1194 application.GetScene().Add(actor);
1196 Vector4 initialColor = Color::WHITE;
1197 Property::Index colorIndex = renderer.RegisterProperty( "uFadeColor", initialColor );
1199 application.SendNotification();
1200 application.Render(0);
1201 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
1204 Constraint constraint = Constraint::New<Vector4>( renderer, colorIndex, TestConstraintNoBlue );
1206 application.SendNotification();
1207 application.Render(0);
1209 // Expect no blue component in either buffer - yellow
1210 DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >( colorIndex ), Color::YELLOW, TEST_LOCATION );
1211 application.Render(0);
1212 DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >( colorIndex ), Color::YELLOW, TEST_LOCATION );
1214 renderer.RemoveConstraints();
1215 renderer.SetProperty(colorIndex, Color::WHITE );
1216 application.SendNotification();
1217 application.Render(0);
1218 DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >( colorIndex ), Color::WHITE, TEST_LOCATION );
1223 int UtcDaliRendererConstraint02(void)
1225 TestApplication application;
1227 tet_infoline("Test that a uniform map renderer property can be constrained");
1229 Shader shader = Shader::New("VertexSource", "FragmentSource");
1230 Geometry geometry = CreateQuadGeometry();
1231 Renderer renderer = Renderer::New( geometry, shader );
1233 Actor actor = Actor::New();
1234 actor.AddRenderer(renderer);
1235 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
1236 application.GetScene().Add(actor);
1237 application.SendNotification();
1238 application.Render(0);
1240 Vector4 initialColor = Color::WHITE;
1241 Property::Index colorIndex = renderer.RegisterProperty( "uFadeColor", initialColor );
1243 TestGlAbstraction& gl = application.GetGlAbstraction();
1245 application.SendNotification();
1246 application.Render(0);
1248 Vector4 actualValue(Vector4::ZERO);
1249 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1250 DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
1253 Constraint constraint = Constraint::New<Vector4>( renderer, colorIndex, TestConstraintNoBlue );
1255 application.SendNotification();
1256 application.Render(0);
1258 // Expect no blue component in either buffer - yellow
1259 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1260 DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
1262 application.Render(0);
1263 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1264 DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
1266 renderer.RemoveConstraints();
1267 renderer.SetProperty(colorIndex, Color::WHITE );
1268 application.SendNotification();
1269 application.Render(0);
1271 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1272 DALI_TEST_EQUALS( actualValue, Color::WHITE, TEST_LOCATION );
1277 int UtcDaliRendererAnimatedProperty01(void)
1279 TestApplication application;
1281 tet_infoline("Test that a non-uniform renderer property can be animated");
1283 Shader shader = Shader::New("VertexSource", "FragmentSource");
1284 Geometry geometry = CreateQuadGeometry();
1285 Renderer renderer = Renderer::New( geometry, shader );
1287 Actor actor = Actor::New();
1288 actor.AddRenderer(renderer);
1289 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
1290 application.GetScene().Add(actor);
1292 Vector4 initialColor = Color::WHITE;
1293 Property::Index colorIndex = renderer.RegisterProperty( "uFadeColor", initialColor );
1295 application.SendNotification();
1296 application.Render(0);
1297 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
1299 Animation animation = Animation::New(1.0f);
1300 KeyFrames keyFrames = KeyFrames::New();
1301 keyFrames.Add(0.0f, initialColor);
1302 keyFrames.Add(1.0f, Color::TRANSPARENT);
1303 animation.AnimateBetween( Property( renderer, colorIndex ), keyFrames );
1306 application.SendNotification();
1307 application.Render(500);
1309 DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >( colorIndex ), Color::WHITE * 0.5f, TEST_LOCATION );
1311 application.Render(500);
1313 DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >( colorIndex ), Color::TRANSPARENT, TEST_LOCATION );
1318 int UtcDaliRendererAnimatedProperty02(void)
1320 TestApplication application;
1322 tet_infoline("Test that a uniform map renderer property can be animated");
1324 Shader shader = Shader::New("VertexSource", "FragmentSource");
1325 Geometry geometry = CreateQuadGeometry();
1326 Renderer renderer = Renderer::New( geometry, shader );
1328 Actor actor = Actor::New();
1329 actor.AddRenderer(renderer);
1330 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
1331 application.GetScene().Add(actor);
1332 application.SendNotification();
1333 application.Render(0);
1335 Vector4 initialColor = Color::WHITE;
1336 Property::Index colorIndex = renderer.RegisterProperty( "uFadeColor", initialColor );
1338 TestGlAbstraction& gl = application.GetGlAbstraction();
1340 application.SendNotification();
1341 application.Render(0);
1343 Vector4 actualValue(Vector4::ZERO);
1344 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1345 DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
1347 Animation animation = Animation::New(1.0f);
1348 KeyFrames keyFrames = KeyFrames::New();
1349 keyFrames.Add(0.0f, initialColor);
1350 keyFrames.Add(1.0f, Color::TRANSPARENT);
1351 animation.AnimateBetween( Property( renderer, colorIndex ), keyFrames );
1354 application.SendNotification();
1355 application.Render(500);
1357 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1358 DALI_TEST_EQUALS( actualValue, Color::WHITE * 0.5f, TEST_LOCATION );
1360 application.Render(500);
1361 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1362 DALI_TEST_EQUALS( actualValue, Color::TRANSPARENT, TEST_LOCATION );
1367 int UtcDaliRendererUniformMapPrecendence01(void)
1369 TestApplication application;
1371 tet_infoline("Test the uniform map precedence is applied properly");
1373 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64);
1375 Shader shader = Shader::New("VertexSource", "FragmentSource");
1376 TextureSet textureSet = CreateTextureSet( image );
1378 Geometry geometry = CreateQuadGeometry();
1379 Renderer renderer = Renderer::New( geometry, shader );
1380 renderer.SetTextures( textureSet );
1382 Actor actor = Actor::New();
1383 actor.AddRenderer(renderer);
1384 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
1385 application.GetScene().Add(actor);
1386 application.SendNotification();
1387 application.Render(0);
1389 renderer.RegisterProperty( "uFadeColor", Color::RED );
1390 actor.RegisterProperty( "uFadeColor", Color::GREEN );
1391 Property::Index shaderFadeColorIndex = shader.RegisterProperty( "uFadeColor", Color::MAGENTA );
1393 TestGlAbstraction& gl = application.GetGlAbstraction();
1395 application.SendNotification();
1396 application.Render(0);
1398 // Expect that the actor's fade color property is accessed
1399 Vector4 actualValue(Vector4::ZERO);
1400 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1401 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1403 // Animate shader's fade color property. Should be no change to uniform
1404 Animation animation = Animation::New(1.0f);
1405 KeyFrames keyFrames = KeyFrames::New();
1406 keyFrames.Add(0.0f, Color::WHITE);
1407 keyFrames.Add(1.0f, Color::TRANSPARENT);
1408 animation.AnimateBetween( Property( shader, shaderFadeColorIndex ), keyFrames );
1411 application.SendNotification();
1412 application.Render(500);
1414 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1415 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1417 application.Render(500);
1418 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1419 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1424 int UtcDaliRendererUniformMapPrecendence02(void)
1426 TestApplication application;
1428 tet_infoline("Test the uniform map precedence is applied properly");
1430 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64);
1432 Shader shader = Shader::New("VertexSource", "FragmentSource");
1433 TextureSet textureSet = CreateTextureSet( image );
1435 Geometry geometry = CreateQuadGeometry();
1436 Renderer renderer = Renderer::New( geometry, shader );
1437 renderer.SetTextures( textureSet );
1439 Actor actor = Actor::New();
1440 actor.AddRenderer(renderer);
1441 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
1442 application.GetScene().Add(actor);
1443 application.SendNotification();
1444 application.Render(0);
1446 // Don't add property / uniform map to renderer
1447 actor.RegisterProperty( "uFadeColor", Color::GREEN );
1448 Property::Index shaderFadeColorIndex = shader.RegisterProperty( "uFadeColor", Color::BLUE );
1450 TestGlAbstraction& gl = application.GetGlAbstraction();
1452 application.SendNotification();
1453 application.Render(0);
1455 // Expect that the actor's fade color property is accessed
1456 Vector4 actualValue(Vector4::ZERO);
1457 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1458 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1460 // Animate texture set's fade color property. Should be no change to uniform
1461 Animation animation = Animation::New(1.0f);
1462 KeyFrames keyFrames = KeyFrames::New();
1463 keyFrames.Add(0.0f, Color::WHITE);
1464 keyFrames.Add(1.0f, Color::TRANSPARENT);
1465 animation.AnimateBetween( Property( shader, shaderFadeColorIndex ), keyFrames );
1468 application.SendNotification();
1469 application.Render(500);
1471 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1472 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1474 application.Render(500);
1475 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1476 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1482 int UtcDaliRendererUniformMapPrecendence03(void)
1484 TestApplication application;
1486 tet_infoline("Test the uniform map precedence is applied properly");
1488 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64);
1490 Shader shader = Shader::New("VertexSource", "FragmentSource");
1491 TextureSet textureSet = CreateTextureSet( image );
1493 Geometry geometry = CreateQuadGeometry();
1494 Renderer renderer = Renderer::New( geometry, shader );
1495 renderer.SetTextures( textureSet );
1497 Actor actor = Actor::New();
1498 actor.AddRenderer(renderer);
1499 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
1500 application.GetScene().Add(actor);
1501 application.SendNotification();
1502 application.Render(0);
1504 // Don't add property / uniform map to renderer or actor
1505 shader.RegisterProperty( "uFadeColor", Color::BLACK );
1507 TestGlAbstraction& gl = application.GetGlAbstraction();
1509 application.SendNotification();
1510 application.Render(0);
1512 // Expect that the shader's fade color property is accessed
1513 Vector4 actualValue(Vector4::ZERO);
1514 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1515 DALI_TEST_EQUALS( actualValue, Color::BLACK, TEST_LOCATION );
1520 int UtcDaliRendererUniformMapMultipleUniforms01(void)
1522 TestApplication application;
1524 tet_infoline("Test the uniform maps are collected from all objects (same type)");
1526 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64);
1528 Shader shader = Shader::New("VertexSource", "FragmentSource");
1529 TextureSet textureSet = CreateTextureSet( image );
1531 Geometry geometry = CreateQuadGeometry();
1532 Renderer renderer = Renderer::New( geometry, shader );
1533 renderer.SetTextures( textureSet );
1535 Actor actor = Actor::New();
1536 actor.AddRenderer(renderer);
1537 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
1538 application.GetScene().Add(actor);
1539 application.SendNotification();
1540 application.Render(0);
1542 renderer.RegisterProperty( "uUniform1", Color::RED );
1543 actor.RegisterProperty( "uUniform2", Color::GREEN );
1544 shader.RegisterProperty( "uUniform3", Color::MAGENTA );
1546 TestGlAbstraction& gl = application.GetGlAbstraction();
1548 application.SendNotification();
1549 application.Render(0);
1551 // Expect that each of the object's uniforms are set
1552 Vector4 uniform1Value(Vector4::ZERO);
1553 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform1", uniform1Value ) );
1554 DALI_TEST_EQUALS( uniform1Value, Color::RED, TEST_LOCATION );
1556 Vector4 uniform2Value(Vector4::ZERO);
1557 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform2", uniform2Value ) );
1558 DALI_TEST_EQUALS( uniform2Value, Color::GREEN, TEST_LOCATION );
1560 Vector4 uniform3Value(Vector4::ZERO);
1561 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform3", uniform3Value ) );
1562 DALI_TEST_EQUALS( uniform3Value, Color::MAGENTA, TEST_LOCATION );
1567 int UtcDaliRendererUniformMapMultipleUniforms02(void)
1569 TestApplication application;
1571 tet_infoline("Test the uniform maps are collected from all objects (different types)");
1573 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64);
1575 Shader shader = Shader::New("VertexSource", "FragmentSource");
1576 TextureSet textureSet = CreateTextureSet( image );
1578 Geometry geometry = CreateQuadGeometry();
1579 Renderer renderer = Renderer::New( geometry, shader );
1580 renderer.SetTextures( textureSet );
1582 Actor actor = Actor::New();
1583 actor.AddRenderer(renderer);
1584 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
1585 application.GetScene().Add(actor);
1586 application.SendNotification();
1587 application.Render(0);
1589 Property::Value value1(Color::RED);
1590 renderer.RegisterProperty( "uFadeColor", value1 );
1592 Property::Value value2(1.0f);
1593 actor.RegisterProperty( "uFadeProgress", value2 );
1595 Property::Value value3(Matrix3::IDENTITY);
1596 shader.RegisterProperty( "uANormalMatrix", value3 );
1598 TestGlAbstraction& gl = application.GetGlAbstraction();
1600 application.SendNotification();
1601 application.Render(0);
1603 // Expect that each of the object's uniforms are set
1604 Vector4 uniform1Value(Vector4::ZERO);
1605 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", uniform1Value ) );
1606 DALI_TEST_EQUALS( uniform1Value, value1.Get<Vector4>(), TEST_LOCATION );
1608 float uniform2Value(0.0f);
1609 DALI_TEST_CHECK( gl.GetUniformValue<float>( "uFadeProgress", uniform2Value ) );
1610 DALI_TEST_EQUALS( uniform2Value, value2.Get<float>(), TEST_LOCATION );
1612 Matrix3 uniform3Value;
1613 DALI_TEST_CHECK( gl.GetUniformValue<Matrix3>( "uANormalMatrix", uniform3Value ) );
1614 DALI_TEST_EQUALS( uniform3Value, value3.Get<Matrix3>(), TEST_LOCATION );
1620 Renderer CreateRenderer( Actor actor, Geometry geometry, Shader shader, int depthIndex )
1622 Texture image0 = Texture::New(TextureType::TEXTURE_2D, Pixel::RGB888, 64, 64);
1623 TextureSet textureSet0 = CreateTextureSet( image0 );
1624 Renderer renderer0 = Renderer::New( geometry, shader );
1625 renderer0.SetTextures( textureSet0 );
1626 renderer0.SetProperty( Renderer::Property::DEPTH_INDEX, depthIndex );
1627 actor.AddRenderer(renderer0);
1632 Actor CreateActor( Actor parent, int siblingOrder, const char* location )
1634 Actor actor = Actor::New();
1635 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER);
1636 actor.SetProperty( Actor::Property::PARENT_ORIGIN,AnchorPoint::CENTER);
1637 actor.SetProperty( Actor::Property::POSITION, Vector2(0.0f,0.0f));
1638 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1640 actor.SetProperty( Dali::DevelActor::Property::SIBLING_ORDER, siblingOrder );
1641 DALI_TEST_EQUALS( actor.GetProperty<int>( Dali::DevelActor::Property::SIBLING_ORDER), siblingOrder, TEST_INNER_LOCATION(location) );
1646 int UtcDaliRendererRenderOrder2DLayer(void)
1648 TestApplication application;
1649 tet_infoline("Test the rendering order in a 2D layer is correct");
1651 Shader shader = Shader::New("VertexSource", "FragmentSource");
1652 Geometry geometry = CreateQuadGeometry();
1654 Actor root = application.GetScene().GetRootLayer();
1656 Actor actor0 = CreateActor( root, 0, TEST_LOCATION );
1657 Renderer renderer0 = CreateRenderer( actor0, geometry, shader, 0 );
1659 Actor actor1 = CreateActor( root, 0, TEST_LOCATION );
1660 Renderer renderer1 = CreateRenderer( actor1, geometry, shader, 0 );
1662 Actor actor2 = CreateActor( root, 0, TEST_LOCATION );
1663 Renderer renderer2 = CreateRenderer( actor2, geometry, shader, 0 );
1665 Actor actor3 = CreateActor( root, 0, TEST_LOCATION );
1666 Renderer renderer3 = CreateRenderer( actor3, geometry, shader, 0 );
1668 application.SendNotification();
1669 application.Render(0);
1672 * Create the following hierarchy:
1685 * Expected rendering order : actor2 - actor1 - actor0 - actor3
1690 application.SendNotification();
1691 application.Render(0);
1693 TestGlAbstraction& gl = application.GetGlAbstraction();
1694 gl.EnableTextureCallTrace(true);
1695 application.SendNotification();
1696 application.Render(0);
1698 int textureBindIndex[4];
1699 for( unsigned int i(0); i<4; ++i )
1701 std::stringstream params;
1702 params << GL_TEXTURE_2D<<", "<<i+1;
1703 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
1706 //Check that actor1 has been rendered after actor2
1707 DALI_TEST_GREATER( textureBindIndex[1], textureBindIndex[2], TEST_LOCATION );
1709 //Check that actor0 has been rendered after actor1
1710 DALI_TEST_GREATER( textureBindIndex[0], textureBindIndex[1], TEST_LOCATION );
1712 //Check that actor3 has been rendered after actor0
1713 DALI_TEST_GREATER( textureBindIndex[3], textureBindIndex[0], TEST_LOCATION );
1718 int UtcDaliRendererRenderOrder2DLayerMultipleRenderers(void)
1720 TestApplication application;
1721 tet_infoline("Test the rendering order in a 2D layer is correct using multiple renderers per actor");
1724 * Creates the following hierarchy:
1726 * actor0------------------------>actor1
1730 * renderer0 renderer1 renderer2 renderer3 renderer4 renderer5
1732 * renderer0 has depth index 2
1733 * renderer1 has depth index 0
1734 * renderer2 has depth index 1
1736 * renderer3 has depth index 1
1737 * renderer4 has depth index 0
1738 * renderer5 has depth index -1
1740 * Expected rendering order: renderer1 - renderer2 - renderer0 - renderer5 - renderer4 - renderer3
1743 Shader shader = Shader::New("VertexSource", "FragmentSource");
1744 Geometry geometry = CreateQuadGeometry();
1746 Actor root = application.GetScene().GetRootLayer();
1748 Actor actor0 = CreateActor( root, 0, TEST_LOCATION );
1749 Actor actor1 = CreateActor( actor0, 0, TEST_LOCATION );
1750 Renderer renderer0 = CreateRenderer( actor0, geometry, shader, 2 );
1751 Renderer renderer1 = CreateRenderer( actor0, geometry, shader, 0 );
1752 Renderer renderer2 = CreateRenderer( actor0, geometry, shader, 1 );
1753 Renderer renderer3 = CreateRenderer( actor1, geometry, shader, 1 );
1754 Renderer renderer4 = CreateRenderer( actor1, geometry, shader, 0 );
1755 Renderer renderer5 = CreateRenderer( actor1, geometry, shader, -1 );
1757 application.SendNotification();
1758 application.Render(0);
1760 TestGlAbstraction& gl = application.GetGlAbstraction();
1761 gl.EnableTextureCallTrace(true);
1762 application.SendNotification();
1763 application.Render(0);
1765 int textureBindIndex[6];
1766 for( unsigned int i(0); i<6; ++i )
1768 std::stringstream params;
1769 params << GL_TEXTURE_2D<<", "<<i+1;
1770 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
1773 //Check that renderer3 has been rendered after renderer4
1774 DALI_TEST_GREATER( textureBindIndex[3], textureBindIndex[4], TEST_LOCATION );
1776 //Check that renderer0 has been rendered after renderer2
1777 DALI_TEST_GREATER( textureBindIndex[4], textureBindIndex[5], TEST_LOCATION );
1779 //Check that renderer5 has been rendered after renderer2
1780 DALI_TEST_GREATER( textureBindIndex[5], textureBindIndex[0], TEST_LOCATION );
1782 //Check that renderer0 has been rendered after renderer2
1783 DALI_TEST_GREATER( textureBindIndex[0], textureBindIndex[2], TEST_LOCATION );
1785 //Check that renderer2 has been rendered after renderer1
1786 DALI_TEST_GREATER( textureBindIndex[2], textureBindIndex[1], TEST_LOCATION );
1792 int UtcDaliRendererRenderOrder2DLayerSiblingOrder(void)
1794 TestApplication application;
1795 tet_infoline("Test the rendering order in a 2D layer is correct using sibling order");
1798 * Creates the following hierarchy:
1806 * actor0 (SIBLING_ORDER:1) actor1 (SIBLING_ORDER:0)
1810 * renderer0 renderer1 actor2 renderer2 renderer3 renderer4
1811 * DI:2 DI:0 | DI:0 DI:1 DI:2
1816 * actor0 has sibling order 1
1817 * actor1 has sibling order 0
1818 * actor2 has sibling order 0
1820 * renderer0 has depth index 2
1821 * renderer1 has depth index 0
1823 * renderer2 has depth index 0
1824 * renderer3 has depth index 1
1825 * renderer4 has depth index 2
1827 * renderer5 has depth index -1
1829 * Expected rendering order: renderer2 - renderer3 - renderer4 - renderer1 - renderer0 - renderer5
1832 Shader shader = Shader::New("VertexSource", "FragmentSource");
1833 Geometry geometry = CreateQuadGeometry();
1834 Actor root = application.GetScene().GetRootLayer();
1835 Actor actor0 = CreateActor( root, 1, TEST_LOCATION );
1836 Actor actor1 = CreateActor( root, 0, TEST_LOCATION );
1837 Actor actor2 = CreateActor( actor0, 0, TEST_LOCATION );
1839 Renderer renderer0 = CreateRenderer( actor0, geometry, shader, 2 );
1840 Renderer renderer1 = CreateRenderer( actor0, geometry, shader, 0 );
1841 Renderer renderer2 = CreateRenderer( actor1, geometry, shader, 0 );
1842 Renderer renderer3 = CreateRenderer( actor1, geometry, shader, 1 );
1843 Renderer renderer4 = CreateRenderer( actor1, geometry, shader, 2 );
1844 Renderer renderer5 = CreateRenderer( actor2, geometry, shader, -1 );
1846 application.SendNotification();
1847 application.Render();
1849 TestGlAbstraction& gl = application.GetGlAbstraction();
1850 gl.EnableTextureCallTrace(true);
1851 application.SendNotification();
1852 application.Render(0);
1854 int textureBindIndex[6];
1855 for( unsigned int i(0); i<6; ++i )
1857 std::stringstream params;
1858 params << GL_TEXTURE_2D<<", "<<i+1;
1859 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
1862 DALI_TEST_EQUALS( textureBindIndex[2], 0, TEST_LOCATION );
1863 DALI_TEST_EQUALS( textureBindIndex[3], 1, TEST_LOCATION );
1864 DALI_TEST_EQUALS( textureBindIndex[4], 2, TEST_LOCATION );
1865 DALI_TEST_EQUALS( textureBindIndex[1], 3, TEST_LOCATION );
1866 DALI_TEST_EQUALS( textureBindIndex[0], 4, TEST_LOCATION );
1867 DALI_TEST_EQUALS( textureBindIndex[5], 5, TEST_LOCATION );
1869 // Change sibling order of actor1
1870 // New Expected rendering order: renderer1 - renderer0 - renderer 5 - renderer2 - renderer3 - renderer4
1871 actor1.SetProperty( Dali::DevelActor::Property::SIBLING_ORDER, 2 );
1873 gl.GetTextureTrace().Reset();
1874 application.SendNotification();
1875 application.Render(0);
1877 for( unsigned int i(0); i<6; ++i )
1879 std::stringstream params;
1880 params << GL_TEXTURE_2D<<", "<<i+1;
1881 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
1884 DALI_TEST_EQUALS( textureBindIndex[1], 0, TEST_LOCATION );
1885 DALI_TEST_EQUALS( textureBindIndex[0], 1, TEST_LOCATION );
1886 DALI_TEST_EQUALS( textureBindIndex[5], 2, TEST_LOCATION );
1887 DALI_TEST_EQUALS( textureBindIndex[2], 3, TEST_LOCATION );
1888 DALI_TEST_EQUALS( textureBindIndex[3], 4, TEST_LOCATION );
1889 DALI_TEST_EQUALS( textureBindIndex[4], 5, TEST_LOCATION );
1894 int UtcDaliRendererRenderOrder2DLayerOverlay(void)
1896 TestApplication application;
1897 tet_infoline("Test the rendering order in a 2D layer is correct for overlays");
1899 Shader shader = Shader::New("VertexSource", "FragmentSource");
1900 Geometry geometry = CreateQuadGeometry();
1901 Actor root = application.GetScene().GetRootLayer();
1904 * Create the following hierarchy:
1911 * (Overlay) (Regular actor)
1921 * Expected rendering order : actor2 - actor4 - actor1 - actor0 - actor3
1924 Actor actor0 = CreateActor( root, 0, TEST_LOCATION );
1925 actor0.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
1926 Renderer renderer0 = CreateRenderer( actor0, geometry, shader, 0 );
1928 Actor actor1 = CreateActor( root, 0, TEST_LOCATION );
1929 actor1.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
1930 Renderer renderer1 = CreateRenderer( actor1, geometry, shader, 0 );
1932 Actor actor2 = CreateActor( root, 0, TEST_LOCATION );
1933 Renderer renderer2 = CreateRenderer( actor2, geometry, shader, 0 );
1935 Actor actor3 = CreateActor( root, 0, TEST_LOCATION );
1936 actor3.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
1937 Renderer renderer3 = CreateRenderer( actor3, geometry, shader, 0 );
1939 Actor actor4 = CreateActor( root, 0, TEST_LOCATION );
1940 Renderer renderer4 = CreateRenderer( actor4, geometry, shader, 0 );
1942 application.SendNotification();
1943 application.Render(0);
1950 TestGlAbstraction& gl = application.GetGlAbstraction();
1951 gl.EnableTextureCallTrace(true);
1952 application.SendNotification();
1953 application.Render(0);
1955 int textureBindIndex[5];
1956 for( unsigned int i(0); i<5; ++i )
1958 std::stringstream params;
1959 params << GL_TEXTURE_2D<<", "<<i+1;
1960 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
1963 //Check that actor4 has been rendered after actor2
1964 DALI_TEST_GREATER( textureBindIndex[4], textureBindIndex[2], TEST_LOCATION );
1966 //Check that actor1 has been rendered after actor4
1967 DALI_TEST_GREATER( textureBindIndex[1], textureBindIndex[4], TEST_LOCATION );
1969 //Check that actor0 has been rendered after actor1
1970 DALI_TEST_GREATER( textureBindIndex[0], textureBindIndex[1], TEST_LOCATION );
1972 //Check that actor3 has been rendered after actor0
1973 DALI_TEST_GREATER( textureBindIndex[3], textureBindIndex[0], TEST_LOCATION );
1978 int UtcDaliRendererSetIndexRange(void)
1982 "attribute vec2 aPosition;\n"
1985 " gl_Position = aPosition;\n"
1991 " gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0)\n"
1995 TestApplication application;
1996 tet_infoline("Test setting the range of indices to draw");
1998 TestGlAbstraction& gl = application.GetGlAbstraction();
1999 gl.EnableDrawCallTrace( true );
2001 Actor actor = Actor::New();
2002 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2005 Geometry geometry = Geometry::New();
2006 geometry.SetType( Geometry::LINE_LOOP );
2008 // --------------------------------------------------------------------------
2010 unsigned short indices[] = { 0, 2, 4, 6, 8, // offset = 0, count = 5
2011 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, // offset = 5, count = 10
2012 1, 3, 5, 7, 9, 1 }; // offset = 15, count = 6 // line strip
2014 // --------------------------------------------------------------------------
2023 { Vector2( 0.0f, 1.00f) }, { Vector2( 0.0f, -1.00f) },
2024 { Vector2( -0.95f, 0.31f) }, { Vector2( 0.59f, 0.81f) },
2025 { Vector2( -0.59f, -0.81f) }, { Vector2( -0.95f, -0.31f) },
2026 { Vector2( 0.59f, -0.81f) }, { Vector2( 0.95f, -0.31f) },
2027 { Vector2( 0.95f, 0.31f) }, { Vector2( -0.59f, 0.81f) },
2029 Property::Map vertexFormat;
2030 vertexFormat["aPosition"] = Property::VECTOR2;
2031 VertexBuffer vertexBuffer = VertexBuffer::New( vertexFormat );
2032 vertexBuffer.SetData( shapes, sizeof(shapes)/sizeof(shapes[0]));
2034 // --------------------------------------------------------------------------
2035 geometry.SetIndexBuffer( indices, sizeof(indices)/sizeof(indices[0]) );
2036 geometry.AddVertexBuffer( vertexBuffer );
2039 Shader shader = Shader::New( vertexShader,fragmentShader );
2040 Renderer renderer = Renderer::New( geometry, shader );
2041 actor.AddRenderer( renderer );
2043 Integration::Scene scene = application.GetScene();
2048 // LINE_LOOP, first 0, count 5
2050 renderer.SetIndexRange( 0, 5 );
2051 application.SendNotification();
2052 application.Render();
2054 Property::Value value = renderer.GetProperty( Renderer::Property::INDEX_RANGE_FIRST );
2056 DALI_TEST_CHECK( value.Get( convertedValue ) );
2057 DALI_TEST_CHECK( convertedValue == 0 );
2059 value = renderer.GetCurrentProperty( Renderer::Property::INDEX_RANGE_FIRST );
2060 DALI_TEST_CHECK( value.Get( convertedValue ) );
2061 DALI_TEST_CHECK( convertedValue == 0 );
2063 value = renderer.GetProperty( Renderer::Property::INDEX_RANGE_COUNT );
2064 DALI_TEST_CHECK( value.Get( convertedValue ) );
2065 DALI_TEST_CHECK( convertedValue == 5 );
2067 value = renderer.GetCurrentProperty( Renderer::Property::INDEX_RANGE_COUNT );
2068 DALI_TEST_CHECK( value.Get( convertedValue ) );
2069 DALI_TEST_CHECK( convertedValue == 5 );
2071 sprintf( buffer, "%u, 5, %u, indices", GL_LINE_LOOP, GL_UNSIGNED_SHORT );
2072 bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
2073 DALI_TEST_CHECK( result );
2076 // LINE_LOOP, first 5, count 10
2078 renderer.SetIndexRange( 5, 10 );
2079 sprintf( buffer, "%u, 10, %u, indices", GL_LINE_LOOP, GL_UNSIGNED_SHORT );
2080 application.SendNotification();
2081 application.Render();
2082 bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
2083 DALI_TEST_CHECK( result );
2086 // LINE_STRIP, first 15, count 6
2088 renderer.SetIndexRange( 15, 6 );
2089 geometry.SetType( Geometry::LINE_STRIP );
2090 sprintf( buffer, "%u, 6, %u, indices", GL_LINE_STRIP, GL_UNSIGNED_SHORT );
2091 application.SendNotification();
2092 application.Render();
2093 bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
2094 DALI_TEST_CHECK( result );
2097 // Index out of bounds
2099 renderer.SetIndexRange( 15, 30 );
2100 geometry.SetType( Geometry::LINE_STRIP );
2101 sprintf( buffer, "%u, 6, %u, indices", GL_LINE_STRIP, GL_UNSIGNED_SHORT );
2102 application.SendNotification();
2103 application.Render();
2104 bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
2105 DALI_TEST_CHECK( result );
2108 // drawing whole buffer starting from 15 ( last valid primitive )
2110 renderer.SetIndexRange( 15, 0 );
2111 geometry.SetType( Geometry::LINE_STRIP );
2112 sprintf( buffer, "%u, 6, %u, indices", GL_LINE_STRIP, GL_UNSIGNED_SHORT );
2113 application.SendNotification();
2114 application.Render();
2115 bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
2116 DALI_TEST_CHECK( result );
2123 int UtcDaliRendererSetDepthFunction(void)
2125 TestApplication application;
2127 tet_infoline("Test setting the depth function");
2129 Geometry geometry = CreateQuadGeometry();
2130 Shader shader = CreateShader();
2131 Renderer renderer = Renderer::New( geometry, shader );
2133 Actor actor = Actor::New();
2134 actor.AddRenderer(renderer);
2135 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
2136 Integration::Scene scene = application.GetScene();
2137 scene.GetRootLayer().SetProperty( Layer::Property::BEHAVIOR, Layer::LAYER_3D );
2140 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2141 glAbstraction.EnableEnableDisableCallTrace(true);
2142 glAbstraction.EnableDepthFunctionCallTrace(true);
2144 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2145 TraceCallStack& glDepthFunctionStack = glAbstraction.GetDepthFunctionTrace();
2147 std::ostringstream depthTestStr;
2148 depthTestStr << GL_DEPTH_TEST;
2152 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::NEVER);
2154 glEnableDisableStack.Reset();
2155 glDepthFunctionStack.Reset();
2156 application.SendNotification();
2157 application.Render();
2159 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", depthTestStr.str().c_str() ) );
2160 std::ostringstream depthFunctionStr;
2161 depthFunctionStr << GL_NEVER;
2162 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2167 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::ALWAYS);
2169 glDepthFunctionStack.Reset();
2170 application.SendNotification();
2171 application.Render();
2173 std::ostringstream depthFunctionStr;
2174 depthFunctionStr << GL_ALWAYS;
2175 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2180 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::LESS);
2182 glDepthFunctionStack.Reset();
2183 application.SendNotification();
2184 application.Render();
2186 std::ostringstream depthFunctionStr;
2187 depthFunctionStr << GL_LESS;
2188 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2193 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::GREATER);
2195 glDepthFunctionStack.Reset();
2196 application.SendNotification();
2197 application.Render();
2199 std::ostringstream depthFunctionStr;
2200 depthFunctionStr << GL_GREATER;
2201 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2206 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::EQUAL);
2208 glDepthFunctionStack.Reset();
2209 application.SendNotification();
2210 application.Render();
2212 std::ostringstream depthFunctionStr;
2213 depthFunctionStr << GL_EQUAL;
2214 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2219 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::NOT_EQUAL);
2221 glDepthFunctionStack.Reset();
2222 application.SendNotification();
2223 application.Render();
2225 std::ostringstream depthFunctionStr;
2226 depthFunctionStr << GL_NOTEQUAL;
2227 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2232 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::LESS_EQUAL);
2234 glDepthFunctionStack.Reset();
2235 application.SendNotification();
2236 application.Render();
2238 std::ostringstream depthFunctionStr;
2239 depthFunctionStr << GL_LEQUAL;
2240 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2245 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::GREATER_EQUAL);
2247 glDepthFunctionStack.Reset();
2248 application.SendNotification();
2249 application.Render();
2251 std::ostringstream depthFunctionStr;
2252 depthFunctionStr << GL_GEQUAL;
2253 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2260 * @brief This templatized function checks an enumeration property is setting and getting correctly.
2261 * The checks performed are as follows:
2262 * - Check the initial/default value.
2263 * - Set a different value via enum.
2264 * - Check it was set.
2265 * - Set a different value via string.
2266 * - Check it was set.
2268 template< typename T >
2269 void CheckEnumerationProperty( TestApplication& application, Renderer& renderer, Property::Index propertyIndex, T initialValue, T firstCheckEnumeration, T secondCheckEnumeration, std::string secondCheckString )
2271 application.SendNotification();
2272 application.Render();
2274 DALI_TEST_CHECK( renderer.GetProperty<int>( propertyIndex ) == static_cast<int>( initialValue ) );
2275 DALI_TEST_CHECK( renderer.GetCurrentProperty< int >( propertyIndex ) == static_cast<int>( initialValue ) );
2276 renderer.SetProperty( propertyIndex, firstCheckEnumeration );
2277 DALI_TEST_CHECK( renderer.GetProperty<int>( propertyIndex ) == static_cast<int>( firstCheckEnumeration ) );
2278 DALI_TEST_CHECK( renderer.GetCurrentProperty< int >( propertyIndex ) != static_cast<int>( firstCheckEnumeration ) );
2280 application.SendNotification();
2281 application.Render();
2283 DALI_TEST_CHECK( renderer.GetProperty<int>( propertyIndex ) == static_cast<int>( firstCheckEnumeration ) );
2284 DALI_TEST_CHECK( renderer.GetCurrentProperty< int >( propertyIndex ) == static_cast<int>( firstCheckEnumeration ) );
2286 renderer.SetProperty( propertyIndex, secondCheckString );
2287 DALI_TEST_CHECK( renderer.GetProperty<int>( propertyIndex ) == static_cast<int>( secondCheckEnumeration ) );
2288 DALI_TEST_CHECK( renderer.GetCurrentProperty< int >( propertyIndex ) != static_cast<int>( secondCheckEnumeration ) );
2290 application.SendNotification();
2291 application.Render();
2293 DALI_TEST_CHECK( renderer.GetProperty<int>( propertyIndex ) == static_cast<int>( secondCheckEnumeration ) );
2294 DALI_TEST_CHECK( renderer.GetCurrentProperty< int >( propertyIndex ) == static_cast<int>( secondCheckEnumeration ) );
2297 int UtcDaliRendererEnumProperties(void)
2299 TestApplication application;
2300 tet_infoline( "Test Renderer enumeration properties can be set with both integer and string values" );
2302 Geometry geometry = CreateQuadGeometry();
2303 Shader shader = CreateShader();
2304 Renderer renderer = Renderer::New( geometry, shader );
2306 Actor actor = Actor::New();
2307 actor.AddRenderer(renderer);
2308 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
2309 application.GetScene().Add(actor);
2312 * Here we use a templatized function to perform several checks on each enumeration property.
2313 * @see CheckEnumerationProperty for details of the checks performed.
2316 CheckEnumerationProperty< FaceCullingMode::Type >( application, renderer, Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::NONE, FaceCullingMode::FRONT, FaceCullingMode::BACK, "BACK" );
2317 CheckEnumerationProperty< BlendMode::Type >( application, renderer, Renderer::Property::BLEND_MODE, BlendMode::AUTO, BlendMode::OFF, BlendMode::ON, "ON" );
2318 CheckEnumerationProperty< BlendEquation::Type >( application, renderer, Renderer::Property::BLEND_EQUATION_RGB, BlendEquation::ADD, BlendEquation::SUBTRACT, BlendEquation::REVERSE_SUBTRACT, "REVERSE_SUBTRACT" );
2319 CheckEnumerationProperty< BlendEquation::Type >( application, renderer, Renderer::Property::BLEND_EQUATION_ALPHA, BlendEquation::ADD, BlendEquation::SUBTRACT, BlendEquation::REVERSE_SUBTRACT, "REVERSE_SUBTRACT" );
2320 CheckEnumerationProperty< BlendFactor::Type >( application, renderer, Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::SRC_ALPHA, BlendFactor::ONE, BlendFactor::SRC_COLOR, "SRC_COLOR" );
2321 CheckEnumerationProperty< BlendFactor::Type >( application, renderer, Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::SRC_COLOR, "SRC_COLOR" );
2322 CheckEnumerationProperty< BlendFactor::Type >( application, renderer, Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::SRC_COLOR, "SRC_COLOR" );
2323 CheckEnumerationProperty< BlendFactor::Type >( application, renderer, Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::SRC_COLOR, "SRC_COLOR" );
2324 CheckEnumerationProperty< DepthWriteMode::Type >( application, renderer, Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::AUTO, DepthWriteMode::OFF, DepthWriteMode::ON, "ON" );
2325 CheckEnumerationProperty< DepthFunction::Type >( application, renderer, Renderer::Property::DEPTH_FUNCTION, DepthFunction::LESS, DepthFunction::ALWAYS, DepthFunction::GREATER, "GREATER" );
2326 CheckEnumerationProperty< DepthTestMode::Type >( application, renderer, Renderer::Property::DEPTH_TEST_MODE, DepthTestMode::AUTO, DepthTestMode::OFF, DepthTestMode::ON, "ON" );
2327 CheckEnumerationProperty< StencilFunction::Type >( application, renderer, Renderer::Property::STENCIL_FUNCTION, StencilFunction::ALWAYS, StencilFunction::LESS, StencilFunction::EQUAL, "EQUAL" );
2328 CheckEnumerationProperty< RenderMode::Type >( application, renderer, Renderer::Property::RENDER_MODE, RenderMode::AUTO, RenderMode::NONE, RenderMode::STENCIL, "STENCIL" );
2329 CheckEnumerationProperty< StencilOperation::Type >( application, renderer, Renderer::Property::STENCIL_OPERATION_ON_FAIL, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT" );
2330 CheckEnumerationProperty< StencilOperation::Type >( application, renderer, Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT" );
2331 CheckEnumerationProperty< StencilOperation::Type >( application, renderer, Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT" );
2336 Renderer RendererTestFixture( TestApplication& application )
2338 Geometry geometry = CreateQuadGeometry();
2339 Shader shader = CreateShader();
2340 Renderer renderer = Renderer::New( geometry, shader );
2342 Actor actor = Actor::New();
2343 actor.AddRenderer( renderer );
2344 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
2345 Integration::Scene scene = application.GetScene();
2346 scene.GetRootLayer().SetProperty( Layer::Property::BEHAVIOR, Layer::LAYER_3D );
2352 int UtcDaliRendererSetDepthTestMode(void)
2354 TestApplication application;
2355 tet_infoline("Test setting the DepthTestMode");
2357 Renderer renderer = RendererTestFixture( application );
2358 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2359 glAbstraction.EnableEnableDisableCallTrace( true );
2360 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2362 glEnableDisableStack.Reset();
2363 application.SendNotification();
2364 application.Render();
2366 // Check depth-test is enabled by default.
2367 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetDepthTestString() ) );
2368 DALI_TEST_CHECK( !glEnableDisableStack.FindMethodAndParams( "Disable", GetDepthTestString() ) );
2370 // 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.
2371 renderer.SetProperty( Renderer::Property::DEPTH_TEST_MODE, DepthTestMode::OFF );
2372 renderer.SetProperty( Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::OFF );
2374 glEnableDisableStack.Reset();
2375 application.SendNotification();
2376 application.Render();
2378 // Check the depth buffer was disabled.
2379 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Disable", GetDepthTestString() ) );
2381 // Turn on automatic mode depth-testing.
2382 // Layer behavior is currently set to LAYER_3D so AUTO should enable depth-testing.
2383 renderer.SetProperty( Renderer::Property::DEPTH_TEST_MODE, DepthTestMode::AUTO );
2385 glEnableDisableStack.Reset();
2386 application.SendNotification();
2387 application.Render();
2389 // Check depth-test is now enabled.
2390 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetDepthTestString() ) );
2391 DALI_TEST_CHECK( !glEnableDisableStack.FindMethodAndParams( "Disable", GetDepthTestString() ) );
2393 // Change the layer behavior to LAYER_UI.
2394 // Note this will also disable depth testing for the layer by default, we test this first.
2395 application.GetScene().GetRootLayer().SetProperty( Layer::Property::BEHAVIOR, Layer::LAYER_UI );
2397 glEnableDisableStack.Reset();
2398 application.SendNotification();
2399 application.Render();
2401 // Check depth-test is disabled.
2402 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Disable", GetDepthTestString() ) );
2404 // Turn the layer depth-test flag back on, and confirm that depth testing is now on.
2405 application.GetScene().GetRootLayer().SetProperty(Layer::Property::DEPTH_TEST, true );
2407 glEnableDisableStack.Reset();
2408 application.SendNotification();
2409 application.Render();
2411 // Check depth-test is *still* disabled.
2412 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetDepthTestString() ) );
2417 int UtcDaliRendererSetDepthWriteMode(void)
2419 TestApplication application;
2420 tet_infoline("Test setting the DepthWriteMode");
2422 Renderer renderer = RendererTestFixture( application );
2423 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2425 application.SendNotification();
2426 application.Render();
2428 // Check the default depth-write status first.
2429 DALI_TEST_CHECK( glAbstraction.GetLastDepthMask() );
2431 // Turn off depth-writing.
2432 renderer.SetProperty( Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::OFF );
2434 application.SendNotification();
2435 application.Render();
2437 // Check depth-write is now disabled.
2438 DALI_TEST_CHECK( !glAbstraction.GetLastDepthMask() );
2440 // Test the AUTO mode for depth-writing.
2441 // As our renderer is opaque, depth-testing should be enabled.
2442 renderer.SetProperty( Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::AUTO );
2444 application.SendNotification();
2445 application.Render();
2447 // Check depth-write is now enabled.
2448 DALI_TEST_CHECK( glAbstraction.GetLastDepthMask() );
2450 // Now make the renderer be treated as translucent by enabling blending.
2451 // The AUTO depth-write mode should turn depth-write off in this scenario.
2452 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON );
2454 application.SendNotification();
2455 application.Render();
2457 // Check depth-write is now disabled.
2458 DALI_TEST_CHECK( !glAbstraction.GetLastDepthMask() );
2463 int UtcDaliRendererCheckStencilDefaults(void)
2465 TestApplication application;
2466 tet_infoline("Test the stencil defaults");
2468 Renderer renderer = RendererTestFixture( application );
2469 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2470 glAbstraction.EnableEnableDisableCallTrace( true );
2471 glAbstraction.EnableStencilFunctionCallTrace( true );
2472 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2473 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
2475 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2477 // Check the defaults:
2478 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION ).Get<int>() ), static_cast<int>( StencilFunction::ALWAYS ), TEST_LOCATION );
2479 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION_MASK ).Get<int>() ), 0xFF, TEST_LOCATION );
2480 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION_REFERENCE ).Get<int>() ), 0x00, TEST_LOCATION );
2481 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_MASK ).Get<int>() ), 0xFF, TEST_LOCATION );
2482 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_OPERATION_ON_FAIL ).Get<int>() ), static_cast<int>( StencilOperation::KEEP ), TEST_LOCATION );
2483 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 );
2484 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 );
2489 int UtcDaliRendererSetRenderModeToUseStencilBuffer(void)
2491 TestApplication application;
2492 tet_infoline("Test setting the RenderMode to use the stencil buffer");
2494 Renderer renderer = RendererTestFixture( application );
2495 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2496 glAbstraction.EnableEnableDisableCallTrace( true );
2497 glAbstraction.EnableStencilFunctionCallTrace( true );
2498 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2499 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
2501 // Set the StencilFunction to something other than the default, to confirm it is set as a property,
2502 // but NO GL call has been made while the RenderMode is set to not use the stencil buffer.
2503 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::NONE );
2504 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2506 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION, StencilFunction::NEVER );
2507 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION ).Get<int>() ), static_cast<int>( StencilFunction::NEVER ), TEST_LOCATION );
2509 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2510 std::string methodString( "StencilFunc" );
2511 DALI_TEST_CHECK( !glStencilFunctionStack.FindMethod( methodString ) );
2513 // Test the other RenderModes that will not enable the stencil buffer.
2514 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::AUTO );
2515 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2516 DALI_TEST_CHECK( !glStencilFunctionStack.FindMethod( methodString ) );
2518 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
2519 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2520 DALI_TEST_CHECK( !glStencilFunctionStack.FindMethod( methodString ) );
2522 // Now set the RenderMode to modes that will use the stencil buffer, and check the StencilFunction has changed.
2523 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL );
2524 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2526 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetStencilTestString() ) );
2527 DALI_TEST_CHECK( glStencilFunctionStack.FindMethod( methodString ) );
2529 // Test the COLOR_STENCIL RenderMode as it also enables the stencil buffer.
2530 // First set a mode to turn off the stencil buffer, so the enable is required.
2531 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
2532 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2533 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR_STENCIL );
2534 // Set a different stencil function as the last one is cached.
2535 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION, StencilFunction::ALWAYS );
2536 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2538 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetStencilTestString() ) );
2539 DALI_TEST_CHECK( glStencilFunctionStack.FindMethod( methodString ) );
2544 // Helper function for the SetRenderModeToUseColorBuffer test.
2545 void CheckRenderModeColorMask( TestApplication& application, Renderer& renderer, RenderMode::Type renderMode, bool expectedValue )
2547 // Set the RenderMode property to a value that should not allow color buffer writes.
2548 renderer.SetProperty( Renderer::Property::RENDER_MODE, renderMode );
2549 application.SendNotification();
2550 application.Render();
2552 // Check if ColorMask has been called, and that the values are correct.
2553 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2554 const TestGlAbstraction::ColorMaskParams& colorMaskParams( glAbstraction.GetColorMaskParams() );
2556 DALI_TEST_EQUALS<bool>( colorMaskParams.red, expectedValue, TEST_LOCATION );
2557 DALI_TEST_EQUALS<bool>( colorMaskParams.green, expectedValue, TEST_LOCATION );
2558 DALI_TEST_EQUALS<bool>( colorMaskParams.blue, expectedValue, TEST_LOCATION );
2559 DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, expectedValue, TEST_LOCATION );
2562 int UtcDaliRendererSetRenderModeToUseColorBuffer(void)
2564 TestApplication application;
2565 tet_infoline("Test setting the RenderMode to use the color buffer");
2567 Renderer renderer = RendererTestFixture( application );
2569 // Set the RenderMode property to a value that should not allow color buffer writes.
2570 // Then check if ColorMask has been called, and that the values are correct.
2571 CheckRenderModeColorMask( application, renderer, RenderMode::AUTO, true );
2572 CheckRenderModeColorMask( application, renderer, RenderMode::NONE, false );
2573 CheckRenderModeColorMask( application, renderer, RenderMode::COLOR, true );
2574 CheckRenderModeColorMask( application, renderer, RenderMode::STENCIL, false );
2575 CheckRenderModeColorMask( application, renderer, RenderMode::COLOR_STENCIL, true );
2580 int UtcDaliRendererSetStencilFunction(void)
2582 TestApplication application;
2583 tet_infoline("Test setting the StencilFunction");
2585 Renderer renderer = RendererTestFixture( application );
2586 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2587 glAbstraction.EnableEnableDisableCallTrace( true );
2588 glAbstraction.EnableStencilFunctionCallTrace( true );
2589 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2590 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
2592 // RenderMode must use the stencil for StencilFunction to operate.
2593 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL );
2594 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2597 * Lookup table for testing StencilFunction.
2598 * Note: This MUST be in the same order as the Dali::StencilFunction enum.
2600 const int StencilFunctionLookupTable[] = {
2609 }; const int StencilFunctionLookupTableCount = sizeof( StencilFunctionLookupTable ) / sizeof( StencilFunctionLookupTable[0] );
2612 * Loop through all types of StencilFunction, checking:
2613 * - The value is cached (set in event thread side)
2614 * - Causes "glStencilFunc" to be called
2615 * - Checks the correct parameters to "glStencilFunc" were used
2617 std::string nonChangingParameters = "0, 255";
2618 std::string methodString( "StencilFunc" );
2619 for( int i = 0; i < StencilFunctionLookupTableCount; ++i )
2621 // Set the property.
2622 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION, static_cast<Dali::StencilFunction::Type>( i ) );
2624 // Check GetProperty returns the same value.
2625 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION ).Get<int>() ), i, TEST_LOCATION );
2627 // Reset the trace debug.
2628 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2630 // Check the function is called and the parameters are correct.
2631 std::stringstream parameterStream;
2632 parameterStream << StencilFunctionLookupTable[ i ] << ", " << nonChangingParameters;
2634 DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterStream.str() ) );
2637 // Change the Function Reference only and check the behavior is correct:
2638 // 170 is 0xaa in hex / 10101010 in binary (every other bit set).
2639 int testValueReference = 170;
2640 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION_REFERENCE, testValueReference );
2642 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION_REFERENCE ).Get<int>() ), testValueReference, TEST_LOCATION );
2644 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2646 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetCurrentProperty( Renderer::Property::STENCIL_FUNCTION_REFERENCE ).Get<int>() ), testValueReference, TEST_LOCATION );
2648 std::stringstream parameterStream;
2649 parameterStream << StencilFunctionLookupTable[ StencilOperation::DECREMENT_WRAP ] << ", " << testValueReference << ", 255";
2651 DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterStream.str() ) );
2654 // Change the Function Mask only and check the behavior is correct:
2655 // 85 is 0x55 in hex / 01010101 in binary (every other bit set).
2656 int testValueMask = 85;
2657 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION_MASK, testValueMask );
2659 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION_MASK ).Get<int>() ), testValueMask, TEST_LOCATION );
2661 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2663 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetCurrentProperty( Renderer::Property::STENCIL_FUNCTION_MASK ).Get<int>() ), testValueMask, TEST_LOCATION );
2665 // Clear the stringstream.
2666 parameterStream.str( std::string() );
2667 parameterStream << StencilFunctionLookupTable[ StencilOperation::DECREMENT_WRAP ] << ", " << testValueReference << ", " << testValueMask;
2669 DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterStream.str() ) );
2674 int UtcDaliRendererSetStencilOperation(void)
2676 TestApplication application;
2677 tet_infoline("Test setting the StencilOperation");
2679 Renderer renderer = RendererTestFixture( application );
2680 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2681 glAbstraction.EnableEnableDisableCallTrace( true );
2682 glAbstraction.EnableStencilFunctionCallTrace( true );
2683 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2684 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
2686 // RenderMode must use the stencil for StencilOperation to operate.
2687 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL );
2690 * Lookup table for testing StencilOperation.
2691 * Note: This MUST be in the same order as the Dali::StencilOperation enum.
2693 const int StencilOperationLookupTable[] = {
2702 }; const int StencilOperationLookupTableCount = sizeof( StencilOperationLookupTable ) / sizeof( StencilOperationLookupTable[0] );
2704 // Set all 3 StencilOperation properties to a default.
2705 renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_FAIL, StencilOperation::KEEP );
2706 renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, StencilOperation::ZERO );
2707 renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, StencilOperation::ZERO );
2709 // Set our expected parameter list to the equivalent result.
2710 int parameters[] = { StencilOperationLookupTable[ StencilOperation::ZERO ], StencilOperationLookupTable[ StencilOperation::ZERO ], StencilOperationLookupTable[ StencilOperation::ZERO ] };
2712 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2715 * Loop through all types of StencilOperation, checking:
2716 * - The value is cached (set in event thread side)
2717 * - Causes "glStencilFunc" to be called
2718 * - Checks the correct parameters to "glStencilFunc" were used
2719 * - Checks the above for all 3 parameter placements of StencilOperation ( OnFail, OnZFail, OnPass )
2721 std::string methodString( "StencilOp" );
2723 for( int i = 0; i < StencilOperationLookupTableCount; ++i )
2725 for( int j = 0; j < StencilOperationLookupTableCount; ++j )
2727 for( int k = 0; k < StencilOperationLookupTableCount; ++k )
2729 // Set the property (outer loop causes all 3 different properties to be set separately).
2730 renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_FAIL, static_cast<Dali::StencilFunction::Type>( i ) );
2731 renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, static_cast<Dali::StencilFunction::Type>( j ) );
2732 renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, static_cast<Dali::StencilFunction::Type>( k ) );
2734 // Check GetProperty returns the same value.
2735 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_OPERATION_ON_FAIL ).Get<int>() ), i, TEST_LOCATION );
2736 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL ).Get<int>() ), j, TEST_LOCATION );
2737 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_PASS ).Get<int>() ), k, TEST_LOCATION );
2739 // Reset the trace debug.
2740 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2742 // Check the function is called and the parameters are correct.
2743 // Set the expected parameter value at its correct index (only)
2744 parameters[ 0u ] = StencilOperationLookupTable[ i ];
2745 parameters[ 1u ] = StencilOperationLookupTable[ j ];
2746 parameters[ 2u ] = StencilOperationLookupTable[ k ];
2748 // Build the parameter list.
2749 std::stringstream parameterStream;
2750 for( int parameterBuild = 0; parameterBuild < 3; ++parameterBuild )
2752 parameterStream << parameters[ parameterBuild ];
2753 // Comma-separate the parameters.
2754 if( parameterBuild < 2 )
2756 parameterStream << ", ";
2760 // Check the function was called and the parameters were correct.
2761 DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterStream.str() ) );
2769 int UtcDaliRendererSetStencilMask(void)
2771 TestApplication application;
2772 tet_infoline("Test setting the StencilMask");
2774 Renderer renderer = RendererTestFixture( application );
2775 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2776 glAbstraction.EnableEnableDisableCallTrace( true );
2777 glAbstraction.EnableStencilFunctionCallTrace( true );
2778 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2779 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
2781 // RenderMode must use the stencil for StencilMask to operate.
2782 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL );
2784 // Set the StencilMask property to a value.
2785 renderer.SetProperty( Renderer::Property::STENCIL_MASK, 0x00 );
2787 // Check GetProperty returns the same value.
2788 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_MASK ).Get<int>() ), 0x00, TEST_LOCATION );
2790 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2792 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetCurrentProperty( Renderer::Property::STENCIL_MASK ).Get<int>() ), 0x00, TEST_LOCATION );
2794 std::string methodString( "StencilMask" );
2795 std::string parameterString = "0";
2797 // Check the function was called and the parameters were correct.
2798 DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterString ) );
2800 // Set the StencilMask property to another value to ensure it has changed.
2801 renderer.SetProperty( Renderer::Property::STENCIL_MASK, 0xFF );
2803 // Check GetProperty returns the same value.
2804 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_MASK ).Get<int>() ), 0xFF, TEST_LOCATION );
2806 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2808 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetCurrentProperty( Renderer::Property::STENCIL_MASK ).Get<int>() ), 0xFF, TEST_LOCATION );
2810 parameterString = "255";
2812 // Check the function was called and the parameters were correct.
2813 DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterString ) );
2818 int UtcDaliRendererWrongNumberOfTextures(void)
2820 TestApplication application;
2821 tet_infoline("Test renderer does render even if number of textures is different than active samplers in the shader");
2823 //Create a TextureSet with 4 textures (One more texture in the texture set than active samplers)
2824 //@note Shaders in the test suit have 3 active samplers. See TestGlAbstraction::GetActiveUniform()
2825 Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 64u, 64u );
2826 TextureSet textureSet = CreateTextureSet();
2827 textureSet.SetTexture(0, texture );
2828 textureSet.SetTexture(1, texture );
2829 textureSet.SetTexture(2, texture );
2830 textureSet.SetTexture(3, texture );
2831 Shader shader = Shader::New("VertexSource", "FragmentSource");
2832 Geometry geometry = CreateQuadGeometry();
2833 Renderer renderer = Renderer::New( geometry, shader );
2834 renderer.SetTextures( textureSet );
2836 Actor actor= Actor::New();
2837 actor.AddRenderer(renderer);
2838 actor.SetProperty( Actor::Property::POSITION, Vector2(0.0f,0.0f));
2839 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2840 application.GetScene().Add(actor);
2842 TestGlAbstraction& gl = application.GetGlAbstraction();
2843 TraceCallStack& drawTrace = gl.GetDrawTrace();
2845 drawTrace.Enable(true);
2847 application.SendNotification();
2848 application.Render(0);
2850 //Test we do the drawcall when TextureSet has more textures than there are active samplers in the shader
2851 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION );
2853 //Create a TextureSet with 1 texture (two more active samplers than texture in the texture set)
2854 //@note Shaders in the test suit have 3 active samplers. See TestGlAbstraction::GetActiveUniform()
2855 textureSet = CreateTextureSet();
2856 renderer.SetTextures( textureSet );
2857 textureSet.SetTexture(0, texture );
2859 application.SendNotification();
2860 application.Render(0);
2862 //Test we do the drawcall when TextureSet has less textures than there are active samplers in the shader.
2863 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION );
2868 int UtcDaliRendererOpacity(void)
2870 TestApplication application;
2872 tet_infoline( "Test OPACITY property" );
2874 Geometry geometry = CreateQuadGeometry();
2875 Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
2876 Renderer renderer = Renderer::New( geometry, shader );
2878 Actor actor = Actor::New();
2879 actor.AddRenderer( renderer );
2880 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
2881 actor.SetProperty( Actor::Property::COLOR, Vector4( 1.0f, 0.0f, 1.0f, 1.0f ) );
2882 application.GetScene().Add( actor );
2884 Property::Value value = renderer.GetProperty( DevelRenderer::Property::OPACITY );
2886 DALI_TEST_CHECK( value.Get( opacity ) );
2887 DALI_TEST_EQUALS( opacity, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION );
2889 application.SendNotification();
2890 application.Render();
2892 Vector4 actualValue;
2893 TestGlAbstraction& gl = application.GetGlAbstraction();
2894 DALI_TEST_CHECK( gl.GetUniformValue< Vector4 >( "uColor", actualValue ) );
2895 DALI_TEST_EQUALS( actualValue.a, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION );
2897 renderer.SetProperty( DevelRenderer::Property::OPACITY, 0.5f );
2899 application.SendNotification();
2900 application.Render();
2902 value = renderer.GetProperty( DevelRenderer::Property::OPACITY );
2903 DALI_TEST_CHECK( value.Get( opacity ) );
2904 DALI_TEST_EQUALS( opacity, 0.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION );
2906 value = renderer.GetCurrentProperty( DevelRenderer::Property::OPACITY );
2907 DALI_TEST_CHECK( value.Get( opacity ) );
2908 DALI_TEST_EQUALS( opacity, 0.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION );
2910 DALI_TEST_CHECK( gl.GetUniformValue< Vector4 >( "uColor", actualValue ) );
2911 DALI_TEST_EQUALS( actualValue.a, 0.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION );
2916 int UtcDaliRendererOpacityAnimation(void)
2918 TestApplication application;
2920 tet_infoline( "Test OPACITY property animation" );
2922 Geometry geometry = CreateQuadGeometry();
2923 Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
2924 Renderer renderer = Renderer::New( geometry, shader );
2926 Actor actor = Actor::New();
2927 actor.AddRenderer( renderer );
2928 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
2929 actor.SetProperty( Actor::Property::COLOR, Vector4( 1.0f, 0.0f, 1.0f, 1.0f ) );
2930 application.GetScene().Add( actor );
2932 application.SendNotification();
2933 application.Render(0);
2935 Property::Value value = renderer.GetProperty( DevelRenderer::Property::OPACITY );
2937 DALI_TEST_CHECK( value.Get( opacity ) );
2938 DALI_TEST_EQUALS( opacity, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION );
2940 Animation animation = Animation::New( 1.0f );
2941 animation.AnimateTo( Property( renderer, DevelRenderer::Property::OPACITY ), 0.0f );
2944 application.SendNotification();
2945 application.Render( 1000 );
2947 value = renderer.GetProperty( DevelRenderer::Property::OPACITY );
2948 DALI_TEST_CHECK( value.Get( opacity ) );
2949 DALI_TEST_EQUALS( opacity, 0.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION );
2951 // Need to clear the animation before setting the property as the animation value is baked and will override any previous setters
2953 renderer.SetProperty( DevelRenderer::Property::OPACITY, 0.1f );
2955 animation.AnimateBy( Property( renderer, DevelRenderer::Property::OPACITY ), 0.5f );
2958 application.SendNotification();
2959 application.Render( 1000 );
2961 value = renderer.GetProperty( DevelRenderer::Property::OPACITY );
2962 DALI_TEST_CHECK( value.Get( opacity ) );
2963 DALI_TEST_EQUALS( opacity, 0.6f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION );
2964 DALI_TEST_EQUALS( opacity, renderer.GetCurrentProperty( DevelRenderer::Property::OPACITY ).Get< float >(), Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION );
2969 int UtcDaliRendererInvalidProperty(void)
2971 TestApplication application;
2973 tet_infoline( "Test invalid property" );
2975 Geometry geometry = CreateQuadGeometry();
2976 Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
2977 Renderer renderer = Renderer::New( geometry, shader );
2979 Actor actor = Actor::New();
2980 actor.AddRenderer( renderer );
2981 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
2982 application.GetScene().Add( actor );
2984 application.SendNotification();
2985 application.Render(0);
2987 Property::Value value = renderer.GetProperty( Renderer::Property::DEPTH_INDEX + 100 );
2988 DALI_TEST_CHECK( value.GetType() == Property::Type::NONE );
2990 value = renderer.GetCurrentProperty( Renderer::Property::DEPTH_INDEX + 100 );
2991 DALI_TEST_CHECK( value.GetType() == Property::Type::NONE );
2996 int UtcDaliRendererRenderingBehavior(void)
2998 TestApplication application;
3000 tet_infoline( "Test RENDERING_BEHAVIOR property" );
3002 Geometry geometry = CreateQuadGeometry();
3003 Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
3004 Renderer renderer = Renderer::New( geometry, shader );
3006 Actor actor = Actor::New();
3007 actor.AddRenderer( renderer );
3008 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
3009 actor.SetProperty( Actor::Property::COLOR, Vector4( 1.0f, 0.0f, 1.0f, 1.0f ) );
3010 application.GetScene().Add( actor );
3012 Property::Value value = renderer.GetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR );
3013 int renderingBehavior;
3014 DALI_TEST_CHECK( value.Get( renderingBehavior ) );
3015 DALI_TEST_EQUALS( static_cast< DevelRenderer::Rendering::Type >( renderingBehavior ), DevelRenderer::Rendering::IF_REQUIRED, TEST_LOCATION );
3017 application.SendNotification();
3018 application.Render();
3020 uint32_t updateStatus = application.GetUpdateStatus();
3022 DALI_TEST_CHECK( !( updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING ) );
3024 renderer.SetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::CONTINUOUSLY );
3026 value = renderer.GetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR );
3027 DALI_TEST_CHECK( value.Get( renderingBehavior ) );
3028 DALI_TEST_EQUALS( static_cast< DevelRenderer::Rendering::Type >( renderingBehavior ), DevelRenderer::Rendering::CONTINUOUSLY, TEST_LOCATION );
3030 // Render and check the update status
3031 application.SendNotification();
3032 application.Render();
3034 updateStatus = application.GetUpdateStatus();
3036 DALI_TEST_CHECK( updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING );
3038 value = renderer.GetCurrentProperty( DevelRenderer::Property::RENDERING_BEHAVIOR );
3039 DALI_TEST_CHECK( value.Get( renderingBehavior ) );
3040 DALI_TEST_EQUALS( static_cast< DevelRenderer::Rendering::Type >( renderingBehavior ), DevelRenderer::Rendering::CONTINUOUSLY, TEST_LOCATION );
3042 // Render again and check the update status
3043 application.SendNotification();
3044 application.Render();
3046 updateStatus = application.GetUpdateStatus();
3048 DALI_TEST_CHECK( updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING );
3050 // Change rendering behavior
3051 renderer.SetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::IF_REQUIRED );
3053 // Render and check the update status
3054 application.SendNotification();
3055 application.Render();
3057 updateStatus = application.GetUpdateStatus();
3059 DALI_TEST_CHECK( !( updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING ) );
3064 int UtcDaliRendererRegenerateUniformMap(void)
3066 TestApplication application;
3068 tet_infoline( "Test regenerating uniform map when attaching renderer to the node" );
3070 Geometry geometry = CreateQuadGeometry();
3071 Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
3072 Renderer renderer = Renderer::New( geometry, shader );
3074 Actor actor = Actor::New();
3075 actor.AddRenderer( renderer );
3076 actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
3077 actor.SetProperty( Actor::Property::COLOR, Vector4( 1.0f, 0.0f, 1.0f, 1.0f ) );
3078 application.GetScene().Add( actor );
3080 application.SendNotification();
3081 application.Render();
3083 actor.RemoveRenderer( renderer );
3084 shader = Shader::New( "vertexSrc", "fragmentSrc" );
3085 shader.RegisterProperty( "opacity", 0.5f );
3086 renderer.SetShader( shader );
3088 Stage::GetCurrent().KeepRendering( 1.0f );
3090 // Update for several frames
3091 application.SendNotification();
3092 application.Render();
3093 application.SendNotification();
3094 application.Render();
3095 application.SendNotification();
3096 application.Render();
3097 application.SendNotification();
3098 application.Render();
3101 actor.AddRenderer( renderer );
3102 application.SendNotification();
3103 application.Render();
3105 // Nothing to test here, the test must not crash
3106 auto updateStatus = application.GetUpdateStatus();
3107 DALI_TEST_CHECK( updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING );
3112 int UtcDaliRendererAddDrawCommands(void)
3114 TestApplication application;
3116 tet_infoline("Test adding draw commands to the renderer");
3118 TestGlAbstraction &glAbstraction = application.GetGlAbstraction();
3119 glAbstraction.EnableEnableDisableCallTrace(true);
3121 Geometry geometry = CreateQuadGeometry();
3122 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
3123 Renderer renderer = Renderer::New(geometry, shader);
3125 renderer.SetProperty( Renderer::Property::BLEND_MODE, Dali::BlendMode::ON );
3126 Actor actor = Actor::New();
3127 actor.AddRenderer(renderer);
3128 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
3129 actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 1.0f));
3130 application.GetScene().Add(actor);
3132 // Expect delivering a single draw call
3133 auto &drawTrace = glAbstraction.GetDrawTrace();
3135 drawTrace.Enable(true);
3136 application.SendNotification();
3137 application.Render();
3139 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION );
3141 auto drawCommand1 = DevelRenderer::DrawCommand{};
3142 drawCommand1.drawType = DevelRenderer::DrawType::INDEXED;
3143 drawCommand1.firstIndex = 0;
3144 drawCommand1.elementCount = 2;
3145 drawCommand1.queue = DevelRenderer::RENDER_QUEUE_OPAQUE;
3147 auto drawCommand2 = DevelRenderer::DrawCommand{};
3148 drawCommand2.drawType = DevelRenderer::DrawType::INDEXED;
3149 drawCommand2.firstIndex = 2;
3150 drawCommand2.elementCount = 2;
3151 drawCommand2.queue = DevelRenderer::RENDER_QUEUE_TRANSPARENT;
3153 auto drawCommand3 = DevelRenderer::DrawCommand{};
3154 drawCommand3.drawType = DevelRenderer::DrawType::ARRAY;
3155 drawCommand3.firstIndex = 2;
3156 drawCommand3.elementCount = 2;
3157 drawCommand3.queue = DevelRenderer::RENDER_QUEUE_OPAQUE;
3159 DevelRenderer::AddDrawCommand(renderer, drawCommand1);
3160 DevelRenderer::AddDrawCommand(renderer, drawCommand2);
3161 DevelRenderer::AddDrawCommand(renderer, drawCommand3);
3164 drawTrace.Enable(true);
3165 application.SendNotification();
3166 application.Render();
3168 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 3, TEST_LOCATION);
3172 int UtcDaliRendererSetGeometryNegative(void)
3174 TestApplication application;
3175 Dali::Renderer instance;
3178 Dali::Geometry arg1;
3179 instance.SetGeometry(arg1);
3180 DALI_TEST_CHECK(false); // Should not get here
3184 DALI_TEST_CHECK(true); // We expect an assert
3189 int UtcDaliRendererSetTexturesNegative(void)
3191 TestApplication application;
3192 Dali::Renderer instance;
3195 Dali::TextureSet arg1;
3196 instance.SetTextures(arg1);
3197 DALI_TEST_CHECK(false); // Should not get here
3201 DALI_TEST_CHECK(true); // We expect an assert
3206 int UtcDaliRendererSetShaderNegative(void)
3208 TestApplication application;
3209 Dali::Renderer instance;
3213 instance.SetShader(arg1);
3214 DALI_TEST_CHECK(false); // Should not get here
3218 DALI_TEST_CHECK(true); // We expect an assert
3223 int UtcDaliRendererGetGeometryNegative(void)
3225 TestApplication application;
3226 Dali::Renderer instance;
3229 instance.GetGeometry();
3230 DALI_TEST_CHECK(false); // Should not get here
3234 DALI_TEST_CHECK(true); // We expect an assert
3239 int UtcDaliRendererGetTexturesNegative(void)
3241 TestApplication application;
3242 Dali::Renderer instance;
3245 instance.GetTextures();
3246 DALI_TEST_CHECK(false); // Should not get here
3250 DALI_TEST_CHECK(true); // We expect an assert
3255 int UtcDaliRendererGetShaderNegative(void)
3257 TestApplication application;
3258 Dali::Renderer instance;
3261 instance.GetShader();
3262 DALI_TEST_CHECK(false); // Should not get here
3266 DALI_TEST_CHECK(true); // We expect an assert