2 * Copyright (c) 2022 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 Renderer CreateRenderer(Actor actor, Geometry geometry, Shader shader, int depthIndex)
83 Texture image0 = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGB888, 64, 64);
84 TextureSet textureSet0 = CreateTextureSet(image0);
85 Renderer renderer0 = Renderer::New(geometry, shader);
86 renderer0.SetTextures(textureSet0);
87 renderer0.SetProperty(Renderer::Property::DEPTH_INDEX, depthIndex);
88 actor.AddRenderer(renderer0);
92 Actor CreateActor(Actor parent, int siblingOrder, const char* location)
94 Actor actor = Actor::New();
95 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
96 actor.SetProperty(Actor::Property::PARENT_ORIGIN, AnchorPoint::CENTER);
97 actor.SetProperty(Actor::Property::POSITION, Vector2(0.0f, 0.0f));
98 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
100 actor.SetProperty(Dali::DevelActor::Property::SIBLING_ORDER, siblingOrder);
101 DALI_TEST_EQUALS(actor.GetProperty<int>(Dali::DevelActor::Property::SIBLING_ORDER), siblingOrder, TEST_INNER_LOCATION(location));
106 } // unnamed namespace
108 void renderer_test_startup(void)
110 test_return_value = TET_UNDEF;
113 void renderer_test_cleanup(void)
115 test_return_value = TET_PASS;
118 int UtcDaliRendererNew01(void)
120 TestApplication application;
122 Geometry geometry = CreateQuadGeometry();
123 Shader shader = CreateShader();
124 Renderer renderer = Renderer::New(geometry, shader);
126 DALI_TEST_EQUALS((bool)renderer, true, TEST_LOCATION);
130 int UtcDaliRendererNew02(void)
132 TestApplication application;
134 DALI_TEST_EQUALS((bool)renderer, false, TEST_LOCATION);
138 int UtcDaliRendererCopyConstructor(void)
140 TestApplication application;
142 Geometry geometry = CreateQuadGeometry();
143 Shader shader = CreateShader();
144 Renderer renderer = Renderer::New(geometry, shader);
146 Renderer rendererCopy(renderer);
147 DALI_TEST_EQUALS((bool)rendererCopy, true, TEST_LOCATION);
152 int UtcDaliRendererAssignmentOperator(void)
154 TestApplication application;
156 Geometry geometry = CreateQuadGeometry();
157 Shader shader = CreateShader();
158 Renderer renderer = Renderer::New(geometry, shader);
161 DALI_TEST_EQUALS((bool)renderer2, false, TEST_LOCATION);
163 renderer2 = renderer;
164 DALI_TEST_EQUALS((bool)renderer2, true, TEST_LOCATION);
168 int UtcDaliRendererMoveConstructor(void)
170 TestApplication application;
172 Geometry geometry = CreateQuadGeometry();
173 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
174 Renderer renderer = Renderer::New(geometry, shader);
175 DALI_TEST_CHECK(renderer);
176 DALI_TEST_EQUALS(1, renderer.GetBaseObject().ReferenceCount(), TEST_LOCATION);
177 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(Renderer::Property::BLEND_COLOR), Color::TRANSPARENT, TEST_LOCATION);
179 renderer.SetProperty(Renderer::Property::BLEND_COLOR, Color::MAGENTA);
180 application.SendNotification();
181 application.Render();
182 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(Renderer::Property::BLEND_COLOR), Color::MAGENTA, TEST_LOCATION);
184 Renderer move = std::move(renderer);
185 DALI_TEST_CHECK(move);
186 DALI_TEST_EQUALS(1, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
187 DALI_TEST_EQUALS(move.GetProperty<Vector4>(Renderer::Property::BLEND_COLOR), Color::MAGENTA, TEST_LOCATION);
188 DALI_TEST_CHECK(!renderer);
193 int UtcDaliRendererMoveAssignment(void)
195 TestApplication application;
197 Geometry geometry = CreateQuadGeometry();
198 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
199 Renderer renderer = Renderer::New(geometry, shader);
200 DALI_TEST_CHECK(renderer);
201 DALI_TEST_EQUALS(1, renderer.GetBaseObject().ReferenceCount(), TEST_LOCATION);
202 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(Renderer::Property::BLEND_COLOR), Color::TRANSPARENT, TEST_LOCATION);
204 renderer.SetProperty(Renderer::Property::BLEND_COLOR, Color::MAGENTA);
205 application.SendNotification();
206 application.Render();
207 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(Renderer::Property::BLEND_COLOR), Color::MAGENTA, TEST_LOCATION);
210 move = std::move(renderer);
211 DALI_TEST_CHECK(move);
212 DALI_TEST_EQUALS(1, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
213 DALI_TEST_EQUALS(move.GetProperty<Vector4>(Renderer::Property::BLEND_COLOR), Color::MAGENTA, TEST_LOCATION);
214 DALI_TEST_CHECK(!renderer);
219 int UtcDaliRendererDownCast01(void)
221 TestApplication application;
223 Geometry geometry = CreateQuadGeometry();
224 Shader shader = CreateShader();
225 Renderer renderer = Renderer::New(geometry, shader);
227 BaseHandle handle(renderer);
228 Renderer renderer2 = Renderer::DownCast(handle);
229 DALI_TEST_EQUALS((bool)renderer2, true, TEST_LOCATION);
233 int UtcDaliRendererDownCast02(void)
235 TestApplication application;
237 Handle handle = Handle::New(); // Create a custom object
238 Renderer renderer = Renderer::DownCast(handle);
239 DALI_TEST_EQUALS((bool)renderer, false, TEST_LOCATION);
243 // using a template to auto deduce the parameter types
244 template<typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8>
245 void TEST_RENDERER_PROPERTY(P1 renderer, P2 stringName, P3 type, P4 isWriteable, P5 isAnimateable, P6 isConstraintInput, P7 enumName, P8 LOCATION)
247 DALI_TEST_EQUALS(renderer.GetPropertyName(enumName), stringName, LOCATION);
248 DALI_TEST_EQUALS(renderer.GetPropertyIndex(stringName), static_cast<Property::Index>(enumName), LOCATION);
249 DALI_TEST_EQUALS(renderer.GetPropertyType(enumName), type, LOCATION);
250 DALI_TEST_EQUALS(renderer.IsPropertyWritable(enumName), isWriteable, LOCATION);
251 DALI_TEST_EQUALS(renderer.IsPropertyAnimatable(enumName), isAnimateable, LOCATION);
252 DALI_TEST_EQUALS(renderer.IsPropertyAConstraintInput(enumName), isConstraintInput, LOCATION);
255 int UtcDaliRendererDefaultProperties(void)
257 TestApplication application;
258 /* from renderer-impl.cpp
259 DALI_PROPERTY( "depthIndex", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_INDEX )
260 DALI_PROPERTY( "faceCullingMode", INTEGER, true, false, false, Dali::Renderer::Property::FACE_CULLING_MODE )
261 DALI_PROPERTY( "blendMode", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_MODE )
262 DALI_PROPERTY( "blendEquationRgb", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_EQUATION_RGB )
263 DALI_PROPERTY( "blendEquationAlpha", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_EQUATION_ALPHA )
264 DALI_PROPERTY( "blendFactorSrcRgb", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_SRC_RGB )
265 DALI_PROPERTY( "blendFactorDestRgb", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_DEST_RGB )
266 DALI_PROPERTY( "blendFactorSrcAlpha", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_SRC_ALPHA )
267 DALI_PROPERTY( "blendFactorDestAlpha", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_DEST_ALPHA )
268 DALI_PROPERTY( "blendColor", VECTOR4, true, false, false, Dali::Renderer::Property::BLEND_COLOR )
269 DALI_PROPERTY( "blendPreMultipliedAlpha", BOOLEAN, true, false, false, Dali::Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA )
270 DALI_PROPERTY( "indexRangeFirst", INTEGER, true, false, false, Dali::Renderer::Property::INDEX_RANGE_FIRST )
271 DALI_PROPERTY( "indexRangeCount", INTEGER, true, false, false, Dali::Renderer::Property::INDEX_RANGE_COUNT )
272 DALI_PROPERTY( "depthWriteMode", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_WRITE_MODE )
273 DALI_PROPERTY( "depthFunction", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_FUNCTION )
274 DALI_PROPERTY( "depthTestMode", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_TEST_MODE )
275 DALI_PROPERTY( "renderMode", INTEGER, true, false, false, Dali::Renderer::Property::RENDER_MODE )
276 DALI_PROPERTY( "stencilFunction", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION )
277 DALI_PROPERTY( "stencilFunctionMask", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION_MASK )
278 DALI_PROPERTY( "stencilFunctionReference", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION_REFERENCE )
279 DALI_PROPERTY( "stencilMask", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_MASK )
280 DALI_PROPERTY( "stencilOperationOnFail", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_FAIL )
281 DALI_PROPERTY( "stencilOperationOnZFail", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL )
282 DALI_PROPERTY( "stencilOperationOnZPass", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_PASS )
283 DALI_PROPERTY( "opacity", FLOAT, true, true, true, Dali::DevelRenderer::Property::OPACITY )
284 DALI_PROPERTY( "renderingBehavior", INTEGER, true, false, false, Dali::DevelRenderer::Property::RENDERING_BEHAVIOR )
285 DALI_PROPERTY( "blendEquation", INTEGER, true, false, false, Dali::DevelRenderer::Property::BLEND_EQUATION )
288 Geometry geometry = CreateQuadGeometry();
289 Shader shader = CreateShader();
290 Renderer renderer = Renderer::New(geometry, shader);
291 DALI_TEST_EQUALS(renderer.GetPropertyCount(), 27, TEST_LOCATION);
293 TEST_RENDERER_PROPERTY(renderer, "depthIndex", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_INDEX, TEST_LOCATION);
294 TEST_RENDERER_PROPERTY(renderer, "faceCullingMode", Property::INTEGER, true, false, false, Renderer::Property::FACE_CULLING_MODE, TEST_LOCATION);
295 TEST_RENDERER_PROPERTY(renderer, "blendMode", Property::INTEGER, true, false, false, Renderer::Property::BLEND_MODE, TEST_LOCATION);
296 TEST_RENDERER_PROPERTY(renderer, "blendEquationRgb", Property::INTEGER, true, false, false, Renderer::Property::BLEND_EQUATION_RGB, TEST_LOCATION);
297 TEST_RENDERER_PROPERTY(renderer, "blendEquationAlpha", Property::INTEGER, true, false, false, Renderer::Property::BLEND_EQUATION_ALPHA, TEST_LOCATION);
298 TEST_RENDERER_PROPERTY(renderer, "blendFactorSrcRgb", Property::INTEGER, true, false, false, Renderer::Property::BLEND_FACTOR_SRC_RGB, TEST_LOCATION);
299 TEST_RENDERER_PROPERTY(renderer, "blendFactorDestRgb", Property::INTEGER, true, false, false, Renderer::Property::BLEND_FACTOR_DEST_RGB, TEST_LOCATION);
300 TEST_RENDERER_PROPERTY(renderer, "blendFactorSrcAlpha", Property::INTEGER, true, false, false, Renderer::Property::BLEND_FACTOR_SRC_ALPHA, TEST_LOCATION);
301 TEST_RENDERER_PROPERTY(renderer, "blendFactorDestAlpha", Property::INTEGER, true, false, false, Renderer::Property::BLEND_FACTOR_DEST_ALPHA, TEST_LOCATION);
302 TEST_RENDERER_PROPERTY(renderer, "blendColor", Property::VECTOR4, true, false, false, Renderer::Property::BLEND_COLOR, TEST_LOCATION);
303 TEST_RENDERER_PROPERTY(renderer, "blendPreMultipliedAlpha", Property::BOOLEAN, true, false, false, Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, TEST_LOCATION);
304 TEST_RENDERER_PROPERTY(renderer, "indexRangeFirst", Property::INTEGER, true, false, false, Renderer::Property::INDEX_RANGE_FIRST, TEST_LOCATION);
305 TEST_RENDERER_PROPERTY(renderer, "indexRangeCount", Property::INTEGER, true, false, false, Renderer::Property::INDEX_RANGE_COUNT, TEST_LOCATION);
306 TEST_RENDERER_PROPERTY(renderer, "depthWriteMode", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_WRITE_MODE, TEST_LOCATION);
307 TEST_RENDERER_PROPERTY(renderer, "depthFunction", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_FUNCTION, TEST_LOCATION);
308 TEST_RENDERER_PROPERTY(renderer, "depthTestMode", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_TEST_MODE, TEST_LOCATION);
309 TEST_RENDERER_PROPERTY(renderer, "renderMode", Property::INTEGER, true, false, false, Renderer::Property::RENDER_MODE, TEST_LOCATION);
310 TEST_RENDERER_PROPERTY(renderer, "stencilFunction", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_FUNCTION, TEST_LOCATION);
311 TEST_RENDERER_PROPERTY(renderer, "stencilFunctionMask", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_FUNCTION_MASK, TEST_LOCATION);
312 TEST_RENDERER_PROPERTY(renderer, "stencilFunctionReference", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_FUNCTION_REFERENCE, TEST_LOCATION);
313 TEST_RENDERER_PROPERTY(renderer, "stencilMask", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_MASK, TEST_LOCATION);
314 TEST_RENDERER_PROPERTY(renderer, "stencilOperationOnFail", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_OPERATION_ON_FAIL, TEST_LOCATION);
315 TEST_RENDERER_PROPERTY(renderer, "stencilOperationOnZFail", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, TEST_LOCATION);
316 TEST_RENDERER_PROPERTY(renderer, "stencilOperationOnZPass", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, TEST_LOCATION);
317 TEST_RENDERER_PROPERTY(renderer, "opacity", Property::FLOAT, true, true, true, DevelRenderer::Property::OPACITY, TEST_LOCATION);
318 TEST_RENDERER_PROPERTY(renderer, "renderingBehavior", Property::INTEGER, true, false, false, DevelRenderer::Property::RENDERING_BEHAVIOR, TEST_LOCATION);
319 TEST_RENDERER_PROPERTY(renderer, "blendEquation", Property::INTEGER, true, false, false, DevelRenderer::Property::BLEND_EQUATION, TEST_LOCATION);
324 int UtcDaliRendererSetGetGeometry(void)
326 TestApplication application;
327 tet_infoline("Test SetGeometry, GetGeometry");
329 Geometry geometry1 = CreateQuadGeometry();
330 Geometry geometry2 = CreateQuadGeometry();
332 Shader shader = CreateShader();
333 Renderer renderer = Renderer::New(geometry1, shader);
334 Actor actor = Actor::New();
335 actor.AddRenderer(renderer);
336 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
337 application.GetScene().Add(actor);
339 application.SendNotification();
340 application.Render(0);
341 DALI_TEST_EQUALS(renderer.GetGeometry(), geometry1, TEST_LOCATION);
343 // Set geometry2 to the renderer
344 renderer.SetGeometry(geometry2);
346 application.SendNotification();
347 application.Render(0);
348 DALI_TEST_EQUALS(renderer.GetGeometry(), geometry2, TEST_LOCATION);
353 int UtcDaliRendererSetGetShader(void)
355 TestApplication application;
356 tet_infoline("Test SetShader, GetShader");
358 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
359 glAbstraction.EnableCullFaceCallTrace(true);
361 Shader shader1 = CreateShader();
362 shader1.RegisterProperty("uFadeColor", Color::RED);
364 Shader shader2 = CreateShader();
365 shader2.RegisterProperty("uFadeColor", Color::GREEN);
367 Geometry geometry = CreateQuadGeometry();
368 Renderer renderer = Renderer::New(geometry, shader1);
369 Actor actor = Actor::New();
370 actor.AddRenderer(renderer);
371 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
372 application.GetScene().Add(actor);
374 TestGlAbstraction& gl = application.GetGlAbstraction();
375 application.SendNotification();
376 application.Render(0);
378 // Expect that the first shaders's fade color property is accessed
379 Vector4 actualValue(Vector4::ZERO);
380 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
381 DALI_TEST_EQUALS(actualValue, Color::RED, TEST_LOCATION);
383 DALI_TEST_EQUALS(renderer.GetShader(), shader1, TEST_LOCATION);
385 // set the second shader to the renderer
386 renderer.SetShader(shader2);
388 application.SendNotification();
389 application.Render(0);
391 // Expect that the second shader's fade color property is accessed
392 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
393 DALI_TEST_EQUALS(actualValue, Color::GREEN, TEST_LOCATION);
395 DALI_TEST_EQUALS(renderer.GetShader(), shader2, TEST_LOCATION);
400 int UtcDaliRendererSetGetDepthIndex(void)
402 TestApplication application;
404 tet_infoline("Test SetDepthIndex, GetDepthIndex");
406 Shader shader = CreateShader();
407 Geometry geometry = CreateQuadGeometry();
408 Renderer renderer = Renderer::New(geometry, shader);
409 Actor actor = Actor::New();
410 actor.AddRenderer(renderer);
411 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
412 application.GetScene().Add(actor);
414 application.SendNotification();
415 application.Render(0);
416 DALI_TEST_EQUALS(renderer.GetProperty<int>(Renderer::Property::DEPTH_INDEX), 0, TEST_LOCATION);
418 renderer.SetProperty(Renderer::Property::DEPTH_INDEX, 1);
420 DALI_TEST_EQUALS(renderer.GetProperty<int>(Renderer::Property::DEPTH_INDEX), 1, TEST_LOCATION);
421 DALI_TEST_EQUALS(renderer.GetCurrentProperty<int>(Renderer::Property::DEPTH_INDEX), 0, TEST_LOCATION);
423 application.SendNotification();
424 application.Render(0);
425 DALI_TEST_EQUALS(renderer.GetCurrentProperty<int>(Renderer::Property::DEPTH_INDEX), 1, TEST_LOCATION);
427 renderer.SetProperty(Renderer::Property::DEPTH_INDEX, 10);
429 DALI_TEST_EQUALS(renderer.GetProperty<int>(Renderer::Property::DEPTH_INDEX), 10, TEST_LOCATION);
430 DALI_TEST_EQUALS(renderer.GetCurrentProperty<int>(Renderer::Property::DEPTH_INDEX), 1, TEST_LOCATION);
432 application.SendNotification();
433 application.Render(0);
434 DALI_TEST_EQUALS(renderer.GetCurrentProperty<int>(Renderer::Property::DEPTH_INDEX), 10, TEST_LOCATION);
439 int UtcDaliRendererSetGetFaceCullingMode(void)
441 TestApplication application;
443 tet_infoline("Test SetFaceCullingMode(cullingMode)");
444 Geometry geometry = CreateQuadGeometry();
445 Shader shader = CreateShader();
446 Renderer renderer = Renderer::New(geometry, shader);
448 Actor actor = Actor::New();
449 actor.AddRenderer(renderer);
450 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
451 application.GetScene().Add(actor);
453 // By default, none of the faces should be culled
454 unsigned int cullFace = renderer.GetProperty<int>(Renderer::Property::FACE_CULLING_MODE);
455 DALI_TEST_CHECK(static_cast<FaceCullingMode::Type>(cullFace) == FaceCullingMode::NONE);
457 TestGlAbstraction& gl = application.GetGlAbstraction();
458 TraceCallStack& cullFaceStack = gl.GetCullFaceTrace();
459 gl.EnableCullFaceCallTrace(true);
462 cullFaceStack.Reset();
463 renderer.SetProperty(Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::FRONT_AND_BACK);
464 application.SendNotification();
465 application.Render();
467 DALI_TEST_EQUALS(cullFaceStack.CountMethod("CullFace"), 1, TEST_LOCATION);
469 std::ostringstream cullModeString;
470 cullModeString << std::hex << GL_FRONT_AND_BACK;
472 DALI_TEST_CHECK(cullFaceStack.FindMethodAndParams("CullFace", cullModeString.str()));
473 cullFace = renderer.GetProperty<int>(Renderer::Property::FACE_CULLING_MODE);
474 DALI_TEST_CHECK(static_cast<FaceCullingMode::Type>(cullFace) == FaceCullingMode::FRONT_AND_BACK);
478 cullFaceStack.Reset();
479 renderer.SetProperty(Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::BACK);
480 application.SendNotification();
481 application.Render();
483 DALI_TEST_EQUALS(cullFaceStack.CountMethod("CullFace"), 1, TEST_LOCATION);
485 std::ostringstream cullModeString;
486 cullModeString << std::hex << GL_BACK;
488 DALI_TEST_CHECK(cullFaceStack.FindMethodAndParams("CullFace", cullModeString.str()));
489 cullFace = renderer.GetProperty<int>(Renderer::Property::FACE_CULLING_MODE);
490 DALI_TEST_CHECK(static_cast<FaceCullingMode::Type>(cullFace) == FaceCullingMode::BACK);
494 cullFaceStack.Reset();
495 renderer.SetProperty(Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::FRONT);
496 application.SendNotification();
497 application.Render();
499 DALI_TEST_EQUALS(cullFaceStack.CountMethod("CullFace"), 1, TEST_LOCATION);
501 std::ostringstream cullModeString;
502 cullModeString << std::hex << GL_FRONT;
504 DALI_TEST_CHECK(cullFaceStack.FindMethodAndParams("CullFace", cullModeString.str()));
505 cullFace = renderer.GetProperty<int>(Renderer::Property::FACE_CULLING_MODE);
506 DALI_TEST_CHECK(static_cast<FaceCullingMode::Type>(cullFace) == FaceCullingMode::FRONT);
510 cullFaceStack.Reset();
511 renderer.SetProperty(Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::NONE);
512 application.SendNotification();
513 application.Render();
515 DALI_TEST_EQUALS(cullFaceStack.CountMethod("CullFace"), 0, TEST_LOCATION);
516 cullFace = renderer.GetProperty<int>(Renderer::Property::FACE_CULLING_MODE);
517 DALI_TEST_CHECK(static_cast<FaceCullingMode::Type>(cullFace) == FaceCullingMode::NONE);
523 int UtcDaliRendererBlendOptions01(void)
525 TestApplication application;
527 tet_infoline("Test BLEND_FACTOR properties ");
529 Geometry geometry = CreateQuadGeometry();
530 Shader shader = CreateShader();
531 Renderer renderer = Renderer::New(geometry, shader);
533 Actor actor = Actor::New();
534 // set a transparent actor color so that blending is enabled
535 actor.SetProperty(Actor::Property::OPACITY, 0.5f);
536 actor.AddRenderer(renderer);
537 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
538 application.GetScene().Add(actor);
540 renderer.SetProperty(Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::ONE_MINUS_SRC_COLOR);
541 renderer.SetProperty(Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::SRC_ALPHA_SATURATE);
542 renderer.SetProperty(Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE_MINUS_SRC_COLOR);
543 renderer.SetProperty(Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::SRC_ALPHA_SATURATE);
545 // Test that Set was successful:
546 int srcFactorRgb = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
547 int destFactorRgb = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
548 int srcFactorAlpha = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
549 int destFactorAlpha = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
551 DALI_TEST_EQUALS((int)BlendFactor::ONE_MINUS_SRC_COLOR, srcFactorRgb, TEST_LOCATION);
552 DALI_TEST_EQUALS((int)BlendFactor::SRC_ALPHA_SATURATE, destFactorRgb, TEST_LOCATION);
553 DALI_TEST_EQUALS((int)BlendFactor::ONE_MINUS_SRC_COLOR, srcFactorAlpha, TEST_LOCATION);
554 DALI_TEST_EQUALS((int)BlendFactor::SRC_ALPHA_SATURATE, destFactorAlpha, TEST_LOCATION);
556 application.SendNotification();
557 application.Render();
559 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
561 DALI_TEST_EQUALS((GLenum)GL_ONE_MINUS_SRC_COLOR, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION);
562 DALI_TEST_EQUALS((GLenum)GL_SRC_ALPHA_SATURATE, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION);
563 DALI_TEST_EQUALS((GLenum)GL_ONE_MINUS_SRC_COLOR, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION);
564 DALI_TEST_EQUALS((GLenum)GL_SRC_ALPHA_SATURATE, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION);
569 int UtcDaliRendererBlendOptions02(void)
571 TestApplication application;
573 tet_infoline("Test BLEND_FACTOR properties ");
575 Geometry geometry = CreateQuadGeometry();
576 Shader shader = CreateShader();
577 Renderer renderer = Renderer::New(geometry, shader);
579 Actor actor = Actor::New();
580 actor.SetProperty(Actor::Property::OPACITY, 0.5f); // enable blending
581 actor.AddRenderer(renderer);
582 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
583 application.GetScene().Add(actor);
585 renderer.SetProperty(Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::CONSTANT_COLOR);
586 renderer.SetProperty(Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ONE_MINUS_CONSTANT_COLOR);
587 renderer.SetProperty(Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::CONSTANT_ALPHA);
588 renderer.SetProperty(Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ONE_MINUS_CONSTANT_ALPHA);
590 // Test that Set was successful:
592 int srcFactorRgb = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
593 int destFactorRgb = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
594 int srcFactorAlpha = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
595 int destFactorAlpha = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
597 DALI_TEST_EQUALS((int)BlendFactor::CONSTANT_COLOR, srcFactorRgb, TEST_LOCATION);
598 DALI_TEST_EQUALS((int)BlendFactor::ONE_MINUS_CONSTANT_COLOR, destFactorRgb, TEST_LOCATION);
599 DALI_TEST_EQUALS((int)BlendFactor::CONSTANT_ALPHA, srcFactorAlpha, TEST_LOCATION);
600 DALI_TEST_EQUALS((int)BlendFactor::ONE_MINUS_CONSTANT_ALPHA, destFactorAlpha, TEST_LOCATION);
603 application.SendNotification();
604 application.Render();
606 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
607 DALI_TEST_EQUALS((GLenum)GL_CONSTANT_COLOR, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION);
608 DALI_TEST_EQUALS((GLenum)GL_ONE_MINUS_CONSTANT_COLOR, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION);
609 DALI_TEST_EQUALS((GLenum)GL_CONSTANT_ALPHA, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION);
610 DALI_TEST_EQUALS((GLenum)GL_ONE_MINUS_CONSTANT_ALPHA, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION);
615 int UtcDaliRendererBlendOptions03(void)
617 TestApplication application;
619 tet_infoline("Test GetBlendEquation() defaults ");
621 Geometry geometry = CreateQuadGeometry();
622 Shader shader = CreateShader();
623 Renderer renderer = Renderer::New(geometry, shader);
625 Actor actor = Actor::New();
626 actor.AddRenderer(renderer);
627 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
628 application.GetScene().Add(actor);
630 // Test the defaults as documented in blending.h
631 int equationRgb = renderer.GetProperty<int>(Renderer::Property::BLEND_EQUATION_RGB);
632 int equationAlpha = renderer.GetProperty<int>(Renderer::Property::BLEND_EQUATION_ALPHA);
634 DALI_TEST_EQUALS((int)BlendEquation::ADD, equationRgb, TEST_LOCATION);
635 DALI_TEST_EQUALS((int)BlendEquation::ADD, equationAlpha, TEST_LOCATION);
640 int UtcDaliRendererBlendOptions04(void)
642 TestApplication application;
644 tet_infoline("Test SetBlendEquation() ");
646 Geometry geometry = CreateQuadGeometry();
647 Shader shader = CreateShader();
648 Renderer renderer = Renderer::New(geometry, shader);
650 Actor actor = Actor::New();
651 actor.SetProperty(Actor::Property::OPACITY, 0.1f);
652 actor.AddRenderer(renderer);
653 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
654 application.GetScene().Add(actor);
656 // Test the single blending equation setting
658 renderer.SetProperty(Renderer::Property::BLEND_EQUATION_RGB, BlendEquation::REVERSE_SUBTRACT);
659 int equationRgb = renderer.GetProperty<int>(Renderer::Property::BLEND_EQUATION_RGB);
660 DALI_TEST_EQUALS((int)BlendEquation::REVERSE_SUBTRACT, equationRgb, TEST_LOCATION);
663 renderer.SetProperty(Renderer::Property::BLEND_EQUATION_RGB, BlendEquation::REVERSE_SUBTRACT);
664 renderer.SetProperty(Renderer::Property::BLEND_EQUATION_ALPHA, BlendEquation::REVERSE_SUBTRACT);
666 // Test that Set was successful
668 int equationRgb = renderer.GetProperty<int>(Renderer::Property::BLEND_EQUATION_RGB);
669 int equationAlpha = renderer.GetProperty<int>(Renderer::Property::BLEND_EQUATION_ALPHA);
670 DALI_TEST_EQUALS((int)BlendEquation::REVERSE_SUBTRACT, equationRgb, TEST_LOCATION);
671 DALI_TEST_EQUALS((int)BlendEquation::REVERSE_SUBTRACT, equationAlpha, TEST_LOCATION);
674 // Render & check GL commands
675 application.SendNotification();
676 application.Render();
678 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
679 DALI_TEST_EQUALS((GLenum)GL_FUNC_REVERSE_SUBTRACT, glAbstraction.GetLastBlendEquationRgb(), TEST_LOCATION);
680 DALI_TEST_EQUALS((GLenum)GL_FUNC_REVERSE_SUBTRACT, glAbstraction.GetLastBlendEquationAlpha(), TEST_LOCATION);
685 int UtcDaliRendererBlendOptions05(void)
687 TestApplication application;
689 tet_infoline("Test SetAdvancedBlendEquation ");
691 Geometry geometry = CreateQuadGeometry();
692 Shader shader = CreateShader();
693 Renderer renderer = Renderer::New(geometry, shader);
695 Actor actor = Actor::New();
696 actor.SetProperty(Actor::Property::OPACITY, 0.1f);
698 actor.AddRenderer(renderer);
699 actor.SetProperty(Actor::Property::SIZE, Vector2(400, 400));
700 application.GetScene().Add(actor);
701 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
702 glAbstraction.EnableEnableDisableCallTrace(true);
704 if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::MAX))
706 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::MAX);
707 int equationRgb = renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION);
708 DALI_TEST_EQUALS((int)DevelBlendEquation::MAX, equationRgb, TEST_LOCATION);
711 if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
713 renderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true);
714 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SCREEN);
715 int equation = renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION);
717 DALI_TEST_EQUALS((int)DevelBlendEquation::SCREEN, equation, TEST_LOCATION);
718 DALI_TEST_EQUALS(DevelRenderer::IsAdvancedBlendEquationApplied(renderer), true, TEST_LOCATION);
720 application.SendNotification();
721 application.Render();
724 if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN) &&
725 Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::MULTIPLY))
727 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::ADD);
728 renderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true);
729 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION_RGB, DevelBlendEquation::SCREEN);
730 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION_ALPHA, DevelBlendEquation::MULTIPLY);
731 int equationRgb = renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION_RGB);
732 int equationAlpha = renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION_ALPHA);
734 DALI_TEST_EQUALS((int)DevelBlendEquation::ADD, equationRgb, TEST_LOCATION);
735 DALI_TEST_EQUALS((int)DevelBlendEquation::ADD, equationAlpha, TEST_LOCATION);
736 DALI_TEST_EQUALS(DevelRenderer::IsAdvancedBlendEquationApplied(renderer), false, TEST_LOCATION);
738 application.SendNotification();
739 application.Render();
742 tet_infoline("Error Checking\n");
743 if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::MULTIPLY) &&
744 Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN) &&
745 Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::OVERLAY) &&
746 Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::DARKEN) &&
747 Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::LIGHTEN) &&
748 Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::COLOR_DODGE) &&
749 Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::COLOR_BURN) &&
750 Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::HARD_LIGHT) &&
751 Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SOFT_LIGHT) &&
752 Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::DIFFERENCE) &&
753 Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::EXCLUSION) &&
754 Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::HUE) &&
755 Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SATURATION) &&
756 Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::COLOR) &&
757 Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::LUMINOSITY))
759 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::MULTIPLY);
760 DALI_TEST_EQUALS((int)DevelBlendEquation::MULTIPLY, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
761 application.SendNotification();
762 application.Render();
763 DALI_TEST_EQUALS(glAbstraction.GetLastBlendEquationRgb(), GL_MULTIPLY, TEST_LOCATION);
765 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SCREEN);
766 DALI_TEST_EQUALS((int)DevelBlendEquation::SCREEN, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
767 application.SendNotification();
768 application.Render();
769 DALI_TEST_EQUALS(glAbstraction.GetLastBlendEquationRgb(), GL_SCREEN, TEST_LOCATION);
771 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::OVERLAY);
772 DALI_TEST_EQUALS((int)DevelBlendEquation::OVERLAY, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
773 application.SendNotification();
774 application.Render();
775 DALI_TEST_EQUALS(glAbstraction.GetLastBlendEquationRgb(), GL_OVERLAY, 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);
779 application.SendNotification();
780 application.Render();
781 DALI_TEST_EQUALS(glAbstraction.GetLastBlendEquationRgb(), GL_DARKEN, TEST_LOCATION);
783 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::LIGHTEN);
784 DALI_TEST_EQUALS((int)DevelBlendEquation::LIGHTEN, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
785 application.SendNotification();
786 application.Render();
787 DALI_TEST_EQUALS(glAbstraction.GetLastBlendEquationRgb(), GL_LIGHTEN, TEST_LOCATION);
789 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::COLOR_DODGE);
790 DALI_TEST_EQUALS((int)DevelBlendEquation::COLOR_DODGE, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
791 application.SendNotification();
792 application.Render();
793 DALI_TEST_EQUALS(glAbstraction.GetLastBlendEquationRgb(), GL_COLORDODGE, TEST_LOCATION);
795 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::COLOR_BURN);
796 DALI_TEST_EQUALS((int)DevelBlendEquation::COLOR_BURN, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
797 application.SendNotification();
798 application.Render();
799 DALI_TEST_EQUALS(glAbstraction.GetLastBlendEquationRgb(), GL_COLORBURN, TEST_LOCATION);
801 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::HARD_LIGHT);
802 DALI_TEST_EQUALS((int)DevelBlendEquation::HARD_LIGHT, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
803 application.SendNotification();
804 application.Render();
805 DALI_TEST_EQUALS(glAbstraction.GetLastBlendEquationRgb(), GL_HARDLIGHT, TEST_LOCATION);
807 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SOFT_LIGHT);
808 DALI_TEST_EQUALS((int)DevelBlendEquation::SOFT_LIGHT, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
809 application.SendNotification();
810 application.Render();
811 DALI_TEST_EQUALS(glAbstraction.GetLastBlendEquationRgb(), GL_SOFTLIGHT, TEST_LOCATION);
813 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::DIFFERENCE);
814 DALI_TEST_EQUALS((int)DevelBlendEquation::DIFFERENCE, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
815 application.SendNotification();
816 application.Render();
817 DALI_TEST_EQUALS(glAbstraction.GetLastBlendEquationRgb(), GL_DIFFERENCE, TEST_LOCATION);
819 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::EXCLUSION);
820 DALI_TEST_EQUALS((int)DevelBlendEquation::EXCLUSION, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
821 application.SendNotification();
822 application.Render();
823 DALI_TEST_EQUALS(glAbstraction.GetLastBlendEquationRgb(), GL_EXCLUSION, TEST_LOCATION);
825 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::HUE);
826 DALI_TEST_EQUALS((int)DevelBlendEquation::HUE, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
827 application.SendNotification();
828 application.Render();
829 DALI_TEST_EQUALS(glAbstraction.GetLastBlendEquationRgb(), GL_HSL_HUE, TEST_LOCATION);
831 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SATURATION);
832 DALI_TEST_EQUALS((int)DevelBlendEquation::SATURATION, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
833 application.SendNotification();
834 application.Render();
835 DALI_TEST_EQUALS(glAbstraction.GetLastBlendEquationRgb(), GL_HSL_SATURATION, TEST_LOCATION);
837 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::COLOR);
838 DALI_TEST_EQUALS((int)DevelBlendEquation::COLOR, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
839 application.SendNotification();
840 application.Render();
841 DALI_TEST_EQUALS(glAbstraction.GetLastBlendEquationRgb(), GL_HSL_COLOR, TEST_LOCATION);
843 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::LUMINOSITY);
844 DALI_TEST_EQUALS((int)DevelBlendEquation::LUMINOSITY, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
845 application.SendNotification();
846 application.Render();
847 DALI_TEST_EQUALS(glAbstraction.GetLastBlendEquationRgb(), GL_HSL_LUMINOSITY, TEST_LOCATION);
853 int UtcDaliRendererSetBlendMode01(void)
855 TestApplication application;
857 tet_infoline("Test setting the blend mode to on with an opaque color renders with blending enabled");
859 Geometry geometry = CreateQuadGeometry();
860 Shader shader = CreateShader();
861 Renderer renderer = Renderer::New(geometry, shader);
863 Actor actor = Actor::New();
864 actor.SetProperty(Actor::Property::OPACITY, 1.0f);
865 actor.AddRenderer(renderer);
866 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
867 application.GetScene().Add(actor);
869 renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
871 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
872 glAbstraction.EnableEnableDisableCallTrace(true);
874 application.SendNotification();
875 application.Render();
877 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
878 TraceCallStack::NamedParams params;
879 params["cap"] << std::hex << GL_BLEND;
880 DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", params));
885 int UtcDaliRendererSetBlendMode01b(void)
887 TestApplication application;
889 tet_infoline("Test setting the blend mode to on with an transparent color renders with blending enabled");
891 Geometry geometry = CreateQuadGeometry();
892 Shader shader = CreateShader();
893 Renderer renderer = Renderer::New(geometry, shader);
895 Actor actor = Actor::New();
896 actor.SetProperty(Actor::Property::OPACITY, 0.0f);
897 actor.AddRenderer(renderer);
898 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
899 application.GetScene().Add(actor);
901 renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
903 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
904 glAbstraction.EnableEnableDisableCallTrace(true);
905 glAbstraction.EnableDrawCallTrace(true);
907 application.SendNotification();
908 application.Render();
910 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
911 DALI_TEST_CHECK(!glEnableStack.FindMethod("Enable"));
913 DALI_TEST_CHECK(!glAbstraction.GetDrawTrace().FindMethod("DrawElements"));
918 int UtcDaliRendererSetBlendMode02(void)
920 TestApplication application;
922 tet_infoline("Test setting the blend mode to off with a transparent color renders with blending disabled (and not enabled)");
924 Geometry geometry = CreateQuadGeometry();
925 Shader shader = CreateShader();
926 Renderer renderer = Renderer::New(geometry, shader);
928 Actor actor = Actor::New();
929 actor.SetProperty(Actor::Property::OPACITY, 0.15f);
930 actor.AddRenderer(renderer);
931 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
932 application.GetScene().Add(actor);
934 renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::OFF);
936 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
937 glAbstraction.EnableEnableDisableCallTrace(true);
939 application.SendNotification();
940 application.Render();
942 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
943 TraceCallStack::NamedParams params;
944 params["cap"] << std::hex << GL_BLEND;
945 DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Enable", params));
950 int UtcDaliRendererSetBlendMode03(void)
952 TestApplication application;
954 tet_infoline("Test setting the blend mode to auto with a transparent color renders with blending enabled");
956 Geometry geometry = CreateQuadGeometry();
957 Shader shader = CreateShader();
958 Renderer renderer = Renderer::New(geometry, shader);
960 Actor actor = Actor::New();
961 actor.SetProperty(Actor::Property::OPACITY, 0.75f);
962 actor.AddRenderer(renderer);
963 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
964 application.GetScene().Add(actor);
966 renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::AUTO);
968 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
969 glAbstraction.EnableEnableDisableCallTrace(true);
971 application.SendNotification();
972 application.Render();
974 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
975 TraceCallStack::NamedParams params;
976 params["cap"] << std::hex << GL_BLEND;
977 DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", params));
982 int UtcDaliRendererSetBlendMode04(void)
984 TestApplication application;
986 tet_infoline("Test setting the blend mode to auto with an opaque color renders with blending disabled");
988 Geometry geometry = CreateQuadGeometry();
989 Shader shader = CreateShader();
990 Renderer renderer = Renderer::New(geometry, shader);
992 Actor actor = Actor::New();
993 actor.AddRenderer(renderer);
994 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
995 application.GetScene().Add(actor);
997 renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::AUTO);
999 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
1000 glAbstraction.EnableEnableDisableCallTrace(true);
1002 application.SendNotification();
1003 application.Render();
1005 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
1006 TraceCallStack::NamedParams params;
1007 params["cap"] << std::hex << GL_BLEND;
1008 DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Enable", params));
1009 DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Disable", params));
1014 int UtcDaliRendererSetBlendMode04b(void)
1016 TestApplication application;
1018 tet_infoline("Test setting the blend mode to auto with a transparent actor color renders with blending enabled");
1020 Geometry geometry = CreateQuadGeometry();
1021 Shader shader = CreateShader();
1022 Renderer renderer = Renderer::New(geometry, shader);
1024 Actor actor = Actor::New();
1025 actor.AddRenderer(renderer);
1026 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1027 actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 0.5f));
1028 application.GetScene().Add(actor);
1030 renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::AUTO);
1032 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
1033 glAbstraction.EnableEnableDisableCallTrace(true);
1035 application.SendNotification();
1036 application.Render();
1038 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
1039 TraceCallStack::NamedParams params;
1040 params["cap"] << std::hex << GL_BLEND;
1041 DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", params));
1046 int UtcDaliRendererSetBlendMode04c(void)
1048 TestApplication application;
1050 tet_infoline("Test setting the blend mode to auto with an opaque opaque actor color renders with blending disabled");
1052 Geometry geometry = CreateQuadGeometry();
1053 Shader shader = CreateShader();
1054 Renderer renderer = Renderer::New(geometry, shader);
1056 Actor actor = Actor::New();
1057 actor.AddRenderer(renderer);
1058 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1059 actor.SetProperty(Actor::Property::COLOR, Color::MAGENTA);
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));
1074 DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Disable", params));
1079 int UtcDaliRendererSetBlendMode05(void)
1081 TestApplication application;
1083 tet_infoline("Test setting the blend mode to auto with an opaque color and an image with an alpha channel renders with blending enabled");
1085 Geometry geometry = CreateQuadGeometry();
1086 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 40, 40);
1088 Shader shader = CreateShader();
1089 TextureSet textureSet = CreateTextureSet(image);
1090 Renderer renderer = Renderer::New(geometry, shader);
1091 renderer.SetTextures(textureSet);
1093 Actor actor = Actor::New();
1094 actor.AddRenderer(renderer);
1095 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1096 application.GetScene().Add(actor);
1098 renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::AUTO);
1100 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
1101 glAbstraction.EnableEnableDisableCallTrace(true);
1103 application.SendNotification();
1104 application.Render();
1106 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
1107 TraceCallStack::NamedParams params;
1108 params["cap"] << std::hex << GL_BLEND;
1109 DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", params));
1114 int UtcDaliRendererSetBlendMode06(void)
1116 TestApplication application;
1117 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");
1119 Geometry geometry = CreateQuadGeometry();
1120 Shader shader = Shader::New("vertexSrc", "fragmentSrc", Shader::Hint::OUTPUT_IS_TRANSPARENT);
1122 Renderer renderer = Renderer::New(geometry, shader);
1124 Actor actor = Actor::New();
1125 actor.AddRenderer(renderer);
1126 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1127 application.GetScene().Add(actor);
1129 renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::AUTO);
1131 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
1132 glAbstraction.EnableEnableDisableCallTrace(true);
1134 application.SendNotification();
1135 application.Render();
1137 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
1138 TraceCallStack::NamedParams params;
1139 params["cap"] << std::hex << GL_BLEND;
1140 DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", params));
1145 int UtcDaliRendererSetBlendMode07(void)
1147 TestApplication application;
1148 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");
1150 Geometry geometry = CreateQuadGeometry();
1151 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
1153 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGB888, 50, 50);
1154 TextureSet textureSet = CreateTextureSet(image);
1155 Renderer renderer = Renderer::New(geometry, shader);
1156 renderer.SetTextures(textureSet);
1158 Actor actor = Actor::New();
1159 actor.AddRenderer(renderer);
1160 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1161 application.GetScene().Add(actor);
1163 renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::AUTO);
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));
1179 int UtcDaliRendererSetBlendMode08(void)
1181 TestApplication application;
1183 tet_infoline("Test setting the blend mode to auto with opaque color and Advanced Blend Equation.");
1185 if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
1187 Geometry geometry = CreateQuadGeometry();
1188 Shader shader = CreateShader();
1189 Renderer renderer = Renderer::New(geometry, shader);
1191 Actor actor = Actor::New();
1192 actor.SetProperty(Actor::Property::OPACITY, 1.0f);
1193 actor.AddRenderer(renderer);
1194 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1195 application.GetScene().Add(actor);
1197 renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::AUTO);
1198 renderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true);
1199 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SCREEN);
1201 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
1202 glAbstraction.EnableEnableDisableCallTrace(true);
1204 application.SendNotification();
1205 application.Render();
1207 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
1208 TraceCallStack::NamedParams params;
1209 params["cap"] << std::hex << GL_BLEND;
1210 DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", params));
1216 int UtcDaliRendererSetBlendMode08b(void)
1218 TestApplication application;
1220 tet_infoline("Test setting the blend mode to off with opaque color and Advanced Blend Equation.");
1222 if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
1224 Geometry geometry = CreateQuadGeometry();
1225 Shader shader = CreateShader();
1226 Renderer renderer = Renderer::New(geometry, shader);
1228 Actor actor = Actor::New();
1229 actor.SetProperty(Actor::Property::OPACITY, 1.0f);
1230 actor.AddRenderer(renderer);
1231 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1232 application.GetScene().Add(actor);
1234 renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::OFF);
1235 renderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true);
1236 renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SCREEN);
1238 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
1239 glAbstraction.EnableEnableDisableCallTrace(true);
1241 application.SendNotification();
1242 application.Render();
1244 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
1245 TraceCallStack::NamedParams params;
1246 params["cap"] << std::hex << GL_BLEND;
1247 DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Enable", params));
1253 int UtcDaliRendererSetBlendMode09(void)
1255 TestApplication application;
1257 tet_infoline("Test setting the blend mode to on_without_cull with an opaque color renders with blending enabled");
1259 Geometry geometry = CreateQuadGeometry();
1260 Shader shader = CreateShader();
1261 Renderer renderer = Renderer::New(geometry, shader);
1263 Actor actor = Actor::New();
1264 actor.SetProperty(Actor::Property::OPACITY, 1.0f);
1265 actor.AddRenderer(renderer);
1266 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1267 application.GetScene().Add(actor);
1269 renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON_WITHOUT_CULL);
1271 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
1272 glAbstraction.EnableEnableDisableCallTrace(true);
1274 application.SendNotification();
1275 application.Render();
1277 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
1278 TraceCallStack::NamedParams params;
1279 params["cap"] << std::hex << GL_BLEND;
1280 DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", params));
1285 int UtcDaliRendererSetBlendMode09b(void)
1287 TestApplication application;
1289 tet_infoline("Test setting the blend mode to on_without_cull with an transparent color renders with blending enabled");
1291 Geometry geometry = CreateQuadGeometry();
1292 Shader shader = CreateShader();
1293 Renderer renderer = Renderer::New(geometry, shader);
1295 Actor actor = Actor::New();
1296 actor.SetProperty(Actor::Property::OPACITY, 0.0f);
1297 actor.AddRenderer(renderer);
1298 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1299 application.GetScene().Add(actor);
1301 renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON_WITHOUT_CULL);
1303 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
1304 glAbstraction.EnableEnableDisableCallTrace(true);
1305 glAbstraction.EnableDrawCallTrace(true);
1307 application.SendNotification();
1308 application.Render();
1310 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
1311 DALI_TEST_CHECK(glEnableStack.FindMethod("Enable"));
1313 DALI_TEST_CHECK(glAbstraction.GetDrawTrace().FindMethod("DrawElements"));
1318 int UtcDaliRendererGetBlendMode(void)
1320 TestApplication application;
1322 tet_infoline("Test GetBlendMode()");
1324 Geometry geometry = CreateQuadGeometry();
1325 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
1326 Renderer renderer = Renderer::New(geometry, shader);
1329 unsigned int mode = renderer.GetProperty<int>(Renderer::Property::BLEND_MODE);
1330 DALI_TEST_EQUALS(static_cast<BlendMode::Type>(mode), BlendMode::AUTO, TEST_LOCATION);
1333 renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
1334 mode = renderer.GetProperty<int>(Renderer::Property::BLEND_MODE);
1335 DALI_TEST_EQUALS(static_cast<BlendMode::Type>(mode), BlendMode::ON, TEST_LOCATION);
1338 renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::OFF);
1339 mode = renderer.GetProperty<int>(Renderer::Property::BLEND_MODE);
1340 DALI_TEST_EQUALS(static_cast<BlendMode::Type>(mode), BlendMode::OFF, TEST_LOCATION);
1343 renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON_WITHOUT_CULL);
1344 mode = renderer.GetProperty<int>(Renderer::Property::BLEND_MODE);
1345 DALI_TEST_EQUALS(static_cast<BlendMode::Type>(mode), BlendMode::ON_WITHOUT_CULL, TEST_LOCATION);
1350 int UtcDaliRendererSetBlendColor(void)
1352 TestApplication application;
1354 tet_infoline("Test SetBlendColor(color)");
1356 Geometry geometry = CreateQuadGeometry();
1357 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
1358 TextureSet textureSet = TextureSet::New();
1359 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 50, 50);
1360 textureSet.SetTexture(0u, image);
1361 Renderer renderer = Renderer::New(geometry, shader);
1362 renderer.SetTextures(textureSet);
1364 Actor actor = Actor::New();
1365 actor.AddRenderer(renderer);
1366 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1367 application.GetScene().Add(actor);
1369 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
1371 renderer.SetProperty(Renderer::Property::BLEND_COLOR, Color::TRANSPARENT);
1373 application.SendNotification();
1374 application.Render();
1376 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(Renderer::Property::BLEND_COLOR), Color::TRANSPARENT, TEST_LOCATION);
1377 DALI_TEST_EQUALS(renderer.GetCurrentProperty<Vector4>(Renderer::Property::BLEND_COLOR), Color::TRANSPARENT, TEST_LOCATION);
1378 DALI_TEST_EQUALS(glAbstraction.GetLastBlendColor(), Color::TRANSPARENT, TEST_LOCATION);
1380 renderer.SetProperty(Renderer::Property::BLEND_COLOR, Color::MAGENTA);
1382 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(Renderer::Property::BLEND_COLOR), Color::MAGENTA, TEST_LOCATION);
1383 DALI_TEST_EQUALS(renderer.GetCurrentProperty<Vector4>(Renderer::Property::BLEND_COLOR), Color::TRANSPARENT, TEST_LOCATION);
1385 application.SendNotification();
1386 application.Render();
1388 DALI_TEST_EQUALS(renderer.GetCurrentProperty<Vector4>(Renderer::Property::BLEND_COLOR), Color::MAGENTA, TEST_LOCATION);
1389 DALI_TEST_EQUALS(glAbstraction.GetLastBlendColor(), Color::MAGENTA, TEST_LOCATION);
1391 Vector4 color(0.1f, 0.2f, 0.3f, 0.4f);
1392 renderer.SetProperty(Renderer::Property::BLEND_COLOR, color);
1393 application.SendNotification();
1394 application.Render();
1395 DALI_TEST_EQUALS(glAbstraction.GetLastBlendColor(), color, TEST_LOCATION);
1400 int UtcDaliRendererGetBlendColor(void)
1402 TestApplication application;
1404 tet_infoline("Test GetBlendColor()");
1406 Geometry geometry = CreateQuadGeometry();
1407 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
1408 Renderer renderer = Renderer::New(geometry, shader);
1410 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(Renderer::Property::BLEND_COLOR), Color::TRANSPARENT, TEST_LOCATION);
1412 renderer.SetProperty(Renderer::Property::BLEND_COLOR, Color::MAGENTA);
1413 application.SendNotification();
1414 application.Render();
1415 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(Renderer::Property::BLEND_COLOR), Color::MAGENTA, TEST_LOCATION);
1417 Vector4 color(0.1f, 0.2f, 0.3f, 0.4f);
1418 renderer.SetProperty(Renderer::Property::BLEND_COLOR, color);
1419 application.SendNotification();
1420 application.Render();
1421 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(Renderer::Property::BLEND_COLOR), color, TEST_LOCATION);
1426 int UtcDaliRendererPreMultipledAlpha(void)
1428 TestApplication application;
1430 tet_infoline("Test BLEND_PRE_MULTIPLIED_ALPHA property");
1432 Geometry geometry = CreateQuadGeometry();
1433 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
1434 Renderer renderer = Renderer::New(geometry, shader);
1436 Actor actor = Actor::New();
1437 actor.AddRenderer(renderer);
1438 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1439 actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 0.5f));
1440 application.GetScene().Add(actor);
1442 Property::Value value = renderer.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
1443 bool preMultipliedAlpha;
1444 DALI_TEST_CHECK(value.Get(preMultipliedAlpha));
1445 DALI_TEST_CHECK(!preMultipliedAlpha);
1447 int srcFactorRgb = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
1448 int destFactorRgb = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
1449 int srcFactorAlpha = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
1450 int destFactorAlpha = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
1452 DALI_TEST_EQUALS((int)DEFAULT_BLEND_FACTOR_SRC_RGB, srcFactorRgb, TEST_LOCATION);
1453 DALI_TEST_EQUALS((int)DEFAULT_BLEND_FACTOR_DEST_RGB, destFactorRgb, TEST_LOCATION);
1454 DALI_TEST_EQUALS((int)DEFAULT_BLEND_FACTOR_SRC_ALPHA, srcFactorAlpha, TEST_LOCATION);
1455 DALI_TEST_EQUALS((int)DEFAULT_BLEND_FACTOR_DEST_ALPHA, destFactorAlpha, TEST_LOCATION);
1457 application.SendNotification();
1458 application.Render();
1460 Vector4 actualValue(Vector4::ZERO);
1461 Vector4 actualActorColor(Vector4::ZERO);
1462 TestGlAbstraction& gl = application.GetGlAbstraction();
1463 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uColor", actualValue));
1464 DALI_TEST_EQUALS(actualValue, Vector4(1.0f, 0.0f, 1.0f, 0.5f), TEST_LOCATION);
1465 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uActorColor", actualActorColor));
1466 DALI_TEST_EQUALS(actualActorColor, Vector4(1.0f, 0.0f, 1.0f, 0.5f), TEST_LOCATION);
1468 // Enable pre-multiplied alpha
1469 renderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true);
1471 application.SendNotification();
1472 application.Render();
1474 value = renderer.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
1475 DALI_TEST_CHECK(value.Get(preMultipliedAlpha));
1476 DALI_TEST_CHECK(preMultipliedAlpha);
1478 value = renderer.GetCurrentProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
1479 DALI_TEST_CHECK(value.Get(preMultipliedAlpha));
1480 DALI_TEST_CHECK(preMultipliedAlpha);
1482 srcFactorRgb = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
1483 destFactorRgb = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
1484 srcFactorAlpha = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
1485 destFactorAlpha = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
1487 DALI_TEST_EQUALS((int)BlendFactor::ONE, srcFactorRgb, TEST_LOCATION);
1488 DALI_TEST_EQUALS((int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorRgb, TEST_LOCATION);
1489 DALI_TEST_EQUALS((int)BlendFactor::ONE, srcFactorAlpha, TEST_LOCATION);
1490 DALI_TEST_EQUALS((int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorAlpha, TEST_LOCATION);
1492 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uColor", actualValue));
1493 DALI_TEST_EQUALS(actualValue, Vector4(0.5f, 0.0f, 0.5f, 0.5f), TEST_LOCATION);
1494 // Note : uActorColor doesn't premultiplied.
1495 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uActorColor", actualActorColor));
1496 DALI_TEST_EQUALS(actualActorColor, Vector4(1.0f, 0.0f, 1.0f, 0.5f), TEST_LOCATION);
1498 // Disable pre-multiplied alpha again
1499 renderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, false);
1501 application.SendNotification();
1502 application.Render();
1504 value = renderer.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
1505 DALI_TEST_CHECK(value.Get(preMultipliedAlpha));
1506 DALI_TEST_CHECK(!preMultipliedAlpha);
1508 value = renderer.GetCurrentProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
1509 DALI_TEST_CHECK(value.Get(preMultipliedAlpha));
1510 DALI_TEST_CHECK(!preMultipliedAlpha);
1512 srcFactorRgb = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
1513 destFactorRgb = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
1514 srcFactorAlpha = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
1515 destFactorAlpha = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
1517 DALI_TEST_EQUALS((int)BlendFactor::SRC_ALPHA, srcFactorRgb, TEST_LOCATION);
1518 DALI_TEST_EQUALS((int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorRgb, TEST_LOCATION);
1519 DALI_TEST_EQUALS((int)BlendFactor::ONE, srcFactorAlpha, TEST_LOCATION);
1520 DALI_TEST_EQUALS((int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorAlpha, TEST_LOCATION);
1522 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uColor", actualValue));
1523 DALI_TEST_EQUALS(actualValue, Vector4(1.0f, 0.0f, 1.0f, 0.5f), TEST_LOCATION);
1524 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uActorColor", actualActorColor));
1525 DALI_TEST_EQUALS(actualActorColor, Vector4(1.0f, 0.0f, 1.0f, 0.5f), TEST_LOCATION);
1530 int UtcDaliRendererConstraint01(void)
1532 TestApplication application;
1534 tet_infoline("Test that a non-uniform renderer property can be constrained");
1536 Shader shader = Shader::New("VertexSource", "FragmentSource");
1537 Geometry geometry = CreateQuadGeometry();
1538 Renderer renderer = Renderer::New(geometry, shader);
1540 Actor actor = Actor::New();
1541 actor.AddRenderer(renderer);
1542 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1543 application.GetScene().Add(actor);
1545 Vector4 initialColor = Color::WHITE;
1546 Property::Index colorIndex = renderer.RegisterProperty("uFadeColor", initialColor);
1548 application.SendNotification();
1549 application.Render(0);
1550 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION);
1553 Constraint constraint = Constraint::New<Vector4>(renderer, colorIndex, TestConstraintNoBlue);
1555 application.SendNotification();
1556 application.Render(0);
1558 // Expect no blue component in either buffer - yellow
1559 DALI_TEST_EQUALS(renderer.GetCurrentProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION);
1560 application.Render(0);
1561 DALI_TEST_EQUALS(renderer.GetCurrentProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION);
1563 renderer.RemoveConstraints();
1564 renderer.SetProperty(colorIndex, Color::WHITE);
1565 application.SendNotification();
1566 application.Render(0);
1567 DALI_TEST_EQUALS(renderer.GetCurrentProperty<Vector4>(colorIndex), Color::WHITE, TEST_LOCATION);
1572 int UtcDaliRendererConstraint02(void)
1574 TestApplication application;
1576 tet_infoline("Test that a uniform map renderer property can be constrained");
1578 Shader shader = Shader::New("VertexSource", "FragmentSource");
1579 Geometry geometry = CreateQuadGeometry();
1580 Renderer renderer = Renderer::New(geometry, shader);
1582 Actor actor = Actor::New();
1583 actor.AddRenderer(renderer);
1584 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1585 application.GetScene().Add(actor);
1586 application.SendNotification();
1587 application.Render(0);
1589 Vector4 initialColor = Color::WHITE;
1590 Property::Index colorIndex = renderer.RegisterProperty("uFadeColor", initialColor);
1592 TestGlAbstraction& gl = application.GetGlAbstraction();
1594 application.SendNotification();
1595 application.Render(0);
1597 Vector4 actualValue(Vector4::ZERO);
1598 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
1599 DALI_TEST_EQUALS(actualValue, initialColor, TEST_LOCATION);
1602 Constraint constraint = Constraint::New<Vector4>(renderer, colorIndex, TestConstraintNoBlue);
1604 application.SendNotification();
1605 application.Render(0);
1607 // Expect no blue component in either buffer - yellow
1608 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
1609 DALI_TEST_EQUALS(actualValue, Color::YELLOW, TEST_LOCATION);
1611 application.Render(0);
1612 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
1613 DALI_TEST_EQUALS(actualValue, Color::YELLOW, TEST_LOCATION);
1615 renderer.RemoveConstraints();
1616 renderer.SetProperty(colorIndex, Color::WHITE);
1617 application.SendNotification();
1618 application.Render(0);
1620 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
1621 DALI_TEST_EQUALS(actualValue, Color::WHITE, TEST_LOCATION);
1626 int UtcDaliRendererAnimatedProperty01(void)
1628 TestApplication application;
1630 tet_infoline("Test that a non-uniform renderer property can be animated");
1632 Shader shader = Shader::New("VertexSource", "FragmentSource");
1633 Geometry geometry = CreateQuadGeometry();
1634 Renderer renderer = Renderer::New(geometry, shader);
1636 Actor actor = Actor::New();
1637 actor.AddRenderer(renderer);
1638 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1639 application.GetScene().Add(actor);
1641 Vector4 initialColor = Color::WHITE;
1642 Property::Index colorIndex = renderer.RegisterProperty("uFadeColor", initialColor);
1644 application.SendNotification();
1645 application.Render(0);
1646 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION);
1648 Animation animation = Animation::New(1.0f);
1649 KeyFrames keyFrames = KeyFrames::New();
1650 keyFrames.Add(0.0f, initialColor);
1651 keyFrames.Add(1.0f, Color::TRANSPARENT);
1652 animation.AnimateBetween(Property(renderer, colorIndex), keyFrames);
1655 application.SendNotification();
1656 application.Render(500);
1658 DALI_TEST_EQUALS(renderer.GetCurrentProperty<Vector4>(colorIndex), Color::WHITE * 0.5f, TEST_LOCATION);
1660 application.Render(500);
1662 DALI_TEST_EQUALS(renderer.GetCurrentProperty<Vector4>(colorIndex), Color::TRANSPARENT, TEST_LOCATION);
1667 int UtcDaliRendererAnimatedProperty02(void)
1669 TestApplication application;
1671 tet_infoline("Test that a uniform map renderer property can be animated");
1673 Shader shader = Shader::New("VertexSource", "FragmentSource");
1674 Geometry geometry = CreateQuadGeometry();
1675 Renderer renderer = Renderer::New(geometry, shader);
1677 Actor actor = Actor::New();
1678 actor.AddRenderer(renderer);
1679 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1680 application.GetScene().Add(actor);
1681 application.SendNotification();
1682 application.Render(0);
1684 Vector4 initialColor = Color::WHITE;
1685 Property::Index colorIndex = renderer.RegisterProperty("uFadeColor", initialColor);
1687 TestGlAbstraction& gl = application.GetGlAbstraction();
1689 application.SendNotification();
1690 application.Render(0);
1692 Vector4 actualValue(Vector4::ZERO);
1693 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
1694 DALI_TEST_EQUALS(actualValue, initialColor, TEST_LOCATION);
1696 Animation animation = Animation::New(1.0f);
1697 KeyFrames keyFrames = KeyFrames::New();
1698 keyFrames.Add(0.0f, initialColor);
1699 keyFrames.Add(1.0f, Color::TRANSPARENT);
1700 animation.AnimateBetween(Property(renderer, colorIndex), keyFrames);
1703 application.SendNotification();
1704 application.Render(500);
1706 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
1707 DALI_TEST_EQUALS(actualValue, Color::WHITE * 0.5f, TEST_LOCATION);
1709 application.Render(500);
1710 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
1711 DALI_TEST_EQUALS(actualValue, Color::TRANSPARENT, TEST_LOCATION);
1716 int UtcDaliRendererUniformMapPrecendence01(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 renderer.RegisterProperty("uFadeColor", Color::RED);
1739 actor.RegisterProperty("uFadeColor", Color::GREEN);
1740 Property::Index shaderFadeColorIndex = shader.RegisterProperty("uFadeColor", Color::MAGENTA);
1742 TestGlAbstraction& gl = application.GetGlAbstraction();
1744 application.SendNotification();
1745 application.Render(0);
1747 // Expect that the actor's fade color property is accessed
1748 Vector4 actualValue(Vector4::ZERO);
1749 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
1750 DALI_TEST_EQUALS(actualValue, Color::GREEN, TEST_LOCATION);
1752 // Animate shader's fade color property. Should be no change to uniform
1753 Animation animation = Animation::New(1.0f);
1754 KeyFrames keyFrames = KeyFrames::New();
1755 keyFrames.Add(0.0f, Color::WHITE);
1756 keyFrames.Add(1.0f, Color::TRANSPARENT);
1757 animation.AnimateBetween(Property(shader, shaderFadeColorIndex), keyFrames);
1760 application.SendNotification();
1761 application.Render(500);
1763 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
1764 DALI_TEST_EQUALS(actualValue, Color::GREEN, TEST_LOCATION);
1766 application.Render(500);
1767 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
1768 DALI_TEST_EQUALS(actualValue, Color::GREEN, TEST_LOCATION);
1773 int UtcDaliRendererUniformMapPrecendence02(void)
1775 TestApplication application;
1777 tet_infoline("Test the uniform map precedence is applied properly");
1779 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64);
1781 Shader shader = Shader::New("VertexSource", "FragmentSource");
1782 TextureSet textureSet = CreateTextureSet(image);
1784 Geometry geometry = CreateQuadGeometry();
1785 Renderer renderer = Renderer::New(geometry, shader);
1786 renderer.SetTextures(textureSet);
1788 Actor actor = Actor::New();
1789 actor.AddRenderer(renderer);
1790 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1791 application.GetScene().Add(actor);
1792 application.SendNotification();
1793 application.Render(0);
1795 // Don't add property / uniform map to renderer
1796 actor.RegisterProperty("uFadeColor", Color::GREEN);
1797 Property::Index shaderFadeColorIndex = shader.RegisterProperty("uFadeColor", Color::BLUE);
1799 TestGlAbstraction& gl = application.GetGlAbstraction();
1801 application.SendNotification();
1802 application.Render(0);
1804 // Expect that the actor's fade color property is accessed
1805 Vector4 actualValue(Vector4::ZERO);
1806 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
1807 DALI_TEST_EQUALS(actualValue, Color::GREEN, TEST_LOCATION);
1809 // Animate texture set's fade color property. Should be no change to uniform
1810 Animation animation = Animation::New(1.0f);
1811 KeyFrames keyFrames = KeyFrames::New();
1812 keyFrames.Add(0.0f, Color::WHITE);
1813 keyFrames.Add(1.0f, Color::TRANSPARENT);
1814 animation.AnimateBetween(Property(shader, shaderFadeColorIndex), keyFrames);
1817 application.SendNotification();
1818 application.Render(500);
1820 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
1821 DALI_TEST_EQUALS(actualValue, Color::GREEN, TEST_LOCATION);
1823 application.Render(500);
1824 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
1825 DALI_TEST_EQUALS(actualValue, Color::GREEN, TEST_LOCATION);
1830 int UtcDaliRendererUniformMapPrecendence03(void)
1832 TestApplication application;
1834 tet_infoline("Test the uniform map precedence is applied properly");
1836 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64);
1838 Shader shader = Shader::New("VertexSource", "FragmentSource");
1839 TextureSet textureSet = CreateTextureSet(image);
1841 Geometry geometry = CreateQuadGeometry();
1842 Renderer renderer = Renderer::New(geometry, shader);
1843 renderer.SetTextures(textureSet);
1845 Actor actor = Actor::New();
1846 actor.AddRenderer(renderer);
1847 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1848 application.GetScene().Add(actor);
1849 application.SendNotification();
1850 application.Render(0);
1852 // Don't add property / uniform map to renderer or actor
1853 shader.RegisterProperty("uFadeColor", Color::BLACK);
1855 TestGlAbstraction& gl = application.GetGlAbstraction();
1857 application.SendNotification();
1858 application.Render(0);
1860 // Expect that the shader's fade color property is accessed
1861 Vector4 actualValue(Vector4::ZERO);
1862 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
1863 DALI_TEST_EQUALS(actualValue, Color::BLACK, TEST_LOCATION);
1868 int UtcDaliRendererUniformMapMultipleUniforms01(void)
1870 TestApplication application;
1872 tet_infoline("Test the uniform maps are collected from all objects (same type)");
1874 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64);
1876 Shader shader = Shader::New("VertexSource", "FragmentSource");
1877 TextureSet textureSet = CreateTextureSet(image);
1879 Geometry geometry = CreateQuadGeometry();
1880 Renderer renderer = Renderer::New(geometry, shader);
1881 renderer.SetTextures(textureSet);
1883 Actor actor = Actor::New();
1884 actor.AddRenderer(renderer);
1885 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1886 application.GetScene().Add(actor);
1887 application.SendNotification();
1888 application.Render(0);
1890 renderer.RegisterProperty("uUniform1", Color::RED);
1891 actor.RegisterProperty("uUniform2", Color::GREEN);
1892 shader.RegisterProperty("uUniform3", Color::MAGENTA);
1894 TestGlAbstraction& gl = application.GetGlAbstraction();
1896 application.SendNotification();
1897 application.Render(0);
1899 // Expect that each of the object's uniforms are set
1900 Vector4 uniform1Value(Vector4::ZERO);
1901 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uUniform1", uniform1Value));
1902 DALI_TEST_EQUALS(uniform1Value, Color::RED, TEST_LOCATION);
1904 Vector4 uniform2Value(Vector4::ZERO);
1905 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uUniform2", uniform2Value));
1906 DALI_TEST_EQUALS(uniform2Value, Color::GREEN, TEST_LOCATION);
1908 Vector4 uniform3Value(Vector4::ZERO);
1909 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uUniform3", uniform3Value));
1910 DALI_TEST_EQUALS(uniform3Value, Color::MAGENTA, TEST_LOCATION);
1915 int UtcDaliRendererUniformMapMultipleUniforms02(void)
1917 TestApplication application;
1919 tet_infoline("Test the uniform maps are collected from all objects (different types)");
1921 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64);
1923 Shader shader = Shader::New("VertexSource", "FragmentSource");
1924 TextureSet textureSet = CreateTextureSet(image);
1926 Geometry geometry = CreateQuadGeometry();
1927 Renderer renderer = Renderer::New(geometry, shader);
1928 renderer.SetTextures(textureSet);
1930 Actor actor = Actor::New();
1931 actor.AddRenderer(renderer);
1932 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
1933 application.GetScene().Add(actor);
1934 application.SendNotification();
1935 application.Render(0);
1937 Property::Value value1(Color::RED);
1938 renderer.RegisterProperty("uFadeColor", value1);
1940 Property::Value value2(1.0f);
1941 actor.RegisterProperty("uFadeProgress", value2);
1943 Property::Value value3(Matrix3::IDENTITY);
1944 shader.RegisterProperty("uANormalMatrix", value3);
1946 TestGlAbstraction& gl = application.GetGlAbstraction();
1948 application.SendNotification();
1949 application.Render(0);
1951 // Expect that each of the object's uniforms are set
1952 Vector4 uniform1Value(Vector4::ZERO);
1953 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", uniform1Value));
1954 DALI_TEST_EQUALS(uniform1Value, value1.Get<Vector4>(), TEST_LOCATION);
1956 float uniform2Value(0.0f);
1957 DALI_TEST_CHECK(gl.GetUniformValue<float>("uFadeProgress", uniform2Value));
1958 DALI_TEST_EQUALS(uniform2Value, value2.Get<float>(), TEST_LOCATION);
1960 Matrix3 uniform3Value;
1961 DALI_TEST_CHECK(gl.GetUniformValue<Matrix3>("uANormalMatrix", uniform3Value));
1962 DALI_TEST_EQUALS(uniform3Value, value3.Get<Matrix3>(), TEST_LOCATION);
1967 int UtcDaliRendererRenderOrder2DLayer(void)
1969 TestApplication application;
1970 tet_infoline("Test the rendering order in a 2D layer is correct");
1972 Shader shader = Shader::New("VertexSource", "FragmentSource");
1973 Geometry geometry = CreateQuadGeometry();
1975 Actor root = application.GetScene().GetRootLayer();
1977 Actor actor0 = CreateActor(root, 0, TEST_LOCATION);
1978 Renderer renderer0 = CreateRenderer(actor0, geometry, shader, 0);
1980 Actor actor1 = CreateActor(root, 0, TEST_LOCATION);
1981 Renderer renderer1 = CreateRenderer(actor1, geometry, shader, 0);
1983 Actor actor2 = CreateActor(root, 0, TEST_LOCATION);
1984 Renderer renderer2 = CreateRenderer(actor2, geometry, shader, 0);
1986 Actor actor3 = CreateActor(root, 0, TEST_LOCATION);
1987 Renderer renderer3 = CreateRenderer(actor3, geometry, shader, 0);
1989 application.SendNotification();
1990 application.Render(0);
1993 * Create the following hierarchy:
2006 * Expected rendering order : actor2 - actor1 - actor0 - actor3
2011 application.SendNotification();
2012 application.Render(0);
2014 TestGlAbstraction& gl = application.GetGlAbstraction();
2015 gl.GetTextureTrace().Reset();
2016 gl.EnableTextureCallTrace(true);
2017 application.SendNotification();
2018 application.Render(0);
2020 int textureBindIndex[4];
2021 for(unsigned int i(0); i < 4; ++i)
2023 std::stringstream params;
2024 params << std::hex << GL_TEXTURE_2D << std::dec << ", " << i + 1;
2025 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str());
2028 //Check that actor1 has been rendered after actor2
2029 DALI_TEST_GREATER(textureBindIndex[1], textureBindIndex[2], TEST_LOCATION);
2031 //Check that actor0 has been rendered after actor1
2032 DALI_TEST_GREATER(textureBindIndex[0], textureBindIndex[1], TEST_LOCATION);
2034 //Check that actor3 has been rendered after actor0
2035 DALI_TEST_GREATER(textureBindIndex[3], textureBindIndex[0], TEST_LOCATION);
2040 int UtcDaliRendererRenderOrder2DLayerMultipleRenderers(void)
2042 TestApplication application;
2043 tet_infoline("Test the rendering order in a 2D layer is correct using multiple renderers per actor");
2046 * Creates the following hierarchy:
2048 * actor0------------------------>actor1
2052 * renderer0 renderer1 renderer2 renderer3 renderer4 renderer5
2054 * renderer0 has depth index 2
2055 * renderer1 has depth index 0
2056 * renderer2 has depth index 1
2058 * renderer3 has depth index 1
2059 * renderer4 has depth index 0
2060 * renderer5 has depth index -1
2062 * Expected rendering order: renderer1 - renderer2 - renderer0 - renderer5 - renderer4 - renderer3
2065 Shader shader = Shader::New("VertexSource", "FragmentSource");
2066 Geometry geometry = CreateQuadGeometry();
2068 Actor root = application.GetScene().GetRootLayer();
2070 Actor actor0 = CreateActor(root, 0, TEST_LOCATION);
2071 Actor actor1 = CreateActor(actor0, 0, TEST_LOCATION);
2072 Renderer renderer0 = CreateRenderer(actor0, geometry, shader, 2);
2073 Renderer renderer1 = CreateRenderer(actor0, geometry, shader, 0);
2074 Renderer renderer2 = CreateRenderer(actor0, geometry, shader, 1);
2075 Renderer renderer3 = CreateRenderer(actor1, geometry, shader, 1);
2076 Renderer renderer4 = CreateRenderer(actor1, geometry, shader, 0);
2077 Renderer renderer5 = CreateRenderer(actor1, geometry, shader, -1);
2079 application.SendNotification();
2080 application.Render(0);
2082 TestGlAbstraction& gl = application.GetGlAbstraction();
2083 gl.GetTextureTrace().Reset();
2084 gl.EnableTextureCallTrace(true);
2085 application.SendNotification();
2086 application.Render(0);
2088 int textureBindIndex[6];
2089 for(unsigned int i(0); i < 6; ++i)
2091 std::stringstream params;
2092 params << std::hex << GL_TEXTURE_2D << std::dec << ", " << i + 1;
2093 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str());
2096 //Check that renderer3 has been rendered after renderer4
2097 DALI_TEST_GREATER(textureBindIndex[3], textureBindIndex[4], TEST_LOCATION);
2099 //Check that renderer0 has been rendered after renderer2
2100 DALI_TEST_GREATER(textureBindIndex[4], textureBindIndex[5], TEST_LOCATION);
2102 //Check that renderer5 has been rendered after renderer2
2103 DALI_TEST_GREATER(textureBindIndex[5], textureBindIndex[0], TEST_LOCATION);
2105 //Check that renderer0 has been rendered after renderer2
2106 DALI_TEST_GREATER(textureBindIndex[0], textureBindIndex[2], TEST_LOCATION);
2108 //Check that renderer2 has been rendered after renderer1
2109 DALI_TEST_GREATER(textureBindIndex[2], textureBindIndex[1], TEST_LOCATION);
2114 int UtcDaliRendererRenderOrder2DLayerSiblingOrder(void)
2116 TestApplication application;
2117 tet_infoline("Test the rendering order in a 2D layer is correct using sibling order");
2120 * Creates the following hierarchy:
2128 * actor0 (SIBLING_ORDER:1) actor1 (SIBLING_ORDER:0)
2132 * renderer0 renderer1 actor2 renderer2 renderer3 renderer4
2133 * DI:2 DI:0 | DI:0 DI:1 DI:2
2138 * actor0 has sibling order 1
2139 * actor1 has sibling order 0
2140 * actor2 has sibling order 0
2142 * renderer0 has depth index 2
2143 * renderer1 has depth index 0
2145 * renderer2 has depth index 0
2146 * renderer3 has depth index 1
2147 * renderer4 has depth index 2
2149 * renderer5 has depth index -1
2151 * Expected rendering order: renderer2 - renderer3 - renderer4 - renderer1 - renderer0 - renderer5
2154 Shader shader = Shader::New("VertexSource", "FragmentSource");
2155 Geometry geometry = CreateQuadGeometry();
2156 Actor root = application.GetScene().GetRootLayer();
2157 Actor actor0 = CreateActor(root, 1, TEST_LOCATION);
2158 Actor actor1 = CreateActor(root, 0, TEST_LOCATION);
2159 Actor actor2 = CreateActor(actor0, 0, TEST_LOCATION);
2161 Renderer renderer0 = CreateRenderer(actor0, geometry, shader, 2);
2162 Renderer renderer1 = CreateRenderer(actor0, geometry, shader, 0);
2163 Renderer renderer2 = CreateRenderer(actor1, geometry, shader, 0);
2164 Renderer renderer3 = CreateRenderer(actor1, geometry, shader, 1);
2165 Renderer renderer4 = CreateRenderer(actor1, geometry, shader, 2);
2166 Renderer renderer5 = CreateRenderer(actor2, geometry, shader, -1);
2168 application.SendNotification();
2169 application.Render();
2171 TestGlAbstraction& gl = application.GetGlAbstraction();
2172 gl.GetTextureTrace().Reset();
2173 gl.EnableTextureCallTrace(true);
2174 application.SendNotification();
2175 application.Render(0);
2177 int textureBindIndex[6];
2178 for(unsigned int i(0); i < 6; ++i)
2180 std::stringstream params;
2181 params << std::hex << GL_TEXTURE_2D << std::dec << ", " << i + 1;
2182 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str());
2185 DALI_TEST_EQUALS(textureBindIndex[2], 0, TEST_LOCATION);
2186 DALI_TEST_EQUALS(textureBindIndex[3], 1, TEST_LOCATION);
2187 DALI_TEST_EQUALS(textureBindIndex[4], 2, TEST_LOCATION);
2188 DALI_TEST_EQUALS(textureBindIndex[1], 3, TEST_LOCATION);
2189 DALI_TEST_EQUALS(textureBindIndex[0], 4, TEST_LOCATION);
2190 DALI_TEST_EQUALS(textureBindIndex[5], 5, TEST_LOCATION);
2192 // Change sibling order of actor1
2193 // New Expected rendering order: renderer1 - renderer0 - renderer 5 - renderer2 - renderer3 - renderer4
2194 actor1.SetProperty(Dali::DevelActor::Property::SIBLING_ORDER, 2);
2196 gl.GetTextureTrace().Reset();
2197 application.SendNotification();
2198 application.Render(0);
2200 for(unsigned int i(0); i < 6; ++i)
2202 std::stringstream params;
2203 params << std::hex << GL_TEXTURE_2D << std::dec << ", " << i + 1;
2204 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str());
2207 DALI_TEST_EQUALS(textureBindIndex[1], 0, TEST_LOCATION);
2208 DALI_TEST_EQUALS(textureBindIndex[0], 1, TEST_LOCATION);
2209 DALI_TEST_EQUALS(textureBindIndex[5], 2, TEST_LOCATION);
2210 DALI_TEST_EQUALS(textureBindIndex[2], 3, TEST_LOCATION);
2211 DALI_TEST_EQUALS(textureBindIndex[3], 4, TEST_LOCATION);
2212 DALI_TEST_EQUALS(textureBindIndex[4], 5, TEST_LOCATION);
2217 int UtcDaliRendererRenderOrder2DLayerOverlay(void)
2219 TestApplication application;
2220 tet_infoline("Test the rendering order in a 2D layer is correct for overlays");
2222 Shader shader = Shader::New("VertexSource", "FragmentSource");
2223 Geometry geometry = CreateQuadGeometry();
2224 Actor root = application.GetScene().GetRootLayer();
2227 * Create the following hierarchy:
2234 * (Overlay) (Regular actor)
2244 * Expected rendering order : actor2 - actor4 - actor1 - actor0 - actor3
2247 Actor actor0 = CreateActor(root, 0, TEST_LOCATION);
2248 actor0.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
2249 Renderer renderer0 = CreateRenderer(actor0, geometry, shader, 0);
2251 Actor actor1 = CreateActor(root, 0, TEST_LOCATION);
2252 actor1.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
2253 Renderer renderer1 = CreateRenderer(actor1, geometry, shader, 0);
2255 Actor actor2 = CreateActor(root, 0, TEST_LOCATION);
2256 Renderer renderer2 = CreateRenderer(actor2, geometry, shader, 0);
2258 Actor actor3 = CreateActor(root, 0, TEST_LOCATION);
2259 actor3.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
2260 Renderer renderer3 = CreateRenderer(actor3, geometry, shader, 0);
2262 Actor actor4 = CreateActor(root, 0, TEST_LOCATION);
2263 Renderer renderer4 = CreateRenderer(actor4, geometry, shader, 0);
2265 application.SendNotification();
2266 application.Render(0);
2273 TestGlAbstraction& gl = application.GetGlAbstraction();
2274 gl.GetTextureTrace().Reset();
2275 gl.EnableTextureCallTrace(true);
2276 application.SendNotification();
2277 application.Render(0);
2279 int textureBindIndex[5];
2280 for(unsigned int i(0); i < 5; ++i)
2282 std::stringstream params;
2283 params << std::hex << GL_TEXTURE_2D << std::dec << ", " << i + 1;
2284 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str());
2287 //Check that actor4 has been rendered after actor2
2288 DALI_TEST_GREATER(textureBindIndex[4], textureBindIndex[2], TEST_LOCATION);
2290 //Check that actor1 has been rendered after actor4
2291 DALI_TEST_GREATER(textureBindIndex[1], textureBindIndex[4], TEST_LOCATION);
2293 //Check that actor0 has been rendered after actor1
2294 DALI_TEST_GREATER(textureBindIndex[0], textureBindIndex[1], TEST_LOCATION);
2296 //Check that actor3 has been rendered after actor0
2297 DALI_TEST_GREATER(textureBindIndex[3], textureBindIndex[0], TEST_LOCATION);
2302 int UtcDaliRendererSetIndexRange(void)
2306 "attribute vec2 aPosition;\n"
2309 " gl_Position = aPosition;\n"
2314 " gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0)\n"
2317 TestApplication application;
2318 tet_infoline("Test setting the range of indices to draw");
2320 TestGlAbstraction& gl = application.GetGlAbstraction();
2321 gl.EnableDrawCallTrace(true);
2323 Actor actor = Actor::New();
2324 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2327 Geometry geometry = Geometry::New();
2328 geometry.SetType(Geometry::LINE_LOOP);
2330 // --------------------------------------------------------------------------
2332 unsigned short indices[] = {0, 2, 4, 6, 8, // offset = 0, count = 5
2342 9, // offset = 5, count = 10
2348 1}; // offset = 15, count = 6 // line strip
2350 // --------------------------------------------------------------------------
2359 {Vector2(0.0f, 1.00f)},
2360 {Vector2(0.0f, -1.00f)},
2361 {Vector2(-0.95f, 0.31f)},
2362 {Vector2(0.59f, 0.81f)},
2363 {Vector2(-0.59f, -0.81f)},
2364 {Vector2(-0.95f, -0.31f)},
2365 {Vector2(0.59f, -0.81f)},
2366 {Vector2(0.95f, -0.31f)},
2367 {Vector2(0.95f, 0.31f)},
2368 {Vector2(-0.59f, 0.81f)},
2370 Property::Map vertexFormat;
2371 vertexFormat["aPosition"] = Property::VECTOR2;
2372 VertexBuffer vertexBuffer = VertexBuffer::New(vertexFormat);
2373 vertexBuffer.SetData(shapes, sizeof(shapes) / sizeof(shapes[0]));
2375 // --------------------------------------------------------------------------
2376 geometry.SetIndexBuffer(indices, sizeof(indices) / sizeof(indices[0]));
2377 geometry.AddVertexBuffer(vertexBuffer);
2380 Shader shader = Shader::New(vertexShader, fragmentShader);
2381 Renderer renderer = Renderer::New(geometry, shader);
2382 actor.AddRenderer(renderer);
2384 Integration::Scene scene = application.GetScene();
2389 // LINE_LOOP, first 0, count 5
2391 renderer.SetIndexRange(0, 5);
2392 application.SendNotification();
2393 application.Render();
2395 Property::Value value = renderer.GetProperty(Renderer::Property::INDEX_RANGE_FIRST);
2397 DALI_TEST_CHECK(value.Get(convertedValue));
2398 DALI_TEST_CHECK(convertedValue == 0);
2400 value = renderer.GetCurrentProperty(Renderer::Property::INDEX_RANGE_FIRST);
2401 DALI_TEST_CHECK(value.Get(convertedValue));
2402 DALI_TEST_CHECK(convertedValue == 0);
2404 value = renderer.GetProperty(Renderer::Property::INDEX_RANGE_COUNT);
2405 DALI_TEST_CHECK(value.Get(convertedValue));
2406 DALI_TEST_CHECK(convertedValue == 5);
2408 value = renderer.GetCurrentProperty(Renderer::Property::INDEX_RANGE_COUNT);
2409 DALI_TEST_CHECK(value.Get(convertedValue));
2410 DALI_TEST_CHECK(convertedValue == 5);
2412 sprintf(buffer, "%u, 5, %u, indices", GL_LINE_LOOP, GL_UNSIGNED_SHORT);
2413 bool result = gl.GetDrawTrace().FindMethodAndParams("DrawElements", buffer);
2414 DALI_TEST_CHECK(result);
2417 // LINE_LOOP, first 5, count 10
2419 renderer.SetIndexRange(5, 10);
2420 sprintf(buffer, "%u, 10, %u, indices", GL_LINE_LOOP, GL_UNSIGNED_SHORT);
2421 application.SendNotification();
2422 application.Render();
2423 bool result = gl.GetDrawTrace().FindMethodAndParams("DrawElements", buffer);
2424 DALI_TEST_CHECK(result);
2427 // LINE_STRIP, first 15, count 6
2429 renderer.SetIndexRange(15, 6);
2430 geometry.SetType(Geometry::LINE_STRIP);
2431 sprintf(buffer, "%u, 6, %u, indices", GL_LINE_STRIP, GL_UNSIGNED_SHORT);
2432 application.SendNotification();
2433 application.Render();
2434 bool result = gl.GetDrawTrace().FindMethodAndParams("DrawElements", buffer);
2435 DALI_TEST_CHECK(result);
2438 // Index out of bounds
2440 renderer.SetIndexRange(15, 30);
2441 geometry.SetType(Geometry::LINE_STRIP);
2442 sprintf(buffer, "%u, 6, %u, indices", GL_LINE_STRIP, GL_UNSIGNED_SHORT);
2443 application.SendNotification();
2444 application.Render();
2445 bool result = gl.GetDrawTrace().FindMethodAndParams("DrawElements", buffer);
2446 DALI_TEST_CHECK(result);
2449 // drawing whole buffer starting from 15 ( last valid primitive )
2451 renderer.SetIndexRange(15, 0);
2452 geometry.SetType(Geometry::LINE_STRIP);
2453 sprintf(buffer, "%u, 6, %u, indices", GL_LINE_STRIP, GL_UNSIGNED_SHORT);
2454 application.SendNotification();
2455 application.Render();
2456 bool result = gl.GetDrawTrace().FindMethodAndParams("DrawElements", buffer);
2457 DALI_TEST_CHECK(result);
2463 int UtcDaliRendererSetDepthFunction(void)
2465 TestApplication application;
2467 tet_infoline("Test setting the depth function");
2469 Geometry geometry = CreateQuadGeometry();
2470 Shader shader = CreateShader();
2471 Renderer renderer = Renderer::New(geometry, shader);
2473 Actor actor = Actor::New();
2474 actor.AddRenderer(renderer);
2475 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
2476 Integration::Scene scene = application.GetScene();
2477 scene.GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
2480 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2481 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2482 TraceCallStack& glDepthFunctionStack = glAbstraction.GetDepthFunctionTrace();
2484 glEnableDisableStack.Enable(true);
2485 glDepthFunctionStack.Enable(true);
2486 glEnableDisableStack.EnableLogging(true);
2487 glDepthFunctionStack.EnableLogging(true);
2489 std::ostringstream depthTestStr;
2490 depthTestStr << std::hex << GL_DEPTH_TEST;
2494 renderer.SetProperty(Renderer::Property::DEPTH_FUNCTION, DepthFunction::NEVER);
2496 glEnableDisableStack.Reset();
2497 glDepthFunctionStack.Reset();
2498 application.SendNotification();
2499 application.Render();
2501 DALI_TEST_CHECK(glEnableDisableStack.FindMethodAndParams("Enable", depthTestStr.str().c_str()));
2502 std::ostringstream depthFunctionStr;
2503 depthFunctionStr << std::hex << GL_NEVER;
2504 DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
2509 renderer.SetProperty(Renderer::Property::DEPTH_FUNCTION, DepthFunction::ALWAYS);
2511 glDepthFunctionStack.Reset();
2512 application.SendNotification();
2513 application.Render();
2515 std::ostringstream depthFunctionStr;
2516 depthFunctionStr << std::hex << GL_ALWAYS;
2517 DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
2522 renderer.SetProperty(Renderer::Property::DEPTH_FUNCTION, DepthFunction::LESS);
2524 glDepthFunctionStack.Reset();
2525 application.SendNotification();
2526 application.Render();
2528 std::ostringstream depthFunctionStr;
2529 depthFunctionStr << std::hex << GL_LESS;
2530 DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
2535 renderer.SetProperty(Renderer::Property::DEPTH_FUNCTION, DepthFunction::GREATER);
2537 glDepthFunctionStack.Reset();
2538 application.SendNotification();
2539 application.Render();
2541 std::ostringstream depthFunctionStr;
2542 depthFunctionStr << std::hex << GL_GREATER;
2543 DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
2548 renderer.SetProperty(Renderer::Property::DEPTH_FUNCTION, DepthFunction::EQUAL);
2550 glDepthFunctionStack.Reset();
2551 application.SendNotification();
2552 application.Render();
2554 std::ostringstream depthFunctionStr;
2555 depthFunctionStr << std::hex << GL_EQUAL;
2556 DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
2561 renderer.SetProperty(Renderer::Property::DEPTH_FUNCTION, DepthFunction::NOT_EQUAL);
2563 glDepthFunctionStack.Reset();
2564 application.SendNotification();
2565 application.Render();
2567 std::ostringstream depthFunctionStr;
2568 depthFunctionStr << std::hex << GL_NOTEQUAL;
2569 DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
2574 renderer.SetProperty(Renderer::Property::DEPTH_FUNCTION, DepthFunction::LESS_EQUAL);
2576 glDepthFunctionStack.Reset();
2577 application.SendNotification();
2578 application.Render();
2580 std::ostringstream depthFunctionStr;
2581 depthFunctionStr << std::hex << GL_LEQUAL;
2582 DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
2587 renderer.SetProperty(Renderer::Property::DEPTH_FUNCTION, DepthFunction::GREATER_EQUAL);
2589 glDepthFunctionStack.Reset();
2590 application.SendNotification();
2591 application.Render();
2593 std::ostringstream depthFunctionStr;
2594 depthFunctionStr << std::hex << GL_GEQUAL;
2595 DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
2602 * @brief This templatized function checks an enumeration property is setting and getting correctly.
2603 * The checks performed are as follows:
2604 * - Check the initial/default value.
2605 * - Set a different value via enum.
2606 * - Check it was set.
2607 * - Set a different value via string.
2608 * - Check it was set.
2610 template<typename T>
2611 void CheckEnumerationProperty(TestApplication& application, Renderer& renderer, Property::Index propertyIndex, T initialValue, T firstCheckEnumeration, T secondCheckEnumeration, std::string secondCheckString)
2613 application.SendNotification();
2614 application.Render();
2616 DALI_TEST_CHECK(renderer.GetProperty<int>(propertyIndex) == static_cast<int>(initialValue));
2617 DALI_TEST_CHECK(renderer.GetCurrentProperty<int>(propertyIndex) == static_cast<int>(initialValue));
2618 renderer.SetProperty(propertyIndex, firstCheckEnumeration);
2619 DALI_TEST_CHECK(renderer.GetProperty<int>(propertyIndex) == static_cast<int>(firstCheckEnumeration));
2620 DALI_TEST_CHECK(renderer.GetCurrentProperty<int>(propertyIndex) != static_cast<int>(firstCheckEnumeration));
2622 application.SendNotification();
2623 application.Render();
2625 DALI_TEST_CHECK(renderer.GetProperty<int>(propertyIndex) == static_cast<int>(firstCheckEnumeration));
2626 DALI_TEST_CHECK(renderer.GetCurrentProperty<int>(propertyIndex) == static_cast<int>(firstCheckEnumeration));
2628 renderer.SetProperty(propertyIndex, secondCheckString);
2629 DALI_TEST_CHECK(renderer.GetProperty<int>(propertyIndex) == static_cast<int>(secondCheckEnumeration));
2630 DALI_TEST_CHECK(renderer.GetCurrentProperty<int>(propertyIndex) != static_cast<int>(secondCheckEnumeration));
2632 application.SendNotification();
2633 application.Render();
2635 DALI_TEST_CHECK(renderer.GetProperty<int>(propertyIndex) == static_cast<int>(secondCheckEnumeration));
2636 DALI_TEST_CHECK(renderer.GetCurrentProperty<int>(propertyIndex) == static_cast<int>(secondCheckEnumeration));
2639 int UtcDaliRendererEnumProperties(void)
2641 TestApplication application;
2642 tet_infoline("Test Renderer enumeration properties can be set with both integer and string values");
2644 Geometry geometry = CreateQuadGeometry();
2645 Shader shader = CreateShader();
2646 Renderer renderer = Renderer::New(geometry, shader);
2648 Actor actor = Actor::New();
2649 actor.AddRenderer(renderer);
2650 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
2651 application.GetScene().Add(actor);
2654 * Here we use a templatized function to perform several checks on each enumeration property.
2655 * @see CheckEnumerationProperty for details of the checks performed.
2658 CheckEnumerationProperty<FaceCullingMode::Type>(application, renderer, Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::NONE, FaceCullingMode::FRONT, FaceCullingMode::BACK, "BACK");
2659 CheckEnumerationProperty<BlendMode::Type>(application, renderer, Renderer::Property::BLEND_MODE, BlendMode::AUTO, BlendMode::OFF, BlendMode::ON, "ON");
2660 CheckEnumerationProperty<BlendEquation::Type>(application, renderer, Renderer::Property::BLEND_EQUATION_RGB, BlendEquation::ADD, BlendEquation::SUBTRACT, BlendEquation::REVERSE_SUBTRACT, "REVERSE_SUBTRACT");
2661 CheckEnumerationProperty<BlendEquation::Type>(application, renderer, Renderer::Property::BLEND_EQUATION_ALPHA, BlendEquation::ADD, BlendEquation::SUBTRACT, BlendEquation::REVERSE_SUBTRACT, "REVERSE_SUBTRACT");
2662 CheckEnumerationProperty<BlendFactor::Type>(application, renderer, Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::SRC_ALPHA, BlendFactor::ONE, BlendFactor::SRC_COLOR, "SRC_COLOR");
2663 CheckEnumerationProperty<BlendFactor::Type>(application, renderer, Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::SRC_COLOR, "SRC_COLOR");
2664 CheckEnumerationProperty<BlendFactor::Type>(application, renderer, Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::SRC_COLOR, "SRC_COLOR");
2665 CheckEnumerationProperty<BlendFactor::Type>(application, renderer, Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::SRC_COLOR, "SRC_COLOR");
2666 CheckEnumerationProperty<DepthWriteMode::Type>(application, renderer, Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::AUTO, DepthWriteMode::OFF, DepthWriteMode::ON, "ON");
2667 CheckEnumerationProperty<DepthFunction::Type>(application, renderer, Renderer::Property::DEPTH_FUNCTION, DepthFunction::LESS, DepthFunction::ALWAYS, DepthFunction::GREATER, "GREATER");
2668 CheckEnumerationProperty<DepthTestMode::Type>(application, renderer, Renderer::Property::DEPTH_TEST_MODE, DepthTestMode::AUTO, DepthTestMode::OFF, DepthTestMode::ON, "ON");
2669 CheckEnumerationProperty<StencilFunction::Type>(application, renderer, Renderer::Property::STENCIL_FUNCTION, StencilFunction::ALWAYS, StencilFunction::LESS, StencilFunction::EQUAL, "EQUAL");
2670 CheckEnumerationProperty<RenderMode::Type>(application, renderer, Renderer::Property::RENDER_MODE, RenderMode::AUTO, RenderMode::NONE, RenderMode::STENCIL, "STENCIL");
2671 CheckEnumerationProperty<StencilOperation::Type>(application, renderer, Renderer::Property::STENCIL_OPERATION_ON_FAIL, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT");
2672 CheckEnumerationProperty<StencilOperation::Type>(application, renderer, Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT");
2673 CheckEnumerationProperty<StencilOperation::Type>(application, renderer, Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT");
2675 if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::MAX) &&
2676 Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::MIN))
2678 application.SendNotification();
2679 application.Render();
2680 CheckEnumerationProperty<DevelBlendEquation::Type>(application, renderer, DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::REVERSE_SUBTRACT, DevelBlendEquation::MAX, DevelBlendEquation::MIN, "MIN");
2683 if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
2685 application.SendNotification();
2686 application.Render();
2687 CheckEnumerationProperty<DevelBlendEquation::Type>(application, renderer, DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::MIN, DevelBlendEquation::MULTIPLY, DevelBlendEquation::SCREEN, "SCREEN");
2693 Renderer RendererTestFixture(TestApplication& application)
2695 Geometry geometry = CreateQuadGeometry();
2696 Shader shader = CreateShader();
2697 Renderer renderer = Renderer::New(geometry, shader);
2699 Actor actor = Actor::New();
2700 actor.AddRenderer(renderer);
2701 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
2702 Integration::Scene scene = application.GetScene();
2703 scene.GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
2709 int UtcDaliRendererSetDepthTestMode(void)
2711 TestApplication application;
2712 tet_infoline("Test setting the DepthTestMode");
2714 Renderer renderer = RendererTestFixture(application);
2715 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2716 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2717 glEnableDisableStack.Enable(true);
2718 glEnableDisableStack.EnableLogging(true);
2720 glEnableDisableStack.Reset();
2721 application.SendNotification();
2722 application.Render();
2724 // Check depth-test is enabled by default.
2725 DALI_TEST_CHECK(glEnableDisableStack.FindMethodAndParams("Enable", GetDepthTestString()));
2726 DALI_TEST_CHECK(!glEnableDisableStack.FindMethodAndParams("Disable", GetDepthTestString()));
2728 // 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.
2729 renderer.SetProperty(Renderer::Property::DEPTH_TEST_MODE, DepthTestMode::OFF);
2730 renderer.SetProperty(Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::OFF);
2732 glEnableDisableStack.Reset();
2733 application.SendNotification();
2734 application.Render();
2736 // Check the depth buffer was disabled.
2737 DALI_TEST_CHECK(glEnableDisableStack.FindMethodAndParams("Disable", GetDepthTestString()));
2739 // Turn on automatic mode depth-testing.
2740 // Layer behavior is currently set to LAYER_3D so AUTO should enable depth-testing.
2741 renderer.SetProperty(Renderer::Property::DEPTH_TEST_MODE, DepthTestMode::AUTO);
2743 glEnableDisableStack.Reset();
2744 application.SendNotification();
2745 application.Render();
2747 // Check depth-test is now enabled.
2748 DALI_TEST_CHECK(glEnableDisableStack.FindMethodAndParams("Enable", GetDepthTestString()));
2749 DALI_TEST_CHECK(!glEnableDisableStack.FindMethodAndParams("Disable", GetDepthTestString()));
2751 // Change the layer behavior to LAYER_UI.
2752 // Note this will also disable depth testing for the layer by default, we test this first.
2753 application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_UI);
2755 glEnableDisableStack.Reset();
2756 application.SendNotification();
2757 application.Render();
2759 // Check depth-test is disabled.
2760 DALI_TEST_CHECK(glEnableDisableStack.FindMethodAndParams("Disable", GetDepthTestString()));
2762 // Turn the layer depth-test flag back on, and confirm that depth testing is now on.
2763 application.GetScene().GetRootLayer().SetProperty(Layer::Property::DEPTH_TEST, true);
2765 glEnableDisableStack.Reset();
2766 application.SendNotification();
2767 application.Render();
2769 // Check depth-test is *still* disabled.
2770 DALI_TEST_CHECK(glEnableDisableStack.FindMethodAndParams("Enable", GetDepthTestString()));
2775 int UtcDaliRendererSetDepthWriteMode(void)
2777 TestApplication application;
2778 tet_infoline("Test setting the DepthWriteMode");
2780 Renderer renderer = RendererTestFixture(application);
2781 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2783 application.SendNotification();
2784 application.Render();
2786 // Check the default depth-write status first.
2787 DALI_TEST_CHECK(glAbstraction.GetLastDepthMask());
2789 // Turn off depth-writing.
2790 renderer.SetProperty(Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::OFF);
2792 application.SendNotification();
2793 application.Render();
2795 // Check depth-write is now disabled.
2796 DALI_TEST_CHECK(!glAbstraction.GetLastDepthMask());
2798 // Test the AUTO mode for depth-writing.
2799 // As our renderer is opaque, depth-testing should be enabled.
2800 renderer.SetProperty(Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::AUTO);
2802 application.SendNotification();
2803 application.Render();
2805 // Check depth-write is now enabled.
2806 DALI_TEST_CHECK(glAbstraction.GetLastDepthMask());
2808 // Now make the renderer be treated as translucent by enabling blending.
2809 // The AUTO depth-write mode should turn depth-write off in this scenario.
2810 renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
2812 application.SendNotification();
2813 application.Render();
2815 // Check depth-write is now disabled.
2816 DALI_TEST_CHECK(!glAbstraction.GetLastDepthMask());
2821 int UtcDaliRendererBlendModeUseActorOpacity(void)
2823 TestApplication application;
2824 tet_infoline("Test setting the UseActorOpacity");
2826 Geometry geometry = CreateQuadGeometry();
2827 Shader shader = CreateShader();
2828 Renderer renderer = Renderer::New(geometry, shader);
2830 Actor actor = Actor::New();
2831 actor.AddRenderer(renderer);
2832 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
2833 Integration::Scene scene = application.GetScene();
2834 scene.GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
2837 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2838 renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::USE_ACTOR_OPACITY);
2839 actor.AddRenderer(renderer);
2840 application.GetScene().Add(actor);
2842 application.SendNotification();
2843 application.Render();
2845 // Check the default depth-write status first.
2846 DALI_TEST_CHECK(glAbstraction.GetLastDepthMask());
2848 // Turn off depth-writing.
2849 actor.SetProperty(Dali::Actor::Property::COLOR, Vector4(1, 1, 1, 0.5));
2851 application.SendNotification();
2852 application.Render();
2854 // Check depth-write is now disabled.
2855 DALI_TEST_CHECK(!glAbstraction.GetLastDepthMask());
2857 // Turn on depth-writing.
2858 actor.SetProperty(Dali::Actor::Property::COLOR, Vector4(1, 1, 1, 1));
2860 application.SendNotification();
2861 application.Render();
2863 // Check depth-write is now enabled.
2864 DALI_TEST_CHECK(glAbstraction.GetLastDepthMask());
2866 // Turn off depth-writing.
2867 actor.SetProperty(Dali::Actor::Property::COLOR, Vector4(1, 1, 1, 0.0));
2869 application.SendNotification();
2870 application.Render();
2872 // if actor alpha is 0, SetDepthWriteEnable is not called so GetLastDepthMask returns default value true;
2873 DALI_TEST_CHECK(glAbstraction.GetLastDepthMask());
2878 int UtcDaliRendererCheckStencilDefaults(void)
2880 TestApplication application;
2881 tet_infoline("Test the stencil defaults");
2883 Renderer renderer = RendererTestFixture(application);
2884 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2885 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2886 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
2887 glEnableDisableStack.Enable(true);
2888 glEnableDisableStack.EnableLogging(true);
2889 glStencilFunctionStack.Enable(true);
2890 glStencilFunctionStack.EnableLogging(true);
2892 ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
2894 // Check the defaults:
2895 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetProperty(Renderer::Property::STENCIL_FUNCTION).Get<int>()), static_cast<int>(StencilFunction::ALWAYS), TEST_LOCATION);
2896 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetProperty(Renderer::Property::STENCIL_FUNCTION_MASK).Get<int>()), 0xFF, TEST_LOCATION);
2897 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetProperty(Renderer::Property::STENCIL_FUNCTION_REFERENCE).Get<int>()), 0x00, TEST_LOCATION);
2898 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetProperty(Renderer::Property::STENCIL_MASK).Get<int>()), 0xFF, TEST_LOCATION);
2899 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetProperty(Renderer::Property::STENCIL_OPERATION_ON_FAIL).Get<int>()), static_cast<int>(StencilOperation::KEEP), TEST_LOCATION);
2900 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);
2901 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);
2906 int UtcDaliRendererSetRenderModeToUseStencilBuffer(void)
2908 TestApplication application;
2909 tet_infoline("Test setting the RenderMode to use the stencil buffer");
2911 Renderer renderer = RendererTestFixture(application);
2912 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2913 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2914 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
2915 glEnableDisableStack.Enable(true);
2916 glEnableDisableStack.EnableLogging(true);
2917 glStencilFunctionStack.Enable(true);
2918 glStencilFunctionStack.EnableLogging(true);
2920 // Set the StencilFunction to something other than the default, to confirm it is set as a property,
2921 // but NO GL call has been made while the RenderMode is set to not use the stencil buffer.
2922 renderer.SetProperty(Renderer::Property::RENDER_MODE, RenderMode::NONE);
2923 ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
2925 renderer.SetProperty(Renderer::Property::STENCIL_FUNCTION, StencilFunction::NEVER);
2926 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetProperty(Renderer::Property::STENCIL_FUNCTION).Get<int>()), static_cast<int>(StencilFunction::NEVER), TEST_LOCATION);
2928 ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
2929 std::string methodString("StencilFunc");
2930 DALI_TEST_CHECK(!glStencilFunctionStack.FindMethod(methodString));
2932 // Test the other RenderModes that will not enable the stencil buffer.
2933 renderer.SetProperty(Renderer::Property::RENDER_MODE, RenderMode::AUTO);
2934 ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
2935 DALI_TEST_CHECK(!glStencilFunctionStack.FindMethod(methodString));
2937 renderer.SetProperty(Renderer::Property::RENDER_MODE, RenderMode::COLOR);
2938 ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
2939 DALI_TEST_CHECK(!glStencilFunctionStack.FindMethod(methodString));
2941 // Now set the RenderMode to modes that will use the stencil buffer, and check the StencilFunction has changed.
2942 renderer.SetProperty(Renderer::Property::RENDER_MODE, RenderMode::STENCIL);
2943 ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
2945 DALI_TEST_CHECK(glEnableDisableStack.FindMethodAndParams("Enable", GetStencilTestString()));
2946 DALI_TEST_CHECK(glStencilFunctionStack.FindMethod(methodString));
2948 // Test the COLOR_STENCIL RenderMode as it also enables the stencil buffer.
2949 // First set a mode to turn off the stencil buffer, so the enable is required.
2950 renderer.SetProperty(Renderer::Property::RENDER_MODE, RenderMode::COLOR);
2951 ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
2952 renderer.SetProperty(Renderer::Property::RENDER_MODE, RenderMode::COLOR_STENCIL);
2953 // Set a different stencil function as the last one is cached.
2954 renderer.SetProperty(Renderer::Property::STENCIL_FUNCTION, StencilFunction::ALWAYS);
2955 ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
2957 DALI_TEST_CHECK(glEnableDisableStack.FindMethodAndParams("Enable", GetStencilTestString()));
2958 DALI_TEST_CHECK(glStencilFunctionStack.FindMethod(methodString));
2963 // Helper function for the SetRenderModeToUseColorBuffer test.
2964 void CheckRenderModeColorMask(TestApplication& application, Renderer& renderer, RenderMode::Type renderMode, bool expectedValue)
2966 // Set the RenderMode property to a value that should not allow color buffer writes.
2967 renderer.SetProperty(Renderer::Property::RENDER_MODE, renderMode);
2968 application.SendNotification();
2969 application.Render();
2971 // Check if ColorMask has been called, and that the values are correct.
2972 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2973 const TestGlAbstraction::ColorMaskParams& colorMaskParams(glAbstraction.GetColorMaskParams());
2975 DALI_TEST_EQUALS<bool>(colorMaskParams.red, expectedValue, TEST_LOCATION);
2976 DALI_TEST_EQUALS<bool>(colorMaskParams.green, expectedValue, TEST_LOCATION);
2977 DALI_TEST_EQUALS<bool>(colorMaskParams.blue, expectedValue, TEST_LOCATION);
2978 // @todo Only check alpha if framebuffer supports it.
2979 //DALI_TEST_EQUALS<bool>(colorMaskParams.alpha, expectedValue, TEST_LOCATION);
2982 int UtcDaliRendererSetRenderModeToUseColorBuffer(void)
2984 TestApplication application;
2985 tet_infoline("Test setting the RenderMode to use the color buffer");
2987 Renderer renderer = RendererTestFixture(application);
2989 // Set the RenderMode property to a value that should not allow color buffer writes.
2990 // Then check if ColorMask has been called, and that the values are correct.
2991 CheckRenderModeColorMask(application, renderer, RenderMode::AUTO, true);
2992 CheckRenderModeColorMask(application, renderer, RenderMode::NONE, false);
2993 CheckRenderModeColorMask(application, renderer, RenderMode::COLOR, true);
2994 CheckRenderModeColorMask(application, renderer, RenderMode::STENCIL, false);
2995 CheckRenderModeColorMask(application, renderer, RenderMode::COLOR_STENCIL, true);
3000 int UtcDaliRendererSetStencilFunction(void)
3002 TestApplication application;
3003 tet_infoline("Test setting the StencilFunction");
3005 Renderer renderer = RendererTestFixture(application);
3006 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3007 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
3008 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
3009 glEnableDisableStack.Enable(true);
3010 glEnableDisableStack.EnableLogging(true);
3011 glStencilFunctionStack.Enable(true);
3012 glStencilFunctionStack.EnableLogging(true);
3014 // RenderMode must use the stencil for StencilFunction to operate.
3015 renderer.SetProperty(Renderer::Property::RENDER_MODE, RenderMode::STENCIL);
3016 ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
3019 * Lookup table for testing StencilFunction.
3020 * Note: This MUST be in the same order as the Dali::StencilFunction enum.
3022 const int StencilFunctionLookupTable[] = {
3031 const int StencilFunctionLookupTableCount = sizeof(StencilFunctionLookupTable) / sizeof(StencilFunctionLookupTable[0]);
3034 * Loop through all types of StencilFunction, checking:
3035 * - The value is cached (set in event thread side)
3036 * - Causes "glStencilFunc" to be called
3037 * - Checks the correct parameters to "glStencilFunc" were used
3039 std::string nonChangingParameters = "0, 255";
3040 std::string methodString("StencilFunc");
3041 for(int i = 0; i < StencilFunctionLookupTableCount; ++i)
3043 // Set the property.
3044 renderer.SetProperty(Renderer::Property::STENCIL_FUNCTION, static_cast<Dali::StencilFunction::Type>(i));
3046 // Check GetProperty returns the same value.
3047 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetProperty(Renderer::Property::STENCIL_FUNCTION).Get<int>()), i, TEST_LOCATION);
3049 // Reset the trace debug.
3050 ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
3052 // Check the function is called and the parameters are correct.
3053 std::stringstream parameterStream;
3054 parameterStream << StencilFunctionLookupTable[i] << ", " << nonChangingParameters;
3056 DALI_TEST_CHECK(glStencilFunctionStack.FindMethodAndParams(methodString, parameterStream.str()));
3059 // Change the Function Reference only and check the behavior is correct:
3060 // 170 is 0xaa in hex / 10101010 in binary (every other bit set).
3061 int testValueReference = 170;
3062 renderer.SetProperty(Renderer::Property::STENCIL_FUNCTION_REFERENCE, testValueReference);
3064 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetProperty(Renderer::Property::STENCIL_FUNCTION_REFERENCE).Get<int>()), testValueReference, TEST_LOCATION);
3066 ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
3068 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetCurrentProperty(Renderer::Property::STENCIL_FUNCTION_REFERENCE).Get<int>()), testValueReference, TEST_LOCATION);
3070 std::stringstream parameterStream;
3071 parameterStream << StencilFunctionLookupTable[StencilOperation::DECREMENT_WRAP] << ", " << testValueReference << ", 255";
3073 DALI_TEST_CHECK(glStencilFunctionStack.FindMethodAndParams(methodString, parameterStream.str()));
3075 // Change the Function Mask only and check the behavior is correct:
3076 // 85 is 0x55 in hex / 01010101 in binary (every other bit set).
3077 int testValueMask = 85;
3078 renderer.SetProperty(Renderer::Property::STENCIL_FUNCTION_MASK, testValueMask);
3080 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetProperty(Renderer::Property::STENCIL_FUNCTION_MASK).Get<int>()), testValueMask, TEST_LOCATION);
3082 ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
3084 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetCurrentProperty(Renderer::Property::STENCIL_FUNCTION_MASK).Get<int>()), testValueMask, TEST_LOCATION);
3086 // Clear the stringstream.
3087 parameterStream.str(std::string());
3088 parameterStream << StencilFunctionLookupTable[StencilOperation::DECREMENT_WRAP] << ", " << testValueReference << ", " << testValueMask;
3090 DALI_TEST_CHECK(glStencilFunctionStack.FindMethodAndParams(methodString, parameterStream.str()));
3095 int UtcDaliRendererSetStencilOperation(void)
3097 TestApplication application;
3098 tet_infoline("Test setting the StencilOperation");
3100 Renderer renderer = RendererTestFixture(application);
3101 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3102 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
3103 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
3104 glEnableDisableStack.Enable(true);
3105 glEnableDisableStack.EnableLogging(true);
3106 glStencilFunctionStack.Enable(true);
3107 glStencilFunctionStack.EnableLogging(true);
3109 // RenderMode must use the stencil for StencilOperation to operate.
3110 renderer.SetProperty(Renderer::Property::RENDER_MODE, RenderMode::STENCIL);
3113 * Lookup table for testing StencilOperation.
3114 * Note: This MUST be in the same order as the Dali::StencilOperation enum.
3116 const int StencilOperationLookupTable[] = {
3125 const int StencilOperationLookupTableCount = sizeof(StencilOperationLookupTable) / sizeof(StencilOperationLookupTable[0]);
3127 // Set all 3 StencilOperation properties to a default.
3128 renderer.SetProperty(Renderer::Property::STENCIL_OPERATION_ON_FAIL, StencilOperation::KEEP);
3129 renderer.SetProperty(Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, StencilOperation::ZERO);
3130 renderer.SetProperty(Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, StencilOperation::ZERO);
3132 // Set our expected parameter list to the equivalent result.
3133 int parameters[] = {StencilOperationLookupTable[StencilOperation::ZERO], StencilOperationLookupTable[StencilOperation::ZERO], StencilOperationLookupTable[StencilOperation::ZERO]};
3135 ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
3138 * Loop through all types of StencilOperation, checking:
3139 * - The value is cached (set in event thread side)
3140 * - Causes "glStencilFunc" to be called
3141 * - Checks the correct parameters to "glStencilFunc" were used
3142 * - Checks the above for all 3 parameter placements of StencilOperation ( OnFail, OnZFail, OnPass )
3144 std::string methodString("StencilOp");
3146 for(int i = 0; i < StencilOperationLookupTableCount; ++i)
3148 for(int j = 0; j < StencilOperationLookupTableCount; ++j)
3150 for(int k = 0; k < StencilOperationLookupTableCount; ++k)
3152 // Set the property (outer loop causes all 3 different properties to be set separately).
3153 renderer.SetProperty(Renderer::Property::STENCIL_OPERATION_ON_FAIL, static_cast<Dali::StencilFunction::Type>(i));
3154 renderer.SetProperty(Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, static_cast<Dali::StencilFunction::Type>(j));
3155 renderer.SetProperty(Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, static_cast<Dali::StencilFunction::Type>(k));
3157 // Check GetProperty returns the same value.
3158 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetProperty(Renderer::Property::STENCIL_OPERATION_ON_FAIL).Get<int>()), i, TEST_LOCATION);
3159 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetProperty(Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL).Get<int>()), j, TEST_LOCATION);
3160 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetProperty(Renderer::Property::STENCIL_OPERATION_ON_Z_PASS).Get<int>()), k, TEST_LOCATION);
3162 // Reset the trace debug.
3163 ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
3165 // Check the function is called and the parameters are correct.
3166 // Set the expected parameter value at its correct index (only)
3167 parameters[0u] = StencilOperationLookupTable[i];
3168 parameters[1u] = StencilOperationLookupTable[j];
3169 parameters[2u] = StencilOperationLookupTable[k];
3171 // Build the parameter list.
3172 std::stringstream parameterStream;
3173 for(int parameterBuild = 0; parameterBuild < 3; ++parameterBuild)
3175 parameterStream << parameters[parameterBuild];
3176 // Comma-separate the parameters.
3177 if(parameterBuild < 2)
3179 parameterStream << ", ";
3183 // Check the function was called and the parameters were correct.
3184 DALI_TEST_CHECK(glStencilFunctionStack.FindMethodAndParams(methodString, parameterStream.str()));
3192 int UtcDaliRendererSetStencilMask(void)
3194 TestApplication application;
3195 tet_infoline("Test setting the StencilMask");
3197 Renderer renderer = RendererTestFixture(application);
3198 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3199 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
3200 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
3201 glEnableDisableStack.Enable(true);
3202 glEnableDisableStack.EnableLogging(true);
3203 glStencilFunctionStack.Enable(true);
3204 glStencilFunctionStack.EnableLogging(true);
3206 // RenderMode must use the stencil for StencilMask to operate.
3207 renderer.SetProperty(Renderer::Property::RENDER_MODE, RenderMode::STENCIL);
3209 // Set the StencilMask property to a value.
3210 renderer.SetProperty(Renderer::Property::STENCIL_MASK, 0x00);
3212 // Check GetProperty returns the same value.
3213 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetProperty(Renderer::Property::STENCIL_MASK).Get<int>()), 0x00, TEST_LOCATION);
3215 ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
3217 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetCurrentProperty(Renderer::Property::STENCIL_MASK).Get<int>()), 0x00, TEST_LOCATION);
3219 std::string methodString("StencilMask");
3220 std::string parameterString = "0";
3222 // Check the function was called and the parameters were correct.
3223 DALI_TEST_CHECK(glStencilFunctionStack.FindMethodAndParams(methodString, parameterString));
3225 // Set the StencilMask property to another value to ensure it has changed.
3226 renderer.SetProperty(Renderer::Property::STENCIL_MASK, 0xFF);
3228 // Check GetProperty returns the same value.
3229 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetProperty(Renderer::Property::STENCIL_MASK).Get<int>()), 0xFF, TEST_LOCATION);
3231 ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
3233 DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetCurrentProperty(Renderer::Property::STENCIL_MASK).Get<int>()), 0xFF, TEST_LOCATION);
3235 parameterString = "255";
3237 // Check the function was called and the parameters were correct.
3238 DALI_TEST_CHECK(glStencilFunctionStack.FindMethodAndParams(methodString, parameterString));
3243 int UtcDaliRendererWrongNumberOfTextures(void)
3245 TestApplication application;
3246 tet_infoline("Test renderer does render even if number of textures is different than active samplers in the shader");
3248 //Create a TextureSet with 4 textures (One more texture in the texture set than active samplers)
3249 //@note Shaders in the test suit have 3 active samplers. See TestGlAbstraction::GetActiveUniform()
3250 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64u, 64u);
3251 TextureSet textureSet = CreateTextureSet();
3252 textureSet.SetTexture(0, texture);
3253 textureSet.SetTexture(1, texture);
3254 textureSet.SetTexture(2, texture);
3255 textureSet.SetTexture(3, texture);
3256 Shader shader = Shader::New("VertexSource", "FragmentSource");
3257 Geometry geometry = CreateQuadGeometry();
3258 Renderer renderer = Renderer::New(geometry, shader);
3259 renderer.SetTextures(textureSet);
3261 Actor actor = Actor::New();
3262 actor.AddRenderer(renderer);
3263 actor.SetProperty(Actor::Property::POSITION, Vector2(0.0f, 0.0f));
3264 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
3265 application.GetScene().Add(actor);
3267 TestGlAbstraction& gl = application.GetGlAbstraction();
3268 TraceCallStack& drawTrace = gl.GetDrawTrace();
3270 drawTrace.Enable(true);
3271 drawTrace.EnableLogging(true);
3273 application.SendNotification();
3274 application.Render(0);
3276 //Test we do the drawcall when TextureSet has more textures than there are active samplers in the shader
3277 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
3279 //Create a TextureSet with 1 texture (two more active samplers than texture in the texture set)
3280 //@note Shaders in the test suit have 3 active samplers. See TestGlAbstraction::GetActiveUniform()
3281 textureSet = CreateTextureSet();
3282 renderer.SetTextures(textureSet);
3283 textureSet.SetTexture(0, texture);
3285 application.SendNotification();
3286 application.Render(0);
3288 //Test we do the drawcall when TextureSet has less textures than there are active samplers in the shader.
3289 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
3294 int UtcDaliRendererOpacity(void)
3296 TestApplication application;
3298 tet_infoline("Test OPACITY property");
3300 Geometry geometry = CreateQuadGeometry();
3301 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
3302 Renderer renderer = Renderer::New(geometry, shader);
3304 Actor actor = Actor::New();
3305 actor.AddRenderer(renderer);
3306 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
3307 actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 1.0f));
3308 application.GetScene().Add(actor);
3310 Property::Value value = renderer.GetProperty(DevelRenderer::Property::OPACITY);
3312 DALI_TEST_CHECK(value.Get(opacity));
3313 DALI_TEST_EQUALS(opacity, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
3315 application.SendNotification();
3316 application.Render();
3318 Vector4 actualValue;
3319 Vector4 actualActorColor;
3320 TestGlAbstraction& gl = application.GetGlAbstraction();
3321 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uColor", actualValue));
3322 DALI_TEST_EQUALS(actualValue.a, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
3323 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uActorColor", actualActorColor));
3324 DALI_TEST_EQUALS(actualActorColor.a, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
3326 renderer.SetProperty(DevelRenderer::Property::OPACITY, 0.5f);
3328 application.SendNotification();
3329 application.Render();
3331 value = renderer.GetProperty(DevelRenderer::Property::OPACITY);
3332 DALI_TEST_CHECK(value.Get(opacity));
3333 DALI_TEST_EQUALS(opacity, 0.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
3335 value = renderer.GetCurrentProperty(DevelRenderer::Property::OPACITY);
3336 DALI_TEST_CHECK(value.Get(opacity));
3337 DALI_TEST_EQUALS(opacity, 0.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
3339 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uColor", actualValue));
3340 DALI_TEST_EQUALS(actualValue.a, 0.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
3342 // Note : Renderer opacity doesn't apply to uActorColor.
3343 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uActorColor", actualActorColor));
3344 DALI_TEST_EQUALS(actualActorColor.a, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
3349 int UtcDaliRendererOpacityAnimation(void)
3351 TestApplication application;
3353 tet_infoline("Test OPACITY property animation");
3355 Geometry geometry = CreateQuadGeometry();
3356 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
3357 Renderer renderer = Renderer::New(geometry, shader);
3359 Actor actor = Actor::New();
3360 actor.AddRenderer(renderer);
3361 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
3362 actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 1.0f));
3363 application.GetScene().Add(actor);
3365 application.SendNotification();
3366 application.Render(0);
3368 Property::Value value = renderer.GetProperty(DevelRenderer::Property::OPACITY);
3370 DALI_TEST_CHECK(value.Get(opacity));
3371 DALI_TEST_EQUALS(opacity, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
3373 Animation animation = Animation::New(1.0f);
3374 animation.AnimateTo(Property(renderer, DevelRenderer::Property::OPACITY), 0.0f);
3377 application.SendNotification();
3378 application.Render(1000);
3380 value = renderer.GetProperty(DevelRenderer::Property::OPACITY);
3381 DALI_TEST_CHECK(value.Get(opacity));
3382 DALI_TEST_EQUALS(opacity, 0.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
3384 // Need to clear the animation before setting the property as the animation value is baked and will override any previous setters
3386 renderer.SetProperty(DevelRenderer::Property::OPACITY, 0.1f);
3388 animation.AnimateBy(Property(renderer, DevelRenderer::Property::OPACITY), 0.5f);
3391 application.SendNotification();
3392 application.Render(1000);
3394 value = renderer.GetProperty(DevelRenderer::Property::OPACITY);
3395 DALI_TEST_CHECK(value.Get(opacity));
3396 DALI_TEST_EQUALS(opacity, 0.6f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
3397 DALI_TEST_EQUALS(opacity, renderer.GetCurrentProperty(DevelRenderer::Property::OPACITY).Get<float>(), Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
3402 int UtcDaliRendererInvalidProperty(void)
3404 TestApplication application;
3406 tet_infoline("Test invalid property");
3408 Geometry geometry = CreateQuadGeometry();
3409 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
3410 Renderer renderer = Renderer::New(geometry, shader);
3412 Actor actor = Actor::New();
3413 actor.AddRenderer(renderer);
3414 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
3415 application.GetScene().Add(actor);
3417 application.SendNotification();
3418 application.Render(0);
3420 Property::Value value = renderer.GetProperty(Renderer::Property::DEPTH_INDEX + 100);
3421 DALI_TEST_CHECK(value.GetType() == Property::Type::NONE);
3423 value = renderer.GetCurrentProperty(Renderer::Property::DEPTH_INDEX + 100);
3424 DALI_TEST_CHECK(value.GetType() == Property::Type::NONE);
3429 int UtcDaliRendererRenderingBehavior(void)
3431 TestApplication application;
3433 tet_infoline("Test RENDERING_BEHAVIOR property");
3435 Geometry geometry = CreateQuadGeometry();
3436 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
3437 Renderer renderer = Renderer::New(geometry, shader);
3439 Actor actor = Actor::New();
3440 actor.AddRenderer(renderer);
3441 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
3442 actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 1.0f));
3443 application.GetScene().Add(actor);
3445 Property::Value value = renderer.GetProperty(DevelRenderer::Property::RENDERING_BEHAVIOR);
3446 int renderingBehavior;
3447 DALI_TEST_CHECK(value.Get(renderingBehavior));
3448 DALI_TEST_EQUALS(static_cast<DevelRenderer::Rendering::Type>(renderingBehavior), DevelRenderer::Rendering::IF_REQUIRED, TEST_LOCATION);
3450 application.SendNotification();
3451 application.Render();
3453 uint32_t updateStatus = application.GetUpdateStatus();
3455 DALI_TEST_CHECK(!(updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING));
3457 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3458 TraceCallStack& drawTrace = glAbstraction.GetDrawTrace();
3459 drawTrace.Enable(true);
3462 renderer.SetProperty(DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::CONTINUOUSLY);
3464 value = renderer.GetProperty(DevelRenderer::Property::RENDERING_BEHAVIOR);
3465 DALI_TEST_CHECK(value.Get(renderingBehavior));
3466 DALI_TEST_EQUALS(static_cast<DevelRenderer::Rendering::Type>(renderingBehavior), DevelRenderer::Rendering::CONTINUOUSLY, TEST_LOCATION);
3468 // Render and check the update status
3469 application.SendNotification();
3470 application.Render();
3472 updateStatus = application.GetUpdateStatus();
3474 DALI_TEST_CHECK(updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING);
3476 value = renderer.GetCurrentProperty(DevelRenderer::Property::RENDERING_BEHAVIOR);
3477 DALI_TEST_CHECK(value.Get(renderingBehavior));
3478 DALI_TEST_EQUALS(static_cast<DevelRenderer::Rendering::Type>(renderingBehavior), DevelRenderer::Rendering::CONTINUOUSLY, TEST_LOCATION);
3480 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
3484 // Render again and check the update status
3485 application.SendNotification();
3486 application.Render();
3488 updateStatus = application.GetUpdateStatus();
3490 DALI_TEST_CHECK(updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING);
3492 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
3495 // Render again and check the update status
3496 Animation animation = Animation::New(1.0f);
3497 animation.AnimateTo(Property(renderer, DevelRenderer::Property::OPACITY), 0.0f, TimePeriod(0.5f, 0.5f));
3502 application.SendNotification();
3503 application.Render(0);
3505 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
3509 application.SendNotification();
3510 application.Render(100);
3512 updateStatus = application.GetUpdateStatus();
3514 DALI_TEST_CHECK(updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING);
3516 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
3519 // Change rendering behavior
3520 renderer.SetProperty(DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::IF_REQUIRED);
3522 // Render and check the update status
3523 application.SendNotification();
3524 application.Render();
3526 updateStatus = application.GetUpdateStatus();
3528 DALI_TEST_CHECK(!(updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING));
3533 int UtcDaliRendererRegenerateUniformMap(void)
3535 TestApplication application;
3537 tet_infoline("Test regenerating uniform map when attaching renderer to the node");
3539 Geometry geometry = CreateQuadGeometry();
3540 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
3541 Renderer renderer = Renderer::New(geometry, shader);
3543 Actor actor = Actor::New();
3544 actor.AddRenderer(renderer);
3545 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
3546 actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 1.0f));
3547 application.GetScene().Add(actor);
3549 application.SendNotification();
3550 application.Render();
3552 actor.RemoveRenderer(renderer);
3553 shader = Shader::New("vertexSrc", "fragmentSrc");
3554 shader.RegisterProperty("opacity", 0.5f);
3555 renderer.SetShader(shader);
3557 Stage::GetCurrent().KeepRendering(1.0f);
3559 // Update for several frames
3560 application.SendNotification();
3561 application.Render();
3562 application.SendNotification();
3563 application.Render();
3564 application.SendNotification();
3565 application.Render();
3566 application.SendNotification();
3567 application.Render();
3570 actor.AddRenderer(renderer);
3571 application.SendNotification();
3572 application.Render();
3574 // Nothing to test here, the test must not crash
3575 auto updateStatus = application.GetUpdateStatus();
3576 DALI_TEST_CHECK(updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING);
3581 int UtcDaliRendererRenderAfterAddShader(void)
3583 TestApplication application;
3584 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3586 tet_infoline("Test regenerating uniform map when shader changed");
3588 Geometry geometry = CreateQuadGeometry();
3589 Shader shader1 = Shader::New("vertexSrc1", "fragmentSrc1");
3590 Shader shader2 = Shader::New("vertexSrc2", "fragmentSrc2");
3591 Renderer renderer = Renderer::New(geometry, shader1);
3593 // Register each shader1 and shader2 only had
3594 shader1.RegisterProperty("uUniform1", Color::CRIMSON);
3595 shader2.RegisterProperty("uShader2Only", Color::AQUA_MARINE);
3597 Actor actor = Actor::New();
3598 actor.AddRenderer(renderer);
3599 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
3600 actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 1.0f));
3601 application.GetScene().Add(actor);
3603 Property::Value value = renderer.GetProperty(DevelRenderer::Property::RENDERING_BEHAVIOR);
3604 int renderingBehavior;
3605 DALI_TEST_CHECK(value.Get(renderingBehavior));
3606 DALI_TEST_EQUALS(static_cast<DevelRenderer::Rendering::Type>(renderingBehavior), DevelRenderer::Rendering::IF_REQUIRED, TEST_LOCATION);
3608 application.SendNotification();
3609 application.Render(0);
3611 // Check uUniform1 rendered and uUniform2 not rendered before
3612 Vector4 actualValue(Vector4::ZERO);
3613 DALI_TEST_CHECK(glAbstraction.GetUniformValue<Vector4>("uUniform1", actualValue));
3614 DALI_TEST_EQUALS(actualValue, Color::CRIMSON, TEST_LOCATION);
3616 uint32_t updateStatus = application.GetUpdateStatus();
3618 DALI_TEST_CHECK(!(updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING));
3620 // Update for several frames
3621 application.SendNotification();
3622 application.Render();
3623 application.SendNotification();
3624 application.Render();
3625 application.SendNotification();
3626 application.Render();
3627 application.SendNotification();
3628 application.Render();
3629 application.SendNotification();
3630 application.Render();
3632 TraceCallStack& drawTrace = glAbstraction.GetDrawTrace();
3633 drawTrace.Enable(true);
3636 std::vector<UniformData> customUniforms{{"uShader2Only", Property::VECTOR4}};
3638 application.GetGraphicsController().AddCustomUniforms(customUniforms);
3641 renderer.SetShader(shader2);
3643 // Render and check the update status
3644 application.SendNotification();
3645 application.Render(0);
3647 updateStatus = application.GetUpdateStatus();
3649 DALI_TEST_CHECK(!(updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING));
3651 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
3653 // Check uUniform2 rendered now
3654 DALI_TEST_CHECK(glAbstraction.GetUniformValue<Vector4>("uShader2Only", actualValue));
3655 DALI_TEST_EQUALS(actualValue, Color::AQUA_MARINE, TEST_LOCATION);
3660 int UtcDaliRendererAddDrawCommands(void)
3662 TestApplication application;
3664 tet_infoline("Test adding draw commands to the renderer");
3666 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3667 glAbstraction.EnableEnableDisableCallTrace(true);
3669 Geometry geometry = CreateQuadGeometry();
3670 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
3671 Renderer renderer = Renderer::New(geometry, shader);
3673 renderer.SetProperty(Renderer::Property::BLEND_MODE, Dali::BlendMode::ON);
3674 Actor actor = Actor::New();
3675 actor.AddRenderer(renderer);
3676 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
3677 actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 1.0f));
3678 application.GetScene().Add(actor);
3680 // Expect delivering a single draw call
3681 auto& drawTrace = glAbstraction.GetDrawTrace();
3683 drawTrace.Enable(true);
3684 application.SendNotification();
3685 application.Render();
3687 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
3689 tet_infoline("\n\nTesting extension draw commands\n");
3690 auto drawCommand1 = DevelRenderer::DrawCommand{};
3691 drawCommand1.drawType = DevelRenderer::DrawType::INDEXED;
3692 drawCommand1.firstIndex = 0;
3693 drawCommand1.elementCount = 2;
3694 drawCommand1.queue = DevelRenderer::RENDER_QUEUE_OPAQUE;
3696 auto drawCommand2 = DevelRenderer::DrawCommand{};
3697 drawCommand2.drawType = DevelRenderer::DrawType::INDEXED;
3698 drawCommand2.firstIndex = 2;
3699 drawCommand2.elementCount = 2;
3700 drawCommand2.queue = DevelRenderer::RENDER_QUEUE_TRANSPARENT;
3702 auto drawCommand3 = DevelRenderer::DrawCommand{};
3703 drawCommand3.drawType = DevelRenderer::DrawType::ARRAY;
3704 drawCommand3.firstIndex = 2;
3705 drawCommand3.elementCount = 2;
3706 drawCommand3.queue = DevelRenderer::RENDER_QUEUE_OPAQUE;
3708 DevelRenderer::AddDrawCommand(renderer, drawCommand1);
3709 DevelRenderer::AddDrawCommand(renderer, drawCommand2);
3710 DevelRenderer::AddDrawCommand(renderer, drawCommand3);
3713 drawTrace.Enable(true);
3714 application.SendNotification();
3715 application.Render();
3717 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 3, TEST_LOCATION);
3720 int UtcDaliRendererSetGeometryNegative(void)
3722 TestApplication application;
3723 Dali::Renderer instance;
3726 Dali::Geometry arg1;
3727 instance.SetGeometry(arg1);
3728 DALI_TEST_CHECK(false); // Should not get here
3732 DALI_TEST_CHECK(true); // We expect an assert
3737 int UtcDaliRendererSetTexturesNegative(void)
3739 TestApplication application;
3740 Dali::Renderer instance;
3743 Dali::TextureSet arg1;
3744 instance.SetTextures(arg1);
3745 DALI_TEST_CHECK(false); // Should not get here
3749 DALI_TEST_CHECK(true); // We expect an assert
3754 int UtcDaliRendererSetShaderNegative(void)
3756 TestApplication application;
3757 Dali::Renderer instance;
3761 instance.SetShader(arg1);
3762 DALI_TEST_CHECK(false); // Should not get here
3766 DALI_TEST_CHECK(true); // We expect an assert
3771 int UtcDaliRendererGetGeometryNegative(void)
3773 TestApplication application;
3774 Dali::Renderer instance;
3777 instance.GetGeometry();
3778 DALI_TEST_CHECK(false); // Should not get here
3782 DALI_TEST_CHECK(true); // We expect an assert
3787 int UtcDaliRendererGetTexturesNegative(void)
3789 TestApplication application;
3790 Dali::Renderer instance;
3793 instance.GetTextures();
3794 DALI_TEST_CHECK(false); // Should not get here
3798 DALI_TEST_CHECK(true); // We expect an assert
3803 int UtcDaliRendererGetShaderNegative(void)
3805 TestApplication application;
3806 Dali::Renderer instance;
3809 instance.GetShader();
3810 DALI_TEST_CHECK(false); // Should not get here
3814 DALI_TEST_CHECK(true); // We expect an assert
3819 int UtcDaliRendererCheckTextureBindingP(void)
3821 TestApplication application;
3823 tet_infoline("Test adding draw commands to the renderer");
3825 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3826 glAbstraction.EnableEnableDisableCallTrace(true);
3828 Geometry geometry = CreateQuadGeometry();
3829 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
3830 Renderer renderer = Renderer::New(geometry, shader);
3832 renderer.SetProperty(Renderer::Property::BLEND_MODE, Dali::BlendMode::ON);
3833 Actor actor = Actor::New();
3834 actor.AddRenderer(renderer);
3835 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
3836 actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 1.0f));
3837 application.GetScene().Add(actor);
3839 TestGraphicsController& graphics = application.GetGraphicsController();
3840 TraceCallStack& cmdBufCallstack = graphics.mCommandBufferCallStack;
3841 cmdBufCallstack.Enable(true);
3843 application.SendNotification();
3844 application.Render();
3846 DALI_TEST_CHECK(!cmdBufCallstack.FindMethod("BindTextures"));
3848 Texture image0 = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGB888, 64, 64);
3849 TextureSet textureSet0 = CreateTextureSet(image0);
3850 renderer.SetTextures(textureSet0);
3852 application.SendNotification();
3853 application.Render();
3855 DALI_TEST_CHECK(cmdBufCallstack.FindMethod("BindTextures"));
3859 int UtcDaliRendererPreparePipeline(void)
3861 TestApplication application;
3863 tet_infoline("Test that rendering an actor binds the attributes locs from the reflection");
3865 Property::Map vf = CreateModelVertexFormat();
3866 Geometry modelGeometry = CreateModelGeometry(vf);
3867 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
3868 Renderer renderer = Renderer::New(modelGeometry, shader);
3869 Actor actor = Actor::New();
3871 // Change the order up to get a fair test
3872 Property::Map modelVF;
3873 modelVF["aBoneIndex[0]"] = Property::INTEGER;
3874 modelVF["aBoneIndex[1]"] = Property::INTEGER;
3875 modelVF["aBoneIndex[2]"] = Property::INTEGER;
3876 modelVF["aBoneIndex[3]"] = Property::INTEGER;
3877 modelVF["aBoneWeights[0]"] = Property::FLOAT;
3878 modelVF["aBoneWeights[1]"] = Property::FLOAT;
3879 modelVF["aBoneWeights[2]"] = Property::FLOAT;
3880 modelVF["aBoneWeights[3]"] = Property::FLOAT;
3881 modelVF["aPosition"] = Property::VECTOR3;
3882 modelVF["aNormal"] = Property::VECTOR3;
3883 modelVF["aTexCoord1"] = Property::VECTOR3;
3884 modelVF["aTexCoord2"] = Property::VECTOR3;
3886 Property::Array vfs;
3887 vfs.PushBack(modelVF);
3888 TestGraphicsController& graphics = application.GetGraphicsController();
3889 graphics.SetVertexFormats(vfs);
3891 actor.AddRenderer(renderer);
3892 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
3893 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
3894 application.GetScene().Add(actor);
3896 TraceCallStack& cmdBufCallstack = graphics.mCommandBufferCallStack;
3897 TraceCallStack& graphicsCallstack = graphics.mCallStack;
3898 cmdBufCallstack.Enable(true);
3899 graphicsCallstack.Enable(true);
3901 application.SendNotification();
3902 application.Render();
3904 DALI_TEST_CHECK(graphicsCallstack.FindMethod("SubmitCommandBuffers"));
3905 std::vector<Graphics::SubmitInfo>& submissions = graphics.mSubmitStack;
3906 DALI_TEST_CHECK(submissions.size() > 0);
3908 TestGraphicsCommandBuffer* cmdBuf = static_cast<TestGraphicsCommandBuffer*>((submissions.back().cmdBuffer[0]));
3910 auto result = cmdBuf->GetChildCommandsByType(0 | CommandType::BIND_PIPELINE);
3911 auto pipeline = result[0]->data.bindPipeline.pipeline;
3915 DALI_TEST_EQUALS(pipeline->vertexInputState.attributes.size(), 12, TEST_LOCATION);
3916 DALI_TEST_EQUALS(pipeline->vertexInputState.attributes[3].location, // 4th requested attr: aTexCoord2
3919 DALI_TEST_EQUALS(pipeline->vertexInputState.attributes[3].format, // 4th requested attr: aTexCoord2
3920 Graphics::VertexInputFormat::FVECTOR3,
3927 int UtcDaliRendererUniformArrayOfStruct(void)
3929 TestApplication application;
3930 tet_infoline("Test that uniforms that are elements of arrays of structs can be accessed");
3932 std::vector<UniformData> customUniforms{{"arrayof[10].color", Property::VECTOR4},
3933 {"arrayof[10].position", Property::VECTOR2},
3934 {"arrayof[10].normal", Property::VECTOR3}};
3936 application.GetGraphicsController().AddCustomUniforms(customUniforms);
3938 Geometry geometry = CreateQuadGeometry();
3939 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
3940 Renderer renderer = Renderer::New(geometry, shader);
3941 Actor actor = Actor::New();
3942 actor.AddRenderer(renderer);
3943 actor[Actor::Property::SIZE] = Vector2(120, 120);
3944 application.GetScene().Add(actor);
3946 // Define some properties to match the custom uniforms.
3947 // Ensure they can be written & read back from the abstraction.
3949 struct UniformIndexPair
3951 Property::Index index;
3953 UniformIndexPair(Property::Index index, std::string name)
3959 std::vector<UniformIndexPair> uniformIndices;
3961 std::ostringstream oss;
3962 for(int i = 0; i < 10; ++i)
3964 Property::Index index;
3965 oss << "arrayof[" << i << "].color";
3966 Vector4 color = Color::WHITE;
3967 color.r = 25.5f * i;
3968 index = renderer.RegisterProperty(oss.str(), color);
3969 uniformIndices.emplace_back(index, oss.str());
3973 oss << "arrayof[" << i << "].position";
3974 Vector2 pos(i, 10 + i * 5);
3975 index = renderer.RegisterProperty(oss.str(), pos);
3976 uniformIndices.emplace_back(index, oss.str());
3980 oss << "arrayof[" << i << "].normal";
3981 Vector3 normal(i, i * 10, i * 100);
3982 index = renderer.RegisterProperty(oss.str(), normal);
3983 uniformIndices.emplace_back(index, oss.str());
3987 auto& gl = application.GetGlAbstraction();
3988 TraceCallStack& callStack = gl.GetSetUniformTrace();
3989 gl.EnableSetUniformCallTrace(true);
3991 application.SendNotification();
3992 application.Render();
3994 // Check that the uniforms match.
3995 TraceCallStack::NamedParams params;
3996 for(auto& uniformInfo : uniformIndices)
3998 Property::Value value = renderer.GetProperty(uniformInfo.index);
3999 switch(value.GetType())
4001 case Property::VECTOR2:
4003 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniformInfo.name, params));
4005 DALI_TEST_CHECK(gl.GetUniformValue<Vector2>(uniformInfo.name.c_str(), setValue));
4006 DALI_TEST_EQUALS(value.Get<Vector2>(), setValue, 0.001f, TEST_LOCATION);
4009 case Property::VECTOR3:
4011 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniformInfo.name, params));
4013 DALI_TEST_CHECK(gl.GetUniformValue<Vector3>(uniformInfo.name.c_str(), setValue));
4014 DALI_TEST_EQUALS(value.Get<Vector3>(), setValue, 0.001f, TEST_LOCATION);
4017 case Property::VECTOR4:
4019 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniformInfo.name, params));
4021 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>(uniformInfo.name.c_str(), setValue));
4022 DALI_TEST_EQUALS(value.Get<Vector4>(), setValue, 0.001f, TEST_LOCATION);
4030 // There is a hash in the property name's uniform map: check this in debugger
4031 // There is a hash in the reflection. Check this in the debugger.
4033 // Check that the reflection contains individual locs for each array entry's struct element
4034 // and that it hashes the whole string
4036 // Ensure that the property name's hash is also for the whole string.
4041 int utcDaliRendererPartialUpdateChangeUniform(void)
4043 TestApplication application(
4044 TestApplication::DEFAULT_SURFACE_WIDTH,
4045 TestApplication::DEFAULT_SURFACE_HEIGHT,
4046 TestApplication::DEFAULT_HORIZONTAL_DPI,
4047 TestApplication::DEFAULT_VERTICAL_DPI,
4051 tet_infoline("Check the damaged rect with changing uniform");
4053 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
4055 std::vector<Rect<int>> damagedRects;
4056 Rect<int> clippingRect;
4057 application.SendNotification();
4058 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
4060 // First render pass, nothing to render, adaptor would just do swap buffer.
4061 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
4062 application.RenderWithPartialUpdate(damagedRects, clippingRect);
4064 Shader shader = Shader::New("VertexSource", "FragmentSource");
4065 Geometry geometry = CreateQuadGeometry();
4066 Renderer renderer = Renderer::New(geometry, shader);
4068 Property::Index colorIndex = renderer.RegisterProperty("uFadeColor", Color::WHITE);
4070 Actor actor = Actor::New();
4071 actor.AddRenderer(renderer);
4072 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4073 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
4074 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
4075 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4076 Stage::GetCurrent().Add(actor);
4078 application.SendNotification();
4080 // 1. Actor added, damaged rect is added size of actor
4081 damagedRects.clear();
4082 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
4083 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
4086 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
4087 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
4088 application.RenderWithPartialUpdate(damagedRects, clippingRect);
4089 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
4090 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
4091 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
4092 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
4094 damagedRects.clear();
4095 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
4096 application.RenderWithPartialUpdate(damagedRects, clippingRect);
4098 // Ensure the damaged rect is empty
4099 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
4101 // 2. Change the uniform value
4102 renderer.SetProperty(colorIndex, Color::RED);
4103 application.SendNotification();
4105 damagedRects.clear();
4106 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
4107 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
4110 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
4111 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
4112 application.RenderWithPartialUpdate(damagedRects, clippingRect);
4113 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
4114 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
4115 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
4116 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
4118 damagedRects.clear();
4119 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
4120 application.RenderWithPartialUpdate(damagedRects, clippingRect);
4122 // 3. Change the uniform value and another property together
4123 actor.SetProperty(Actor::Property::COLOR, Color::YELLOW);
4124 renderer.SetProperty(colorIndex, Color::BLUE);
4125 application.SendNotification();
4127 damagedRects.clear();
4128 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
4129 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
4132 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
4133 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
4134 application.RenderWithPartialUpdate(damagedRects, clippingRect);
4135 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
4136 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
4137 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
4138 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
4140 damagedRects.clear();
4141 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
4142 application.RenderWithPartialUpdate(damagedRects, clippingRect);
4144 // 4. Change the uniform value only
4145 renderer.SetProperty(colorIndex, Color::RED); // Set the previous value (#2)
4146 application.SendNotification();
4148 damagedRects.clear();
4149 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
4150 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
4153 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
4154 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
4155 application.RenderWithPartialUpdate(damagedRects, clippingRect);
4156 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
4157 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
4158 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
4159 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
4164 int utcDaliRendererPartialUpdateAddRemoveRenderer(void)
4166 TestApplication application(
4167 TestApplication::DEFAULT_SURFACE_WIDTH,
4168 TestApplication::DEFAULT_SURFACE_HEIGHT,
4169 TestApplication::DEFAULT_HORIZONTAL_DPI,
4170 TestApplication::DEFAULT_VERTICAL_DPI,
4174 tet_infoline("Check the damaged rect with adding / removing renderer");
4176 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
4178 Shader shader = Shader::New("VertexSource", "FragmentSource");
4179 Geometry geometry = CreateQuadGeometry();
4180 Renderer renderer = Renderer::New(geometry, shader);
4182 Actor actor = Actor::New();
4183 actor.AddRenderer(renderer);
4184 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4185 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
4186 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
4187 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4188 Stage::GetCurrent().Add(actor);
4190 application.SendNotification();
4192 std::vector<Rect<int>> damagedRects;
4193 Rect<int> clippingRect;
4195 // 1. Actor added, damaged rect is added size of actor
4196 damagedRects.clear();
4197 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
4198 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
4201 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
4202 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
4203 application.RenderWithPartialUpdate(damagedRects, clippingRect);
4204 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
4205 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
4206 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
4207 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
4209 // 2. Remove renderer
4210 actor.RemoveRenderer(renderer);
4211 application.SendNotification();
4213 damagedRects.clear();
4214 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
4216 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
4217 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
4219 application.RenderWithPartialUpdate(damagedRects, clippingRect);
4221 // 3. Change a property value of the Renderer
4222 renderer.SetProperty(DevelRenderer::Property::OPACITY, 0.5f);
4223 application.SendNotification();
4225 damagedRects.clear();
4226 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
4228 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
4230 application.RenderWithPartialUpdate(damagedRects, clippingRect);
4232 // 4. Add renderer again
4233 actor.AddRenderer(renderer);
4234 application.SendNotification();
4236 damagedRects.clear();
4237 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
4239 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
4240 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
4242 application.RenderWithPartialUpdate(damagedRects, clippingRect);
4244 // 5. Remove renderer agin
4245 actor.RemoveRenderer(renderer);
4246 application.SendNotification();
4248 damagedRects.clear();
4249 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
4251 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
4252 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
4254 application.RenderWithPartialUpdate(damagedRects, clippingRect);