2 * Copyright (c) 2021 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/common/capabilities.h>
21 #include <dali/devel-api/common/stage.h>
22 #include <dali/devel-api/rendering/renderer-devel.h>
23 #include <dali/integration-api/render-task-list-integ.h>
24 #include <dali/public-api/dali-core.h>
29 #include <dali-test-suite-utils.h>
30 #include <mesh-builder.h>
31 #include <test-trace-call-stack.h>
32 #include "test-graphics-command-buffer.h"
36 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 << std::hex << 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 << std::hex << 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 Texture CreateTexture(TextureType::Type type, Pixel::Format format, int width, int height)
83 Texture texture = Texture::New(type, format, width, height);
85 int bufferSize = width * height * Pixel::GetBytesPerPixel(format);
86 uint8_t* buffer = reinterpret_cast<uint8_t*>(malloc(bufferSize));
87 PixelData pixelData = PixelData::New(buffer, bufferSize, width, height, format, PixelData::FREE);
88 texture.Upload(pixelData, 0u, 0u, 0u, 0u, width, height);
92 Renderer CreateRenderer(Actor actor, Geometry geometry, Shader shader, int depthIndex)
94 Texture image0 = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGB888, 64, 64);
95 TextureSet textureSet0 = CreateTextureSet(image0);
96 Renderer renderer0 = Renderer::New(geometry, shader);
97 renderer0.SetTextures(textureSet0);
98 renderer0.SetProperty(Renderer::Property::DEPTH_INDEX, depthIndex);
99 actor.AddRenderer(renderer0);
103 Actor CreateActor(Actor parent, int siblingOrder, const char* location)
105 Actor actor = Actor::New();
106 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
107 actor.SetProperty(Actor::Property::PARENT_ORIGIN, AnchorPoint::CENTER);
108 actor.SetProperty(Actor::Property::POSITION, Vector2(0.0f, 0.0f));
109 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
111 actor.SetProperty(Dali::DevelActor::Property::SIBLING_ORDER, siblingOrder);
112 DALI_TEST_EQUALS(actor.GetProperty<int>(Dali::DevelActor::Property::SIBLING_ORDER), siblingOrder, TEST_INNER_LOCATION(location));
117 } // unnamed namespace
119 void renderer_test_startup(void)
121 test_return_value = TET_UNDEF;
124 void renderer_test_cleanup(void)
126 test_return_value = TET_PASS;
129 int UtcDaliRendererNew01(void)
131 TestApplication application;
133 Geometry geometry = CreateQuadGeometry();
134 Shader shader = CreateShader();
135 Renderer renderer = Renderer::New(geometry, shader);
137 DALI_TEST_EQUALS((bool)renderer, true, TEST_LOCATION);
141 int UtcDaliRendererNew02(void)
143 TestApplication application;
145 DALI_TEST_EQUALS((bool)renderer, false, TEST_LOCATION);
149 int UtcDaliRendererCopyConstructor(void)
151 TestApplication application;
153 Geometry geometry = CreateQuadGeometry();
154 Shader shader = CreateShader();
155 Renderer renderer = Renderer::New(geometry, shader);
157 Renderer rendererCopy(renderer);
158 DALI_TEST_EQUALS((bool)rendererCopy, true, TEST_LOCATION);
163 int UtcDaliRendererAssignmentOperator(void)
165 TestApplication application;
167 Geometry geometry = CreateQuadGeometry();
168 Shader shader = CreateShader();
169 Renderer renderer = Renderer::New(geometry, shader);
172 DALI_TEST_EQUALS((bool)renderer2, false, TEST_LOCATION);
174 renderer2 = renderer;
175 DALI_TEST_EQUALS((bool)renderer2, true, TEST_LOCATION);
179 int UtcDaliRendererMoveConstructor(void)
181 TestApplication application;
183 Geometry geometry = CreateQuadGeometry();
184 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
185 Renderer renderer = Renderer::New(geometry, shader);
186 DALI_TEST_CHECK(renderer);
187 DALI_TEST_EQUALS(1, renderer.GetBaseObject().ReferenceCount(), TEST_LOCATION);
188 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(Renderer::Property::BLEND_COLOR), Color::TRANSPARENT, TEST_LOCATION);
190 renderer.SetProperty(Renderer::Property::BLEND_COLOR, Color::MAGENTA);
191 application.SendNotification();
192 application.Render();
193 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(Renderer::Property::BLEND_COLOR), Color::MAGENTA, TEST_LOCATION);
195 Renderer move = std::move(renderer);
196 DALI_TEST_CHECK(move);
197 DALI_TEST_EQUALS(1, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
198 DALI_TEST_EQUALS(move.GetProperty<Vector4>(Renderer::Property::BLEND_COLOR), Color::MAGENTA, TEST_LOCATION);
199 DALI_TEST_CHECK(!renderer);
204 int UtcDaliRendererMoveAssignment(void)
206 TestApplication application;
208 Geometry geometry = CreateQuadGeometry();
209 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
210 Renderer renderer = Renderer::New(geometry, shader);
211 DALI_TEST_CHECK(renderer);
212 DALI_TEST_EQUALS(1, renderer.GetBaseObject().ReferenceCount(), TEST_LOCATION);
213 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(Renderer::Property::BLEND_COLOR), Color::TRANSPARENT, TEST_LOCATION);
215 renderer.SetProperty(Renderer::Property::BLEND_COLOR, Color::MAGENTA);
216 application.SendNotification();
217 application.Render();
218 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(Renderer::Property::BLEND_COLOR), Color::MAGENTA, TEST_LOCATION);
221 move = std::move(renderer);
222 DALI_TEST_CHECK(move);
223 DALI_TEST_EQUALS(1, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
224 DALI_TEST_EQUALS(move.GetProperty<Vector4>(Renderer::Property::BLEND_COLOR), Color::MAGENTA, TEST_LOCATION);
225 DALI_TEST_CHECK(!renderer);
230 int UtcDaliRendererDownCast01(void)
232 TestApplication application;
234 Geometry geometry = CreateQuadGeometry();
235 Shader shader = CreateShader();
236 Renderer renderer = Renderer::New(geometry, shader);
238 BaseHandle handle(renderer);
239 Renderer renderer2 = Renderer::DownCast(handle);
240 DALI_TEST_EQUALS((bool)renderer2, true, TEST_LOCATION);
244 int UtcDaliRendererDownCast02(void)
246 TestApplication application;
248 Handle handle = Handle::New(); // Create a custom object
249 Renderer renderer = Renderer::DownCast(handle);
250 DALI_TEST_EQUALS((bool)renderer, false, TEST_LOCATION);
254 // using a template to auto deduce the parameter types
255 template<typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8>
256 void TEST_RENDERER_PROPERTY(P1 renderer, P2 stringName, P3 type, P4 isWriteable, P5 isAnimateable, P6 isConstraintInput, P7 enumName, P8 LOCATION)
258 DALI_TEST_EQUALS(renderer.GetPropertyName(enumName), stringName, LOCATION);
259 DALI_TEST_EQUALS(renderer.GetPropertyIndex(stringName), static_cast<Property::Index>(enumName), LOCATION);
260 DALI_TEST_EQUALS(renderer.GetPropertyType(enumName), type, LOCATION);
261 DALI_TEST_EQUALS(renderer.IsPropertyWritable(enumName), isWriteable, LOCATION);
262 DALI_TEST_EQUALS(renderer.IsPropertyAnimatable(enumName), isAnimateable, LOCATION);
263 DALI_TEST_EQUALS(renderer.IsPropertyAConstraintInput(enumName), isConstraintInput, LOCATION);
266 int UtcDaliRendererDefaultProperties(void)
268 TestApplication application;
269 /* from renderer-impl.cpp
270 DALI_PROPERTY( "depthIndex", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_INDEX )
271 DALI_PROPERTY( "faceCullingMode", INTEGER, true, false, false, Dali::Renderer::Property::FACE_CULLING_MODE )
272 DALI_PROPERTY( "blendMode", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_MODE )
273 DALI_PROPERTY( "blendEquationRgb", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_EQUATION_RGB )
274 DALI_PROPERTY( "blendEquationAlpha", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_EQUATION_ALPHA )
275 DALI_PROPERTY( "blendFactorSrcRgb", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_SRC_RGB )
276 DALI_PROPERTY( "blendFactorDestRgb", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_DEST_RGB )
277 DALI_PROPERTY( "blendFactorSrcAlpha", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_SRC_ALPHA )
278 DALI_PROPERTY( "blendFactorDestAlpha", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_DEST_ALPHA )
279 DALI_PROPERTY( "blendColor", VECTOR4, true, false, false, Dali::Renderer::Property::BLEND_COLOR )
280 DALI_PROPERTY( "blendPreMultipliedAlpha", BOOLEAN, true, false, false, Dali::Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA )
281 DALI_PROPERTY( "indexRangeFirst", INTEGER, true, false, false, Dali::Renderer::Property::INDEX_RANGE_FIRST )
282 DALI_PROPERTY( "indexRangeCount", INTEGER, true, false, false, Dali::Renderer::Property::INDEX_RANGE_COUNT )
283 DALI_PROPERTY( "depthWriteMode", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_WRITE_MODE )
284 DALI_PROPERTY( "depthFunction", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_FUNCTION )
285 DALI_PROPERTY( "depthTestMode", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_TEST_MODE )
286 DALI_PROPERTY( "renderMode", INTEGER, true, false, false, Dali::Renderer::Property::RENDER_MODE )
287 DALI_PROPERTY( "stencilFunction", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION )
288 DALI_PROPERTY( "stencilFunctionMask", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION_MASK )
289 DALI_PROPERTY( "stencilFunctionReference", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION_REFERENCE )
290 DALI_PROPERTY( "stencilMask", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_MASK )
291 DALI_PROPERTY( "stencilOperationOnFail", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_FAIL )
292 DALI_PROPERTY( "stencilOperationOnZFail", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL )
293 DALI_PROPERTY( "stencilOperationOnZPass", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_PASS )
294 DALI_PROPERTY( "opacity", FLOAT, true, true, true, Dali::DevelRenderer::Property::OPACITY )
295 DALI_PROPERTY( "renderingBehavior", INTEGER, true, false, false, Dali::DevelRenderer::Property::RENDERING_BEHAVIOR )
296 DALI_PROPERTY( "blendEquation", INTEGER, true, false, false, Dali::DevelRenderer::Property::BLEND_EQUATION )
299 Geometry geometry = CreateQuadGeometry();
300 Shader shader = CreateShader();
301 Renderer renderer = Renderer::New(geometry, shader);
302 DALI_TEST_EQUALS(renderer.GetPropertyCount(), 27, TEST_LOCATION);
304 TEST_RENDERER_PROPERTY(renderer, "depthIndex", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_INDEX, TEST_LOCATION);
305 TEST_RENDERER_PROPERTY(renderer, "faceCullingMode", Property::INTEGER, true, false, false, Renderer::Property::FACE_CULLING_MODE, TEST_LOCATION);
306 TEST_RENDERER_PROPERTY(renderer, "blendMode", Property::INTEGER, true, false, false, Renderer::Property::BLEND_MODE, TEST_LOCATION);
307 TEST_RENDERER_PROPERTY(renderer, "blendEquationRgb", Property::INTEGER, true, false, false, Renderer::Property::BLEND_EQUATION_RGB, TEST_LOCATION);
308 TEST_RENDERER_PROPERTY(renderer, "blendEquationAlpha", Property::INTEGER, true, false, false, Renderer::Property::BLEND_EQUATION_ALPHA, TEST_LOCATION);
309 TEST_RENDERER_PROPERTY(renderer, "blendFactorSrcRgb", Property::INTEGER, true, false, false, Renderer::Property::BLEND_FACTOR_SRC_RGB, TEST_LOCATION);
310 TEST_RENDERER_PROPERTY(renderer, "blendFactorDestRgb", Property::INTEGER, true, false, false, Renderer::Property::BLEND_FACTOR_DEST_RGB, TEST_LOCATION);
311 TEST_RENDERER_PROPERTY(renderer, "blendFactorSrcAlpha", Property::INTEGER, true, false, false, Renderer::Property::BLEND_FACTOR_SRC_ALPHA, TEST_LOCATION);
312 TEST_RENDERER_PROPERTY(renderer, "blendFactorDestAlpha", Property::INTEGER, true, false, false, Renderer::Property::BLEND_FACTOR_DEST_ALPHA, TEST_LOCATION);
313 TEST_RENDERER_PROPERTY(renderer, "blendColor", Property::VECTOR4, true, false, false, Renderer::Property::BLEND_COLOR, TEST_LOCATION);
314 TEST_RENDERER_PROPERTY(renderer, "blendPreMultipliedAlpha", Property::BOOLEAN, true, false, false, Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, TEST_LOCATION);
315 TEST_RENDERER_PROPERTY(renderer, "indexRangeFirst", Property::INTEGER, true, false, false, Renderer::Property::INDEX_RANGE_FIRST, TEST_LOCATION);
316 TEST_RENDERER_PROPERTY(renderer, "indexRangeCount", Property::INTEGER, true, false, false, Renderer::Property::INDEX_RANGE_COUNT, TEST_LOCATION);
317 TEST_RENDERER_PROPERTY(renderer, "depthWriteMode", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_WRITE_MODE, TEST_LOCATION);
318 TEST_RENDERER_PROPERTY(renderer, "depthFunction", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_FUNCTION, TEST_LOCATION);
319 TEST_RENDERER_PROPERTY(renderer, "depthTestMode", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_TEST_MODE, TEST_LOCATION);
320 TEST_RENDERER_PROPERTY(renderer, "renderMode", Property::INTEGER, true, false, false, Renderer::Property::RENDER_MODE, TEST_LOCATION);
321 TEST_RENDERER_PROPERTY(renderer, "stencilFunction", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_FUNCTION, TEST_LOCATION);
322 TEST_RENDERER_PROPERTY(renderer, "stencilFunctionMask", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_FUNCTION_MASK, TEST_LOCATION);
323 TEST_RENDERER_PROPERTY(renderer, "stencilFunctionReference", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_FUNCTION_REFERENCE, TEST_LOCATION);
324 TEST_RENDERER_PROPERTY(renderer, "stencilMask", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_MASK, TEST_LOCATION);
325 TEST_RENDERER_PROPERTY(renderer, "stencilOperationOnFail", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_OPERATION_ON_FAIL, TEST_LOCATION);
326 TEST_RENDERER_PROPERTY(renderer, "stencilOperationOnZFail", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, TEST_LOCATION);
327 TEST_RENDERER_PROPERTY(renderer, "stencilOperationOnZPass", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, TEST_LOCATION);
328 TEST_RENDERER_PROPERTY(renderer, "opacity", Property::FLOAT, true, true, true, DevelRenderer::Property::OPACITY, TEST_LOCATION);
329 TEST_RENDERER_PROPERTY(renderer, "renderingBehavior", Property::INTEGER, true, false, false, DevelRenderer::Property::RENDERING_BEHAVIOR, TEST_LOCATION);
330 TEST_RENDERER_PROPERTY(renderer, "blendEquation", Property::INTEGER, true, false, false, DevelRenderer::Property::BLEND_EQUATION, TEST_LOCATION);
335 int UtcDaliRendererSetGetGeometry(void)
337 TestApplication application;
338 tet_infoline("Test SetGeometry, GetGeometry");
340 Geometry geometry1 = CreateQuadGeometry();
341 Geometry geometry2 = CreateQuadGeometry();
343 Shader shader = CreateShader();
344 Renderer renderer = Renderer::New(geometry1, shader);
345 Actor actor = Actor::New();
346 actor.AddRenderer(renderer);
347 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
348 application.GetScene().Add(actor);
350 application.SendNotification();
351 application.Render(0);
352 DALI_TEST_EQUALS(renderer.GetGeometry(), geometry1, TEST_LOCATION);
354 // Set geometry2 to the renderer
355 renderer.SetGeometry(geometry2);
357 application.SendNotification();
358 application.Render(0);
359 DALI_TEST_EQUALS(renderer.GetGeometry(), geometry2, TEST_LOCATION);
364 int UtcDaliRendererSetGetShader(void)
366 TestApplication application;
367 tet_infoline("Test SetShader, GetShader");
369 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
370 glAbstraction.EnableCullFaceCallTrace(true);
372 Shader shader1 = CreateShader();
373 shader1.RegisterProperty("uFadeColor", Color::RED);
375 Shader shader2 = CreateShader();
376 shader2.RegisterProperty("uFadeColor", Color::GREEN);
378 Geometry geometry = CreateQuadGeometry();
379 Renderer renderer = Renderer::New(geometry, shader1);
380 Actor actor = Actor::New();
381 actor.AddRenderer(renderer);
382 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
383 application.GetScene().Add(actor);
385 TestGlAbstraction& gl = application.GetGlAbstraction();
386 application.SendNotification();
387 application.Render(0);
389 // Expect that the first shaders's fade color property is accessed
390 Vector4 actualValue(Vector4::ZERO);
391 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
392 DALI_TEST_EQUALS(actualValue, Color::RED, TEST_LOCATION);
394 DALI_TEST_EQUALS(renderer.GetShader(), shader1, TEST_LOCATION);
396 // set the second shader to the renderer
397 renderer.SetShader(shader2);
399 application.SendNotification();
400 application.Render(0);
402 // Expect that the second shader's fade color property is accessed
403 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
404 DALI_TEST_EQUALS(actualValue, Color::GREEN, TEST_LOCATION);
406 DALI_TEST_EQUALS(renderer.GetShader(), shader2, TEST_LOCATION);
411 int UtcDaliRendererSetGetDepthIndex(void)
413 TestApplication application;
415 tet_infoline("Test SetDepthIndex, GetDepthIndex");
417 Shader shader = CreateShader();
418 Geometry geometry = CreateQuadGeometry();
419 Renderer renderer = Renderer::New(geometry, shader);
420 Actor actor = Actor::New();
421 actor.AddRenderer(renderer);
422 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
423 application.GetScene().Add(actor);
425 application.SendNotification();
426 application.Render(0);
427 DALI_TEST_EQUALS(renderer.GetProperty<int>(Renderer::Property::DEPTH_INDEX), 0, TEST_LOCATION);
429 renderer.SetProperty(Renderer::Property::DEPTH_INDEX, 1);
431 DALI_TEST_EQUALS(renderer.GetProperty<int>(Renderer::Property::DEPTH_INDEX), 1, TEST_LOCATION);
432 DALI_TEST_EQUALS(renderer.GetCurrentProperty<int>(Renderer::Property::DEPTH_INDEX), 0, TEST_LOCATION);
434 application.SendNotification();
435 application.Render(0);
436 DALI_TEST_EQUALS(renderer.GetCurrentProperty<int>(Renderer::Property::DEPTH_INDEX), 1, TEST_LOCATION);
438 renderer.SetProperty(Renderer::Property::DEPTH_INDEX, 10);
440 DALI_TEST_EQUALS(renderer.GetProperty<int>(Renderer::Property::DEPTH_INDEX), 10, TEST_LOCATION);
441 DALI_TEST_EQUALS(renderer.GetCurrentProperty<int>(Renderer::Property::DEPTH_INDEX), 1, TEST_LOCATION);
443 application.SendNotification();
444 application.Render(0);
445 DALI_TEST_EQUALS(renderer.GetCurrentProperty<int>(Renderer::Property::DEPTH_INDEX), 10, TEST_LOCATION);
450 int UtcDaliRendererSetGetFaceCullingMode(void)
452 TestApplication application;
454 tet_infoline("Test SetFaceCullingMode(cullingMode)");
455 Geometry geometry = CreateQuadGeometry();
456 Shader shader = CreateShader();
457 Renderer renderer = Renderer::New(geometry, shader);
459 Actor actor = Actor::New();
460 actor.AddRenderer(renderer);
461 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
462 application.GetScene().Add(actor);
464 // By default, none of the faces should be culled
465 unsigned int cullFace = renderer.GetProperty<int>(Renderer::Property::FACE_CULLING_MODE);
466 DALI_TEST_CHECK(static_cast<FaceCullingMode::Type>(cullFace) == FaceCullingMode::NONE);
468 TestGlAbstraction& gl = application.GetGlAbstraction();
469 TraceCallStack& cullFaceStack = gl.GetCullFaceTrace();
470 gl.EnableCullFaceCallTrace(true);
473 cullFaceStack.Reset();
474 renderer.SetProperty(Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::FRONT_AND_BACK);
475 application.SendNotification();
476 application.Render();
478 DALI_TEST_EQUALS(cullFaceStack.CountMethod("CullFace"), 1, TEST_LOCATION);
480 std::ostringstream cullModeString;
481 cullModeString << std::hex << GL_FRONT_AND_BACK;
483 DALI_TEST_CHECK(cullFaceStack.FindMethodAndParams("CullFace", cullModeString.str()));
484 cullFace = renderer.GetProperty<int>(Renderer::Property::FACE_CULLING_MODE);
485 DALI_TEST_CHECK(static_cast<FaceCullingMode::Type>(cullFace) == FaceCullingMode::FRONT_AND_BACK);
489 cullFaceStack.Reset();
490 renderer.SetProperty(Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::BACK);
491 application.SendNotification();
492 application.Render();
494 DALI_TEST_EQUALS(cullFaceStack.CountMethod("CullFace"), 1, TEST_LOCATION);
496 std::ostringstream cullModeString;
497 cullModeString << std::hex << GL_BACK;
499 DALI_TEST_CHECK(cullFaceStack.FindMethodAndParams("CullFace", cullModeString.str()));
500 cullFace = renderer.GetProperty<int>(Renderer::Property::FACE_CULLING_MODE);
501 DALI_TEST_CHECK(static_cast<FaceCullingMode::Type>(cullFace) == FaceCullingMode::BACK);
505 cullFaceStack.Reset();
506 renderer.SetProperty(Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::FRONT);
507 application.SendNotification();
508 application.Render();
510 DALI_TEST_EQUALS(cullFaceStack.CountMethod("CullFace"), 1, TEST_LOCATION);
512 std::ostringstream cullModeString;
513 cullModeString << std::hex << GL_FRONT;
515 DALI_TEST_CHECK(cullFaceStack.FindMethodAndParams("CullFace", cullModeString.str()));
516 cullFace = renderer.GetProperty<int>(Renderer::Property::FACE_CULLING_MODE);
517 DALI_TEST_CHECK(static_cast<FaceCullingMode::Type>(cullFace) == FaceCullingMode::FRONT);
521 cullFaceStack.Reset();
522 renderer.SetProperty(Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::NONE);
523 application.SendNotification();
524 application.Render();
526 DALI_TEST_EQUALS(cullFaceStack.CountMethod("CullFace"), 0, TEST_LOCATION);
527 cullFace = renderer.GetProperty<int>(Renderer::Property::FACE_CULLING_MODE);
528 DALI_TEST_CHECK(static_cast<FaceCullingMode::Type>(cullFace) == FaceCullingMode::NONE);
534 int UtcDaliRendererBlendOptions01(void)
536 TestApplication application;
538 tet_infoline("Test BLEND_FACTOR properties ");
540 Geometry geometry = CreateQuadGeometry();
541 Shader shader = CreateShader();
542 Renderer renderer = Renderer::New(geometry, shader);
544 Actor actor = Actor::New();
545 // set a transparent actor color so that blending is enabled
546 actor.SetProperty(Actor::Property::OPACITY, 0.5f);
547 actor.AddRenderer(renderer);
548 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
549 application.GetScene().Add(actor);
551 renderer.SetProperty(Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::ONE_MINUS_SRC_COLOR);
552 renderer.SetProperty(Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::SRC_ALPHA_SATURATE);
553 renderer.SetProperty(Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE_MINUS_SRC_COLOR);
554 renderer.SetProperty(Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::SRC_ALPHA_SATURATE);
556 // Test that Set was successful:
557 int srcFactorRgb = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
558 int destFactorRgb = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
559 int srcFactorAlpha = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
560 int destFactorAlpha = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
562 DALI_TEST_EQUALS((int)BlendFactor::ONE_MINUS_SRC_COLOR, srcFactorRgb, TEST_LOCATION);
563 DALI_TEST_EQUALS((int)BlendFactor::SRC_ALPHA_SATURATE, destFactorRgb, TEST_LOCATION);
564 DALI_TEST_EQUALS((int)BlendFactor::ONE_MINUS_SRC_COLOR, srcFactorAlpha, TEST_LOCATION);
565 DALI_TEST_EQUALS((int)BlendFactor::SRC_ALPHA_SATURATE, destFactorAlpha, TEST_LOCATION);
567 application.SendNotification();
568 application.Render();
570 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
572 DALI_TEST_EQUALS((GLenum)GL_ONE_MINUS_SRC_COLOR, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION);
573 DALI_TEST_EQUALS((GLenum)GL_SRC_ALPHA_SATURATE, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION);
574 DALI_TEST_EQUALS((GLenum)GL_ONE_MINUS_SRC_COLOR, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION);
575 DALI_TEST_EQUALS((GLenum)GL_SRC_ALPHA_SATURATE, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION);
580 int UtcDaliRendererBlendOptions02(void)
582 TestApplication application;
584 tet_infoline("Test BLEND_FACTOR properties ");
586 Geometry geometry = CreateQuadGeometry();
587 Shader shader = CreateShader();
588 Renderer renderer = Renderer::New(geometry, shader);
590 Actor actor = Actor::New();
591 actor.SetProperty(Actor::Property::OPACITY, 0.5f); // enable blending
592 actor.AddRenderer(renderer);
593 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
594 application.GetScene().Add(actor);
596 renderer.SetProperty(Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::CONSTANT_COLOR);
597 renderer.SetProperty(Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ONE_MINUS_CONSTANT_COLOR);
598 renderer.SetProperty(Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::CONSTANT_ALPHA);
599 renderer.SetProperty(Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ONE_MINUS_CONSTANT_ALPHA);
601 // Test that Set was successful:
603 int srcFactorRgb = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
604 int destFactorRgb = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
605 int srcFactorAlpha = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
606 int destFactorAlpha = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
608 DALI_TEST_EQUALS((int)BlendFactor::CONSTANT_COLOR, srcFactorRgb, TEST_LOCATION);
609 DALI_TEST_EQUALS((int)BlendFactor::ONE_MINUS_CONSTANT_COLOR, destFactorRgb, TEST_LOCATION);
610 DALI_TEST_EQUALS((int)BlendFactor::CONSTANT_ALPHA, srcFactorAlpha, TEST_LOCATION);
611 DALI_TEST_EQUALS((int)BlendFactor::ONE_MINUS_CONSTANT_ALPHA, destFactorAlpha, TEST_LOCATION);
614 application.SendNotification();
615 application.Render();
617 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
618 DALI_TEST_EQUALS((GLenum)GL_CONSTANT_COLOR, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION);
619 DALI_TEST_EQUALS((GLenum)GL_ONE_MINUS_CONSTANT_COLOR, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION);
620 DALI_TEST_EQUALS((GLenum)GL_CONSTANT_ALPHA, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION);
621 DALI_TEST_EQUALS((GLenum)GL_ONE_MINUS_CONSTANT_ALPHA, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION);
626 int UtcDaliRendererBlendOptions03(void)
628 TestApplication application;
630 tet_infoline("Test GetBlendEquation() defaults ");
632 Geometry geometry = CreateQuadGeometry();
633 Shader shader = CreateShader();
634 Renderer renderer = Renderer::New(geometry, shader);
636 Actor actor = Actor::New();
637 actor.AddRenderer(renderer);
638 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
639 application.GetScene().Add(actor);
641 // Test the defaults as documented in blending.h
642 int equationRgb = renderer.GetProperty<int>(Renderer::Property::BLEND_EQUATION_RGB);
643 int equationAlpha = renderer.GetProperty<int>(Renderer::Property::BLEND_EQUATION_ALPHA);
645 DALI_TEST_EQUALS((int)BlendEquation::ADD, equationRgb, TEST_LOCATION);
646 DALI_TEST_EQUALS((int)BlendEquation::ADD, equationAlpha, TEST_LOCATION);
651 int UtcDaliRendererBlendOptions04(void)
653 TestApplication application;
655 tet_infoline("Test SetBlendEquation() ");
657 Geometry geometry = CreateQuadGeometry();
658 Shader shader = CreateShader();
659 Renderer renderer = Renderer::New(geometry, shader);
661 Actor actor = Actor::New();
662 actor.SetProperty(Actor::Property::OPACITY, 0.1f);
663 actor.AddRenderer(renderer);
664 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
665 application.GetScene().Add(actor);
667 // Test the single blending equation setting
669 renderer.SetProperty(Renderer::Property::BLEND_EQUATION_RGB, BlendEquation::REVERSE_SUBTRACT);
670 int equationRgb = renderer.GetProperty<int>(Renderer::Property::BLEND_EQUATION_RGB);
671 DALI_TEST_EQUALS((int)BlendEquation::REVERSE_SUBTRACT, equationRgb, TEST_LOCATION);
674 renderer.SetProperty(Renderer::Property::BLEND_EQUATION_RGB, BlendEquation::REVERSE_SUBTRACT);
675 renderer.SetProperty(Renderer::Property::BLEND_EQUATION_ALPHA, BlendEquation::REVERSE_SUBTRACT);
677 // Test that Set was successful
679 int equationRgb = renderer.GetProperty<int>(Renderer::Property::BLEND_EQUATION_RGB);
680 int equationAlpha = renderer.GetProperty<int>(Renderer::Property::BLEND_EQUATION_ALPHA);
681 DALI_TEST_EQUALS((int)BlendEquation::REVERSE_SUBTRACT, equationRgb, TEST_LOCATION);
682 DALI_TEST_EQUALS((int)BlendEquation::REVERSE_SUBTRACT, equationAlpha, TEST_LOCATION);
685 // Render & check GL commands
686 application.SendNotification();
687 application.Render();
689 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
690 DALI_TEST_EQUALS((GLenum)GL_FUNC_REVERSE_SUBTRACT, glAbstraction.GetLastBlendEquationRgb(), TEST_LOCATION);
691 DALI_TEST_EQUALS((GLenum)GL_FUNC_REVERSE_SUBTRACT, glAbstraction.GetLastBlendEquationAlpha(), TEST_LOCATION);
696 int UtcDaliRendererBlendOptions05(void)
698 TestApplication application;
700 tet_infoline("Test SetAdvancedBlendEquation ");
702 Geometry geometry = CreateQuadGeometry();
703 Shader shader = CreateShader();
704 Renderer renderer = Renderer::New(geometry, shader);
706 Actor actor = Actor::New();
707 actor.SetProperty(Actor::Property::OPACITY, 0.1f);
709 actor.AddRenderer(renderer);
710 actor.SetProperty(Actor::Property::SIZE, Vector2(400, 400));
711 application.GetScene().Add(actor);
713 if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::MAX))
715 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::MAX);
716 int equationRgb = renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION);
717 DALI_TEST_EQUALS((int)DevelBlendEquation::MAX, equationRgb, TEST_LOCATION);
720 if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
722 renderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true);
723 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SCREEN);
724 int equation = renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION);
726 DALI_TEST_EQUALS((int)DevelBlendEquation::SCREEN, equation, TEST_LOCATION);
727 DALI_TEST_EQUALS(DevelRenderer::IsAdvancedBlendEquationApplied(renderer), true, TEST_LOCATION);
729 application.SendNotification();
730 application.Render();
733 if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN) &&
734 Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::MULTIPLY))
736 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::ADD);
737 renderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true);
738 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION_RGB, DevelBlendEquation::SCREEN);
739 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION_ALPHA, DevelBlendEquation::MULTIPLY);
740 int equationRgb = renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION_RGB);
741 int equationAlpha = renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION_ALPHA);
743 DALI_TEST_EQUALS((int)DevelBlendEquation::ADD, equationRgb, TEST_LOCATION);
744 DALI_TEST_EQUALS((int)DevelBlendEquation::ADD, equationAlpha, TEST_LOCATION);
745 DALI_TEST_EQUALS(DevelRenderer::IsAdvancedBlendEquationApplied(renderer), false, TEST_LOCATION);
747 application.SendNotification();
748 application.Render();
751 tet_infoline("Error Checking\n");
752 if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::MULTIPLY) &&
753 Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN) &&
754 Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::OVERLAY) &&
755 Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::DARKEN) &&
756 Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::LIGHTEN) &&
757 Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::COLOR_DODGE) &&
758 Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::COLOR_BURN) &&
759 Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::HARD_LIGHT) &&
760 Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SOFT_LIGHT) &&
761 Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::DIFFERENCE) &&
762 Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::EXCLUSION) &&
763 Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::HUE) &&
764 Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SATURATION) &&
765 Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::COLOR) &&
766 Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::LUMINOSITY))
768 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::MULTIPLY);
769 DALI_TEST_EQUALS((int)DevelBlendEquation::MULTIPLY, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
771 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SCREEN);
772 DALI_TEST_EQUALS((int)DevelBlendEquation::SCREEN, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
774 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::OVERLAY);
775 DALI_TEST_EQUALS((int)DevelBlendEquation::OVERLAY, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
777 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::DARKEN);
778 DALI_TEST_EQUALS((int)DevelBlendEquation::DARKEN, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
780 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::LIGHTEN);
781 DALI_TEST_EQUALS((int)DevelBlendEquation::LIGHTEN, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
783 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::COLOR_DODGE);
784 DALI_TEST_EQUALS((int)DevelBlendEquation::COLOR_DODGE, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
786 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::COLOR_BURN);
787 DALI_TEST_EQUALS((int)DevelBlendEquation::COLOR_BURN, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
789 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::HARD_LIGHT);
790 DALI_TEST_EQUALS((int)DevelBlendEquation::HARD_LIGHT, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
792 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SOFT_LIGHT);
793 DALI_TEST_EQUALS((int)DevelBlendEquation::SOFT_LIGHT, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
795 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::DIFFERENCE);
796 DALI_TEST_EQUALS((int)DevelBlendEquation::DIFFERENCE, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
798 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::EXCLUSION);
799 DALI_TEST_EQUALS((int)DevelBlendEquation::EXCLUSION, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
801 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::HUE);
802 DALI_TEST_EQUALS((int)DevelBlendEquation::HUE, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
804 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SATURATION);
805 DALI_TEST_EQUALS((int)DevelBlendEquation::SATURATION, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
807 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::COLOR);
808 DALI_TEST_EQUALS((int)DevelBlendEquation::COLOR, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
810 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::LUMINOSITY);
811 DALI_TEST_EQUALS((int)DevelBlendEquation::LUMINOSITY, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
817 int UtcDaliRendererSetBlendMode01(void)
819 TestApplication application;
821 tet_infoline("Test setting the blend mode to on with an opaque color renders with blending enabled");
823 Geometry geometry = CreateQuadGeometry();
824 Shader shader = CreateShader();
825 Renderer renderer = Renderer::New(geometry, shader);
827 Actor actor = Actor::New();
828 actor.SetProperty(Actor::Property::OPACITY, 0.98f);
829 actor.AddRenderer(renderer);
830 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
831 application.GetScene().Add(actor);
833 renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
835 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
836 glAbstraction.EnableEnableDisableCallTrace(true);
838 application.SendNotification();
839 application.Render();
841 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
842 TraceCallStack::NamedParams params;
843 params["cap"] << std::hex << GL_BLEND;
844 DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", params));
849 int UtcDaliRendererSetBlendMode01b(void)
851 TestApplication application;
853 tet_infoline("Test setting the blend mode to on with an transparent color renders with blending enabled");
855 Geometry geometry = CreateQuadGeometry();
856 Shader shader = CreateShader();
857 Renderer renderer = Renderer::New(geometry, shader);
859 Actor actor = Actor::New();
860 actor.SetProperty(Actor::Property::OPACITY, 0.0f);
861 actor.AddRenderer(renderer);
862 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
863 application.GetScene().Add(actor);
865 renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
867 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
868 glAbstraction.EnableEnableDisableCallTrace(true);
869 glAbstraction.EnableDrawCallTrace(true);
871 application.SendNotification();
872 application.Render();
874 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
875 DALI_TEST_CHECK(!glEnableStack.FindMethod("Enable"));
877 DALI_TEST_CHECK(!glAbstraction.GetDrawTrace().FindMethod("DrawElements"));
882 int UtcDaliRendererSetBlendMode02(void)
884 TestApplication application;
886 tet_infoline("Test setting the blend mode to off with a transparent color renders with blending disabled (and not enabled)");
888 Geometry geometry = CreateQuadGeometry();
889 Shader shader = CreateShader();
890 Renderer renderer = Renderer::New(geometry, shader);
892 Actor actor = Actor::New();
893 actor.SetProperty(Actor::Property::OPACITY, 0.15f);
894 actor.AddRenderer(renderer);
895 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
896 application.GetScene().Add(actor);
898 renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::OFF);
900 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
901 glAbstraction.EnableEnableDisableCallTrace(true);
903 application.SendNotification();
904 application.Render();
906 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
907 TraceCallStack::NamedParams params;
908 params["cap"] << std::hex << GL_BLEND;
909 DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Enable", params));
914 int UtcDaliRendererSetBlendMode03(void)
916 TestApplication application;
918 tet_infoline("Test setting the blend mode to auto with a transparent color renders with blending enabled");
920 Geometry geometry = CreateQuadGeometry();
921 Shader shader = CreateShader();
922 Renderer renderer = Renderer::New(geometry, shader);
924 Actor actor = Actor::New();
925 actor.SetProperty(Actor::Property::OPACITY, 0.75f);
926 actor.AddRenderer(renderer);
927 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
928 application.GetScene().Add(actor);
930 renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::AUTO);
932 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
933 glAbstraction.EnableEnableDisableCallTrace(true);
935 application.SendNotification();
936 application.Render();
938 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
939 TraceCallStack::NamedParams params;
940 params["cap"] << std::hex << GL_BLEND;
941 DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", params));
946 int UtcDaliRendererSetBlendMode04(void)
948 TestApplication application;
950 tet_infoline("Test setting the blend mode to auto with an opaque color renders with blending disabled");
952 Geometry geometry = CreateQuadGeometry();
953 Shader shader = CreateShader();
954 Renderer renderer = Renderer::New(geometry, shader);
956 Actor actor = Actor::New();
957 actor.AddRenderer(renderer);
958 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
959 application.GetScene().Add(actor);
961 renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::AUTO);
963 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
964 glAbstraction.EnableEnableDisableCallTrace(true);
966 application.SendNotification();
967 application.Render();
969 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
970 TraceCallStack::NamedParams params;
971 params["cap"] << std::hex << GL_BLEND;
972 DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Enable", params));
973 DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Disable", params));
978 int UtcDaliRendererSetBlendMode04b(void)
980 TestApplication application;
982 tet_infoline("Test setting the blend mode to auto with a transparent actor color renders with blending enabled");
984 Geometry geometry = CreateQuadGeometry();
985 Shader shader = CreateShader();
986 Renderer renderer = Renderer::New(geometry, shader);
988 Actor actor = Actor::New();
989 actor.AddRenderer(renderer);
990 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
991 actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 0.5f));
992 application.GetScene().Add(actor);
994 renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::AUTO);
996 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
997 glAbstraction.EnableEnableDisableCallTrace(true);
999 application.SendNotification();
1000 application.Render();
1002 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
1003 TraceCallStack::NamedParams params;
1004 params["cap"] << std::hex << GL_BLEND;
1005 DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", params));
1010 int UtcDaliRendererSetBlendMode04c(void)
1012 TestApplication application;
1014 tet_infoline("Test setting the blend mode to auto with an opaque opaque actor color renders with blending disabled");
1016 Geometry geometry = CreateQuadGeometry();
1017 Shader shader = CreateShader();
1018 Renderer renderer = Renderer::New(geometry, shader);
1020 Actor actor = Actor::New();
1021 actor.AddRenderer(renderer);
1022 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1023 actor.SetProperty(Actor::Property::COLOR, Color::MAGENTA);
1024 application.GetScene().Add(actor);
1026 renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::AUTO);
1028 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
1029 glAbstraction.EnableEnableDisableCallTrace(true);
1031 application.SendNotification();
1032 application.Render();
1034 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
1035 TraceCallStack::NamedParams params;
1036 params["cap"] << std::hex << GL_BLEND;
1037 DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Enable", params));
1038 DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Disable", params));
1043 int UtcDaliRendererSetBlendMode05(void)
1045 TestApplication application;
1047 tet_infoline("Test setting the blend mode to auto with an opaque color and an image with an alpha channel renders with blending enabled");
1049 Geometry geometry = CreateQuadGeometry();
1050 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 40, 40);
1052 Shader shader = CreateShader();
1053 TextureSet textureSet = CreateTextureSet(image);
1054 Renderer renderer = Renderer::New(geometry, shader);
1055 renderer.SetTextures(textureSet);
1057 Actor actor = Actor::New();
1058 actor.AddRenderer(renderer);
1059 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1060 application.GetScene().Add(actor);
1062 renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::AUTO);
1064 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
1065 glAbstraction.EnableEnableDisableCallTrace(true);
1067 application.SendNotification();
1068 application.Render();
1070 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
1071 TraceCallStack::NamedParams params;
1072 params["cap"] << std::hex << GL_BLEND;
1073 DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", params));
1078 int UtcDaliRendererSetBlendMode06(void)
1080 TestApplication application;
1081 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");
1083 Geometry geometry = CreateQuadGeometry();
1084 Shader shader = Shader::New("vertexSrc", "fragmentSrc", Shader::Hint::OUTPUT_IS_TRANSPARENT);
1086 Renderer renderer = Renderer::New(geometry, shader);
1088 Actor actor = Actor::New();
1089 actor.AddRenderer(renderer);
1090 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1091 application.GetScene().Add(actor);
1093 renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::AUTO);
1095 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
1096 glAbstraction.EnableEnableDisableCallTrace(true);
1098 application.SendNotification();
1099 application.Render();
1101 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
1102 TraceCallStack::NamedParams params;
1103 params["cap"] << std::hex << GL_BLEND;
1104 DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", params));
1109 int UtcDaliRendererSetBlendMode07(void)
1111 TestApplication application;
1112 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");
1114 Geometry geometry = CreateQuadGeometry();
1115 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
1117 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGB888, 50, 50);
1118 TextureSet textureSet = CreateTextureSet(image);
1119 Renderer renderer = Renderer::New(geometry, shader);
1120 renderer.SetTextures(textureSet);
1122 Actor actor = Actor::New();
1123 actor.AddRenderer(renderer);
1124 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1125 application.GetScene().Add(actor);
1127 renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::AUTO);
1129 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
1130 glAbstraction.EnableEnableDisableCallTrace(true);
1132 application.SendNotification();
1133 application.Render();
1135 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
1136 TraceCallStack::NamedParams params;
1137 params["cap"] << std::hex << GL_BLEND;
1138 DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Enable", params));
1143 int UtcDaliRendererSetBlendMode08(void)
1145 TestApplication application;
1147 tet_infoline("Test setting the blend mode to auto with opaque color and Advanced Blend Equation.");
1149 if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
1151 Geometry geometry = CreateQuadGeometry();
1152 Shader shader = CreateShader();
1153 Renderer renderer = Renderer::New(geometry, shader);
1155 Actor actor = Actor::New();
1156 actor.SetProperty(Actor::Property::OPACITY, 1.0f);
1157 actor.AddRenderer(renderer);
1158 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1159 application.GetScene().Add(actor);
1161 renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::AUTO);
1162 renderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true);
1163 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SCREEN);
1165 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
1166 glAbstraction.EnableEnableDisableCallTrace(true);
1168 application.SendNotification();
1169 application.Render();
1171 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
1172 TraceCallStack::NamedParams params;
1173 params["cap"] << std::hex << GL_BLEND;
1174 DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", params));
1180 int UtcDaliRendererSetBlendMode08b(void)
1182 TestApplication application;
1184 tet_infoline("Test setting the blend mode to off with opaque color and Advanced Blend Equation.");
1186 if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
1188 Geometry geometry = CreateQuadGeometry();
1189 Shader shader = CreateShader();
1190 Renderer renderer = Renderer::New(geometry, shader);
1192 Actor actor = Actor::New();
1193 actor.SetProperty(Actor::Property::OPACITY, 1.0f);
1194 actor.AddRenderer(renderer);
1195 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1196 application.GetScene().Add(actor);
1198 renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::OFF);
1199 renderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true);
1200 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SCREEN);
1202 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
1203 glAbstraction.EnableEnableDisableCallTrace(true);
1205 application.SendNotification();
1206 application.Render();
1208 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
1209 TraceCallStack::NamedParams params;
1210 params["cap"] << std::hex << GL_BLEND;
1211 DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Enable", params));
1217 int UtcDaliRendererGetBlendMode(void)
1219 TestApplication application;
1221 tet_infoline("Test GetBlendMode()");
1223 Geometry geometry = CreateQuadGeometry();
1224 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
1225 Renderer renderer = Renderer::New(geometry, shader);
1228 unsigned int mode = renderer.GetProperty<int>(Renderer::Property::BLEND_MODE);
1229 DALI_TEST_EQUALS(static_cast<BlendMode::Type>(mode), BlendMode::AUTO, TEST_LOCATION);
1232 renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
1233 mode = renderer.GetProperty<int>(Renderer::Property::BLEND_MODE);
1234 DALI_TEST_EQUALS(static_cast<BlendMode::Type>(mode), BlendMode::ON, TEST_LOCATION);
1237 renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::OFF);
1238 mode = renderer.GetProperty<int>(Renderer::Property::BLEND_MODE);
1239 DALI_TEST_EQUALS(static_cast<BlendMode::Type>(mode), BlendMode::OFF, TEST_LOCATION);
1244 int UtcDaliRendererSetBlendColor(void)
1246 TestApplication application;
1248 tet_infoline("Test SetBlendColor(color)");
1250 Geometry geometry = CreateQuadGeometry();
1251 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
1252 TextureSet textureSet = TextureSet::New();
1253 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 50, 50);
1254 textureSet.SetTexture(0u, image);
1255 Renderer renderer = Renderer::New(geometry, shader);
1256 renderer.SetTextures(textureSet);
1258 Actor actor = Actor::New();
1259 actor.AddRenderer(renderer);
1260 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1261 application.GetScene().Add(actor);
1263 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
1265 renderer.SetProperty(Renderer::Property::BLEND_COLOR, Color::TRANSPARENT);
1267 application.SendNotification();
1268 application.Render();
1270 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(Renderer::Property::BLEND_COLOR), Color::TRANSPARENT, TEST_LOCATION);
1271 DALI_TEST_EQUALS(renderer.GetCurrentProperty<Vector4>(Renderer::Property::BLEND_COLOR), Color::TRANSPARENT, TEST_LOCATION);
1272 DALI_TEST_EQUALS(glAbstraction.GetLastBlendColor(), Color::TRANSPARENT, TEST_LOCATION);
1274 renderer.SetProperty(Renderer::Property::BLEND_COLOR, Color::MAGENTA);
1276 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(Renderer::Property::BLEND_COLOR), Color::MAGENTA, TEST_LOCATION);
1277 DALI_TEST_EQUALS(renderer.GetCurrentProperty<Vector4>(Renderer::Property::BLEND_COLOR), Color::TRANSPARENT, TEST_LOCATION);
1279 application.SendNotification();
1280 application.Render();
1282 DALI_TEST_EQUALS(renderer.GetCurrentProperty<Vector4>(Renderer::Property::BLEND_COLOR), Color::MAGENTA, TEST_LOCATION);
1283 DALI_TEST_EQUALS(glAbstraction.GetLastBlendColor(), Color::MAGENTA, TEST_LOCATION);
1285 Vector4 color(0.1f, 0.2f, 0.3f, 0.4f);
1286 renderer.SetProperty(Renderer::Property::BLEND_COLOR, color);
1287 application.SendNotification();
1288 application.Render();
1289 DALI_TEST_EQUALS(glAbstraction.GetLastBlendColor(), color, TEST_LOCATION);
1294 int UtcDaliRendererGetBlendColor(void)
1296 TestApplication application;
1298 tet_infoline("Test GetBlendColor()");
1300 Geometry geometry = CreateQuadGeometry();
1301 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
1302 Renderer renderer = Renderer::New(geometry, shader);
1304 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(Renderer::Property::BLEND_COLOR), Color::TRANSPARENT, TEST_LOCATION);
1306 renderer.SetProperty(Renderer::Property::BLEND_COLOR, Color::MAGENTA);
1307 application.SendNotification();
1308 application.Render();
1309 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(Renderer::Property::BLEND_COLOR), Color::MAGENTA, TEST_LOCATION);
1311 Vector4 color(0.1f, 0.2f, 0.3f, 0.4f);
1312 renderer.SetProperty(Renderer::Property::BLEND_COLOR, color);
1313 application.SendNotification();
1314 application.Render();
1315 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(Renderer::Property::BLEND_COLOR), color, TEST_LOCATION);
1320 int UtcDaliRendererPreMultipledAlpha(void)
1322 TestApplication application;
1324 tet_infoline("Test BLEND_PRE_MULTIPLIED_ALPHA property");
1326 Geometry geometry = CreateQuadGeometry();
1327 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
1328 Renderer renderer = Renderer::New(geometry, shader);
1330 Actor actor = Actor::New();
1331 actor.AddRenderer(renderer);
1332 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1333 actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 0.5f));
1334 application.GetScene().Add(actor);
1336 Property::Value value = renderer.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
1337 bool preMultipliedAlpha;
1338 DALI_TEST_CHECK(value.Get(preMultipliedAlpha));
1339 DALI_TEST_CHECK(!preMultipliedAlpha);
1341 int srcFactorRgb = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
1342 int destFactorRgb = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
1343 int srcFactorAlpha = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
1344 int destFactorAlpha = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
1346 DALI_TEST_EQUALS((int)DEFAULT_BLEND_FACTOR_SRC_RGB, srcFactorRgb, TEST_LOCATION);
1347 DALI_TEST_EQUALS((int)DEFAULT_BLEND_FACTOR_DEST_RGB, destFactorRgb, TEST_LOCATION);
1348 DALI_TEST_EQUALS((int)DEFAULT_BLEND_FACTOR_SRC_ALPHA, srcFactorAlpha, TEST_LOCATION);
1349 DALI_TEST_EQUALS((int)DEFAULT_BLEND_FACTOR_DEST_ALPHA, destFactorAlpha, TEST_LOCATION);
1351 application.SendNotification();
1352 application.Render();
1354 Vector4 actualValue(Vector4::ZERO);
1355 TestGlAbstraction& gl = application.GetGlAbstraction();
1356 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uColor", actualValue));
1357 DALI_TEST_EQUALS(actualValue, Vector4(1.0f, 0.0f, 1.0f, 0.5f), TEST_LOCATION);
1359 // Enable pre-multiplied alpha
1360 renderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true);
1362 application.SendNotification();
1363 application.Render();
1365 value = renderer.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
1366 DALI_TEST_CHECK(value.Get(preMultipliedAlpha));
1367 DALI_TEST_CHECK(preMultipliedAlpha);
1369 value = renderer.GetCurrentProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
1370 DALI_TEST_CHECK(value.Get(preMultipliedAlpha));
1371 DALI_TEST_CHECK(preMultipliedAlpha);
1373 srcFactorRgb = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
1374 destFactorRgb = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
1375 srcFactorAlpha = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
1376 destFactorAlpha = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
1378 DALI_TEST_EQUALS((int)BlendFactor::ONE, srcFactorRgb, TEST_LOCATION);
1379 DALI_TEST_EQUALS((int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorRgb, TEST_LOCATION);
1380 DALI_TEST_EQUALS((int)BlendFactor::ONE, srcFactorAlpha, TEST_LOCATION);
1381 DALI_TEST_EQUALS((int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorAlpha, TEST_LOCATION);
1383 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uColor", actualValue));
1384 DALI_TEST_EQUALS(actualValue, Vector4(0.5f, 0.0f, 0.5f, 0.5f), TEST_LOCATION);
1386 // Disable pre-multiplied alpha again
1387 renderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, false);
1389 application.SendNotification();
1390 application.Render();
1392 value = renderer.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
1393 DALI_TEST_CHECK(value.Get(preMultipliedAlpha));
1394 DALI_TEST_CHECK(!preMultipliedAlpha);
1396 value = renderer.GetCurrentProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
1397 DALI_TEST_CHECK(value.Get(preMultipliedAlpha));
1398 DALI_TEST_CHECK(!preMultipliedAlpha);
1400 srcFactorRgb = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
1401 destFactorRgb = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
1402 srcFactorAlpha = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
1403 destFactorAlpha = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
1405 DALI_TEST_EQUALS((int)BlendFactor::SRC_ALPHA, srcFactorRgb, TEST_LOCATION);
1406 DALI_TEST_EQUALS((int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorRgb, TEST_LOCATION);
1407 DALI_TEST_EQUALS((int)BlendFactor::ONE, srcFactorAlpha, TEST_LOCATION);
1408 DALI_TEST_EQUALS((int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorAlpha, TEST_LOCATION);
1410 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uColor", actualValue));
1411 DALI_TEST_EQUALS(actualValue, Vector4(1.0f, 0.0f, 1.0f, 0.5f), TEST_LOCATION);
1416 int UtcDaliRendererConstraint01(void)
1418 TestApplication application;
1420 tet_infoline("Test that a non-uniform renderer property can be constrained");
1422 Shader shader = Shader::New("VertexSource", "FragmentSource");
1423 Geometry geometry = CreateQuadGeometry();
1424 Renderer renderer = Renderer::New(geometry, shader);
1426 Actor actor = Actor::New();
1427 actor.AddRenderer(renderer);
1428 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1429 application.GetScene().Add(actor);
1431 Vector4 initialColor = Color::WHITE;
1432 Property::Index colorIndex = renderer.RegisterProperty("uFadeColor", initialColor);
1434 application.SendNotification();
1435 application.Render(0);
1436 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION);
1439 Constraint constraint = Constraint::New<Vector4>(renderer, colorIndex, TestConstraintNoBlue);
1441 application.SendNotification();
1442 application.Render(0);
1444 // Expect no blue component in either buffer - yellow
1445 DALI_TEST_EQUALS(renderer.GetCurrentProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION);
1446 application.Render(0);
1447 DALI_TEST_EQUALS(renderer.GetCurrentProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION);
1449 renderer.RemoveConstraints();
1450 renderer.SetProperty(colorIndex, Color::WHITE);
1451 application.SendNotification();
1452 application.Render(0);
1453 DALI_TEST_EQUALS(renderer.GetCurrentProperty<Vector4>(colorIndex), Color::WHITE, TEST_LOCATION);
1458 int UtcDaliRendererConstraint02(void)
1460 TestApplication application;
1462 tet_infoline("Test that a uniform map renderer property can be constrained");
1464 Shader shader = Shader::New("VertexSource", "FragmentSource");
1465 Geometry geometry = CreateQuadGeometry();
1466 Renderer renderer = Renderer::New(geometry, shader);
1468 Actor actor = Actor::New();
1469 actor.AddRenderer(renderer);
1470 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1471 application.GetScene().Add(actor);
1472 application.SendNotification();
1473 application.Render(0);
1475 Vector4 initialColor = Color::WHITE;
1476 Property::Index colorIndex = renderer.RegisterProperty("uFadeColor", initialColor);
1478 TestGlAbstraction& gl = application.GetGlAbstraction();
1480 application.SendNotification();
1481 application.Render(0);
1483 Vector4 actualValue(Vector4::ZERO);
1484 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
1485 DALI_TEST_EQUALS(actualValue, initialColor, TEST_LOCATION);
1488 Constraint constraint = Constraint::New<Vector4>(renderer, colorIndex, TestConstraintNoBlue);
1490 application.SendNotification();
1491 application.Render(0);
1493 // Expect no blue component in either buffer - yellow
1494 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
1495 DALI_TEST_EQUALS(actualValue, Color::YELLOW, TEST_LOCATION);
1497 application.Render(0);
1498 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
1499 DALI_TEST_EQUALS(actualValue, Color::YELLOW, TEST_LOCATION);
1501 renderer.RemoveConstraints();
1502 renderer.SetProperty(colorIndex, Color::WHITE);
1503 application.SendNotification();
1504 application.Render(0);
1506 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
1507 DALI_TEST_EQUALS(actualValue, Color::WHITE, TEST_LOCATION);
1512 int UtcDaliRendererAnimatedProperty01(void)
1514 TestApplication application;
1516 tet_infoline("Test that a non-uniform renderer property can be animated");
1518 Shader shader = Shader::New("VertexSource", "FragmentSource");
1519 Geometry geometry = CreateQuadGeometry();
1520 Renderer renderer = Renderer::New(geometry, shader);
1522 Actor actor = Actor::New();
1523 actor.AddRenderer(renderer);
1524 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1525 application.GetScene().Add(actor);
1527 Vector4 initialColor = Color::WHITE;
1528 Property::Index colorIndex = renderer.RegisterProperty("uFadeColor", initialColor);
1530 application.SendNotification();
1531 application.Render(0);
1532 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION);
1534 Animation animation = Animation::New(1.0f);
1535 KeyFrames keyFrames = KeyFrames::New();
1536 keyFrames.Add(0.0f, initialColor);
1537 keyFrames.Add(1.0f, Color::TRANSPARENT);
1538 animation.AnimateBetween(Property(renderer, colorIndex), keyFrames);
1541 application.SendNotification();
1542 application.Render(500);
1544 DALI_TEST_EQUALS(renderer.GetCurrentProperty<Vector4>(colorIndex), Color::WHITE * 0.5f, TEST_LOCATION);
1546 application.Render(500);
1548 DALI_TEST_EQUALS(renderer.GetCurrentProperty<Vector4>(colorIndex), Color::TRANSPARENT, TEST_LOCATION);
1553 int UtcDaliRendererAnimatedProperty02(void)
1555 TestApplication application;
1557 tet_infoline("Test that a uniform map renderer property can be animated");
1559 Shader shader = Shader::New("VertexSource", "FragmentSource");
1560 Geometry geometry = CreateQuadGeometry();
1561 Renderer renderer = Renderer::New(geometry, shader);
1563 Actor actor = Actor::New();
1564 actor.AddRenderer(renderer);
1565 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1566 application.GetScene().Add(actor);
1567 application.SendNotification();
1568 application.Render(0);
1570 Vector4 initialColor = Color::WHITE;
1571 Property::Index colorIndex = renderer.RegisterProperty("uFadeColor", initialColor);
1573 TestGlAbstraction& gl = application.GetGlAbstraction();
1575 application.SendNotification();
1576 application.Render(0);
1578 Vector4 actualValue(Vector4::ZERO);
1579 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
1580 DALI_TEST_EQUALS(actualValue, initialColor, TEST_LOCATION);
1582 Animation animation = Animation::New(1.0f);
1583 KeyFrames keyFrames = KeyFrames::New();
1584 keyFrames.Add(0.0f, initialColor);
1585 keyFrames.Add(1.0f, Color::TRANSPARENT);
1586 animation.AnimateBetween(Property(renderer, colorIndex), keyFrames);
1589 application.SendNotification();
1590 application.Render(500);
1592 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
1593 DALI_TEST_EQUALS(actualValue, Color::WHITE * 0.5f, TEST_LOCATION);
1595 application.Render(500);
1596 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
1597 DALI_TEST_EQUALS(actualValue, Color::TRANSPARENT, TEST_LOCATION);
1602 int UtcDaliRendererUniformMapPrecendence01(void)
1604 TestApplication application;
1606 tet_infoline("Test the uniform map precedence is applied properly");
1608 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64);
1610 Shader shader = Shader::New("VertexSource", "FragmentSource");
1611 TextureSet textureSet = CreateTextureSet(image);
1613 Geometry geometry = CreateQuadGeometry();
1614 Renderer renderer = Renderer::New(geometry, shader);
1615 renderer.SetTextures(textureSet);
1617 Actor actor = Actor::New();
1618 actor.AddRenderer(renderer);
1619 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1620 application.GetScene().Add(actor);
1621 application.SendNotification();
1622 application.Render(0);
1624 renderer.RegisterProperty("uFadeColor", Color::RED);
1625 actor.RegisterProperty("uFadeColor", Color::GREEN);
1626 Property::Index shaderFadeColorIndex = shader.RegisterProperty("uFadeColor", Color::MAGENTA);
1628 TestGlAbstraction& gl = application.GetGlAbstraction();
1630 application.SendNotification();
1631 application.Render(0);
1633 // Expect that the actor's fade color property is accessed
1634 Vector4 actualValue(Vector4::ZERO);
1635 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
1636 DALI_TEST_EQUALS(actualValue, Color::GREEN, TEST_LOCATION);
1638 // Animate shader's fade color property. Should be no change to uniform
1639 Animation animation = Animation::New(1.0f);
1640 KeyFrames keyFrames = KeyFrames::New();
1641 keyFrames.Add(0.0f, Color::WHITE);
1642 keyFrames.Add(1.0f, Color::TRANSPARENT);
1643 animation.AnimateBetween(Property(shader, shaderFadeColorIndex), keyFrames);
1646 application.SendNotification();
1647 application.Render(500);
1649 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
1650 DALI_TEST_EQUALS(actualValue, Color::GREEN, TEST_LOCATION);
1652 application.Render(500);
1653 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
1654 DALI_TEST_EQUALS(actualValue, Color::GREEN, TEST_LOCATION);
1659 int UtcDaliRendererUniformMapPrecendence02(void)
1661 TestApplication application;
1663 tet_infoline("Test the uniform map precedence is applied properly");
1665 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64);
1667 Shader shader = Shader::New("VertexSource", "FragmentSource");
1668 TextureSet textureSet = CreateTextureSet(image);
1670 Geometry geometry = CreateQuadGeometry();
1671 Renderer renderer = Renderer::New(geometry, shader);
1672 renderer.SetTextures(textureSet);
1674 Actor actor = Actor::New();
1675 actor.AddRenderer(renderer);
1676 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1677 application.GetScene().Add(actor);
1678 application.SendNotification();
1679 application.Render(0);
1681 // Don't add property / uniform map to renderer
1682 actor.RegisterProperty("uFadeColor", Color::GREEN);
1683 Property::Index shaderFadeColorIndex = shader.RegisterProperty("uFadeColor", Color::BLUE);
1685 TestGlAbstraction& gl = application.GetGlAbstraction();
1687 application.SendNotification();
1688 application.Render(0);
1690 // Expect that the actor's fade color property is accessed
1691 Vector4 actualValue(Vector4::ZERO);
1692 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
1693 DALI_TEST_EQUALS(actualValue, Color::GREEN, TEST_LOCATION);
1695 // Animate texture set's fade color property. Should be no change to uniform
1696 Animation animation = Animation::New(1.0f);
1697 KeyFrames keyFrames = KeyFrames::New();
1698 keyFrames.Add(0.0f, Color::WHITE);
1699 keyFrames.Add(1.0f, Color::TRANSPARENT);
1700 animation.AnimateBetween(Property(shader, shaderFadeColorIndex), keyFrames);
1703 application.SendNotification();
1704 application.Render(500);
1706 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
1707 DALI_TEST_EQUALS(actualValue, Color::GREEN, TEST_LOCATION);
1709 application.Render(500);
1710 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
1711 DALI_TEST_EQUALS(actualValue, Color::GREEN, TEST_LOCATION);
1716 int UtcDaliRendererUniformMapPrecendence03(void)
1718 TestApplication application;
1720 tet_infoline("Test the uniform map precedence is applied properly");
1722 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64);
1724 Shader shader = Shader::New("VertexSource", "FragmentSource");
1725 TextureSet textureSet = CreateTextureSet(image);
1727 Geometry geometry = CreateQuadGeometry();
1728 Renderer renderer = Renderer::New(geometry, shader);
1729 renderer.SetTextures(textureSet);
1731 Actor actor = Actor::New();
1732 actor.AddRenderer(renderer);
1733 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1734 application.GetScene().Add(actor);
1735 application.SendNotification();
1736 application.Render(0);
1738 // Don't add property / uniform map to renderer or actor
1739 shader.RegisterProperty("uFadeColor", Color::BLACK);
1741 TestGlAbstraction& gl = application.GetGlAbstraction();
1743 application.SendNotification();
1744 application.Render(0);
1746 // Expect that the shader's fade color property is accessed
1747 Vector4 actualValue(Vector4::ZERO);
1748 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
1749 DALI_TEST_EQUALS(actualValue, Color::BLACK, TEST_LOCATION);
1754 int UtcDaliRendererUniformMapMultipleUniforms01(void)
1756 TestApplication application;
1758 tet_infoline("Test the uniform maps are collected from all objects (same type)");
1760 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64);
1762 Shader shader = Shader::New("VertexSource", "FragmentSource");
1763 TextureSet textureSet = CreateTextureSet(image);
1765 Geometry geometry = CreateQuadGeometry();
1766 Renderer renderer = Renderer::New(geometry, shader);
1767 renderer.SetTextures(textureSet);
1769 Actor actor = Actor::New();
1770 actor.AddRenderer(renderer);
1771 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1772 application.GetScene().Add(actor);
1773 application.SendNotification();
1774 application.Render(0);
1776 renderer.RegisterProperty("uUniform1", Color::RED);
1777 actor.RegisterProperty("uUniform2", Color::GREEN);
1778 shader.RegisterProperty("uUniform3", Color::MAGENTA);
1780 TestGlAbstraction& gl = application.GetGlAbstraction();
1782 application.SendNotification();
1783 application.Render(0);
1785 // Expect that each of the object's uniforms are set
1786 Vector4 uniform1Value(Vector4::ZERO);
1787 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uUniform1", uniform1Value));
1788 DALI_TEST_EQUALS(uniform1Value, Color::RED, TEST_LOCATION);
1790 Vector4 uniform2Value(Vector4::ZERO);
1791 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uUniform2", uniform2Value));
1792 DALI_TEST_EQUALS(uniform2Value, Color::GREEN, TEST_LOCATION);
1794 Vector4 uniform3Value(Vector4::ZERO);
1795 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uUniform3", uniform3Value));
1796 DALI_TEST_EQUALS(uniform3Value, Color::MAGENTA, TEST_LOCATION);
1801 int UtcDaliRendererUniformMapMultipleUniforms02(void)
1803 TestApplication application;
1805 tet_infoline("Test the uniform maps are collected from all objects (different types)");
1807 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64);
1809 Shader shader = Shader::New("VertexSource", "FragmentSource");
1810 TextureSet textureSet = CreateTextureSet(image);
1812 Geometry geometry = CreateQuadGeometry();
1813 Renderer renderer = Renderer::New(geometry, shader);
1814 renderer.SetTextures(textureSet);
1816 Actor actor = Actor::New();
1817 actor.AddRenderer(renderer);
1818 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1819 application.GetScene().Add(actor);
1820 application.SendNotification();
1821 application.Render(0);
1823 Property::Value value1(Color::RED);
1824 renderer.RegisterProperty("uFadeColor", value1);
1826 Property::Value value2(1.0f);
1827 actor.RegisterProperty("uFadeProgress", value2);
1829 Property::Value value3(Matrix3::IDENTITY);
1830 shader.RegisterProperty("uANormalMatrix", value3);
1832 TestGlAbstraction& gl = application.GetGlAbstraction();
1834 application.SendNotification();
1835 application.Render(0);
1837 // Expect that each of the object's uniforms are set
1838 Vector4 uniform1Value(Vector4::ZERO);
1839 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", uniform1Value));
1840 DALI_TEST_EQUALS(uniform1Value, value1.Get<Vector4>(), TEST_LOCATION);
1842 float uniform2Value(0.0f);
1843 DALI_TEST_CHECK(gl.GetUniformValue<float>("uFadeProgress", uniform2Value));
1844 DALI_TEST_EQUALS(uniform2Value, value2.Get<float>(), TEST_LOCATION);
1846 Matrix3 uniform3Value;
1847 DALI_TEST_CHECK(gl.GetUniformValue<Matrix3>("uANormalMatrix", uniform3Value));
1848 DALI_TEST_EQUALS(uniform3Value, value3.Get<Matrix3>(), TEST_LOCATION);
1853 int UtcDaliRendererRenderOrder2DLayer(void)
1855 TestApplication application;
1856 tet_infoline("Test the rendering order in a 2D layer is correct");
1858 Shader shader = Shader::New("VertexSource", "FragmentSource");
1859 Geometry geometry = CreateQuadGeometry();
1861 Actor root = application.GetScene().GetRootLayer();
1863 Actor actor0 = CreateActor(root, 0, TEST_LOCATION);
1864 Renderer renderer0 = CreateRenderer(actor0, geometry, shader, 0);
1866 Actor actor1 = CreateActor(root, 0, TEST_LOCATION);
1867 Renderer renderer1 = CreateRenderer(actor1, geometry, shader, 0);
1869 Actor actor2 = CreateActor(root, 0, TEST_LOCATION);
1870 Renderer renderer2 = CreateRenderer(actor2, geometry, shader, 0);
1872 Actor actor3 = CreateActor(root, 0, TEST_LOCATION);
1873 Renderer renderer3 = CreateRenderer(actor3, geometry, shader, 0);
1875 application.SendNotification();
1876 application.Render(0);
1879 * Create the following hierarchy:
1892 * Expected rendering order : actor2 - actor1 - actor0 - actor3
1897 application.SendNotification();
1898 application.Render(0);
1900 TestGlAbstraction& gl = application.GetGlAbstraction();
1901 gl.GetTextureTrace().Reset();
1902 gl.EnableTextureCallTrace(true);
1903 application.SendNotification();
1904 application.Render(0);
1906 int textureBindIndex[4];
1907 for(unsigned int i(0); i < 4; ++i)
1909 std::stringstream params;
1910 params << std::hex << GL_TEXTURE_2D << std::dec << ", " << i + 1;
1911 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str());
1914 //Check that actor1 has been rendered after actor2
1915 DALI_TEST_GREATER(textureBindIndex[1], textureBindIndex[2], TEST_LOCATION);
1917 //Check that actor0 has been rendered after actor1
1918 DALI_TEST_GREATER(textureBindIndex[0], textureBindIndex[1], TEST_LOCATION);
1920 //Check that actor3 has been rendered after actor0
1921 DALI_TEST_GREATER(textureBindIndex[3], textureBindIndex[0], TEST_LOCATION);
1926 int UtcDaliRendererRenderOrder2DLayerMultipleRenderers(void)
1928 TestApplication application;
1929 tet_infoline("Test the rendering order in a 2D layer is correct using multiple renderers per actor");
1932 * Creates the following hierarchy:
1934 * actor0------------------------>actor1
1938 * renderer0 renderer1 renderer2 renderer3 renderer4 renderer5
1940 * renderer0 has depth index 2
1941 * renderer1 has depth index 0
1942 * renderer2 has depth index 1
1944 * renderer3 has depth index 1
1945 * renderer4 has depth index 0
1946 * renderer5 has depth index -1
1948 * Expected rendering order: renderer1 - renderer2 - renderer0 - renderer5 - renderer4 - renderer3
1951 Shader shader = Shader::New("VertexSource", "FragmentSource");
1952 Geometry geometry = CreateQuadGeometry();
1954 Actor root = application.GetScene().GetRootLayer();
1956 Actor actor0 = CreateActor(root, 0, TEST_LOCATION);
1957 Actor actor1 = CreateActor(actor0, 0, TEST_LOCATION);
1958 Renderer renderer0 = CreateRenderer(actor0, geometry, shader, 2);
1959 Renderer renderer1 = CreateRenderer(actor0, geometry, shader, 0);
1960 Renderer renderer2 = CreateRenderer(actor0, geometry, shader, 1);
1961 Renderer renderer3 = CreateRenderer(actor1, geometry, shader, 1);
1962 Renderer renderer4 = CreateRenderer(actor1, geometry, shader, 0);
1963 Renderer renderer5 = CreateRenderer(actor1, geometry, shader, -1);
1965 application.SendNotification();
1966 application.Render(0);
1968 TestGlAbstraction& gl = application.GetGlAbstraction();
1969 gl.GetTextureTrace().Reset();
1970 gl.EnableTextureCallTrace(true);
1971 application.SendNotification();
1972 application.Render(0);
1974 int textureBindIndex[6];
1975 for(unsigned int i(0); i < 6; ++i)
1977 std::stringstream params;
1978 params << std::hex << GL_TEXTURE_2D << std::dec << ", " << i + 1;
1979 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str());
1982 //Check that renderer3 has been rendered after renderer4
1983 DALI_TEST_GREATER(textureBindIndex[3], textureBindIndex[4], TEST_LOCATION);
1985 //Check that renderer0 has been rendered after renderer2
1986 DALI_TEST_GREATER(textureBindIndex[4], textureBindIndex[5], TEST_LOCATION);
1988 //Check that renderer5 has been rendered after renderer2
1989 DALI_TEST_GREATER(textureBindIndex[5], textureBindIndex[0], TEST_LOCATION);
1991 //Check that renderer0 has been rendered after renderer2
1992 DALI_TEST_GREATER(textureBindIndex[0], textureBindIndex[2], TEST_LOCATION);
1994 //Check that renderer2 has been rendered after renderer1
1995 DALI_TEST_GREATER(textureBindIndex[2], textureBindIndex[1], TEST_LOCATION);
2000 int UtcDaliRendererRenderOrder2DLayerSiblingOrder(void)
2002 TestApplication application;
2003 tet_infoline("Test the rendering order in a 2D layer is correct using sibling order");
2006 * Creates the following hierarchy:
2014 * actor0 (SIBLING_ORDER:1) actor1 (SIBLING_ORDER:0)
2018 * renderer0 renderer1 actor2 renderer2 renderer3 renderer4
2019 * DI:2 DI:0 | DI:0 DI:1 DI:2
2024 * actor0 has sibling order 1
2025 * actor1 has sibling order 0
2026 * actor2 has sibling order 0
2028 * renderer0 has depth index 2
2029 * renderer1 has depth index 0
2031 * renderer2 has depth index 0
2032 * renderer3 has depth index 1
2033 * renderer4 has depth index 2
2035 * renderer5 has depth index -1
2037 * Expected rendering order: renderer2 - renderer3 - renderer4 - renderer1 - renderer0 - renderer5
2040 Shader shader = Shader::New("VertexSource", "FragmentSource");
2041 Geometry geometry = CreateQuadGeometry();
2042 Actor root = application.GetScene().GetRootLayer();
2043 Actor actor0 = CreateActor(root, 1, TEST_LOCATION);
2044 Actor actor1 = CreateActor(root, 0, TEST_LOCATION);
2045 Actor actor2 = CreateActor(actor0, 0, TEST_LOCATION);
2047 Renderer renderer0 = CreateRenderer(actor0, geometry, shader, 2);
2048 Renderer renderer1 = CreateRenderer(actor0, geometry, shader, 0);
2049 Renderer renderer2 = CreateRenderer(actor1, geometry, shader, 0);
2050 Renderer renderer3 = CreateRenderer(actor1, geometry, shader, 1);
2051 Renderer renderer4 = CreateRenderer(actor1, geometry, shader, 2);
2052 Renderer renderer5 = CreateRenderer(actor2, geometry, shader, -1);
2054 application.SendNotification();
2055 application.Render();
2057 TestGlAbstraction& gl = application.GetGlAbstraction();
2058 gl.GetTextureTrace().Reset();
2059 gl.EnableTextureCallTrace(true);
2060 application.SendNotification();
2061 application.Render(0);
2063 int textureBindIndex[6];
2064 for(unsigned int i(0); i < 6; ++i)
2066 std::stringstream params;
2067 params << std::hex << GL_TEXTURE_2D << std::dec << ", " << i + 1;
2068 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str());
2071 DALI_TEST_EQUALS(textureBindIndex[2], 0, TEST_LOCATION);
2072 DALI_TEST_EQUALS(textureBindIndex[3], 1, TEST_LOCATION);
2073 DALI_TEST_EQUALS(textureBindIndex[4], 2, TEST_LOCATION);
2074 DALI_TEST_EQUALS(textureBindIndex[1], 3, TEST_LOCATION);
2075 DALI_TEST_EQUALS(textureBindIndex[0], 4, TEST_LOCATION);
2076 DALI_TEST_EQUALS(textureBindIndex[5], 5, TEST_LOCATION);
2078 // Change sibling order of actor1
2079 // New Expected rendering order: renderer1 - renderer0 - renderer 5 - renderer2 - renderer3 - renderer4
2080 actor1.SetProperty(Dali::DevelActor::Property::SIBLING_ORDER, 2);
2082 gl.GetTextureTrace().Reset();
2083 application.SendNotification();
2084 application.Render(0);
2086 for(unsigned int i(0); i < 6; ++i)
2088 std::stringstream params;
2089 params << std::hex << GL_TEXTURE_2D << std::dec << ", " << i + 1;
2090 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str());
2093 DALI_TEST_EQUALS(textureBindIndex[1], 0, TEST_LOCATION);
2094 DALI_TEST_EQUALS(textureBindIndex[0], 1, TEST_LOCATION);
2095 DALI_TEST_EQUALS(textureBindIndex[5], 2, TEST_LOCATION);
2096 DALI_TEST_EQUALS(textureBindIndex[2], 3, TEST_LOCATION);
2097 DALI_TEST_EQUALS(textureBindIndex[3], 4, TEST_LOCATION);
2098 DALI_TEST_EQUALS(textureBindIndex[4], 5, TEST_LOCATION);
2103 int UtcDaliRendererRenderOrder2DLayerOverlay(void)
2105 TestApplication application;
2106 tet_infoline("Test the rendering order in a 2D layer is correct for overlays");
2108 Shader shader = Shader::New("VertexSource", "FragmentSource");
2109 Geometry geometry = CreateQuadGeometry();
2110 Actor root = application.GetScene().GetRootLayer();
2113 * Create the following hierarchy:
2120 * (Overlay) (Regular actor)
2130 * Expected rendering order : actor2 - actor4 - actor1 - actor0 - actor3
2133 Actor actor0 = CreateActor(root, 0, TEST_LOCATION);
2134 actor0.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
2135 Renderer renderer0 = CreateRenderer(actor0, geometry, shader, 0);
2137 Actor actor1 = CreateActor(root, 0, TEST_LOCATION);
2138 actor1.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
2139 Renderer renderer1 = CreateRenderer(actor1, geometry, shader, 0);
2141 Actor actor2 = CreateActor(root, 0, TEST_LOCATION);
2142 Renderer renderer2 = CreateRenderer(actor2, geometry, shader, 0);
2144 Actor actor3 = CreateActor(root, 0, TEST_LOCATION);
2145 actor3.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
2146 Renderer renderer3 = CreateRenderer(actor3, geometry, shader, 0);
2148 Actor actor4 = CreateActor(root, 0, TEST_LOCATION);
2149 Renderer renderer4 = CreateRenderer(actor4, geometry, shader, 0);
2151 application.SendNotification();
2152 application.Render(0);
2159 TestGlAbstraction& gl = application.GetGlAbstraction();
2160 gl.GetTextureTrace().Reset();
2161 gl.EnableTextureCallTrace(true);
2162 application.SendNotification();
2163 application.Render(0);
2165 int textureBindIndex[5];
2166 for(unsigned int i(0); i < 5; ++i)
2168 std::stringstream params;
2169 params << std::hex << GL_TEXTURE_2D << std::dec << ", " << i + 1;
2170 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str());
2173 //Check that actor4 has been rendered after actor2
2174 DALI_TEST_GREATER(textureBindIndex[4], textureBindIndex[2], TEST_LOCATION);
2176 //Check that actor1 has been rendered after actor4
2177 DALI_TEST_GREATER(textureBindIndex[1], textureBindIndex[4], TEST_LOCATION);
2179 //Check that actor0 has been rendered after actor1
2180 DALI_TEST_GREATER(textureBindIndex[0], textureBindIndex[1], TEST_LOCATION);
2182 //Check that actor3 has been rendered after actor0
2183 DALI_TEST_GREATER(textureBindIndex[3], textureBindIndex[0], TEST_LOCATION);
2188 int UtcDaliRendererSetIndexRange(void)
2192 "attribute vec2 aPosition;\n"
2195 " gl_Position = aPosition;\n"
2200 " gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0)\n"
2203 TestApplication application;
2204 tet_infoline("Test setting the range of indices to draw");
2206 TestGlAbstraction& gl = application.GetGlAbstraction();
2207 gl.EnableDrawCallTrace(true);
2209 Actor actor = Actor::New();
2210 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2213 Geometry geometry = Geometry::New();
2214 geometry.SetType(Geometry::LINE_LOOP);
2216 // --------------------------------------------------------------------------
2218 unsigned short indices[] = {0, 2, 4, 6, 8, // offset = 0, count = 5
2228 9, // offset = 5, count = 10
2234 1}; // offset = 15, count = 6 // line strip
2236 // --------------------------------------------------------------------------
2245 {Vector2(0.0f, 1.00f)},
2246 {Vector2(0.0f, -1.00f)},
2247 {Vector2(-0.95f, 0.31f)},
2248 {Vector2(0.59f, 0.81f)},
2249 {Vector2(-0.59f, -0.81f)},
2250 {Vector2(-0.95f, -0.31f)},
2251 {Vector2(0.59f, -0.81f)},
2252 {Vector2(0.95f, -0.31f)},
2253 {Vector2(0.95f, 0.31f)},
2254 {Vector2(-0.59f, 0.81f)},
2256 Property::Map vertexFormat;
2257 vertexFormat["aPosition"] = Property::VECTOR2;
2258 VertexBuffer vertexBuffer = VertexBuffer::New(vertexFormat);
2259 vertexBuffer.SetData(shapes, sizeof(shapes) / sizeof(shapes[0]));
2261 // --------------------------------------------------------------------------
2262 geometry.SetIndexBuffer(indices, sizeof(indices) / sizeof(indices[0]));
2263 geometry.AddVertexBuffer(vertexBuffer);
2266 Shader shader = Shader::New(vertexShader, fragmentShader);
2267 Renderer renderer = Renderer::New(geometry, shader);
2268 actor.AddRenderer(renderer);
2270 Integration::Scene scene = application.GetScene();
2275 // LINE_LOOP, first 0, count 5
2277 renderer.SetIndexRange(0, 5);
2278 application.SendNotification();
2279 application.Render();
2281 Property::Value value = renderer.GetProperty(Renderer::Property::INDEX_RANGE_FIRST);
2283 DALI_TEST_CHECK(value.Get(convertedValue));
2284 DALI_TEST_CHECK(convertedValue == 0);
2286 value = renderer.GetCurrentProperty(Renderer::Property::INDEX_RANGE_FIRST);
2287 DALI_TEST_CHECK(value.Get(convertedValue));
2288 DALI_TEST_CHECK(convertedValue == 0);
2290 value = renderer.GetProperty(Renderer::Property::INDEX_RANGE_COUNT);
2291 DALI_TEST_CHECK(value.Get(convertedValue));
2292 DALI_TEST_CHECK(convertedValue == 5);
2294 value = renderer.GetCurrentProperty(Renderer::Property::INDEX_RANGE_COUNT);
2295 DALI_TEST_CHECK(value.Get(convertedValue));
2296 DALI_TEST_CHECK(convertedValue == 5);
2298 sprintf(buffer, "%u, 5, %u, indices", GL_LINE_LOOP, GL_UNSIGNED_SHORT);
2299 bool result = gl.GetDrawTrace().FindMethodAndParams("DrawElements", buffer);
2300 DALI_TEST_CHECK(result);
2303 // LINE_LOOP, first 5, count 10
2305 renderer.SetIndexRange(5, 10);
2306 sprintf(buffer, "%u, 10, %u, indices", GL_LINE_LOOP, GL_UNSIGNED_SHORT);
2307 application.SendNotification();
2308 application.Render();
2309 bool result = gl.GetDrawTrace().FindMethodAndParams("DrawElements", buffer);
2310 DALI_TEST_CHECK(result);
2313 // LINE_STRIP, first 15, count 6
2315 renderer.SetIndexRange(15, 6);
2316 geometry.SetType(Geometry::LINE_STRIP);
2317 sprintf(buffer, "%u, 6, %u, indices", GL_LINE_STRIP, GL_UNSIGNED_SHORT);
2318 application.SendNotification();
2319 application.Render();
2320 bool result = gl.GetDrawTrace().FindMethodAndParams("DrawElements", buffer);
2321 DALI_TEST_CHECK(result);
2324 // Index out of bounds
2326 renderer.SetIndexRange(15, 30);
2327 geometry.SetType(Geometry::LINE_STRIP);
2328 sprintf(buffer, "%u, 6, %u, indices", GL_LINE_STRIP, GL_UNSIGNED_SHORT);
2329 application.SendNotification();
2330 application.Render();
2331 bool result = gl.GetDrawTrace().FindMethodAndParams("DrawElements", buffer);
2332 DALI_TEST_CHECK(result);
2335 // drawing whole buffer starting from 15 ( last valid primitive )
2337 renderer.SetIndexRange(15, 0);
2338 geometry.SetType(Geometry::LINE_STRIP);
2339 sprintf(buffer, "%u, 6, %u, indices", GL_LINE_STRIP, GL_UNSIGNED_SHORT);
2340 application.SendNotification();
2341 application.Render();
2342 bool result = gl.GetDrawTrace().FindMethodAndParams("DrawElements", buffer);
2343 DALI_TEST_CHECK(result);
2349 int UtcDaliRendererSetDepthFunction(void)
2351 TestApplication application;
2353 tet_infoline("Test setting the depth function");
2355 Geometry geometry = CreateQuadGeometry();
2356 Shader shader = CreateShader();
2357 Renderer renderer = Renderer::New(geometry, shader);
2359 Actor actor = Actor::New();
2360 actor.AddRenderer(renderer);
2361 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
2362 Integration::Scene scene = application.GetScene();
2363 scene.GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
2366 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2367 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2368 TraceCallStack& glDepthFunctionStack = glAbstraction.GetDepthFunctionTrace();
2370 glEnableDisableStack.Enable(true);
2371 glDepthFunctionStack.Enable(true);
2372 glEnableDisableStack.EnableLogging(true);
2373 glDepthFunctionStack.EnableLogging(true);
2375 std::ostringstream depthTestStr;
2376 depthTestStr << std::hex << GL_DEPTH_TEST;
2380 renderer.SetProperty(Renderer::Property::DEPTH_FUNCTION, DepthFunction::NEVER);
2382 glEnableDisableStack.Reset();
2383 glDepthFunctionStack.Reset();
2384 application.SendNotification();
2385 application.Render();
2387 DALI_TEST_CHECK(glEnableDisableStack.FindMethodAndParams("Enable", depthTestStr.str().c_str()));
2388 std::ostringstream depthFunctionStr;
2389 depthFunctionStr << std::hex << GL_NEVER;
2390 DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
2395 renderer.SetProperty(Renderer::Property::DEPTH_FUNCTION, DepthFunction::ALWAYS);
2397 glDepthFunctionStack.Reset();
2398 application.SendNotification();
2399 application.Render();
2401 std::ostringstream depthFunctionStr;
2402 depthFunctionStr << std::hex << GL_ALWAYS;
2403 DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
2408 renderer.SetProperty(Renderer::Property::DEPTH_FUNCTION, DepthFunction::LESS);
2410 glDepthFunctionStack.Reset();
2411 application.SendNotification();
2412 application.Render();
2414 std::ostringstream depthFunctionStr;
2415 depthFunctionStr << std::hex << GL_LESS;
2416 DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
2421 renderer.SetProperty(Renderer::Property::DEPTH_FUNCTION, DepthFunction::GREATER);
2423 glDepthFunctionStack.Reset();
2424 application.SendNotification();
2425 application.Render();
2427 std::ostringstream depthFunctionStr;
2428 depthFunctionStr << std::hex << GL_GREATER;
2429 DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
2434 renderer.SetProperty(Renderer::Property::DEPTH_FUNCTION, DepthFunction::EQUAL);
2436 glDepthFunctionStack.Reset();
2437 application.SendNotification();
2438 application.Render();
2440 std::ostringstream depthFunctionStr;
2441 depthFunctionStr << std::hex << GL_EQUAL;
2442 DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
2447 renderer.SetProperty(Renderer::Property::DEPTH_FUNCTION, DepthFunction::NOT_EQUAL);
2449 glDepthFunctionStack.Reset();
2450 application.SendNotification();
2451 application.Render();
2453 std::ostringstream depthFunctionStr;
2454 depthFunctionStr << std::hex << GL_NOTEQUAL;
2455 DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
2460 renderer.SetProperty(Renderer::Property::DEPTH_FUNCTION, DepthFunction::LESS_EQUAL);
2462 glDepthFunctionStack.Reset();
2463 application.SendNotification();
2464 application.Render();
2466 std::ostringstream depthFunctionStr;
2467 depthFunctionStr << std::hex << GL_LEQUAL;
2468 DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
2473 renderer.SetProperty(Renderer::Property::DEPTH_FUNCTION, DepthFunction::GREATER_EQUAL);
2475 glDepthFunctionStack.Reset();
2476 application.SendNotification();
2477 application.Render();
2479 std::ostringstream depthFunctionStr;
2480 depthFunctionStr << std::hex << GL_GEQUAL;
2481 DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
2488 * @brief This templatized function checks an enumeration property is setting and getting correctly.
2489 * The checks performed are as follows:
2490 * - Check the initial/default value.
2491 * - Set a different value via enum.
2492 * - Check it was set.
2493 * - Set a different value via string.
2494 * - Check it was set.
2496 template<typename T>
2497 void CheckEnumerationProperty(TestApplication& application, Renderer& renderer, Property::Index propertyIndex, T initialValue, T firstCheckEnumeration, T secondCheckEnumeration, std::string secondCheckString)
2499 application.SendNotification();
2500 application.Render();
2502 DALI_TEST_CHECK(renderer.GetProperty<int>(propertyIndex) == static_cast<int>(initialValue));
2503 DALI_TEST_CHECK(renderer.GetCurrentProperty<int>(propertyIndex) == static_cast<int>(initialValue));
2504 renderer.SetProperty(propertyIndex, firstCheckEnumeration);
2505 DALI_TEST_CHECK(renderer.GetProperty<int>(propertyIndex) == static_cast<int>(firstCheckEnumeration));
2506 DALI_TEST_CHECK(renderer.GetCurrentProperty<int>(propertyIndex) != static_cast<int>(firstCheckEnumeration));
2508 application.SendNotification();
2509 application.Render();
2511 DALI_TEST_CHECK(renderer.GetProperty<int>(propertyIndex) == static_cast<int>(firstCheckEnumeration));
2512 DALI_TEST_CHECK(renderer.GetCurrentProperty<int>(propertyIndex) == static_cast<int>(firstCheckEnumeration));
2514 renderer.SetProperty(propertyIndex, secondCheckString);
2515 DALI_TEST_CHECK(renderer.GetProperty<int>(propertyIndex) == static_cast<int>(secondCheckEnumeration));
2516 DALI_TEST_CHECK(renderer.GetCurrentProperty<int>(propertyIndex) != static_cast<int>(secondCheckEnumeration));
2518 application.SendNotification();
2519 application.Render();
2521 DALI_TEST_CHECK(renderer.GetProperty<int>(propertyIndex) == static_cast<int>(secondCheckEnumeration));
2522 DALI_TEST_CHECK(renderer.GetCurrentProperty<int>(propertyIndex) == static_cast<int>(secondCheckEnumeration));
2525 int UtcDaliRendererEnumProperties(void)
2527 TestApplication application;
2528 tet_infoline("Test Renderer enumeration properties can be set with both integer and string values");
2530 Geometry geometry = CreateQuadGeometry();
2531 Shader shader = CreateShader();
2532 Renderer renderer = Renderer::New(geometry, shader);
2534 Actor actor = Actor::New();
2535 actor.AddRenderer(renderer);
2536 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
2537 application.GetScene().Add(actor);
2540 * Here we use a templatized function to perform several checks on each enumeration property.
2541 * @see CheckEnumerationProperty for details of the checks performed.
2544 CheckEnumerationProperty<FaceCullingMode::Type>(application, renderer, Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::NONE, FaceCullingMode::FRONT, FaceCullingMode::BACK, "BACK");
2545 CheckEnumerationProperty<BlendMode::Type>(application, renderer, Renderer::Property::BLEND_MODE, BlendMode::AUTO, BlendMode::OFF, BlendMode::ON, "ON");
2546 CheckEnumerationProperty<BlendEquation::Type>(application, renderer, Renderer::Property::BLEND_EQUATION_RGB, BlendEquation::ADD, BlendEquation::SUBTRACT, BlendEquation::REVERSE_SUBTRACT, "REVERSE_SUBTRACT");
2547 CheckEnumerationProperty<BlendEquation::Type>(application, renderer, Renderer::Property::BLEND_EQUATION_ALPHA, BlendEquation::ADD, BlendEquation::SUBTRACT, BlendEquation::REVERSE_SUBTRACT, "REVERSE_SUBTRACT");
2548 CheckEnumerationProperty<BlendFactor::Type>(application, renderer, Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::SRC_ALPHA, BlendFactor::ONE, BlendFactor::SRC_COLOR, "SRC_COLOR");
2549 CheckEnumerationProperty<BlendFactor::Type>(application, renderer, Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::SRC_COLOR, "SRC_COLOR");
2550 CheckEnumerationProperty<BlendFactor::Type>(application, renderer, Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::SRC_COLOR, "SRC_COLOR");
2551 CheckEnumerationProperty<BlendFactor::Type>(application, renderer, Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::SRC_COLOR, "SRC_COLOR");
2552 CheckEnumerationProperty<DepthWriteMode::Type>(application, renderer, Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::AUTO, DepthWriteMode::OFF, DepthWriteMode::ON, "ON");
2553 CheckEnumerationProperty<DepthFunction::Type>(application, renderer, Renderer::Property::DEPTH_FUNCTION, DepthFunction::LESS, DepthFunction::ALWAYS, DepthFunction::GREATER, "GREATER");
2554 CheckEnumerationProperty<DepthTestMode::Type>(application, renderer, Renderer::Property::DEPTH_TEST_MODE, DepthTestMode::AUTO, DepthTestMode::OFF, DepthTestMode::ON, "ON");
2555 CheckEnumerationProperty<StencilFunction::Type>(application, renderer, Renderer::Property::STENCIL_FUNCTION, StencilFunction::ALWAYS, StencilFunction::LESS, StencilFunction::EQUAL, "EQUAL");
2556 CheckEnumerationProperty<RenderMode::Type>(application, renderer, Renderer::Property::RENDER_MODE, RenderMode::AUTO, RenderMode::NONE, RenderMode::STENCIL, "STENCIL");
2557 CheckEnumerationProperty<StencilOperation::Type>(application, renderer, Renderer::Property::STENCIL_OPERATION_ON_FAIL, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT");
2558 CheckEnumerationProperty<StencilOperation::Type>(application, renderer, Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT");
2559 CheckEnumerationProperty<StencilOperation::Type>(application, renderer, Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT");
2561 if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::MAX) &&
2562 Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::MIN))
2564 application.SendNotification();
2565 application.Render();
2566 CheckEnumerationProperty<DevelBlendEquation::Type>(application, renderer, DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::REVERSE_SUBTRACT, DevelBlendEquation::MAX, DevelBlendEquation::MIN, "MIN");
2569 if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
2571 application.SendNotification();
2572 application.Render();
2573 CheckEnumerationProperty<DevelBlendEquation::Type>(application, renderer, DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::MIN, DevelBlendEquation::MULTIPLY, DevelBlendEquation::SCREEN, "SCREEN");
2579 Renderer RendererTestFixture(TestApplication& application)
2581 Geometry geometry = CreateQuadGeometry();
2582 Shader shader = CreateShader();
2583 Renderer renderer = Renderer::New(geometry, shader);
2585 Actor actor = Actor::New();
2586 actor.AddRenderer(renderer);
2587 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
2588 Integration::Scene scene = application.GetScene();
2589 scene.GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
2595 int UtcDaliRendererSetDepthTestMode(void)
2597 TestApplication application;
2598 tet_infoline("Test setting the DepthTestMode");
2600 Renderer renderer = RendererTestFixture(application);
2601 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2602 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2603 glEnableDisableStack.Enable(true);
2604 glEnableDisableStack.EnableLogging(true);
2606 glEnableDisableStack.Reset();
2607 application.SendNotification();
2608 application.Render();
2610 // Check depth-test is enabled by default.
2611 DALI_TEST_CHECK(glEnableDisableStack.FindMethodAndParams("Enable", GetDepthTestString()));
2612 DALI_TEST_CHECK(!glEnableDisableStack.FindMethodAndParams("Disable", GetDepthTestString()));
2614 // 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.
2615 renderer.SetProperty(Renderer::Property::DEPTH_TEST_MODE, DepthTestMode::OFF);
2616 renderer.SetProperty(Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::OFF);
2618 glEnableDisableStack.Reset();
2619 application.SendNotification();
2620 application.Render();
2622 // Check the depth buffer was disabled.
2623 DALI_TEST_CHECK(glEnableDisableStack.FindMethodAndParams("Disable", GetDepthTestString()));
2625 // Turn on automatic mode depth-testing.
2626 // Layer behavior is currently set to LAYER_3D so AUTO should enable depth-testing.
2627 renderer.SetProperty(Renderer::Property::DEPTH_TEST_MODE, DepthTestMode::AUTO);
2629 glEnableDisableStack.Reset();
2630 application.SendNotification();
2631 application.Render();
2633 // Check depth-test is now enabled.
2634 DALI_TEST_CHECK(glEnableDisableStack.FindMethodAndParams("Enable", GetDepthTestString()));
2635 DALI_TEST_CHECK(!glEnableDisableStack.FindMethodAndParams("Disable", GetDepthTestString()));
2637 // Change the layer behavior to LAYER_UI.
2638 // Note this will also disable depth testing for the layer by default, we test this first.
2639 application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_UI);
2641 glEnableDisableStack.Reset();
2642 application.SendNotification();
2643 application.Render();
2645 // Check depth-test is disabled.
2646 DALI_TEST_CHECK(glEnableDisableStack.FindMethodAndParams("Disable", GetDepthTestString()));
2648 // Turn the layer depth-test flag back on, and confirm that depth testing is now on.
2649 application.GetScene().GetRootLayer().SetProperty(Layer::Property::DEPTH_TEST, true);
2651 glEnableDisableStack.Reset();
2652 application.SendNotification();
2653 application.Render();
2655 // Check depth-test is *still* disabled.
2656 DALI_TEST_CHECK(glEnableDisableStack.FindMethodAndParams("Enable", GetDepthTestString()));
2661 int UtcDaliRendererSetDepthWriteMode(void)
2663 TestApplication application;
2664 tet_infoline("Test setting the DepthWriteMode");
2666 Renderer renderer = RendererTestFixture(application);
2667 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2669 application.SendNotification();
2670 application.Render();
2672 // Check the default depth-write status first.
2673 DALI_TEST_CHECK(glAbstraction.GetLastDepthMask());
2675 // Turn off depth-writing.
2676 renderer.SetProperty(Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::OFF);
2678 application.SendNotification();
2679 application.Render();
2681 // Check depth-write is now disabled.
2682 DALI_TEST_CHECK(!glAbstraction.GetLastDepthMask());
2684 // Test the AUTO mode for depth-writing.
2685 // As our renderer is opaque, depth-testing should be enabled.
2686 renderer.SetProperty(Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::AUTO);
2688 application.SendNotification();
2689 application.Render();
2691 // Check depth-write is now enabled.
2692 DALI_TEST_CHECK(glAbstraction.GetLastDepthMask());
2694 // Now make the renderer be treated as translucent by enabling blending.
2695 // The AUTO depth-write mode should turn depth-write off in this scenario.
2696 renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
2698 application.SendNotification();
2699 application.Render();
2701 // Check depth-write is now disabled.
2702 DALI_TEST_CHECK(!glAbstraction.GetLastDepthMask());
2707 int UtcDaliRendererCheckStencilDefaults(void)
2709 TestApplication application;
2710 tet_infoline("Test the stencil defaults");
2712 Renderer renderer = RendererTestFixture(application);
2713 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2714 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2715 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
2716 glEnableDisableStack.Enable(true);
2717 glEnableDisableStack.EnableLogging(true);
2718 glStencilFunctionStack.Enable(true);
2719 glStencilFunctionStack.EnableLogging(true);
2721 ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
2723 // Check the defaults:
2724 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetProperty(Renderer::Property::STENCIL_FUNCTION).Get<int>()), static_cast<int>(StencilFunction::ALWAYS), TEST_LOCATION);
2725 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetProperty(Renderer::Property::STENCIL_FUNCTION_MASK).Get<int>()), 0xFF, TEST_LOCATION);
2726 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetProperty(Renderer::Property::STENCIL_FUNCTION_REFERENCE).Get<int>()), 0x00, TEST_LOCATION);
2727 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetProperty(Renderer::Property::STENCIL_MASK).Get<int>()), 0xFF, TEST_LOCATION);
2728 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetProperty(Renderer::Property::STENCIL_OPERATION_ON_FAIL).Get<int>()), static_cast<int>(StencilOperation::KEEP), TEST_LOCATION);
2729 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);
2730 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);
2735 int UtcDaliRendererSetRenderModeToUseStencilBuffer(void)
2737 TestApplication application;
2738 tet_infoline("Test setting the RenderMode to use the stencil buffer");
2740 Renderer renderer = RendererTestFixture(application);
2741 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2742 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2743 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
2744 glEnableDisableStack.Enable(true);
2745 glEnableDisableStack.EnableLogging(true);
2746 glStencilFunctionStack.Enable(true);
2747 glStencilFunctionStack.EnableLogging(true);
2749 // Set the StencilFunction to something other than the default, to confirm it is set as a property,
2750 // but NO GL call has been made while the RenderMode is set to not use the stencil buffer.
2751 renderer.SetProperty(Renderer::Property::RENDER_MODE, RenderMode::NONE);
2752 ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
2754 renderer.SetProperty(Renderer::Property::STENCIL_FUNCTION, StencilFunction::NEVER);
2755 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetProperty(Renderer::Property::STENCIL_FUNCTION).Get<int>()), static_cast<int>(StencilFunction::NEVER), TEST_LOCATION);
2757 ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
2758 std::string methodString("StencilFunc");
2759 DALI_TEST_CHECK(!glStencilFunctionStack.FindMethod(methodString));
2761 // Test the other RenderModes that will not enable the stencil buffer.
2762 renderer.SetProperty(Renderer::Property::RENDER_MODE, RenderMode::AUTO);
2763 ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
2764 DALI_TEST_CHECK(!glStencilFunctionStack.FindMethod(methodString));
2766 renderer.SetProperty(Renderer::Property::RENDER_MODE, RenderMode::COLOR);
2767 ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
2768 DALI_TEST_CHECK(!glStencilFunctionStack.FindMethod(methodString));
2770 // Now set the RenderMode to modes that will use the stencil buffer, and check the StencilFunction has changed.
2771 renderer.SetProperty(Renderer::Property::RENDER_MODE, RenderMode::STENCIL);
2772 ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
2774 DALI_TEST_CHECK(glEnableDisableStack.FindMethodAndParams("Enable", GetStencilTestString()));
2775 DALI_TEST_CHECK(glStencilFunctionStack.FindMethod(methodString));
2777 // Test the COLOR_STENCIL RenderMode as it also enables the stencil buffer.
2778 // First set a mode to turn off the stencil buffer, so the enable is required.
2779 renderer.SetProperty(Renderer::Property::RENDER_MODE, RenderMode::COLOR);
2780 ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
2781 renderer.SetProperty(Renderer::Property::RENDER_MODE, RenderMode::COLOR_STENCIL);
2782 // Set a different stencil function as the last one is cached.
2783 renderer.SetProperty(Renderer::Property::STENCIL_FUNCTION, StencilFunction::ALWAYS);
2784 ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
2786 DALI_TEST_CHECK(glEnableDisableStack.FindMethodAndParams("Enable", GetStencilTestString()));
2787 DALI_TEST_CHECK(glStencilFunctionStack.FindMethod(methodString));
2792 // Helper function for the SetRenderModeToUseColorBuffer test.
2793 void CheckRenderModeColorMask(TestApplication& application, Renderer& renderer, RenderMode::Type renderMode, bool expectedValue)
2795 // Set the RenderMode property to a value that should not allow color buffer writes.
2796 renderer.SetProperty(Renderer::Property::RENDER_MODE, renderMode);
2797 application.SendNotification();
2798 application.Render();
2800 // Check if ColorMask has been called, and that the values are correct.
2801 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2802 const TestGlAbstraction::ColorMaskParams& colorMaskParams(glAbstraction.GetColorMaskParams());
2804 DALI_TEST_EQUALS<bool>(colorMaskParams.red, expectedValue, TEST_LOCATION);
2805 DALI_TEST_EQUALS<bool>(colorMaskParams.green, expectedValue, TEST_LOCATION);
2806 DALI_TEST_EQUALS<bool>(colorMaskParams.blue, expectedValue, TEST_LOCATION);
2807 DALI_TEST_EQUALS<bool>(colorMaskParams.alpha, expectedValue, TEST_LOCATION);
2810 int UtcDaliRendererSetRenderModeToUseColorBuffer(void)
2812 TestApplication application;
2813 tet_infoline("Test setting the RenderMode to use the color buffer");
2815 Renderer renderer = RendererTestFixture(application);
2817 // Set the RenderMode property to a value that should not allow color buffer writes.
2818 // Then check if ColorMask has been called, and that the values are correct.
2819 CheckRenderModeColorMask(application, renderer, RenderMode::AUTO, true);
2820 CheckRenderModeColorMask(application, renderer, RenderMode::NONE, false);
2821 CheckRenderModeColorMask(application, renderer, RenderMode::COLOR, true);
2822 CheckRenderModeColorMask(application, renderer, RenderMode::STENCIL, false);
2823 CheckRenderModeColorMask(application, renderer, RenderMode::COLOR_STENCIL, true);
2828 int UtcDaliRendererSetStencilFunction(void)
2830 TestApplication application;
2831 tet_infoline("Test setting the StencilFunction");
2833 Renderer renderer = RendererTestFixture(application);
2834 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2835 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2836 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
2837 glEnableDisableStack.Enable(true);
2838 glEnableDisableStack.EnableLogging(true);
2839 glStencilFunctionStack.Enable(true);
2840 glStencilFunctionStack.EnableLogging(true);
2842 // RenderMode must use the stencil for StencilFunction to operate.
2843 renderer.SetProperty(Renderer::Property::RENDER_MODE, RenderMode::STENCIL);
2844 ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
2847 * Lookup table for testing StencilFunction.
2848 * Note: This MUST be in the same order as the Dali::StencilFunction enum.
2850 const int StencilFunctionLookupTable[] = {
2859 const int StencilFunctionLookupTableCount = sizeof(StencilFunctionLookupTable) / sizeof(StencilFunctionLookupTable[0]);
2862 * Loop through all types of StencilFunction, checking:
2863 * - The value is cached (set in event thread side)
2864 * - Causes "glStencilFunc" to be called
2865 * - Checks the correct parameters to "glStencilFunc" were used
2867 std::string nonChangingParameters = "0, 255";
2868 std::string methodString("StencilFunc");
2869 for(int i = 0; i < StencilFunctionLookupTableCount; ++i)
2871 // Set the property.
2872 renderer.SetProperty(Renderer::Property::STENCIL_FUNCTION, static_cast<Dali::StencilFunction::Type>(i));
2874 // Check GetProperty returns the same value.
2875 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetProperty(Renderer::Property::STENCIL_FUNCTION).Get<int>()), i, TEST_LOCATION);
2877 // Reset the trace debug.
2878 ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
2880 // Check the function is called and the parameters are correct.
2881 std::stringstream parameterStream;
2882 parameterStream << StencilFunctionLookupTable[i] << ", " << nonChangingParameters;
2884 DALI_TEST_CHECK(glStencilFunctionStack.FindMethodAndParams(methodString, parameterStream.str()));
2887 // Change the Function Reference only and check the behavior is correct:
2888 // 170 is 0xaa in hex / 10101010 in binary (every other bit set).
2889 int testValueReference = 170;
2890 renderer.SetProperty(Renderer::Property::STENCIL_FUNCTION_REFERENCE, testValueReference);
2892 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetProperty(Renderer::Property::STENCIL_FUNCTION_REFERENCE).Get<int>()), testValueReference, TEST_LOCATION);
2894 ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
2896 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetCurrentProperty(Renderer::Property::STENCIL_FUNCTION_REFERENCE).Get<int>()), testValueReference, TEST_LOCATION);
2898 std::stringstream parameterStream;
2899 parameterStream << StencilFunctionLookupTable[StencilOperation::DECREMENT_WRAP] << ", " << testValueReference << ", 255";
2901 DALI_TEST_CHECK(glStencilFunctionStack.FindMethodAndParams(methodString, parameterStream.str()));
2903 // Change the Function Mask only and check the behavior is correct:
2904 // 85 is 0x55 in hex / 01010101 in binary (every other bit set).
2905 int testValueMask = 85;
2906 renderer.SetProperty(Renderer::Property::STENCIL_FUNCTION_MASK, testValueMask);
2908 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetProperty(Renderer::Property::STENCIL_FUNCTION_MASK).Get<int>()), testValueMask, TEST_LOCATION);
2910 ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
2912 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetCurrentProperty(Renderer::Property::STENCIL_FUNCTION_MASK).Get<int>()), testValueMask, TEST_LOCATION);
2914 // Clear the stringstream.
2915 parameterStream.str(std::string());
2916 parameterStream << StencilFunctionLookupTable[StencilOperation::DECREMENT_WRAP] << ", " << testValueReference << ", " << testValueMask;
2918 DALI_TEST_CHECK(glStencilFunctionStack.FindMethodAndParams(methodString, parameterStream.str()));
2923 int UtcDaliRendererSetStencilOperation(void)
2925 TestApplication application;
2926 tet_infoline("Test setting the StencilOperation");
2928 Renderer renderer = RendererTestFixture(application);
2929 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2930 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2931 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
2932 glEnableDisableStack.Enable(true);
2933 glEnableDisableStack.EnableLogging(true);
2934 glStencilFunctionStack.Enable(true);
2935 glStencilFunctionStack.EnableLogging(true);
2937 // RenderMode must use the stencil for StencilOperation to operate.
2938 renderer.SetProperty(Renderer::Property::RENDER_MODE, RenderMode::STENCIL);
2941 * Lookup table for testing StencilOperation.
2942 * Note: This MUST be in the same order as the Dali::StencilOperation enum.
2944 const int StencilOperationLookupTable[] = {
2953 const int StencilOperationLookupTableCount = sizeof(StencilOperationLookupTable) / sizeof(StencilOperationLookupTable[0]);
2955 // Set all 3 StencilOperation properties to a default.
2956 renderer.SetProperty(Renderer::Property::STENCIL_OPERATION_ON_FAIL, StencilOperation::KEEP);
2957 renderer.SetProperty(Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, StencilOperation::ZERO);
2958 renderer.SetProperty(Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, StencilOperation::ZERO);
2960 // Set our expected parameter list to the equivalent result.
2961 int parameters[] = {StencilOperationLookupTable[StencilOperation::ZERO], StencilOperationLookupTable[StencilOperation::ZERO], StencilOperationLookupTable[StencilOperation::ZERO]};
2963 ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
2966 * Loop through all types of StencilOperation, checking:
2967 * - The value is cached (set in event thread side)
2968 * - Causes "glStencilFunc" to be called
2969 * - Checks the correct parameters to "glStencilFunc" were used
2970 * - Checks the above for all 3 parameter placements of StencilOperation ( OnFail, OnZFail, OnPass )
2972 std::string methodString("StencilOp");
2974 for(int i = 0; i < StencilOperationLookupTableCount; ++i)
2976 for(int j = 0; j < StencilOperationLookupTableCount; ++j)
2978 for(int k = 0; k < StencilOperationLookupTableCount; ++k)
2980 // Set the property (outer loop causes all 3 different properties to be set separately).
2981 renderer.SetProperty(Renderer::Property::STENCIL_OPERATION_ON_FAIL, static_cast<Dali::StencilFunction::Type>(i));
2982 renderer.SetProperty(Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, static_cast<Dali::StencilFunction::Type>(j));
2983 renderer.SetProperty(Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, static_cast<Dali::StencilFunction::Type>(k));
2985 // Check GetProperty returns the same value.
2986 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetProperty(Renderer::Property::STENCIL_OPERATION_ON_FAIL).Get<int>()), i, TEST_LOCATION);
2987 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetProperty(Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL).Get<int>()), j, TEST_LOCATION);
2988 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetProperty(Renderer::Property::STENCIL_OPERATION_ON_Z_PASS).Get<int>()), k, TEST_LOCATION);
2990 // Reset the trace debug.
2991 ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
2993 // Check the function is called and the parameters are correct.
2994 // Set the expected parameter value at its correct index (only)
2995 parameters[0u] = StencilOperationLookupTable[i];
2996 parameters[1u] = StencilOperationLookupTable[j];
2997 parameters[2u] = StencilOperationLookupTable[k];
2999 // Build the parameter list.
3000 std::stringstream parameterStream;
3001 for(int parameterBuild = 0; parameterBuild < 3; ++parameterBuild)
3003 parameterStream << parameters[parameterBuild];
3004 // Comma-separate the parameters.
3005 if(parameterBuild < 2)
3007 parameterStream << ", ";
3011 // Check the function was called and the parameters were correct.
3012 DALI_TEST_CHECK(glStencilFunctionStack.FindMethodAndParams(methodString, parameterStream.str()));
3020 int UtcDaliRendererSetStencilMask(void)
3022 TestApplication application;
3023 tet_infoline("Test setting the StencilMask");
3025 Renderer renderer = RendererTestFixture(application);
3026 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3027 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
3028 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
3029 glEnableDisableStack.Enable(true);
3030 glEnableDisableStack.EnableLogging(true);
3031 glStencilFunctionStack.Enable(true);
3032 glStencilFunctionStack.EnableLogging(true);
3034 // RenderMode must use the stencil for StencilMask to operate.
3035 renderer.SetProperty(Renderer::Property::RENDER_MODE, RenderMode::STENCIL);
3037 // Set the StencilMask property to a value.
3038 renderer.SetProperty(Renderer::Property::STENCIL_MASK, 0x00);
3040 // Check GetProperty returns the same value.
3041 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetProperty(Renderer::Property::STENCIL_MASK).Get<int>()), 0x00, TEST_LOCATION);
3043 ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
3045 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetCurrentProperty(Renderer::Property::STENCIL_MASK).Get<int>()), 0x00, TEST_LOCATION);
3047 std::string methodString("StencilMask");
3048 std::string parameterString = "0";
3050 // Check the function was called and the parameters were correct.
3051 DALI_TEST_CHECK(glStencilFunctionStack.FindMethodAndParams(methodString, parameterString));
3053 // Set the StencilMask property to another value to ensure it has changed.
3054 renderer.SetProperty(Renderer::Property::STENCIL_MASK, 0xFF);
3056 // Check GetProperty returns the same value.
3057 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetProperty(Renderer::Property::STENCIL_MASK).Get<int>()), 0xFF, TEST_LOCATION);
3059 ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
3061 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetCurrentProperty(Renderer::Property::STENCIL_MASK).Get<int>()), 0xFF, TEST_LOCATION);
3063 parameterString = "255";
3065 // Check the function was called and the parameters were correct.
3066 DALI_TEST_CHECK(glStencilFunctionStack.FindMethodAndParams(methodString, parameterString));
3071 int UtcDaliRendererWrongNumberOfTextures(void)
3073 TestApplication application;
3074 tet_infoline("Test renderer does render even if number of textures is different than active samplers in the shader");
3076 //Create a TextureSet with 4 textures (One more texture in the texture set than active samplers)
3077 //@note Shaders in the test suit have 3 active samplers. See TestGlAbstraction::GetActiveUniform()
3078 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64u, 64u);
3079 TextureSet textureSet = CreateTextureSet();
3080 textureSet.SetTexture(0, texture);
3081 textureSet.SetTexture(1, texture);
3082 textureSet.SetTexture(2, texture);
3083 textureSet.SetTexture(3, texture);
3084 Shader shader = Shader::New("VertexSource", "FragmentSource");
3085 Geometry geometry = CreateQuadGeometry();
3086 Renderer renderer = Renderer::New(geometry, shader);
3087 renderer.SetTextures(textureSet);
3089 Actor actor = Actor::New();
3090 actor.AddRenderer(renderer);
3091 actor.SetProperty(Actor::Property::POSITION, Vector2(0.0f, 0.0f));
3092 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
3093 application.GetScene().Add(actor);
3095 TestGlAbstraction& gl = application.GetGlAbstraction();
3096 TraceCallStack& drawTrace = gl.GetDrawTrace();
3098 drawTrace.Enable(true);
3099 drawTrace.EnableLogging(true);
3101 application.SendNotification();
3102 application.Render(0);
3104 //Test we do the drawcall when TextureSet has more textures than there are active samplers in the shader
3105 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
3107 //Create a TextureSet with 1 texture (two more active samplers than texture in the texture set)
3108 //@note Shaders in the test suit have 3 active samplers. See TestGlAbstraction::GetActiveUniform()
3109 textureSet = CreateTextureSet();
3110 renderer.SetTextures(textureSet);
3111 textureSet.SetTexture(0, texture);
3113 application.SendNotification();
3114 application.Render(0);
3116 //Test we do the drawcall when TextureSet has less textures than there are active samplers in the shader.
3117 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
3122 int UtcDaliRendererOpacity(void)
3124 TestApplication application;
3126 tet_infoline("Test OPACITY property");
3128 Geometry geometry = CreateQuadGeometry();
3129 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
3130 Renderer renderer = Renderer::New(geometry, shader);
3132 Actor actor = Actor::New();
3133 actor.AddRenderer(renderer);
3134 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
3135 actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 1.0f));
3136 application.GetScene().Add(actor);
3138 Property::Value value = renderer.GetProperty(DevelRenderer::Property::OPACITY);
3140 DALI_TEST_CHECK(value.Get(opacity));
3141 DALI_TEST_EQUALS(opacity, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
3143 application.SendNotification();
3144 application.Render();
3146 Vector4 actualValue;
3147 TestGlAbstraction& gl = application.GetGlAbstraction();
3148 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uColor", actualValue));
3149 DALI_TEST_EQUALS(actualValue.a, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
3151 renderer.SetProperty(DevelRenderer::Property::OPACITY, 0.5f);
3153 application.SendNotification();
3154 application.Render();
3156 value = renderer.GetProperty(DevelRenderer::Property::OPACITY);
3157 DALI_TEST_CHECK(value.Get(opacity));
3158 DALI_TEST_EQUALS(opacity, 0.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
3160 value = renderer.GetCurrentProperty(DevelRenderer::Property::OPACITY);
3161 DALI_TEST_CHECK(value.Get(opacity));
3162 DALI_TEST_EQUALS(opacity, 0.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
3164 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uColor", actualValue));
3165 DALI_TEST_EQUALS(actualValue.a, 0.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
3170 int UtcDaliRendererOpacityAnimation(void)
3172 TestApplication application;
3174 tet_infoline("Test OPACITY property animation");
3176 Geometry geometry = CreateQuadGeometry();
3177 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
3178 Renderer renderer = Renderer::New(geometry, shader);
3180 Actor actor = Actor::New();
3181 actor.AddRenderer(renderer);
3182 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
3183 actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 1.0f));
3184 application.GetScene().Add(actor);
3186 application.SendNotification();
3187 application.Render(0);
3189 Property::Value value = renderer.GetProperty(DevelRenderer::Property::OPACITY);
3191 DALI_TEST_CHECK(value.Get(opacity));
3192 DALI_TEST_EQUALS(opacity, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
3194 Animation animation = Animation::New(1.0f);
3195 animation.AnimateTo(Property(renderer, DevelRenderer::Property::OPACITY), 0.0f);
3198 application.SendNotification();
3199 application.Render(1000);
3201 value = renderer.GetProperty(DevelRenderer::Property::OPACITY);
3202 DALI_TEST_CHECK(value.Get(opacity));
3203 DALI_TEST_EQUALS(opacity, 0.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
3205 // Need to clear the animation before setting the property as the animation value is baked and will override any previous setters
3207 renderer.SetProperty(DevelRenderer::Property::OPACITY, 0.1f);
3209 animation.AnimateBy(Property(renderer, DevelRenderer::Property::OPACITY), 0.5f);
3212 application.SendNotification();
3213 application.Render(1000);
3215 value = renderer.GetProperty(DevelRenderer::Property::OPACITY);
3216 DALI_TEST_CHECK(value.Get(opacity));
3217 DALI_TEST_EQUALS(opacity, 0.6f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
3218 DALI_TEST_EQUALS(opacity, renderer.GetCurrentProperty(DevelRenderer::Property::OPACITY).Get<float>(), Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
3223 int UtcDaliRendererInvalidProperty(void)
3225 TestApplication application;
3227 tet_infoline("Test invalid property");
3229 Geometry geometry = CreateQuadGeometry();
3230 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
3231 Renderer renderer = Renderer::New(geometry, shader);
3233 Actor actor = Actor::New();
3234 actor.AddRenderer(renderer);
3235 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
3236 application.GetScene().Add(actor);
3238 application.SendNotification();
3239 application.Render(0);
3241 Property::Value value = renderer.GetProperty(Renderer::Property::DEPTH_INDEX + 100);
3242 DALI_TEST_CHECK(value.GetType() == Property::Type::NONE);
3244 value = renderer.GetCurrentProperty(Renderer::Property::DEPTH_INDEX + 100);
3245 DALI_TEST_CHECK(value.GetType() == Property::Type::NONE);
3250 int UtcDaliRendererRenderingBehavior(void)
3252 TestApplication application;
3254 tet_infoline("Test RENDERING_BEHAVIOR property");
3256 Geometry geometry = CreateQuadGeometry();
3257 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
3258 Renderer renderer = Renderer::New(geometry, shader);
3260 Actor actor = Actor::New();
3261 actor.AddRenderer(renderer);
3262 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
3263 actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 1.0f));
3264 application.GetScene().Add(actor);
3266 Property::Value value = renderer.GetProperty(DevelRenderer::Property::RENDERING_BEHAVIOR);
3267 int renderingBehavior;
3268 DALI_TEST_CHECK(value.Get(renderingBehavior));
3269 DALI_TEST_EQUALS(static_cast<DevelRenderer::Rendering::Type>(renderingBehavior), DevelRenderer::Rendering::IF_REQUIRED, TEST_LOCATION);
3271 application.SendNotification();
3272 application.Render();
3274 uint32_t updateStatus = application.GetUpdateStatus();
3276 DALI_TEST_CHECK(!(updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING));
3278 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3279 TraceCallStack& drawTrace = glAbstraction.GetDrawTrace();
3280 drawTrace.Enable(true);
3283 renderer.SetProperty(DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::CONTINUOUSLY);
3285 value = renderer.GetProperty(DevelRenderer::Property::RENDERING_BEHAVIOR);
3286 DALI_TEST_CHECK(value.Get(renderingBehavior));
3287 DALI_TEST_EQUALS(static_cast<DevelRenderer::Rendering::Type>(renderingBehavior), DevelRenderer::Rendering::CONTINUOUSLY, TEST_LOCATION);
3289 // Render and check the update status
3290 application.SendNotification();
3291 application.Render();
3293 updateStatus = application.GetUpdateStatus();
3295 DALI_TEST_CHECK(updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING);
3297 value = renderer.GetCurrentProperty(DevelRenderer::Property::RENDERING_BEHAVIOR);
3298 DALI_TEST_CHECK(value.Get(renderingBehavior));
3299 DALI_TEST_EQUALS(static_cast<DevelRenderer::Rendering::Type>(renderingBehavior), DevelRenderer::Rendering::CONTINUOUSLY, TEST_LOCATION);
3301 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
3305 // Render again and check the update status
3306 application.SendNotification();
3307 application.Render();
3309 updateStatus = application.GetUpdateStatus();
3311 DALI_TEST_CHECK(updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING);
3313 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
3316 // Render again and check the update status
3317 Animation animation = Animation::New(1.0f);
3318 animation.AnimateTo(Property(renderer, DevelRenderer::Property::OPACITY), 0.0f, TimePeriod(0.5f, 0.5f));
3323 application.SendNotification();
3324 application.Render(0);
3326 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
3330 application.SendNotification();
3331 application.Render(100);
3333 updateStatus = application.GetUpdateStatus();
3335 DALI_TEST_CHECK(updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING);
3337 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
3340 // Change rendering behavior
3341 renderer.SetProperty(DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::IF_REQUIRED);
3343 // Render and check the update status
3344 application.SendNotification();
3345 application.Render();
3347 updateStatus = application.GetUpdateStatus();
3349 DALI_TEST_CHECK(!(updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING));
3354 int UtcDaliRendererRegenerateUniformMap(void)
3356 TestApplication application;
3358 tet_infoline("Test regenerating uniform map when attaching renderer to the node");
3360 Geometry geometry = CreateQuadGeometry();
3361 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
3362 Renderer renderer = Renderer::New(geometry, shader);
3364 Actor actor = Actor::New();
3365 actor.AddRenderer(renderer);
3366 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
3367 actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 1.0f));
3368 application.GetScene().Add(actor);
3370 application.SendNotification();
3371 application.Render();
3373 actor.RemoveRenderer(renderer);
3374 shader = Shader::New("vertexSrc", "fragmentSrc");
3375 shader.RegisterProperty("opacity", 0.5f);
3376 renderer.SetShader(shader);
3378 Stage::GetCurrent().KeepRendering(1.0f);
3380 // Update for several frames
3381 application.SendNotification();
3382 application.Render();
3383 application.SendNotification();
3384 application.Render();
3385 application.SendNotification();
3386 application.Render();
3387 application.SendNotification();
3388 application.Render();
3391 actor.AddRenderer(renderer);
3392 application.SendNotification();
3393 application.Render();
3395 // Nothing to test here, the test must not crash
3396 auto updateStatus = application.GetUpdateStatus();
3397 DALI_TEST_CHECK(updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING);
3402 int UtcDaliRendererAddDrawCommands(void)
3404 TestApplication application;
3406 tet_infoline("Test adding draw commands to the renderer");
3408 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3409 glAbstraction.EnableEnableDisableCallTrace(true);
3411 Geometry geometry = CreateQuadGeometry();
3412 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
3413 Renderer renderer = Renderer::New(geometry, shader);
3415 renderer.SetProperty(Renderer::Property::BLEND_MODE, Dali::BlendMode::ON);
3416 Actor actor = Actor::New();
3417 actor.AddRenderer(renderer);
3418 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
3419 actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 1.0f));
3420 application.GetScene().Add(actor);
3422 // Expect delivering a single draw call
3423 auto& drawTrace = glAbstraction.GetDrawTrace();
3425 drawTrace.Enable(true);
3426 application.SendNotification();
3427 application.Render();
3429 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
3431 tet_infoline("\n\nTesting extension draw commands\n");
3432 tet_infoline("TEMPORARILY REMOVED. MUST PUT BACK!\n");
3433 #ifdef TEMPORARY_TEST_REMOVAL
3434 auto drawCommand1 = DevelRenderer::DrawCommand{};
3435 drawCommand1.drawType = DevelRenderer::DrawType::INDEXED;
3436 drawCommand1.firstIndex = 0;
3437 drawCommand1.elementCount = 2;
3438 drawCommand1.queue = DevelRenderer::RENDER_QUEUE_OPAQUE;
3440 auto drawCommand2 = DevelRenderer::DrawCommand{};
3441 drawCommand2.drawType = DevelRenderer::DrawType::INDEXED;
3442 drawCommand2.firstIndex = 2;
3443 drawCommand2.elementCount = 2;
3444 drawCommand2.queue = DevelRenderer::RENDER_QUEUE_TRANSPARENT;
3446 auto drawCommand3 = DevelRenderer::DrawCommand{};
3447 drawCommand3.drawType = DevelRenderer::DrawType::ARRAY;
3448 drawCommand3.firstIndex = 2;
3449 drawCommand3.elementCount = 2;
3450 drawCommand3.queue = DevelRenderer::RENDER_QUEUE_OPAQUE;
3452 DevelRenderer::AddDrawCommand(renderer, drawCommand1);
3453 DevelRenderer::AddDrawCommand(renderer, drawCommand2);
3454 DevelRenderer::AddDrawCommand(renderer, drawCommand3);
3457 drawTrace.Enable(true);
3458 application.SendNotification();
3459 application.Render();
3461 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 3, TEST_LOCATION);
3465 int UtcDaliRendererSetGeometryNegative(void)
3467 TestApplication application;
3468 Dali::Renderer instance;
3471 Dali::Geometry arg1;
3472 instance.SetGeometry(arg1);
3473 DALI_TEST_CHECK(false); // Should not get here
3477 DALI_TEST_CHECK(true); // We expect an assert
3482 int UtcDaliRendererSetTexturesNegative(void)
3484 TestApplication application;
3485 Dali::Renderer instance;
3488 Dali::TextureSet arg1;
3489 instance.SetTextures(arg1);
3490 DALI_TEST_CHECK(false); // Should not get here
3494 DALI_TEST_CHECK(true); // We expect an assert
3499 int UtcDaliRendererSetShaderNegative(void)
3501 TestApplication application;
3502 Dali::Renderer instance;
3506 instance.SetShader(arg1);
3507 DALI_TEST_CHECK(false); // Should not get here
3511 DALI_TEST_CHECK(true); // We expect an assert
3516 int UtcDaliRendererGetGeometryNegative(void)
3518 TestApplication application;
3519 Dali::Renderer instance;
3522 instance.GetGeometry();
3523 DALI_TEST_CHECK(false); // Should not get here
3527 DALI_TEST_CHECK(true); // We expect an assert
3532 int UtcDaliRendererGetTexturesNegative(void)
3534 TestApplication application;
3535 Dali::Renderer instance;
3538 instance.GetTextures();
3539 DALI_TEST_CHECK(false); // Should not get here
3543 DALI_TEST_CHECK(true); // We expect an assert
3548 int UtcDaliRendererGetShaderNegative(void)
3550 TestApplication application;
3551 Dali::Renderer instance;
3554 instance.GetShader();
3555 DALI_TEST_CHECK(false); // Should not get here
3559 DALI_TEST_CHECK(true); // We expect an assert
3564 int UtcDaliRendererCheckTextureBindingP(void)
3566 TestApplication application;
3568 tet_infoline("Test adding draw commands to the renderer");
3570 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3571 glAbstraction.EnableEnableDisableCallTrace(true);
3573 Geometry geometry = CreateQuadGeometry();
3574 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
3575 Renderer renderer = Renderer::New(geometry, shader);
3577 renderer.SetProperty(Renderer::Property::BLEND_MODE, Dali::BlendMode::ON);
3578 Actor actor = Actor::New();
3579 actor.AddRenderer(renderer);
3580 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
3581 actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 1.0f));
3582 application.GetScene().Add(actor);
3584 TestGraphicsController& graphics = application.GetGraphicsController();
3585 TraceCallStack& cmdBufCallstack = graphics.mCommandBufferCallStack;
3586 cmdBufCallstack.Enable(true);
3588 application.SendNotification();
3589 application.Render();
3591 DALI_TEST_CHECK(!cmdBufCallstack.FindMethod("BindTextures"));
3593 Texture image0 = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGB888, 64, 64);
3594 TextureSet textureSet0 = CreateTextureSet(image0);
3595 renderer.SetTextures(textureSet0);
3597 application.SendNotification();
3598 application.Render();
3600 DALI_TEST_CHECK(cmdBufCallstack.FindMethod("BindTextures"));
3604 int UtcDaliRendererPreparePipeline(void)
3606 TestApplication application;
3608 tet_infoline("Test that rendering an actor binds the attributes locs from the reflection");
3610 Property::Map vf = CreateModelVertexFormat();
3611 Geometry modelGeometry = CreateModelGeometry(vf);
3612 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
3613 Renderer renderer = Renderer::New(modelGeometry, shader);
3614 Actor actor = Actor::New();
3616 // Change the order up to get a fair test
3617 Property::Map modelVF;
3618 modelVF["aBoneIndex[0]"] = Property::INTEGER;
3619 modelVF["aBoneIndex[1]"] = Property::INTEGER;
3620 modelVF["aBoneIndex[2]"] = Property::INTEGER;
3621 modelVF["aBoneIndex[3]"] = Property::INTEGER;
3622 modelVF["aBoneWeights[0]"] = Property::FLOAT;
3623 modelVF["aBoneWeights[1]"] = Property::FLOAT;
3624 modelVF["aBoneWeights[2]"] = Property::FLOAT;
3625 modelVF["aBoneWeights[3]"] = Property::FLOAT;
3626 modelVF["aPosition"] = Property::VECTOR3;
3627 modelVF["aNormal"] = Property::VECTOR3;
3628 modelVF["aTexCoord1"] = Property::VECTOR3;
3629 modelVF["aTexCoord2"] = Property::VECTOR3;
3631 Property::Array vfs;
3632 vfs.PushBack(modelVF);
3633 TestGraphicsController& graphics = application.GetGraphicsController();
3634 graphics.SetVertexFormats(vfs);
3636 actor.AddRenderer(renderer);
3637 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
3638 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
3639 application.GetScene().Add(actor);
3641 TraceCallStack& cmdBufCallstack = graphics.mCommandBufferCallStack;
3642 TraceCallStack& graphicsCallstack = graphics.mCallStack;
3643 cmdBufCallstack.Enable(true);
3644 graphicsCallstack.Enable(true);
3646 application.SendNotification();
3647 application.Render();
3649 DALI_TEST_CHECK(graphicsCallstack.FindMethod("SubmitCommandBuffers"));
3650 std::vector<Graphics::SubmitInfo>& submissions = graphics.mSubmitStack;
3651 DALI_TEST_EQUALS(submissions.size(), 1, TEST_LOCATION);
3652 DALI_TEST_EQUALS(submissions[0].cmdBuffer.size(), 1, TEST_LOCATION);
3653 TestGraphicsCommandBuffer* cmdBuf = static_cast<TestGraphicsCommandBuffer*>((submissions[0].cmdBuffer[0]));
3654 //auto pipeline = cmdBuf->mPipeline;
3655 auto result = cmdBuf->GetCommandsByType( 0 | CommandType::BIND_PIPELINE );
3656 auto pipeline = result[0]->data.bindPipeline.pipeline;
3660 DALI_TEST_EQUALS(pipeline->vertexInputState.attributes.size(), 12, TEST_LOCATION);
3661 DALI_TEST_EQUALS(pipeline->vertexInputState.attributes[3].location, // 4th requested attr: aTexCoord2
3664 DALI_TEST_EQUALS(pipeline->vertexInputState.attributes[3].format, // 4th requested attr: aTexCoord2
3665 Graphics::VertexInputFormat::FVECTOR3,