X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali%2Futc-Dali-Renderer.cpp;h=763fa6798e6bc37a659bd630409111c56618d13b;hb=c4750afbf79f15bf71e2aa8ef54f84750463aae2;hp=00f503880103c2463e3d80593ae2941a7e80fa5f;hpb=8de71324ecc174553fce43619f4e6bef82657a45;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/automated-tests/src/dali/utc-Dali-Renderer.cpp b/automated-tests/src/dali/utc-Dali-Renderer.cpp index 00f5038..763fa67 100644 --- a/automated-tests/src/dali/utc-Dali-Renderer.cpp +++ b/automated-tests/src/dali/utc-Dali-Renderer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,30 +17,31 @@ // EXTERNAL INCLUDES #include +#include +#include #include - -#include #include +#include #include #include // INTERNAL INCLUDES #include -#include #include +#include +#include "test-graphics-command-buffer.h" using namespace Dali; namespace // unnamed namespace { +const BlendFactor::Type DEFAULT_BLEND_FACTOR_SRC_RGB(BlendFactor::SRC_ALPHA); +const BlendFactor::Type DEFAULT_BLEND_FACTOR_DEST_RGB(BlendFactor::ONE_MINUS_SRC_ALPHA); +const BlendFactor::Type DEFAULT_BLEND_FACTOR_SRC_ALPHA(BlendFactor::ONE); +const BlendFactor::Type DEFAULT_BLEND_FACTOR_DEST_ALPHA(BlendFactor::ONE_MINUS_SRC_ALPHA); -const BlendFactor::Type DEFAULT_BLEND_FACTOR_SRC_RGB( BlendFactor::SRC_ALPHA ); -const BlendFactor::Type DEFAULT_BLEND_FACTOR_DEST_RGB( BlendFactor::ONE_MINUS_SRC_ALPHA ); -const BlendFactor::Type DEFAULT_BLEND_FACTOR_SRC_ALPHA( BlendFactor::ONE ); -const BlendFactor::Type DEFAULT_BLEND_FACTOR_DEST_ALPHA( BlendFactor::ONE_MINUS_SRC_ALPHA ); - -const BlendEquation::Type DEFAULT_BLEND_EQUATION_RGB( BlendEquation::ADD ); -const BlendEquation::Type DEFAULT_BLEND_EQUATION_ALPHA( BlendEquation::ADD ); +const BlendEquation::Type DEFAULT_BLEND_EQUATION_RGB(BlendEquation::ADD); +const BlendEquation::Type DEFAULT_BLEND_EQUATION_ALPHA(BlendEquation::ADD); /** * @brief Get GL stencil test enumeration value as a string. @@ -49,7 +50,7 @@ const BlendEquation::Type DEFAULT_BLEND_EQUATION_ALPHA( BlendEquation::ADD ); std::string GetStencilTestString(void) { std::stringstream stream; - stream << GL_STENCIL_TEST; + stream << std::hex << GL_STENCIL_TEST; return stream.str(); } @@ -60,11 +61,11 @@ std::string GetStencilTestString(void) std::string GetDepthTestString(void) { std::stringstream stream; - stream << GL_DEPTH_TEST; + stream << std::hex << GL_DEPTH_TEST; return stream.str(); } -void ResetDebugAndFlush( TestApplication& application, TraceCallStack& glEnableDisableStack, TraceCallStack& glStencilFunctionStack ) +void ResetDebugAndFlush(TestApplication& application, TraceCallStack& glEnableDisableStack, TraceCallStack& glStencilFunctionStack) { glEnableDisableStack.Reset(); glStencilFunctionStack.Reset(); @@ -72,11 +73,36 @@ void ResetDebugAndFlush( TestApplication& application, TraceCallStack& glEnableD application.Render(); } -void TestConstraintNoBlue( Vector4& current, const PropertyInputContainer& inputs ) +void TestConstraintNoBlue(Vector4& current, const PropertyInputContainer& inputs) { current.b = 0.0f; } +Renderer CreateRenderer(Actor actor, Geometry geometry, Shader shader, int depthIndex) +{ + Texture image0 = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGB888, 64, 64); + TextureSet textureSet0 = CreateTextureSet(image0); + Renderer renderer0 = Renderer::New(geometry, shader); + renderer0.SetTextures(textureSet0); + renderer0.SetProperty(Renderer::Property::DEPTH_INDEX, depthIndex); + actor.AddRenderer(renderer0); + return renderer0; +} + +Actor CreateActor(Actor parent, int siblingOrder, const char* location) +{ + Actor actor = Actor::New(); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + actor.SetProperty(Actor::Property::PARENT_ORIGIN, AnchorPoint::CENTER); + actor.SetProperty(Actor::Property::POSITION, Vector2(0.0f, 0.0f)); + actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + parent.Add(actor); + actor.SetProperty(Dali::DevelActor::Property::SIBLING_ORDER, siblingOrder); + DALI_TEST_EQUALS(actor.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER), siblingOrder, TEST_INNER_LOCATION(location)); + + return actor; +} + } // unnamed namespace void renderer_test_startup(void) @@ -94,18 +120,18 @@ int UtcDaliRendererNew01(void) TestApplication application; Geometry geometry = CreateQuadGeometry(); - Shader shader = CreateShader(); + Shader shader = CreateShader(); Renderer renderer = Renderer::New(geometry, shader); - DALI_TEST_EQUALS( (bool)renderer, true, TEST_LOCATION ); + DALI_TEST_EQUALS((bool)renderer, true, TEST_LOCATION); END_TEST; } int UtcDaliRendererNew02(void) { TestApplication application; - Renderer renderer; - DALI_TEST_EQUALS( (bool)renderer, false, TEST_LOCATION ); + Renderer renderer; + DALI_TEST_EQUALS((bool)renderer, false, TEST_LOCATION); END_TEST; } @@ -114,11 +140,11 @@ int UtcDaliRendererCopyConstructor(void) TestApplication application; Geometry geometry = CreateQuadGeometry(); - Shader shader = CreateShader(); + Shader shader = CreateShader(); Renderer renderer = Renderer::New(geometry, shader); - Renderer rendererCopy( renderer ); - DALI_TEST_EQUALS( (bool)rendererCopy, true, TEST_LOCATION ); + Renderer rendererCopy(renderer); + DALI_TEST_EQUALS((bool)rendererCopy, true, TEST_LOCATION); END_TEST; } @@ -128,14 +154,65 @@ int UtcDaliRendererAssignmentOperator(void) TestApplication application; Geometry geometry = CreateQuadGeometry(); - Shader shader = CreateShader(); + Shader shader = CreateShader(); Renderer renderer = Renderer::New(geometry, shader); Renderer renderer2; - DALI_TEST_EQUALS( (bool)renderer2, false, TEST_LOCATION ); + DALI_TEST_EQUALS((bool)renderer2, false, TEST_LOCATION); renderer2 = renderer; - DALI_TEST_EQUALS( (bool)renderer2, true, TEST_LOCATION ); + DALI_TEST_EQUALS((bool)renderer2, true, TEST_LOCATION); + END_TEST; +} + +int UtcDaliRendererMoveConstructor(void) +{ + TestApplication application; + + Geometry geometry = CreateQuadGeometry(); + Shader shader = Shader::New("vertexSrc", "fragmentSrc"); + Renderer renderer = Renderer::New(geometry, shader); + DALI_TEST_CHECK(renderer); + DALI_TEST_EQUALS(1, renderer.GetBaseObject().ReferenceCount(), TEST_LOCATION); + DALI_TEST_EQUALS(renderer.GetProperty(Renderer::Property::BLEND_COLOR), Color::TRANSPARENT, TEST_LOCATION); + + renderer.SetProperty(Renderer::Property::BLEND_COLOR, Color::MAGENTA); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS(renderer.GetProperty(Renderer::Property::BLEND_COLOR), Color::MAGENTA, TEST_LOCATION); + + Renderer move = std::move(renderer); + DALI_TEST_CHECK(move); + DALI_TEST_EQUALS(1, move.GetBaseObject().ReferenceCount(), TEST_LOCATION); + DALI_TEST_EQUALS(move.GetProperty(Renderer::Property::BLEND_COLOR), Color::MAGENTA, TEST_LOCATION); + DALI_TEST_CHECK(!renderer); + + END_TEST; +} + +int UtcDaliRendererMoveAssignment(void) +{ + TestApplication application; + + Geometry geometry = CreateQuadGeometry(); + Shader shader = Shader::New("vertexSrc", "fragmentSrc"); + Renderer renderer = Renderer::New(geometry, shader); + DALI_TEST_CHECK(renderer); + DALI_TEST_EQUALS(1, renderer.GetBaseObject().ReferenceCount(), TEST_LOCATION); + DALI_TEST_EQUALS(renderer.GetProperty(Renderer::Property::BLEND_COLOR), Color::TRANSPARENT, TEST_LOCATION); + + renderer.SetProperty(Renderer::Property::BLEND_COLOR, Color::MAGENTA); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS(renderer.GetProperty(Renderer::Property::BLEND_COLOR), Color::MAGENTA, TEST_LOCATION); + + Renderer move; + move = std::move(renderer); + DALI_TEST_CHECK(move); + DALI_TEST_EQUALS(1, move.GetBaseObject().ReferenceCount(), TEST_LOCATION); + DALI_TEST_EQUALS(move.GetProperty(Renderer::Property::BLEND_COLOR), Color::MAGENTA, TEST_LOCATION); + DALI_TEST_CHECK(!renderer); + END_TEST; } @@ -144,12 +221,12 @@ int UtcDaliRendererDownCast01(void) TestApplication application; Geometry geometry = CreateQuadGeometry(); - Shader shader = CreateShader(); + Shader shader = CreateShader(); Renderer renderer = Renderer::New(geometry, shader); BaseHandle handle(renderer); - Renderer renderer2 = Renderer::DownCast(handle); - DALI_TEST_EQUALS( (bool)renderer2, true, TEST_LOCATION ); + Renderer renderer2 = Renderer::DownCast(handle); + DALI_TEST_EQUALS((bool)renderer2, true, TEST_LOCATION); END_TEST; } @@ -157,28 +234,28 @@ int UtcDaliRendererDownCast02(void) { TestApplication application; - Handle handle = Handle::New(); // Create a custom object + Handle handle = Handle::New(); // Create a custom object Renderer renderer = Renderer::DownCast(handle); - DALI_TEST_EQUALS( (bool)renderer, false, TEST_LOCATION ); + DALI_TEST_EQUALS((bool)renderer, false, TEST_LOCATION); END_TEST; } // using a template to auto deduce the parameter types -template< typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8> -void TEST_RENDERER_PROPERTY( P1 renderer, P2 stringName, P3 type, P4 isWriteable, P5 isAnimateable, P6 isConstraintInput, P7 enumName, P8 LOCATION ) +template +void TEST_RENDERER_PROPERTY(P1 renderer, P2 stringName, P3 type, P4 isWriteable, P5 isAnimateable, P6 isConstraintInput, P7 enumName, P8 LOCATION) { - DALI_TEST_EQUALS( renderer.GetPropertyName( enumName ), stringName, LOCATION ); - DALI_TEST_EQUALS( renderer.GetPropertyIndex( stringName ), static_cast(enumName), LOCATION ); - DALI_TEST_EQUALS( renderer.GetPropertyType( enumName ), type, LOCATION ); - DALI_TEST_EQUALS( renderer.IsPropertyWritable( enumName ), isWriteable, LOCATION ); - DALI_TEST_EQUALS( renderer.IsPropertyAnimatable( enumName ), isAnimateable, LOCATION ); - DALI_TEST_EQUALS( renderer.IsPropertyAConstraintInput( enumName ), isConstraintInput, LOCATION ); + DALI_TEST_EQUALS(renderer.GetPropertyName(enumName), stringName, LOCATION); + DALI_TEST_EQUALS(renderer.GetPropertyIndex(stringName), static_cast(enumName), LOCATION); + DALI_TEST_EQUALS(renderer.GetPropertyType(enumName), type, LOCATION); + DALI_TEST_EQUALS(renderer.IsPropertyWritable(enumName), isWriteable, LOCATION); + DALI_TEST_EQUALS(renderer.IsPropertyAnimatable(enumName), isAnimateable, LOCATION); + DALI_TEST_EQUALS(renderer.IsPropertyAConstraintInput(enumName), isConstraintInput, LOCATION); } int UtcDaliRendererDefaultProperties(void) { TestApplication application; -/* from renderer-impl.cpp + /* from renderer-impl.cpp DALI_PROPERTY( "depthIndex", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_INDEX ) DALI_PROPERTY( "faceCullingMode", INTEGER, true, false, false, Dali::Renderer::Property::FACE_CULLING_MODE ) DALI_PROPERTY( "blendMode", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_MODE ) @@ -205,39 +282,41 @@ int UtcDaliRendererDefaultProperties(void) DALI_PROPERTY( "stencilOperationOnZPass", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_PASS ) DALI_PROPERTY( "opacity", FLOAT, true, true, true, Dali::DevelRenderer::Property::OPACITY ) DALI_PROPERTY( "renderingBehavior", INTEGER, true, false, false, Dali::DevelRenderer::Property::RENDERING_BEHAVIOR ) + DALI_PROPERTY( "blendEquation", INTEGER, true, false, false, Dali::DevelRenderer::Property::BLEND_EQUATION ) */ Geometry geometry = CreateQuadGeometry(); - Shader shader = CreateShader(); + Shader shader = CreateShader(); Renderer renderer = Renderer::New(geometry, shader); - DALI_TEST_EQUALS( renderer.GetPropertyCount(), 26, TEST_LOCATION ); - - TEST_RENDERER_PROPERTY( renderer, "depthIndex", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_INDEX, TEST_LOCATION ); - TEST_RENDERER_PROPERTY( renderer, "faceCullingMode", Property::INTEGER, true, false, false, Renderer::Property::FACE_CULLING_MODE, TEST_LOCATION ); - TEST_RENDERER_PROPERTY( renderer, "blendMode", Property::INTEGER, true, false, false, Renderer::Property::BLEND_MODE, TEST_LOCATION ); - TEST_RENDERER_PROPERTY( renderer, "blendEquationRgb", Property::INTEGER, true, false, false, Renderer::Property::BLEND_EQUATION_RGB, TEST_LOCATION ); - TEST_RENDERER_PROPERTY( renderer, "blendEquationAlpha", Property::INTEGER, true, false, false, Renderer::Property::BLEND_EQUATION_ALPHA, TEST_LOCATION ); - TEST_RENDERER_PROPERTY( renderer, "blendFactorSrcRgb", Property::INTEGER, true, false, false, Renderer::Property::BLEND_FACTOR_SRC_RGB, TEST_LOCATION ); - TEST_RENDERER_PROPERTY( renderer, "blendFactorDestRgb", Property::INTEGER, true, false, false, Renderer::Property::BLEND_FACTOR_DEST_RGB, TEST_LOCATION ); - TEST_RENDERER_PROPERTY( renderer, "blendFactorSrcAlpha", Property::INTEGER, true, false, false, Renderer::Property::BLEND_FACTOR_SRC_ALPHA, TEST_LOCATION ); - TEST_RENDERER_PROPERTY( renderer, "blendFactorDestAlpha", Property::INTEGER, true, false, false, Renderer::Property::BLEND_FACTOR_DEST_ALPHA, TEST_LOCATION ); - TEST_RENDERER_PROPERTY( renderer, "blendColor", Property::VECTOR4, true, false, false, Renderer::Property::BLEND_COLOR, TEST_LOCATION ); - TEST_RENDERER_PROPERTY( renderer, "blendPreMultipliedAlpha", Property::BOOLEAN, true, false, false, Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, TEST_LOCATION ); - TEST_RENDERER_PROPERTY( renderer, "indexRangeFirst", Property::INTEGER, true, false, false, Renderer::Property::INDEX_RANGE_FIRST, TEST_LOCATION ); - TEST_RENDERER_PROPERTY( renderer, "indexRangeCount", Property::INTEGER, true, false, false, Renderer::Property::INDEX_RANGE_COUNT, TEST_LOCATION ); - TEST_RENDERER_PROPERTY( renderer, "depthWriteMode", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_WRITE_MODE, TEST_LOCATION ); - TEST_RENDERER_PROPERTY( renderer, "depthFunction", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_FUNCTION, TEST_LOCATION ); - TEST_RENDERER_PROPERTY( renderer, "depthTestMode", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_TEST_MODE, TEST_LOCATION ); - TEST_RENDERER_PROPERTY( renderer, "renderMode", Property::INTEGER, true, false, false, Renderer::Property::RENDER_MODE, TEST_LOCATION ); - TEST_RENDERER_PROPERTY( renderer, "stencilFunction", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_FUNCTION, TEST_LOCATION ); - TEST_RENDERER_PROPERTY( renderer, "stencilFunctionMask", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_FUNCTION_MASK, TEST_LOCATION ); - TEST_RENDERER_PROPERTY( renderer, "stencilFunctionReference",Property::INTEGER, true, false, false, Renderer::Property::STENCIL_FUNCTION_REFERENCE, TEST_LOCATION ); - TEST_RENDERER_PROPERTY( renderer, "stencilMask", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_MASK, TEST_LOCATION ); - TEST_RENDERER_PROPERTY( renderer, "stencilOperationOnFail", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_OPERATION_ON_FAIL, TEST_LOCATION ); - TEST_RENDERER_PROPERTY( renderer, "stencilOperationOnZFail", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, TEST_LOCATION ); - TEST_RENDERER_PROPERTY( renderer, "stencilOperationOnZPass", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, TEST_LOCATION ); - TEST_RENDERER_PROPERTY( renderer, "opacity", Property::FLOAT, true, true, true, DevelRenderer::Property::OPACITY, TEST_LOCATION ); - TEST_RENDERER_PROPERTY( renderer, "renderingBehavior", Property::INTEGER, true, false, false, DevelRenderer::Property::RENDERING_BEHAVIOR, TEST_LOCATION ); + DALI_TEST_EQUALS(renderer.GetPropertyCount(), 27, TEST_LOCATION); + + TEST_RENDERER_PROPERTY(renderer, "depthIndex", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_INDEX, TEST_LOCATION); + TEST_RENDERER_PROPERTY(renderer, "faceCullingMode", Property::INTEGER, true, false, false, Renderer::Property::FACE_CULLING_MODE, TEST_LOCATION); + TEST_RENDERER_PROPERTY(renderer, "blendMode", Property::INTEGER, true, false, false, Renderer::Property::BLEND_MODE, TEST_LOCATION); + TEST_RENDERER_PROPERTY(renderer, "blendEquationRgb", Property::INTEGER, true, false, false, Renderer::Property::BLEND_EQUATION_RGB, TEST_LOCATION); + TEST_RENDERER_PROPERTY(renderer, "blendEquationAlpha", Property::INTEGER, true, false, false, Renderer::Property::BLEND_EQUATION_ALPHA, TEST_LOCATION); + TEST_RENDERER_PROPERTY(renderer, "blendFactorSrcRgb", Property::INTEGER, true, false, false, Renderer::Property::BLEND_FACTOR_SRC_RGB, TEST_LOCATION); + TEST_RENDERER_PROPERTY(renderer, "blendFactorDestRgb", Property::INTEGER, true, false, false, Renderer::Property::BLEND_FACTOR_DEST_RGB, TEST_LOCATION); + TEST_RENDERER_PROPERTY(renderer, "blendFactorSrcAlpha", Property::INTEGER, true, false, false, Renderer::Property::BLEND_FACTOR_SRC_ALPHA, TEST_LOCATION); + TEST_RENDERER_PROPERTY(renderer, "blendFactorDestAlpha", Property::INTEGER, true, false, false, Renderer::Property::BLEND_FACTOR_DEST_ALPHA, TEST_LOCATION); + TEST_RENDERER_PROPERTY(renderer, "blendColor", Property::VECTOR4, true, false, false, Renderer::Property::BLEND_COLOR, TEST_LOCATION); + TEST_RENDERER_PROPERTY(renderer, "blendPreMultipliedAlpha", Property::BOOLEAN, true, false, false, Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, TEST_LOCATION); + TEST_RENDERER_PROPERTY(renderer, "indexRangeFirst", Property::INTEGER, true, false, false, Renderer::Property::INDEX_RANGE_FIRST, TEST_LOCATION); + TEST_RENDERER_PROPERTY(renderer, "indexRangeCount", Property::INTEGER, true, false, false, Renderer::Property::INDEX_RANGE_COUNT, TEST_LOCATION); + TEST_RENDERER_PROPERTY(renderer, "depthWriteMode", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_WRITE_MODE, TEST_LOCATION); + TEST_RENDERER_PROPERTY(renderer, "depthFunction", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_FUNCTION, TEST_LOCATION); + TEST_RENDERER_PROPERTY(renderer, "depthTestMode", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_TEST_MODE, TEST_LOCATION); + TEST_RENDERER_PROPERTY(renderer, "renderMode", Property::INTEGER, true, false, false, Renderer::Property::RENDER_MODE, TEST_LOCATION); + TEST_RENDERER_PROPERTY(renderer, "stencilFunction", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_FUNCTION, TEST_LOCATION); + TEST_RENDERER_PROPERTY(renderer, "stencilFunctionMask", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_FUNCTION_MASK, TEST_LOCATION); + TEST_RENDERER_PROPERTY(renderer, "stencilFunctionReference", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_FUNCTION_REFERENCE, TEST_LOCATION); + TEST_RENDERER_PROPERTY(renderer, "stencilMask", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_MASK, TEST_LOCATION); + TEST_RENDERER_PROPERTY(renderer, "stencilOperationOnFail", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_OPERATION_ON_FAIL, TEST_LOCATION); + TEST_RENDERER_PROPERTY(renderer, "stencilOperationOnZFail", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, TEST_LOCATION); + TEST_RENDERER_PROPERTY(renderer, "stencilOperationOnZPass", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, TEST_LOCATION); + TEST_RENDERER_PROPERTY(renderer, "opacity", Property::FLOAT, true, true, true, DevelRenderer::Property::OPACITY, TEST_LOCATION); + TEST_RENDERER_PROPERTY(renderer, "renderingBehavior", Property::INTEGER, true, false, false, DevelRenderer::Property::RENDERING_BEHAVIOR, TEST_LOCATION); + TEST_RENDERER_PROPERTY(renderer, "blendEquation", Property::INTEGER, true, false, false, DevelRenderer::Property::BLEND_EQUATION, TEST_LOCATION); END_TEST; } @@ -245,28 +324,28 @@ int UtcDaliRendererDefaultProperties(void) int UtcDaliRendererSetGetGeometry(void) { TestApplication application; - tet_infoline( "Test SetGeometry, GetGeometry" ); + tet_infoline("Test SetGeometry, GetGeometry"); Geometry geometry1 = CreateQuadGeometry(); Geometry geometry2 = CreateQuadGeometry(); - Shader shader = CreateShader(); + Shader shader = CreateShader(); Renderer renderer = Renderer::New(geometry1, shader); - Actor actor = Actor::New(); + Actor actor = Actor::New(); actor.AddRenderer(renderer); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); application.GetScene().Add(actor); application.SendNotification(); application.Render(0); - DALI_TEST_EQUALS( renderer.GetGeometry(), geometry1, TEST_LOCATION ); + DALI_TEST_EQUALS(renderer.GetGeometry(), geometry1, TEST_LOCATION); // Set geometry2 to the renderer - renderer.SetGeometry( geometry2 ); + renderer.SetGeometry(geometry2); application.SendNotification(); application.Render(0); - DALI_TEST_EQUALS( renderer.GetGeometry(), geometry2, TEST_LOCATION ); + DALI_TEST_EQUALS(renderer.GetGeometry(), geometry2, TEST_LOCATION); END_TEST; } @@ -274,22 +353,22 @@ int UtcDaliRendererSetGetGeometry(void) int UtcDaliRendererSetGetShader(void) { TestApplication application; - tet_infoline( "Test SetShader, GetShader" ); + tet_infoline("Test SetShader, GetShader"); TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); glAbstraction.EnableCullFaceCallTrace(true); Shader shader1 = CreateShader(); - shader1.RegisterProperty( "uFadeColor", Color::RED ); + shader1.RegisterProperty("uFadeColor", Color::RED); Shader shader2 = CreateShader(); - shader2.RegisterProperty( "uFadeColor", Color::GREEN ); + shader2.RegisterProperty("uFadeColor", Color::GREEN); Geometry geometry = CreateQuadGeometry(); Renderer renderer = Renderer::New(geometry, shader1); - Actor actor = Actor::New(); + Actor actor = Actor::New(); actor.AddRenderer(renderer); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); application.GetScene().Add(actor); TestGlAbstraction& gl = application.GetGlAbstraction(); @@ -298,22 +377,22 @@ int UtcDaliRendererSetGetShader(void) // Expect that the first shaders's fade color property is accessed Vector4 actualValue(Vector4::ZERO); - DALI_TEST_CHECK( gl.GetUniformValue( "uFadeColor", actualValue ) ); - DALI_TEST_EQUALS( actualValue, Color::RED, TEST_LOCATION ); + DALI_TEST_CHECK(gl.GetUniformValue("uFadeColor", actualValue)); + DALI_TEST_EQUALS(actualValue, Color::RED, TEST_LOCATION); - DALI_TEST_EQUALS( renderer.GetShader(), shader1, TEST_LOCATION ); + DALI_TEST_EQUALS(renderer.GetShader(), shader1, TEST_LOCATION); // set the second shader to the renderer - renderer.SetShader( shader2 ); + renderer.SetShader(shader2); application.SendNotification(); application.Render(0); // Expect that the second shader's fade color property is accessed - DALI_TEST_CHECK( gl.GetUniformValue( "uFadeColor", actualValue ) ); - DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION ); + DALI_TEST_CHECK(gl.GetUniformValue("uFadeColor", actualValue)); + DALI_TEST_EQUALS(actualValue, Color::GREEN, TEST_LOCATION); - DALI_TEST_EQUALS( renderer.GetShader(), shader2, TEST_LOCATION ); + DALI_TEST_EQUALS(renderer.GetShader(), shader2, TEST_LOCATION); END_TEST; } @@ -324,35 +403,35 @@ int UtcDaliRendererSetGetDepthIndex(void) tet_infoline("Test SetDepthIndex, GetDepthIndex"); - Shader shader = CreateShader(); + Shader shader = CreateShader(); Geometry geometry = CreateQuadGeometry(); Renderer renderer = Renderer::New(geometry, shader); - Actor actor = Actor::New(); + Actor actor = Actor::New(); actor.AddRenderer(renderer); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); application.GetScene().Add(actor); application.SendNotification(); application.Render(0); - DALI_TEST_EQUALS( renderer.GetProperty(Renderer::Property::DEPTH_INDEX), 0, TEST_LOCATION ); + DALI_TEST_EQUALS(renderer.GetProperty(Renderer::Property::DEPTH_INDEX), 0, TEST_LOCATION); - renderer.SetProperty( Renderer::Property::DEPTH_INDEX, 1 ); + renderer.SetProperty(Renderer::Property::DEPTH_INDEX, 1); - DALI_TEST_EQUALS( renderer.GetProperty(Renderer::Property::DEPTH_INDEX), 1, TEST_LOCATION ); - DALI_TEST_EQUALS( renderer.GetCurrentProperty(Renderer::Property::DEPTH_INDEX), 0, TEST_LOCATION ); + DALI_TEST_EQUALS(renderer.GetProperty(Renderer::Property::DEPTH_INDEX), 1, TEST_LOCATION); + DALI_TEST_EQUALS(renderer.GetCurrentProperty(Renderer::Property::DEPTH_INDEX), 0, TEST_LOCATION); application.SendNotification(); application.Render(0); - DALI_TEST_EQUALS( renderer.GetCurrentProperty(Renderer::Property::DEPTH_INDEX), 1, TEST_LOCATION ); + DALI_TEST_EQUALS(renderer.GetCurrentProperty(Renderer::Property::DEPTH_INDEX), 1, TEST_LOCATION); - renderer.SetProperty( Renderer::Property::DEPTH_INDEX, 10 ); + renderer.SetProperty(Renderer::Property::DEPTH_INDEX, 10); - DALI_TEST_EQUALS( renderer.GetProperty(Renderer::Property::DEPTH_INDEX), 10, TEST_LOCATION ); - DALI_TEST_EQUALS( renderer.GetCurrentProperty(Renderer::Property::DEPTH_INDEX), 1, TEST_LOCATION ); + DALI_TEST_EQUALS(renderer.GetProperty(Renderer::Property::DEPTH_INDEX), 10, TEST_LOCATION); + DALI_TEST_EQUALS(renderer.GetCurrentProperty(Renderer::Property::DEPTH_INDEX), 1, TEST_LOCATION); application.SendNotification(); application.Render(0); - DALI_TEST_EQUALS( renderer.GetCurrentProperty(Renderer::Property::DEPTH_INDEX), 10, TEST_LOCATION ); + DALI_TEST_EQUALS(renderer.GetCurrentProperty(Renderer::Property::DEPTH_INDEX), 10, TEST_LOCATION); END_TEST; } @@ -363,79 +442,79 @@ int UtcDaliRendererSetGetFaceCullingMode(void) tet_infoline("Test SetFaceCullingMode(cullingMode)"); Geometry geometry = CreateQuadGeometry(); - Shader shader = CreateShader(); - Renderer renderer = Renderer::New( geometry, shader ); + Shader shader = CreateShader(); + Renderer renderer = Renderer::New(geometry, shader); Actor actor = Actor::New(); actor.AddRenderer(renderer); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); application.GetScene().Add(actor); // By default, none of the faces should be culled - unsigned int cullFace = renderer.GetProperty( Renderer::Property::FACE_CULLING_MODE ); - DALI_TEST_CHECK( static_cast< FaceCullingMode::Type >( cullFace ) == FaceCullingMode::NONE ); + unsigned int cullFace = renderer.GetProperty(Renderer::Property::FACE_CULLING_MODE); + DALI_TEST_CHECK(static_cast(cullFace) == FaceCullingMode::NONE); - TestGlAbstraction& gl = application.GetGlAbstraction(); - TraceCallStack& cullFaceStack = gl.GetCullFaceTrace(); + TestGlAbstraction& gl = application.GetGlAbstraction(); + TraceCallStack& cullFaceStack = gl.GetCullFaceTrace(); gl.EnableCullFaceCallTrace(true); { cullFaceStack.Reset(); - renderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::FRONT_AND_BACK ); + renderer.SetProperty(Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::FRONT_AND_BACK); application.SendNotification(); application.Render(); - DALI_TEST_EQUALS( cullFaceStack.CountMethod( "CullFace" ), 1, TEST_LOCATION ); + DALI_TEST_EQUALS(cullFaceStack.CountMethod("CullFace"), 1, TEST_LOCATION); std::ostringstream cullModeString; - cullModeString << GL_FRONT_AND_BACK; + cullModeString << std::hex << GL_FRONT_AND_BACK; - DALI_TEST_CHECK( cullFaceStack.FindMethodAndParams( "CullFace", cullModeString.str() ) ); - cullFace = renderer.GetProperty( Renderer::Property::FACE_CULLING_MODE ); - DALI_TEST_CHECK( static_cast< FaceCullingMode::Type >( cullFace ) == FaceCullingMode::FRONT_AND_BACK ); + DALI_TEST_CHECK(cullFaceStack.FindMethodAndParams("CullFace", cullModeString.str())); + cullFace = renderer.GetProperty(Renderer::Property::FACE_CULLING_MODE); + DALI_TEST_CHECK(static_cast(cullFace) == FaceCullingMode::FRONT_AND_BACK); } { cullFaceStack.Reset(); - renderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::BACK ); + renderer.SetProperty(Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::BACK); application.SendNotification(); application.Render(); - DALI_TEST_EQUALS( cullFaceStack.CountMethod( "CullFace" ), 1, TEST_LOCATION ); + DALI_TEST_EQUALS(cullFaceStack.CountMethod("CullFace"), 1, TEST_LOCATION); std::ostringstream cullModeString; - cullModeString << GL_BACK; + cullModeString << std::hex << GL_BACK; - DALI_TEST_CHECK( cullFaceStack.FindMethodAndParams( "CullFace", cullModeString.str() ) ); - cullFace = renderer.GetProperty( Renderer::Property::FACE_CULLING_MODE ); - DALI_TEST_CHECK( static_cast< FaceCullingMode::Type >( cullFace ) == FaceCullingMode::BACK ); + DALI_TEST_CHECK(cullFaceStack.FindMethodAndParams("CullFace", cullModeString.str())); + cullFace = renderer.GetProperty(Renderer::Property::FACE_CULLING_MODE); + DALI_TEST_CHECK(static_cast(cullFace) == FaceCullingMode::BACK); } { cullFaceStack.Reset(); - renderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::FRONT ); + renderer.SetProperty(Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::FRONT); application.SendNotification(); application.Render(); - DALI_TEST_EQUALS( cullFaceStack.CountMethod( "CullFace" ), 1, TEST_LOCATION ); + DALI_TEST_EQUALS(cullFaceStack.CountMethod("CullFace"), 1, TEST_LOCATION); std::ostringstream cullModeString; - cullModeString << GL_FRONT; + cullModeString << std::hex << GL_FRONT; - DALI_TEST_CHECK( cullFaceStack.FindMethodAndParams( "CullFace", cullModeString.str() ) ); - cullFace = renderer.GetProperty( Renderer::Property::FACE_CULLING_MODE ); - DALI_TEST_CHECK( static_cast< FaceCullingMode::Type >( cullFace ) == FaceCullingMode::FRONT ); + DALI_TEST_CHECK(cullFaceStack.FindMethodAndParams("CullFace", cullModeString.str())); + cullFace = renderer.GetProperty(Renderer::Property::FACE_CULLING_MODE); + DALI_TEST_CHECK(static_cast(cullFace) == FaceCullingMode::FRONT); } { cullFaceStack.Reset(); - renderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::NONE ); + renderer.SetProperty(Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::NONE); application.SendNotification(); application.Render(); - DALI_TEST_EQUALS( cullFaceStack.CountMethod( "CullFace" ), 0, TEST_LOCATION ); - cullFace = renderer.GetProperty( Renderer::Property::FACE_CULLING_MODE ); - DALI_TEST_CHECK( static_cast< FaceCullingMode::Type >( cullFace ) == FaceCullingMode::NONE ); + DALI_TEST_EQUALS(cullFaceStack.CountMethod("CullFace"), 0, TEST_LOCATION); + cullFace = renderer.GetProperty(Renderer::Property::FACE_CULLING_MODE); + DALI_TEST_CHECK(static_cast(cullFace) == FaceCullingMode::NONE); } END_TEST; @@ -448,41 +527,41 @@ int UtcDaliRendererBlendOptions01(void) tet_infoline("Test BLEND_FACTOR properties "); Geometry geometry = CreateQuadGeometry(); - Shader shader = CreateShader(); - Renderer renderer = Renderer::New( geometry, shader ); + Shader shader = CreateShader(); + Renderer renderer = Renderer::New(geometry, shader); Actor actor = Actor::New(); // set a transparent actor color so that blending is enabled - actor.SetProperty( Actor::Property::OPACITY, 0.5f ); + actor.SetProperty(Actor::Property::OPACITY, 0.5f); actor.AddRenderer(renderer); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); application.GetScene().Add(actor); - renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::ONE_MINUS_SRC_COLOR ); - renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::SRC_ALPHA_SATURATE ); - renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE_MINUS_SRC_COLOR ); - renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::SRC_ALPHA_SATURATE ); + renderer.SetProperty(Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::ONE_MINUS_SRC_COLOR); + renderer.SetProperty(Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::SRC_ALPHA_SATURATE); + renderer.SetProperty(Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE_MINUS_SRC_COLOR); + renderer.SetProperty(Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::SRC_ALPHA_SATURATE); // Test that Set was successful: - int srcFactorRgb = renderer.GetProperty( Renderer::Property::BLEND_FACTOR_SRC_RGB ); - int destFactorRgb = renderer.GetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB ); - int srcFactorAlpha = renderer.GetProperty( Renderer::Property::BLEND_FACTOR_SRC_ALPHA ); - int destFactorAlpha = renderer.GetProperty( Renderer::Property::BLEND_FACTOR_DEST_ALPHA ); + int srcFactorRgb = renderer.GetProperty(Renderer::Property::BLEND_FACTOR_SRC_RGB); + int destFactorRgb = renderer.GetProperty(Renderer::Property::BLEND_FACTOR_DEST_RGB); + int srcFactorAlpha = renderer.GetProperty(Renderer::Property::BLEND_FACTOR_SRC_ALPHA); + int destFactorAlpha = renderer.GetProperty(Renderer::Property::BLEND_FACTOR_DEST_ALPHA); - DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_SRC_COLOR, srcFactorRgb, TEST_LOCATION ); - DALI_TEST_EQUALS( (int)BlendFactor::SRC_ALPHA_SATURATE, destFactorRgb, TEST_LOCATION ); - DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_SRC_COLOR, srcFactorAlpha, TEST_LOCATION ); - DALI_TEST_EQUALS( (int)BlendFactor::SRC_ALPHA_SATURATE, destFactorAlpha, TEST_LOCATION ); + DALI_TEST_EQUALS((int)BlendFactor::ONE_MINUS_SRC_COLOR, srcFactorRgb, TEST_LOCATION); + DALI_TEST_EQUALS((int)BlendFactor::SRC_ALPHA_SATURATE, destFactorRgb, TEST_LOCATION); + DALI_TEST_EQUALS((int)BlendFactor::ONE_MINUS_SRC_COLOR, srcFactorAlpha, TEST_LOCATION); + DALI_TEST_EQUALS((int)BlendFactor::SRC_ALPHA_SATURATE, destFactorAlpha, TEST_LOCATION); application.SendNotification(); application.Render(); TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); - DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_SRC_COLOR, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION ); - DALI_TEST_EQUALS( (GLenum)GL_SRC_ALPHA_SATURATE, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION ); - DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_SRC_COLOR, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION ); - DALI_TEST_EQUALS( (GLenum)GL_SRC_ALPHA_SATURATE, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION ); + DALI_TEST_EQUALS((GLenum)GL_ONE_MINUS_SRC_COLOR, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION); + DALI_TEST_EQUALS((GLenum)GL_SRC_ALPHA_SATURATE, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION); + DALI_TEST_EQUALS((GLenum)GL_ONE_MINUS_SRC_COLOR, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION); + DALI_TEST_EQUALS((GLenum)GL_SRC_ALPHA_SATURATE, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION); END_TEST; } @@ -494,41 +573,41 @@ int UtcDaliRendererBlendOptions02(void) tet_infoline("Test BLEND_FACTOR properties "); Geometry geometry = CreateQuadGeometry(); - Shader shader = CreateShader(); - Renderer renderer = Renderer::New( geometry, shader ); + Shader shader = CreateShader(); + Renderer renderer = Renderer::New(geometry, shader); Actor actor = Actor::New(); - actor.SetProperty( Actor::Property::OPACITY, 0.5f ); // enable blending + actor.SetProperty(Actor::Property::OPACITY, 0.5f); // enable blending actor.AddRenderer(renderer); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); application.GetScene().Add(actor); - renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::CONSTANT_COLOR ); - renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ONE_MINUS_CONSTANT_COLOR ); - renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::CONSTANT_ALPHA ); - renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ONE_MINUS_CONSTANT_ALPHA ); + renderer.SetProperty(Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::CONSTANT_COLOR); + renderer.SetProperty(Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ONE_MINUS_CONSTANT_COLOR); + renderer.SetProperty(Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::CONSTANT_ALPHA); + renderer.SetProperty(Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ONE_MINUS_CONSTANT_ALPHA); // Test that Set was successful: { - int srcFactorRgb = renderer.GetProperty( Renderer::Property::BLEND_FACTOR_SRC_RGB ); - int destFactorRgb = renderer.GetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB ); - int srcFactorAlpha = renderer.GetProperty( Renderer::Property::BLEND_FACTOR_SRC_ALPHA ); - int destFactorAlpha = renderer.GetProperty( Renderer::Property::BLEND_FACTOR_DEST_ALPHA ); - - DALI_TEST_EQUALS( (int)BlendFactor::CONSTANT_COLOR, srcFactorRgb, TEST_LOCATION ); - DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_CONSTANT_COLOR, destFactorRgb, TEST_LOCATION ); - DALI_TEST_EQUALS( (int)BlendFactor::CONSTANT_ALPHA, srcFactorAlpha, TEST_LOCATION ); - DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_CONSTANT_ALPHA, destFactorAlpha, TEST_LOCATION ); + int srcFactorRgb = renderer.GetProperty(Renderer::Property::BLEND_FACTOR_SRC_RGB); + int destFactorRgb = renderer.GetProperty(Renderer::Property::BLEND_FACTOR_DEST_RGB); + int srcFactorAlpha = renderer.GetProperty(Renderer::Property::BLEND_FACTOR_SRC_ALPHA); + int destFactorAlpha = renderer.GetProperty(Renderer::Property::BLEND_FACTOR_DEST_ALPHA); + + DALI_TEST_EQUALS((int)BlendFactor::CONSTANT_COLOR, srcFactorRgb, TEST_LOCATION); + DALI_TEST_EQUALS((int)BlendFactor::ONE_MINUS_CONSTANT_COLOR, destFactorRgb, TEST_LOCATION); + DALI_TEST_EQUALS((int)BlendFactor::CONSTANT_ALPHA, srcFactorAlpha, TEST_LOCATION); + DALI_TEST_EQUALS((int)BlendFactor::ONE_MINUS_CONSTANT_ALPHA, destFactorAlpha, TEST_LOCATION); } application.SendNotification(); application.Render(); TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); - DALI_TEST_EQUALS( (GLenum)GL_CONSTANT_COLOR, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION ); - DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_CONSTANT_COLOR, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION ); - DALI_TEST_EQUALS( (GLenum)GL_CONSTANT_ALPHA, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION ); - DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_CONSTANT_ALPHA, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION ); + DALI_TEST_EQUALS((GLenum)GL_CONSTANT_COLOR, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION); + DALI_TEST_EQUALS((GLenum)GL_ONE_MINUS_CONSTANT_COLOR, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION); + DALI_TEST_EQUALS((GLenum)GL_CONSTANT_ALPHA, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION); + DALI_TEST_EQUALS((GLenum)GL_ONE_MINUS_CONSTANT_ALPHA, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION); END_TEST; } @@ -540,20 +619,20 @@ int UtcDaliRendererBlendOptions03(void) tet_infoline("Test GetBlendEquation() defaults "); Geometry geometry = CreateQuadGeometry(); - Shader shader = CreateShader(); - Renderer renderer = Renderer::New( geometry, shader ); + Shader shader = CreateShader(); + Renderer renderer = Renderer::New(geometry, shader); Actor actor = Actor::New(); actor.AddRenderer(renderer); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); application.GetScene().Add(actor); // Test the defaults as documented in blending.h - int equationRgb = renderer.GetProperty( Renderer::Property::BLEND_EQUATION_RGB ); - int equationAlpha = renderer.GetProperty( Renderer::Property::BLEND_EQUATION_ALPHA ); + int equationRgb = renderer.GetProperty(Renderer::Property::BLEND_EQUATION_RGB); + int equationAlpha = renderer.GetProperty(Renderer::Property::BLEND_EQUATION_ALPHA); - DALI_TEST_EQUALS( (int)BlendEquation::ADD, equationRgb, TEST_LOCATION ); - DALI_TEST_EQUALS( (int)BlendEquation::ADD, equationAlpha, TEST_LOCATION ); + DALI_TEST_EQUALS((int)BlendEquation::ADD, equationRgb, TEST_LOCATION); + DALI_TEST_EQUALS((int)BlendEquation::ADD, equationAlpha, TEST_LOCATION); END_TEST; } @@ -565,31 +644,31 @@ int UtcDaliRendererBlendOptions04(void) tet_infoline("Test SetBlendEquation() "); Geometry geometry = CreateQuadGeometry(); - Shader shader = CreateShader(); - Renderer renderer = Renderer::New( geometry, shader ); + Shader shader = CreateShader(); + Renderer renderer = Renderer::New(geometry, shader); Actor actor = Actor::New(); - actor.SetProperty( Actor::Property::OPACITY, 0.1f ); + actor.SetProperty(Actor::Property::OPACITY, 0.1f); actor.AddRenderer(renderer); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); application.GetScene().Add(actor); // Test the single blending equation setting { - renderer.SetProperty( Renderer::Property::BLEND_EQUATION_RGB, BlendEquation::REVERSE_SUBTRACT ); - int equationRgb = renderer.GetProperty( Renderer::Property::BLEND_EQUATION_RGB ); - DALI_TEST_EQUALS( (int)BlendEquation::REVERSE_SUBTRACT, equationRgb, TEST_LOCATION ); + renderer.SetProperty(Renderer::Property::BLEND_EQUATION_RGB, BlendEquation::REVERSE_SUBTRACT); + int equationRgb = renderer.GetProperty(Renderer::Property::BLEND_EQUATION_RGB); + DALI_TEST_EQUALS((int)BlendEquation::REVERSE_SUBTRACT, equationRgb, TEST_LOCATION); } - renderer.SetProperty( Renderer::Property::BLEND_EQUATION_RGB, BlendEquation::REVERSE_SUBTRACT ); - renderer.SetProperty( Renderer::Property::BLEND_EQUATION_ALPHA, BlendEquation::REVERSE_SUBTRACT ); + renderer.SetProperty(Renderer::Property::BLEND_EQUATION_RGB, BlendEquation::REVERSE_SUBTRACT); + renderer.SetProperty(Renderer::Property::BLEND_EQUATION_ALPHA, BlendEquation::REVERSE_SUBTRACT); // Test that Set was successful { - int equationRgb = renderer.GetProperty( Renderer::Property::BLEND_EQUATION_RGB ); - int equationAlpha = renderer.GetProperty( Renderer::Property::BLEND_EQUATION_ALPHA ); - DALI_TEST_EQUALS( (int)BlendEquation::REVERSE_SUBTRACT, equationRgb, TEST_LOCATION ); - DALI_TEST_EQUALS( (int)BlendEquation::REVERSE_SUBTRACT, equationAlpha, TEST_LOCATION ); + int equationRgb = renderer.GetProperty(Renderer::Property::BLEND_EQUATION_RGB); + int equationAlpha = renderer.GetProperty(Renderer::Property::BLEND_EQUATION_ALPHA); + DALI_TEST_EQUALS((int)BlendEquation::REVERSE_SUBTRACT, equationRgb, TEST_LOCATION); + DALI_TEST_EQUALS((int)BlendEquation::REVERSE_SUBTRACT, equationAlpha, TEST_LOCATION); } // Render & check GL commands @@ -597,8 +676,176 @@ int UtcDaliRendererBlendOptions04(void) application.Render(); TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); - DALI_TEST_EQUALS( (GLenum)GL_FUNC_REVERSE_SUBTRACT, glAbstraction.GetLastBlendEquationRgb(), TEST_LOCATION ); - DALI_TEST_EQUALS( (GLenum)GL_FUNC_REVERSE_SUBTRACT, glAbstraction.GetLastBlendEquationAlpha(), TEST_LOCATION ); + DALI_TEST_EQUALS((GLenum)GL_FUNC_REVERSE_SUBTRACT, glAbstraction.GetLastBlendEquationRgb(), TEST_LOCATION); + DALI_TEST_EQUALS((GLenum)GL_FUNC_REVERSE_SUBTRACT, glAbstraction.GetLastBlendEquationAlpha(), TEST_LOCATION); + + END_TEST; +} + +int UtcDaliRendererBlendOptions05(void) +{ + TestApplication application; + + tet_infoline("Test SetAdvancedBlendEquation "); + + Geometry geometry = CreateQuadGeometry(); + Shader shader = CreateShader(); + Renderer renderer = Renderer::New(geometry, shader); + + Actor actor = Actor::New(); + actor.SetProperty(Actor::Property::OPACITY, 0.1f); + + actor.AddRenderer(renderer); + actor.SetProperty(Actor::Property::SIZE, Vector2(400, 400)); + application.GetScene().Add(actor); + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + glAbstraction.EnableEnableDisableCallTrace(true); + + if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::MAX)) + { + renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::MAX); + int equationRgb = renderer.GetProperty(DevelRenderer::Property::BLEND_EQUATION); + DALI_TEST_EQUALS((int)DevelBlendEquation::MAX, equationRgb, TEST_LOCATION); + } + + if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN)) + { + renderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true); + renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SCREEN); + int equation = renderer.GetProperty(DevelRenderer::Property::BLEND_EQUATION); + + DALI_TEST_EQUALS((int)DevelBlendEquation::SCREEN, equation, TEST_LOCATION); + DALI_TEST_EQUALS(DevelRenderer::IsAdvancedBlendEquationApplied(renderer), true, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + } + + if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN) && + Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::MULTIPLY)) + { + renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::ADD); + renderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true); + renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION_RGB, DevelBlendEquation::SCREEN); + renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION_ALPHA, DevelBlendEquation::MULTIPLY); + int equationRgb = renderer.GetProperty(DevelRenderer::Property::BLEND_EQUATION_RGB); + int equationAlpha = renderer.GetProperty(DevelRenderer::Property::BLEND_EQUATION_ALPHA); + + DALI_TEST_EQUALS((int)DevelBlendEquation::ADD, equationRgb, TEST_LOCATION); + DALI_TEST_EQUALS((int)DevelBlendEquation::ADD, equationAlpha, TEST_LOCATION); + DALI_TEST_EQUALS(DevelRenderer::IsAdvancedBlendEquationApplied(renderer), false, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + } + + tet_infoline("Error Checking\n"); + if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::MULTIPLY) && + Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN) && + Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::OVERLAY) && + Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::DARKEN) && + Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::LIGHTEN) && + Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::COLOR_DODGE) && + Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::COLOR_BURN) && + Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::HARD_LIGHT) && + Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SOFT_LIGHT) && + Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::DIFFERENCE) && + Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::EXCLUSION) && + Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::HUE) && + Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SATURATION) && + Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::COLOR) && + Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::LUMINOSITY)) + { + renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::MULTIPLY); + DALI_TEST_EQUALS((int)DevelBlendEquation::MULTIPLY, renderer.GetProperty(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS(glAbstraction.GetLastBlendEquationRgb(), GL_MULTIPLY, TEST_LOCATION); + + renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SCREEN); + DALI_TEST_EQUALS((int)DevelBlendEquation::SCREEN, renderer.GetProperty(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS(glAbstraction.GetLastBlendEquationRgb(), GL_SCREEN, TEST_LOCATION); + + renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::OVERLAY); + DALI_TEST_EQUALS((int)DevelBlendEquation::OVERLAY, renderer.GetProperty(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS(glAbstraction.GetLastBlendEquationRgb(), GL_OVERLAY, TEST_LOCATION); + + renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::DARKEN); + DALI_TEST_EQUALS((int)DevelBlendEquation::DARKEN, renderer.GetProperty(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS(glAbstraction.GetLastBlendEquationRgb(), GL_DARKEN, TEST_LOCATION); + + renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::LIGHTEN); + DALI_TEST_EQUALS((int)DevelBlendEquation::LIGHTEN, renderer.GetProperty(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS(glAbstraction.GetLastBlendEquationRgb(), GL_LIGHTEN, TEST_LOCATION); + + renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::COLOR_DODGE); + DALI_TEST_EQUALS((int)DevelBlendEquation::COLOR_DODGE, renderer.GetProperty(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS(glAbstraction.GetLastBlendEquationRgb(), GL_COLORDODGE, TEST_LOCATION); + + renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::COLOR_BURN); + DALI_TEST_EQUALS((int)DevelBlendEquation::COLOR_BURN, renderer.GetProperty(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS(glAbstraction.GetLastBlendEquationRgb(), GL_COLORBURN, TEST_LOCATION); + + renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::HARD_LIGHT); + DALI_TEST_EQUALS((int)DevelBlendEquation::HARD_LIGHT, renderer.GetProperty(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS(glAbstraction.GetLastBlendEquationRgb(), GL_HARDLIGHT, TEST_LOCATION); + + renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SOFT_LIGHT); + DALI_TEST_EQUALS((int)DevelBlendEquation::SOFT_LIGHT, renderer.GetProperty(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS(glAbstraction.GetLastBlendEquationRgb(), GL_SOFTLIGHT, TEST_LOCATION); + + renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::DIFFERENCE); + DALI_TEST_EQUALS((int)DevelBlendEquation::DIFFERENCE, renderer.GetProperty(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS(glAbstraction.GetLastBlendEquationRgb(), GL_DIFFERENCE, TEST_LOCATION); + + renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::EXCLUSION); + DALI_TEST_EQUALS((int)DevelBlendEquation::EXCLUSION, renderer.GetProperty(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS(glAbstraction.GetLastBlendEquationRgb(), GL_EXCLUSION, TEST_LOCATION); + + renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::HUE); + DALI_TEST_EQUALS((int)DevelBlendEquation::HUE, renderer.GetProperty(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS(glAbstraction.GetLastBlendEquationRgb(), GL_HSL_HUE, TEST_LOCATION); + + renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SATURATION); + DALI_TEST_EQUALS((int)DevelBlendEquation::SATURATION, renderer.GetProperty(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS(glAbstraction.GetLastBlendEquationRgb(), GL_HSL_SATURATION, TEST_LOCATION); + + renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::COLOR); + DALI_TEST_EQUALS((int)DevelBlendEquation::COLOR, renderer.GetProperty(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS(glAbstraction.GetLastBlendEquationRgb(), GL_HSL_COLOR, TEST_LOCATION); + + renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::LUMINOSITY); + DALI_TEST_EQUALS((int)DevelBlendEquation::LUMINOSITY, renderer.GetProperty(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS(glAbstraction.GetLastBlendEquationRgb(), GL_HSL_LUMINOSITY, TEST_LOCATION); + } END_TEST; } @@ -610,16 +857,16 @@ int UtcDaliRendererSetBlendMode01(void) tet_infoline("Test setting the blend mode to on with an opaque color renders with blending enabled"); Geometry geometry = CreateQuadGeometry(); - Shader shader = CreateShader(); - Renderer renderer = Renderer::New( geometry, shader ); + Shader shader = CreateShader(); + Renderer renderer = Renderer::New(geometry, shader); Actor actor = Actor::New(); - actor.SetProperty( Actor::Property::OPACITY, 0.98f ); + actor.SetProperty(Actor::Property::OPACITY, 1.0f); actor.AddRenderer(renderer); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); application.GetScene().Add(actor); - renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON); + renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON); TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); glAbstraction.EnableEnableDisableCallTrace(true); @@ -627,10 +874,10 @@ int UtcDaliRendererSetBlendMode01(void) application.SendNotification(); application.Render(); - TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace(); - std::ostringstream blendStr; - blendStr << GL_BLEND; - DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) ); + TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace(); + TraceCallStack::NamedParams params; + params["cap"] << std::hex << GL_BLEND; + DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", params)); END_TEST; } @@ -642,30 +889,28 @@ int UtcDaliRendererSetBlendMode01b(void) tet_infoline("Test setting the blend mode to on with an transparent color renders with blending enabled"); Geometry geometry = CreateQuadGeometry(); - Shader shader = CreateShader(); - Renderer renderer = Renderer::New( geometry, shader ); + Shader shader = CreateShader(); + Renderer renderer = Renderer::New(geometry, shader); Actor actor = Actor::New(); - actor.SetProperty( Actor::Property::OPACITY, 0.0f ); + actor.SetProperty(Actor::Property::OPACITY, 0.0f); actor.AddRenderer(renderer); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); application.GetScene().Add(actor); - renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON); + renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON); TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); glAbstraction.EnableEnableDisableCallTrace(true); - glAbstraction.EnableDrawCallTrace( true ); + glAbstraction.EnableDrawCallTrace(true); application.SendNotification(); application.Render(); TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace(); - std::ostringstream blendStr; - blendStr << GL_BLEND; - DALI_TEST_CHECK( !glEnableStack.FindMethod( "Enable" ) ); + DALI_TEST_CHECK(!glEnableStack.FindMethod("Enable")); - DALI_TEST_CHECK( !glAbstraction.GetDrawTrace().FindMethod( "DrawElements" ) ); + DALI_TEST_CHECK(!glAbstraction.GetDrawTrace().FindMethod("DrawElements")); END_TEST; } @@ -677,16 +922,16 @@ int UtcDaliRendererSetBlendMode02(void) tet_infoline("Test setting the blend mode to off with a transparent color renders with blending disabled (and not enabled)"); Geometry geometry = CreateQuadGeometry(); - Shader shader = CreateShader(); - Renderer renderer = Renderer::New( geometry, shader ); + Shader shader = CreateShader(); + Renderer renderer = Renderer::New(geometry, shader); Actor actor = Actor::New(); - actor.SetProperty( Actor::Property::OPACITY, 0.15f ); + actor.SetProperty(Actor::Property::OPACITY, 0.15f); actor.AddRenderer(renderer); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); application.GetScene().Add(actor); - renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::OFF); + renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::OFF); TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); glAbstraction.EnableEnableDisableCallTrace(true); @@ -694,10 +939,10 @@ int UtcDaliRendererSetBlendMode02(void) application.SendNotification(); application.Render(); - TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace(); - std::ostringstream blendStr; - blendStr << GL_BLEND; - DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) ); + TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace(); + TraceCallStack::NamedParams params; + params["cap"] << std::hex << GL_BLEND; + DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Enable", params)); END_TEST; } @@ -709,16 +954,16 @@ int UtcDaliRendererSetBlendMode03(void) tet_infoline("Test setting the blend mode to auto with a transparent color renders with blending enabled"); Geometry geometry = CreateQuadGeometry(); - Shader shader = CreateShader(); - Renderer renderer = Renderer::New( geometry, shader ); + Shader shader = CreateShader(); + Renderer renderer = Renderer::New(geometry, shader); Actor actor = Actor::New(); - actor.SetProperty( Actor::Property::OPACITY, 0.75f ); + actor.SetProperty(Actor::Property::OPACITY, 0.75f); actor.AddRenderer(renderer); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); application.GetScene().Add(actor); - renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO); + renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::AUTO); TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); glAbstraction.EnableEnableDisableCallTrace(true); @@ -726,10 +971,10 @@ int UtcDaliRendererSetBlendMode03(void) application.SendNotification(); application.Render(); - TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace(); - std::ostringstream blendStr; - blendStr << GL_BLEND; - DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) ); + TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace(); + TraceCallStack::NamedParams params; + params["cap"] << std::hex << GL_BLEND; + DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", params)); END_TEST; } @@ -741,15 +986,15 @@ int UtcDaliRendererSetBlendMode04(void) tet_infoline("Test setting the blend mode to auto with an opaque color renders with blending disabled"); Geometry geometry = CreateQuadGeometry(); - Shader shader = CreateShader(); - Renderer renderer = Renderer::New( geometry, shader ); + Shader shader = CreateShader(); + Renderer renderer = Renderer::New(geometry, shader); Actor actor = Actor::New(); actor.AddRenderer(renderer); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); application.GetScene().Add(actor); - renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO); + renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::AUTO); TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); glAbstraction.EnableEnableDisableCallTrace(true); @@ -757,10 +1002,11 @@ int UtcDaliRendererSetBlendMode04(void) application.SendNotification(); application.Render(); - TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace(); - std::ostringstream blendStr; - blendStr << GL_BLEND; - DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) ); + TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace(); + TraceCallStack::NamedParams params; + params["cap"] << std::hex << GL_BLEND; + DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Enable", params)); + DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Disable", params)); END_TEST; } @@ -772,16 +1018,16 @@ int UtcDaliRendererSetBlendMode04b(void) tet_infoline("Test setting the blend mode to auto with a transparent actor color renders with blending enabled"); Geometry geometry = CreateQuadGeometry(); - Shader shader = CreateShader(); - Renderer renderer = Renderer::New( geometry, shader ); + Shader shader = CreateShader(); + Renderer renderer = Renderer::New(geometry, shader); Actor actor = Actor::New(); actor.AddRenderer(renderer); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); - actor.SetProperty( Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 0.5f) ); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); + actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 0.5f)); application.GetScene().Add(actor); - renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO); + renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::AUTO); TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); glAbstraction.EnableEnableDisableCallTrace(true); @@ -789,10 +1035,10 @@ int UtcDaliRendererSetBlendMode04b(void) application.SendNotification(); application.Render(); - TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace(); - std::ostringstream blendStr; - blendStr << GL_BLEND; - DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) ); + TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace(); + TraceCallStack::NamedParams params; + params["cap"] << std::hex << GL_BLEND; + DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", params)); END_TEST; } @@ -804,16 +1050,16 @@ int UtcDaliRendererSetBlendMode04c(void) tet_infoline("Test setting the blend mode to auto with an opaque opaque actor color renders with blending disabled"); Geometry geometry = CreateQuadGeometry(); - Shader shader = CreateShader(); - Renderer renderer = Renderer::New( geometry, shader ); + Shader shader = CreateShader(); + Renderer renderer = Renderer::New(geometry, shader); Actor actor = Actor::New(); actor.AddRenderer(renderer); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); - actor.SetProperty( Actor::Property::COLOR, Color::MAGENTA ); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); + actor.SetProperty(Actor::Property::COLOR, Color::MAGENTA); application.GetScene().Add(actor); - renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO); + renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::AUTO); TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); glAbstraction.EnableEnableDisableCallTrace(true); @@ -821,10 +1067,11 @@ int UtcDaliRendererSetBlendMode04c(void) application.SendNotification(); application.Render(); - TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace(); - std::ostringstream blendStr; - blendStr << GL_BLEND; - DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) ); + TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace(); + TraceCallStack::NamedParams params; + params["cap"] << std::hex << GL_BLEND; + DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Enable", params)); + DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Disable", params)); END_TEST; } @@ -836,19 +1083,19 @@ int UtcDaliRendererSetBlendMode05(void) tet_infoline("Test setting the blend mode to auto with an opaque color and an image with an alpha channel renders with blending enabled"); Geometry geometry = CreateQuadGeometry(); - Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 40, 40); + Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 40, 40); - Shader shader = CreateShader(); - TextureSet textureSet = CreateTextureSet( image ); - Renderer renderer = Renderer::New( geometry, shader ); - renderer.SetTextures( textureSet ); + Shader shader = CreateShader(); + TextureSet textureSet = CreateTextureSet(image); + Renderer renderer = Renderer::New(geometry, shader); + renderer.SetTextures(textureSet); Actor actor = Actor::New(); actor.AddRenderer(renderer); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); application.GetScene().Add(actor); - renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO); + renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::AUTO); TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); glAbstraction.EnableEnableDisableCallTrace(true); @@ -856,10 +1103,10 @@ int UtcDaliRendererSetBlendMode05(void) application.SendNotification(); application.Render(); - TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace(); - std::ostringstream blendStr; - blendStr << GL_BLEND; - DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) ); + TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace(); + TraceCallStack::NamedParams params; + params["cap"] << std::hex << GL_BLEND; + DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", params)); END_TEST; } @@ -870,16 +1117,16 @@ int UtcDaliRendererSetBlendMode06(void) 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"); Geometry geometry = CreateQuadGeometry(); - Shader shader = Shader::New( "vertexSrc", "fragmentSrc", Shader::Hint::OUTPUT_IS_TRANSPARENT ); + Shader shader = Shader::New("vertexSrc", "fragmentSrc", Shader::Hint::OUTPUT_IS_TRANSPARENT); - Renderer renderer = Renderer::New( geometry, shader ); + Renderer renderer = Renderer::New(geometry, shader); Actor actor = Actor::New(); actor.AddRenderer(renderer); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); application.GetScene().Add(actor); - renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO); + renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::AUTO); TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); glAbstraction.EnableEnableDisableCallTrace(true); @@ -887,10 +1134,10 @@ int UtcDaliRendererSetBlendMode06(void) application.SendNotification(); application.Render(); - TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace(); - std::ostringstream blendStr; - blendStr << GL_BLEND; - DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) ); + TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace(); + TraceCallStack::NamedParams params; + params["cap"] << std::hex << GL_BLEND; + DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", params)); END_TEST; } @@ -901,28 +1148,169 @@ int UtcDaliRendererSetBlendMode07(void) 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"); Geometry geometry = CreateQuadGeometry(); - Shader shader = Shader::New( "vertexSrc", "fragmentSrc" ); + Shader shader = Shader::New("vertexSrc", "fragmentSrc"); + + Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGB888, 50, 50); + TextureSet textureSet = CreateTextureSet(image); + Renderer renderer = Renderer::New(geometry, shader); + renderer.SetTextures(textureSet); + + Actor actor = Actor::New(); + actor.AddRenderer(renderer); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); + application.GetScene().Add(actor); + + renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::AUTO); + + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + glAbstraction.EnableEnableDisableCallTrace(true); + + application.SendNotification(); + application.Render(); + + TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace(); + TraceCallStack::NamedParams params; + params["cap"] << std::hex << GL_BLEND; + DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Enable", params)); + + END_TEST; +} + +int UtcDaliRendererSetBlendMode08(void) +{ + TestApplication application; + + tet_infoline("Test setting the blend mode to auto with opaque color and Advanced Blend Equation."); + + if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN)) + { + Geometry geometry = CreateQuadGeometry(); + Shader shader = CreateShader(); + Renderer renderer = Renderer::New(geometry, shader); + + Actor actor = Actor::New(); + actor.SetProperty(Actor::Property::OPACITY, 1.0f); + actor.AddRenderer(renderer); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); + application.GetScene().Add(actor); + + renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::AUTO); + renderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true); + renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SCREEN); + + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + glAbstraction.EnableEnableDisableCallTrace(true); + + application.SendNotification(); + application.Render(); + + TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace(); + TraceCallStack::NamedParams params; + params["cap"] << std::hex << GL_BLEND; + DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", params)); + } + + END_TEST; +} + +int UtcDaliRendererSetBlendMode08b(void) +{ + TestApplication application; + + tet_infoline("Test setting the blend mode to off with opaque color and Advanced Blend Equation."); + + if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN)) + { + Geometry geometry = CreateQuadGeometry(); + Shader shader = CreateShader(); + Renderer renderer = Renderer::New(geometry, shader); + + Actor actor = Actor::New(); + actor.SetProperty(Actor::Property::OPACITY, 1.0f); + actor.AddRenderer(renderer); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); + application.GetScene().Add(actor); + + renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::OFF); + renderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true); + renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SCREEN); + + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + glAbstraction.EnableEnableDisableCallTrace(true); + + application.SendNotification(); + application.Render(); + + TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace(); + TraceCallStack::NamedParams params; + params["cap"] << std::hex << GL_BLEND; + DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Enable", params)); + } + + END_TEST; +} + +int UtcDaliRendererSetBlendMode09(void) +{ + TestApplication application; + + tet_infoline("Test setting the blend mode to on_without_cull with an opaque color renders with blending enabled"); + + Geometry geometry = CreateQuadGeometry(); + Shader shader = CreateShader(); + Renderer renderer = Renderer::New(geometry, shader); + + Actor actor = Actor::New(); + actor.SetProperty(Actor::Property::OPACITY, 1.0f); + actor.AddRenderer(renderer); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); + application.GetScene().Add(actor); + + renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON_WITHOUT_CULL); + + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + glAbstraction.EnableEnableDisableCallTrace(true); + + application.SendNotification(); + application.Render(); + + TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace(); + TraceCallStack::NamedParams params; + params["cap"] << std::hex << GL_BLEND; + DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", params)); + + END_TEST; +} + +int UtcDaliRendererSetBlendMode09b(void) +{ + TestApplication application; + + tet_infoline("Test setting the blend mode to on_without_cull with an transparent color renders with blending enabled"); - Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGB888, 50, 50); - TextureSet textureSet = CreateTextureSet( image ); - Renderer renderer = Renderer::New( geometry, shader ); - renderer.SetTextures( textureSet ); + Geometry geometry = CreateQuadGeometry(); + Shader shader = CreateShader(); + Renderer renderer = Renderer::New(geometry, shader); Actor actor = Actor::New(); + actor.SetProperty(Actor::Property::OPACITY, 0.0f); actor.AddRenderer(renderer); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); application.GetScene().Add(actor); - renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO); + renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON_WITHOUT_CULL); TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); glAbstraction.EnableEnableDisableCallTrace(true); + glAbstraction.EnableDrawCallTrace(true); application.SendNotification(); application.Render(); TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace(); - DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", "GL_BLEND" ) ); + DALI_TEST_CHECK(glEnableStack.FindMethod("Enable")); + + DALI_TEST_CHECK(glAbstraction.GetDrawTrace().FindMethod("DrawElements")); END_TEST; } @@ -934,22 +1322,27 @@ int UtcDaliRendererGetBlendMode(void) tet_infoline("Test GetBlendMode()"); Geometry geometry = CreateQuadGeometry(); - Shader shader = Shader::New( "vertexSrc", "fragmentSrc" ); - Renderer renderer = Renderer::New( geometry, shader ); + Shader shader = Shader::New("vertexSrc", "fragmentSrc"); + Renderer renderer = Renderer::New(geometry, shader); // default value - unsigned int mode = renderer.GetProperty( Renderer::Property::BLEND_MODE ); - DALI_TEST_EQUALS( static_cast< BlendMode::Type >( mode ), BlendMode::AUTO, TEST_LOCATION ); + unsigned int mode = renderer.GetProperty(Renderer::Property::BLEND_MODE); + DALI_TEST_EQUALS(static_cast(mode), BlendMode::AUTO, TEST_LOCATION); // ON - renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON ); - mode = renderer.GetProperty( Renderer::Property::BLEND_MODE ); - DALI_TEST_EQUALS( static_cast< BlendMode::Type >( mode ), BlendMode::ON, TEST_LOCATION ); + renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON); + mode = renderer.GetProperty(Renderer::Property::BLEND_MODE); + DALI_TEST_EQUALS(static_cast(mode), BlendMode::ON, TEST_LOCATION); // OFF - renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::OFF ); - mode = renderer.GetProperty( Renderer::Property::BLEND_MODE ); - DALI_TEST_EQUALS( static_cast< BlendMode::Type >( mode ), BlendMode::OFF, TEST_LOCATION ); + renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::OFF); + mode = renderer.GetProperty(Renderer::Property::BLEND_MODE); + DALI_TEST_EQUALS(static_cast(mode), BlendMode::OFF, TEST_LOCATION); + + // ON_WITHOUT_CULL + renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON_WITHOUT_CULL); + mode = renderer.GetProperty(Renderer::Property::BLEND_MODE); + DALI_TEST_EQUALS(static_cast(mode), BlendMode::ON_WITHOUT_CULL, TEST_LOCATION); END_TEST; } @@ -960,46 +1353,46 @@ int UtcDaliRendererSetBlendColor(void) tet_infoline("Test SetBlendColor(color)"); - Geometry geometry = CreateQuadGeometry(); - Shader shader = Shader::New( "vertexSrc", "fragmentSrc" ); + Geometry geometry = CreateQuadGeometry(); + Shader shader = Shader::New("vertexSrc", "fragmentSrc"); TextureSet textureSet = TextureSet::New(); - Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 50, 50); + Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 50, 50); textureSet.SetTexture(0u, image); - Renderer renderer = Renderer::New( geometry, shader ); - renderer.SetTextures( textureSet ); + Renderer renderer = Renderer::New(geometry, shader); + renderer.SetTextures(textureSet); Actor actor = Actor::New(); actor.AddRenderer(renderer); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); application.GetScene().Add(actor); TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); - renderer.SetProperty( Renderer::Property::BLEND_COLOR, Color::TRANSPARENT ); + renderer.SetProperty(Renderer::Property::BLEND_COLOR, Color::TRANSPARENT); application.SendNotification(); application.Render(); - DALI_TEST_EQUALS( renderer.GetProperty< Vector4 >(Renderer::Property::BLEND_COLOR), Color::TRANSPARENT, TEST_LOCATION ); - DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >(Renderer::Property::BLEND_COLOR), Color::TRANSPARENT, TEST_LOCATION ); - DALI_TEST_EQUALS( glAbstraction.GetLastBlendColor(), Color::TRANSPARENT, TEST_LOCATION ); + DALI_TEST_EQUALS(renderer.GetProperty(Renderer::Property::BLEND_COLOR), Color::TRANSPARENT, TEST_LOCATION); + DALI_TEST_EQUALS(renderer.GetCurrentProperty(Renderer::Property::BLEND_COLOR), Color::TRANSPARENT, TEST_LOCATION); + DALI_TEST_EQUALS(glAbstraction.GetLastBlendColor(), Color::TRANSPARENT, TEST_LOCATION); - renderer.SetProperty( Renderer::Property::BLEND_COLOR, Color::MAGENTA ); + renderer.SetProperty(Renderer::Property::BLEND_COLOR, Color::MAGENTA); - DALI_TEST_EQUALS( renderer.GetProperty< Vector4 >(Renderer::Property::BLEND_COLOR), Color::MAGENTA, TEST_LOCATION ); - DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >(Renderer::Property::BLEND_COLOR), Color::TRANSPARENT, TEST_LOCATION ); + DALI_TEST_EQUALS(renderer.GetProperty(Renderer::Property::BLEND_COLOR), Color::MAGENTA, TEST_LOCATION); + DALI_TEST_EQUALS(renderer.GetCurrentProperty(Renderer::Property::BLEND_COLOR), Color::TRANSPARENT, TEST_LOCATION); application.SendNotification(); application.Render(); - DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >(Renderer::Property::BLEND_COLOR), Color::MAGENTA, TEST_LOCATION ); - DALI_TEST_EQUALS( glAbstraction.GetLastBlendColor(), Color::MAGENTA, TEST_LOCATION ); + DALI_TEST_EQUALS(renderer.GetCurrentProperty(Renderer::Property::BLEND_COLOR), Color::MAGENTA, TEST_LOCATION); + DALI_TEST_EQUALS(glAbstraction.GetLastBlendColor(), Color::MAGENTA, TEST_LOCATION); - Vector4 color( 0.1f, 0.2f, 0.3f, 0.4f ); - renderer.SetProperty( Renderer::Property::BLEND_COLOR, color ); + Vector4 color(0.1f, 0.2f, 0.3f, 0.4f); + renderer.SetProperty(Renderer::Property::BLEND_COLOR, color); application.SendNotification(); application.Render(); - DALI_TEST_EQUALS( glAbstraction.GetLastBlendColor(), color, TEST_LOCATION ); + DALI_TEST_EQUALS(glAbstraction.GetLastBlendColor(), color, TEST_LOCATION); END_TEST; } @@ -1011,21 +1404,21 @@ int UtcDaliRendererGetBlendColor(void) tet_infoline("Test GetBlendColor()"); Geometry geometry = CreateQuadGeometry(); - Shader shader = Shader::New( "vertexSrc", "fragmentSrc" ); - Renderer renderer = Renderer::New( geometry, shader ); + Shader shader = Shader::New("vertexSrc", "fragmentSrc"); + Renderer renderer = Renderer::New(geometry, shader); - DALI_TEST_EQUALS( renderer.GetProperty( Renderer::Property::BLEND_COLOR ), Color::TRANSPARENT, TEST_LOCATION ); + DALI_TEST_EQUALS(renderer.GetProperty(Renderer::Property::BLEND_COLOR), Color::TRANSPARENT, TEST_LOCATION); - renderer.SetProperty( Renderer::Property::BLEND_COLOR, Color::MAGENTA ); + renderer.SetProperty(Renderer::Property::BLEND_COLOR, Color::MAGENTA); application.SendNotification(); application.Render(); - DALI_TEST_EQUALS( renderer.GetProperty( Renderer::Property::BLEND_COLOR ), Color::MAGENTA, TEST_LOCATION ); + DALI_TEST_EQUALS(renderer.GetProperty(Renderer::Property::BLEND_COLOR), Color::MAGENTA, TEST_LOCATION); - Vector4 color( 0.1f, 0.2f, 0.3f, 0.4f ); - renderer.SetProperty( Renderer::Property::BLEND_COLOR, color ); + Vector4 color(0.1f, 0.2f, 0.3f, 0.4f); + renderer.SetProperty(Renderer::Property::BLEND_COLOR, color); application.SendNotification(); application.Render(); - DALI_TEST_EQUALS( renderer.GetProperty( Renderer::Property::BLEND_COLOR ), color, TEST_LOCATION ); + DALI_TEST_EQUALS(renderer.GetProperty(Renderer::Property::BLEND_COLOR), color, TEST_LOCATION); END_TEST; } @@ -1037,91 +1430,99 @@ int UtcDaliRendererPreMultipledAlpha(void) tet_infoline("Test BLEND_PRE_MULTIPLIED_ALPHA property"); Geometry geometry = CreateQuadGeometry(); - Shader shader = Shader::New( "vertexSrc", "fragmentSrc" ); - Renderer renderer = Renderer::New( geometry, shader ); + Shader shader = Shader::New("vertexSrc", "fragmentSrc"); + Renderer renderer = Renderer::New(geometry, shader); Actor actor = Actor::New(); actor.AddRenderer(renderer); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); - actor.SetProperty( Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 0.5f) ); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); + actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 0.5f)); application.GetScene().Add(actor); - Property::Value value = renderer.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA ); - bool preMultipliedAlpha; - DALI_TEST_CHECK( value.Get( preMultipliedAlpha ) ); - DALI_TEST_CHECK( !preMultipliedAlpha ); + Property::Value value = renderer.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA); + bool preMultipliedAlpha; + DALI_TEST_CHECK(value.Get(preMultipliedAlpha)); + DALI_TEST_CHECK(!preMultipliedAlpha); - int srcFactorRgb = renderer.GetProperty( Renderer::Property::BLEND_FACTOR_SRC_RGB ); - int destFactorRgb = renderer.GetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB ); - int srcFactorAlpha = renderer.GetProperty( Renderer::Property::BLEND_FACTOR_SRC_ALPHA ); - int destFactorAlpha = renderer.GetProperty( Renderer::Property::BLEND_FACTOR_DEST_ALPHA ); + int srcFactorRgb = renderer.GetProperty(Renderer::Property::BLEND_FACTOR_SRC_RGB); + int destFactorRgb = renderer.GetProperty(Renderer::Property::BLEND_FACTOR_DEST_RGB); + int srcFactorAlpha = renderer.GetProperty(Renderer::Property::BLEND_FACTOR_SRC_ALPHA); + int destFactorAlpha = renderer.GetProperty(Renderer::Property::BLEND_FACTOR_DEST_ALPHA); - DALI_TEST_EQUALS( (int)DEFAULT_BLEND_FACTOR_SRC_RGB, srcFactorRgb, TEST_LOCATION ); - DALI_TEST_EQUALS( (int)DEFAULT_BLEND_FACTOR_DEST_RGB, destFactorRgb, TEST_LOCATION ); - DALI_TEST_EQUALS( (int)DEFAULT_BLEND_FACTOR_SRC_ALPHA, srcFactorAlpha, TEST_LOCATION ); - DALI_TEST_EQUALS( (int)DEFAULT_BLEND_FACTOR_DEST_ALPHA, destFactorAlpha, TEST_LOCATION ); + DALI_TEST_EQUALS((int)DEFAULT_BLEND_FACTOR_SRC_RGB, srcFactorRgb, TEST_LOCATION); + DALI_TEST_EQUALS((int)DEFAULT_BLEND_FACTOR_DEST_RGB, destFactorRgb, TEST_LOCATION); + DALI_TEST_EQUALS((int)DEFAULT_BLEND_FACTOR_SRC_ALPHA, srcFactorAlpha, TEST_LOCATION); + DALI_TEST_EQUALS((int)DEFAULT_BLEND_FACTOR_DEST_ALPHA, destFactorAlpha, TEST_LOCATION); application.SendNotification(); application.Render(); - Vector4 actualValue(Vector4::ZERO); + Vector4 actualValue(Vector4::ZERO); + Vector4 actualActorColor(Vector4::ZERO); TestGlAbstraction& gl = application.GetGlAbstraction(); - DALI_TEST_CHECK( gl.GetUniformValue( "uColor", actualValue ) ); - DALI_TEST_EQUALS( actualValue, Vector4(1.0f, 0.0f, 1.0f, 0.5f), TEST_LOCATION ); + DALI_TEST_CHECK(gl.GetUniformValue("uColor", actualValue)); + DALI_TEST_EQUALS(actualValue, Vector4(1.0f, 0.0f, 1.0f, 0.5f), TEST_LOCATION); + DALI_TEST_CHECK(gl.GetUniformValue("uActorColor", actualActorColor)); + DALI_TEST_EQUALS(actualActorColor, Vector4(1.0f, 0.0f, 1.0f, 0.5f), TEST_LOCATION); // Enable pre-multiplied alpha - renderer.SetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true ); + renderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true); application.SendNotification(); application.Render(); - value = renderer.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA ); - DALI_TEST_CHECK( value.Get( preMultipliedAlpha ) ); - DALI_TEST_CHECK( preMultipliedAlpha ); + value = renderer.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA); + DALI_TEST_CHECK(value.Get(preMultipliedAlpha)); + DALI_TEST_CHECK(preMultipliedAlpha); - value = renderer.GetCurrentProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA ); - DALI_TEST_CHECK( value.Get( preMultipliedAlpha ) ); - DALI_TEST_CHECK( preMultipliedAlpha ); + value = renderer.GetCurrentProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA); + DALI_TEST_CHECK(value.Get(preMultipliedAlpha)); + DALI_TEST_CHECK(preMultipliedAlpha); - srcFactorRgb = renderer.GetProperty( Renderer::Property::BLEND_FACTOR_SRC_RGB ); - destFactorRgb = renderer.GetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB ); - srcFactorAlpha = renderer.GetProperty( Renderer::Property::BLEND_FACTOR_SRC_ALPHA ); - destFactorAlpha = renderer.GetProperty( Renderer::Property::BLEND_FACTOR_DEST_ALPHA ); + srcFactorRgb = renderer.GetProperty(Renderer::Property::BLEND_FACTOR_SRC_RGB); + destFactorRgb = renderer.GetProperty(Renderer::Property::BLEND_FACTOR_DEST_RGB); + srcFactorAlpha = renderer.GetProperty(Renderer::Property::BLEND_FACTOR_SRC_ALPHA); + destFactorAlpha = renderer.GetProperty(Renderer::Property::BLEND_FACTOR_DEST_ALPHA); - DALI_TEST_EQUALS( (int)BlendFactor::ONE, srcFactorRgb, TEST_LOCATION ); - DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorRgb, TEST_LOCATION ); - DALI_TEST_EQUALS( (int)BlendFactor::ONE, srcFactorAlpha, TEST_LOCATION ); - DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorAlpha, TEST_LOCATION ); + DALI_TEST_EQUALS((int)BlendFactor::ONE, srcFactorRgb, TEST_LOCATION); + DALI_TEST_EQUALS((int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorRgb, TEST_LOCATION); + DALI_TEST_EQUALS((int)BlendFactor::ONE, srcFactorAlpha, TEST_LOCATION); + DALI_TEST_EQUALS((int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorAlpha, TEST_LOCATION); - DALI_TEST_CHECK( gl.GetUniformValue( "uColor", actualValue ) ); - DALI_TEST_EQUALS( actualValue, Vector4(0.5f, 0.0f, 0.5f, 0.5f), TEST_LOCATION ); + DALI_TEST_CHECK(gl.GetUniformValue("uColor", actualValue)); + DALI_TEST_EQUALS(actualValue, Vector4(0.5f, 0.0f, 0.5f, 0.5f), TEST_LOCATION); + // Note : uActorColor doesn't premultiplied. + DALI_TEST_CHECK(gl.GetUniformValue("uActorColor", actualActorColor)); + DALI_TEST_EQUALS(actualActorColor, Vector4(1.0f, 0.0f, 1.0f, 0.5f), TEST_LOCATION); // Disable pre-multiplied alpha again - renderer.SetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, false ); + renderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, false); application.SendNotification(); application.Render(); - value = renderer.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA ); - DALI_TEST_CHECK( value.Get( preMultipliedAlpha ) ); - DALI_TEST_CHECK( !preMultipliedAlpha ); + value = renderer.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA); + DALI_TEST_CHECK(value.Get(preMultipliedAlpha)); + DALI_TEST_CHECK(!preMultipliedAlpha); - value = renderer.GetCurrentProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA ); - DALI_TEST_CHECK( value.Get( preMultipliedAlpha ) ); - DALI_TEST_CHECK( !preMultipliedAlpha ); + value = renderer.GetCurrentProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA); + DALI_TEST_CHECK(value.Get(preMultipliedAlpha)); + DALI_TEST_CHECK(!preMultipliedAlpha); - srcFactorRgb = renderer.GetProperty( Renderer::Property::BLEND_FACTOR_SRC_RGB ); - destFactorRgb = renderer.GetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB ); - srcFactorAlpha = renderer.GetProperty( Renderer::Property::BLEND_FACTOR_SRC_ALPHA ); - destFactorAlpha = renderer.GetProperty( Renderer::Property::BLEND_FACTOR_DEST_ALPHA ); + srcFactorRgb = renderer.GetProperty(Renderer::Property::BLEND_FACTOR_SRC_RGB); + destFactorRgb = renderer.GetProperty(Renderer::Property::BLEND_FACTOR_DEST_RGB); + srcFactorAlpha = renderer.GetProperty(Renderer::Property::BLEND_FACTOR_SRC_ALPHA); + destFactorAlpha = renderer.GetProperty(Renderer::Property::BLEND_FACTOR_DEST_ALPHA); - DALI_TEST_EQUALS( (int)BlendFactor::SRC_ALPHA, srcFactorRgb, TEST_LOCATION ); - DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorRgb, TEST_LOCATION ); - DALI_TEST_EQUALS( (int)BlendFactor::ONE, srcFactorAlpha, TEST_LOCATION ); - DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorAlpha, TEST_LOCATION ); + DALI_TEST_EQUALS((int)BlendFactor::SRC_ALPHA, srcFactorRgb, TEST_LOCATION); + DALI_TEST_EQUALS((int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorRgb, TEST_LOCATION); + DALI_TEST_EQUALS((int)BlendFactor::ONE, srcFactorAlpha, TEST_LOCATION); + DALI_TEST_EQUALS((int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorAlpha, TEST_LOCATION); - DALI_TEST_CHECK( gl.GetUniformValue( "uColor", actualValue ) ); - DALI_TEST_EQUALS( actualValue, Vector4( 1.0f, 0.0f, 1.0f, 0.5f ), TEST_LOCATION ); + DALI_TEST_CHECK(gl.GetUniformValue("uColor", actualValue)); + DALI_TEST_EQUALS(actualValue, Vector4(1.0f, 0.0f, 1.0f, 0.5f), TEST_LOCATION); + DALI_TEST_CHECK(gl.GetUniformValue("uActorColor", actualActorColor)); + DALI_TEST_EQUALS(actualActorColor, Vector4(1.0f, 0.0f, 1.0f, 0.5f), TEST_LOCATION); END_TEST; } @@ -1132,38 +1533,38 @@ int UtcDaliRendererConstraint01(void) tet_infoline("Test that a non-uniform renderer property can be constrained"); - Shader shader = Shader::New("VertexSource", "FragmentSource"); + Shader shader = Shader::New("VertexSource", "FragmentSource"); Geometry geometry = CreateQuadGeometry(); - Renderer renderer = Renderer::New( geometry, shader ); + Renderer renderer = Renderer::New(geometry, shader); Actor actor = Actor::New(); actor.AddRenderer(renderer); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); application.GetScene().Add(actor); - Vector4 initialColor = Color::WHITE; - Property::Index colorIndex = renderer.RegisterProperty( "uFadeColor", initialColor ); + Vector4 initialColor = Color::WHITE; + Property::Index colorIndex = renderer.RegisterProperty("uFadeColor", initialColor); application.SendNotification(); application.Render(0); - DALI_TEST_EQUALS( renderer.GetProperty(colorIndex), initialColor, TEST_LOCATION ); + DALI_TEST_EQUALS(renderer.GetProperty(colorIndex), initialColor, TEST_LOCATION); // Apply constraint - Constraint constraint = Constraint::New( renderer, colorIndex, TestConstraintNoBlue ); + Constraint constraint = Constraint::New(renderer, colorIndex, TestConstraintNoBlue); constraint.Apply(); application.SendNotification(); application.Render(0); // Expect no blue component in either buffer - yellow - DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >( colorIndex ), Color::YELLOW, TEST_LOCATION ); + DALI_TEST_EQUALS(renderer.GetCurrentProperty(colorIndex), Color::YELLOW, TEST_LOCATION); application.Render(0); - DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >( colorIndex ), Color::YELLOW, TEST_LOCATION ); + DALI_TEST_EQUALS(renderer.GetCurrentProperty(colorIndex), Color::YELLOW, TEST_LOCATION); renderer.RemoveConstraints(); - renderer.SetProperty(colorIndex, Color::WHITE ); + renderer.SetProperty(colorIndex, Color::WHITE); application.SendNotification(); application.Render(0); - DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >( colorIndex ), Color::WHITE, TEST_LOCATION ); + DALI_TEST_EQUALS(renderer.GetCurrentProperty(colorIndex), Color::WHITE, TEST_LOCATION); END_TEST; } @@ -1174,19 +1575,19 @@ int UtcDaliRendererConstraint02(void) tet_infoline("Test that a uniform map renderer property can be constrained"); - Shader shader = Shader::New("VertexSource", "FragmentSource"); + Shader shader = Shader::New("VertexSource", "FragmentSource"); Geometry geometry = CreateQuadGeometry(); - Renderer renderer = Renderer::New( geometry, shader ); + Renderer renderer = Renderer::New(geometry, shader); Actor actor = Actor::New(); actor.AddRenderer(renderer); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); application.GetScene().Add(actor); application.SendNotification(); application.Render(0); - Vector4 initialColor = Color::WHITE; - Property::Index colorIndex = renderer.RegisterProperty( "uFadeColor", initialColor ); + Vector4 initialColor = Color::WHITE; + Property::Index colorIndex = renderer.RegisterProperty("uFadeColor", initialColor); TestGlAbstraction& gl = application.GetGlAbstraction(); @@ -1194,30 +1595,30 @@ int UtcDaliRendererConstraint02(void) application.Render(0); Vector4 actualValue(Vector4::ZERO); - DALI_TEST_CHECK( gl.GetUniformValue( "uFadeColor", actualValue ) ); - DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION ); + DALI_TEST_CHECK(gl.GetUniformValue("uFadeColor", actualValue)); + DALI_TEST_EQUALS(actualValue, initialColor, TEST_LOCATION); // Apply constraint - Constraint constraint = Constraint::New( renderer, colorIndex, TestConstraintNoBlue ); + Constraint constraint = Constraint::New(renderer, colorIndex, TestConstraintNoBlue); constraint.Apply(); application.SendNotification(); application.Render(0); - // Expect no blue component in either buffer - yellow - DALI_TEST_CHECK( gl.GetUniformValue( "uFadeColor", actualValue ) ); - DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION ); + // Expect no blue component in either buffer - yellow + DALI_TEST_CHECK(gl.GetUniformValue("uFadeColor", actualValue)); + DALI_TEST_EQUALS(actualValue, Color::YELLOW, TEST_LOCATION); application.Render(0); - DALI_TEST_CHECK( gl.GetUniformValue( "uFadeColor", actualValue ) ); - DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION ); + DALI_TEST_CHECK(gl.GetUniformValue("uFadeColor", actualValue)); + DALI_TEST_EQUALS(actualValue, Color::YELLOW, TEST_LOCATION); renderer.RemoveConstraints(); - renderer.SetProperty(colorIndex, Color::WHITE ); + renderer.SetProperty(colorIndex, Color::WHITE); application.SendNotification(); application.Render(0); - DALI_TEST_CHECK( gl.GetUniformValue( "uFadeColor", actualValue ) ); - DALI_TEST_EQUALS( actualValue, Color::WHITE, TEST_LOCATION ); + DALI_TEST_CHECK(gl.GetUniformValue("uFadeColor", actualValue)); + DALI_TEST_EQUALS(actualValue, Color::WHITE, TEST_LOCATION); END_TEST; } @@ -1228,37 +1629,37 @@ int UtcDaliRendererAnimatedProperty01(void) tet_infoline("Test that a non-uniform renderer property can be animated"); - Shader shader = Shader::New("VertexSource", "FragmentSource"); + Shader shader = Shader::New("VertexSource", "FragmentSource"); Geometry geometry = CreateQuadGeometry(); - Renderer renderer = Renderer::New( geometry, shader ); + Renderer renderer = Renderer::New(geometry, shader); Actor actor = Actor::New(); actor.AddRenderer(renderer); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); application.GetScene().Add(actor); - Vector4 initialColor = Color::WHITE; - Property::Index colorIndex = renderer.RegisterProperty( "uFadeColor", initialColor ); + Vector4 initialColor = Color::WHITE; + Property::Index colorIndex = renderer.RegisterProperty("uFadeColor", initialColor); application.SendNotification(); application.Render(0); - DALI_TEST_EQUALS( renderer.GetProperty(colorIndex), initialColor, TEST_LOCATION ); + DALI_TEST_EQUALS(renderer.GetProperty(colorIndex), initialColor, TEST_LOCATION); - Animation animation = Animation::New(1.0f); + Animation animation = Animation::New(1.0f); KeyFrames keyFrames = KeyFrames::New(); keyFrames.Add(0.0f, initialColor); keyFrames.Add(1.0f, Color::TRANSPARENT); - animation.AnimateBetween( Property( renderer, colorIndex ), keyFrames ); + animation.AnimateBetween(Property(renderer, colorIndex), keyFrames); animation.Play(); application.SendNotification(); application.Render(500); - DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >( colorIndex ), Color::WHITE * 0.5f, TEST_LOCATION ); + DALI_TEST_EQUALS(renderer.GetCurrentProperty(colorIndex), Color::WHITE * 0.5f, TEST_LOCATION); application.Render(500); - DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >( colorIndex ), Color::TRANSPARENT, TEST_LOCATION ); + DALI_TEST_EQUALS(renderer.GetCurrentProperty(colorIndex), Color::TRANSPARENT, TEST_LOCATION); END_TEST; } @@ -1269,19 +1670,19 @@ int UtcDaliRendererAnimatedProperty02(void) tet_infoline("Test that a uniform map renderer property can be animated"); - Shader shader = Shader::New("VertexSource", "FragmentSource"); + Shader shader = Shader::New("VertexSource", "FragmentSource"); Geometry geometry = CreateQuadGeometry(); - Renderer renderer = Renderer::New( geometry, shader ); + Renderer renderer = Renderer::New(geometry, shader); Actor actor = Actor::New(); actor.AddRenderer(renderer); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); application.GetScene().Add(actor); application.SendNotification(); application.Render(0); - Vector4 initialColor = Color::WHITE; - Property::Index colorIndex = renderer.RegisterProperty( "uFadeColor", initialColor ); + Vector4 initialColor = Color::WHITE; + Property::Index colorIndex = renderer.RegisterProperty("uFadeColor", initialColor); TestGlAbstraction& gl = application.GetGlAbstraction(); @@ -1289,25 +1690,25 @@ int UtcDaliRendererAnimatedProperty02(void) application.Render(0); Vector4 actualValue(Vector4::ZERO); - DALI_TEST_CHECK( gl.GetUniformValue( "uFadeColor", actualValue ) ); - DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION ); + DALI_TEST_CHECK(gl.GetUniformValue("uFadeColor", actualValue)); + DALI_TEST_EQUALS(actualValue, initialColor, TEST_LOCATION); - Animation animation = Animation::New(1.0f); + Animation animation = Animation::New(1.0f); KeyFrames keyFrames = KeyFrames::New(); keyFrames.Add(0.0f, initialColor); keyFrames.Add(1.0f, Color::TRANSPARENT); - animation.AnimateBetween( Property( renderer, colorIndex ), keyFrames ); + animation.AnimateBetween(Property(renderer, colorIndex), keyFrames); animation.Play(); application.SendNotification(); application.Render(500); - DALI_TEST_CHECK( gl.GetUniformValue( "uFadeColor", actualValue ) ); - DALI_TEST_EQUALS( actualValue, Color::WHITE * 0.5f, TEST_LOCATION ); + DALI_TEST_CHECK(gl.GetUniformValue("uFadeColor", actualValue)); + DALI_TEST_EQUALS(actualValue, Color::WHITE * 0.5f, TEST_LOCATION); application.Render(500); - DALI_TEST_CHECK( gl.GetUniformValue( "uFadeColor", actualValue ) ); - DALI_TEST_EQUALS( actualValue, Color::TRANSPARENT, TEST_LOCATION ); + DALI_TEST_CHECK(gl.GetUniformValue("uFadeColor", actualValue)); + DALI_TEST_EQUALS(actualValue, Color::TRANSPARENT, TEST_LOCATION); END_TEST; } @@ -1320,23 +1721,23 @@ int UtcDaliRendererUniformMapPrecendence01(void) Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64); - Shader shader = Shader::New("VertexSource", "FragmentSource"); - TextureSet textureSet = CreateTextureSet( image ); + Shader shader = Shader::New("VertexSource", "FragmentSource"); + TextureSet textureSet = CreateTextureSet(image); Geometry geometry = CreateQuadGeometry(); - Renderer renderer = Renderer::New( geometry, shader ); - renderer.SetTextures( textureSet ); + Renderer renderer = Renderer::New(geometry, shader); + renderer.SetTextures(textureSet); Actor actor = Actor::New(); actor.AddRenderer(renderer); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); application.GetScene().Add(actor); application.SendNotification(); application.Render(0); - renderer.RegisterProperty( "uFadeColor", Color::RED ); - actor.RegisterProperty( "uFadeColor", Color::GREEN ); - Property::Index shaderFadeColorIndex = shader.RegisterProperty( "uFadeColor", Color::MAGENTA ); + renderer.RegisterProperty("uFadeColor", Color::RED); + actor.RegisterProperty("uFadeColor", Color::GREEN); + Property::Index shaderFadeColorIndex = shader.RegisterProperty("uFadeColor", Color::MAGENTA); TestGlAbstraction& gl = application.GetGlAbstraction(); @@ -1345,26 +1746,26 @@ int UtcDaliRendererUniformMapPrecendence01(void) // Expect that the actor's fade color property is accessed Vector4 actualValue(Vector4::ZERO); - DALI_TEST_CHECK( gl.GetUniformValue( "uFadeColor", actualValue ) ); - DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION ); + DALI_TEST_CHECK(gl.GetUniformValue("uFadeColor", actualValue)); + DALI_TEST_EQUALS(actualValue, Color::GREEN, TEST_LOCATION); // Animate shader's fade color property. Should be no change to uniform - Animation animation = Animation::New(1.0f); + Animation animation = Animation::New(1.0f); KeyFrames keyFrames = KeyFrames::New(); keyFrames.Add(0.0f, Color::WHITE); keyFrames.Add(1.0f, Color::TRANSPARENT); - animation.AnimateBetween( Property( shader, shaderFadeColorIndex ), keyFrames ); + animation.AnimateBetween(Property(shader, shaderFadeColorIndex), keyFrames); animation.Play(); application.SendNotification(); application.Render(500); - DALI_TEST_CHECK( gl.GetUniformValue( "uFadeColor", actualValue ) ); - DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION ); + DALI_TEST_CHECK(gl.GetUniformValue("uFadeColor", actualValue)); + DALI_TEST_EQUALS(actualValue, Color::GREEN, TEST_LOCATION); application.Render(500); - DALI_TEST_CHECK( gl.GetUniformValue( "uFadeColor", actualValue ) ); - DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION ); + DALI_TEST_CHECK(gl.GetUniformValue("uFadeColor", actualValue)); + DALI_TEST_EQUALS(actualValue, Color::GREEN, TEST_LOCATION); END_TEST; } @@ -1377,23 +1778,23 @@ int UtcDaliRendererUniformMapPrecendence02(void) Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64); - Shader shader = Shader::New("VertexSource", "FragmentSource"); - TextureSet textureSet = CreateTextureSet( image ); + Shader shader = Shader::New("VertexSource", "FragmentSource"); + TextureSet textureSet = CreateTextureSet(image); Geometry geometry = CreateQuadGeometry(); - Renderer renderer = Renderer::New( geometry, shader ); - renderer.SetTextures( textureSet ); + Renderer renderer = Renderer::New(geometry, shader); + renderer.SetTextures(textureSet); Actor actor = Actor::New(); actor.AddRenderer(renderer); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); application.GetScene().Add(actor); application.SendNotification(); application.Render(0); // Don't add property / uniform map to renderer - actor.RegisterProperty( "uFadeColor", Color::GREEN ); - Property::Index shaderFadeColorIndex = shader.RegisterProperty( "uFadeColor", Color::BLUE ); + actor.RegisterProperty("uFadeColor", Color::GREEN); + Property::Index shaderFadeColorIndex = shader.RegisterProperty("uFadeColor", Color::BLUE); TestGlAbstraction& gl = application.GetGlAbstraction(); @@ -1402,31 +1803,30 @@ int UtcDaliRendererUniformMapPrecendence02(void) // Expect that the actor's fade color property is accessed Vector4 actualValue(Vector4::ZERO); - DALI_TEST_CHECK( gl.GetUniformValue( "uFadeColor", actualValue ) ); - DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION ); + DALI_TEST_CHECK(gl.GetUniformValue("uFadeColor", actualValue)); + DALI_TEST_EQUALS(actualValue, Color::GREEN, TEST_LOCATION); // Animate texture set's fade color property. Should be no change to uniform - Animation animation = Animation::New(1.0f); + Animation animation = Animation::New(1.0f); KeyFrames keyFrames = KeyFrames::New(); keyFrames.Add(0.0f, Color::WHITE); keyFrames.Add(1.0f, Color::TRANSPARENT); - animation.AnimateBetween( Property( shader, shaderFadeColorIndex ), keyFrames ); + animation.AnimateBetween(Property(shader, shaderFadeColorIndex), keyFrames); animation.Play(); application.SendNotification(); application.Render(500); - DALI_TEST_CHECK( gl.GetUniformValue( "uFadeColor", actualValue ) ); - DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION ); + DALI_TEST_CHECK(gl.GetUniformValue("uFadeColor", actualValue)); + DALI_TEST_EQUALS(actualValue, Color::GREEN, TEST_LOCATION); application.Render(500); - DALI_TEST_CHECK( gl.GetUniformValue( "uFadeColor", actualValue ) ); - DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION ); + DALI_TEST_CHECK(gl.GetUniformValue("uFadeColor", actualValue)); + DALI_TEST_EQUALS(actualValue, Color::GREEN, TEST_LOCATION); END_TEST; } - int UtcDaliRendererUniformMapPrecendence03(void) { TestApplication application; @@ -1435,22 +1835,22 @@ int UtcDaliRendererUniformMapPrecendence03(void) Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64); - Shader shader = Shader::New("VertexSource", "FragmentSource"); - TextureSet textureSet = CreateTextureSet( image ); + Shader shader = Shader::New("VertexSource", "FragmentSource"); + TextureSet textureSet = CreateTextureSet(image); Geometry geometry = CreateQuadGeometry(); - Renderer renderer = Renderer::New( geometry, shader ); - renderer.SetTextures( textureSet ); + Renderer renderer = Renderer::New(geometry, shader); + renderer.SetTextures(textureSet); Actor actor = Actor::New(); actor.AddRenderer(renderer); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); application.GetScene().Add(actor); application.SendNotification(); application.Render(0); // Don't add property / uniform map to renderer or actor - shader.RegisterProperty( "uFadeColor", Color::BLACK ); + shader.RegisterProperty("uFadeColor", Color::BLACK); TestGlAbstraction& gl = application.GetGlAbstraction(); @@ -1459,8 +1859,8 @@ int UtcDaliRendererUniformMapPrecendence03(void) // Expect that the shader's fade color property is accessed Vector4 actualValue(Vector4::ZERO); - DALI_TEST_CHECK( gl.GetUniformValue( "uFadeColor", actualValue ) ); - DALI_TEST_EQUALS( actualValue, Color::BLACK, TEST_LOCATION ); + DALI_TEST_CHECK(gl.GetUniformValue("uFadeColor", actualValue)); + DALI_TEST_EQUALS(actualValue, Color::BLACK, TEST_LOCATION); END_TEST; } @@ -1473,23 +1873,23 @@ int UtcDaliRendererUniformMapMultipleUniforms01(void) Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64); - Shader shader = Shader::New("VertexSource", "FragmentSource"); - TextureSet textureSet = CreateTextureSet( image ); + Shader shader = Shader::New("VertexSource", "FragmentSource"); + TextureSet textureSet = CreateTextureSet(image); Geometry geometry = CreateQuadGeometry(); - Renderer renderer = Renderer::New( geometry, shader ); - renderer.SetTextures( textureSet ); + Renderer renderer = Renderer::New(geometry, shader); + renderer.SetTextures(textureSet); Actor actor = Actor::New(); actor.AddRenderer(renderer); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); application.GetScene().Add(actor); application.SendNotification(); application.Render(0); - renderer.RegisterProperty( "uUniform1", Color::RED ); - actor.RegisterProperty( "uUniform2", Color::GREEN ); - shader.RegisterProperty( "uUniform3", Color::MAGENTA ); + renderer.RegisterProperty("uUniform1", Color::RED); + actor.RegisterProperty("uUniform2", Color::GREEN); + shader.RegisterProperty("uUniform3", Color::MAGENTA); TestGlAbstraction& gl = application.GetGlAbstraction(); @@ -1498,16 +1898,16 @@ int UtcDaliRendererUniformMapMultipleUniforms01(void) // Expect that each of the object's uniforms are set Vector4 uniform1Value(Vector4::ZERO); - DALI_TEST_CHECK( gl.GetUniformValue( "uUniform1", uniform1Value ) ); - DALI_TEST_EQUALS( uniform1Value, Color::RED, TEST_LOCATION ); + DALI_TEST_CHECK(gl.GetUniformValue("uUniform1", uniform1Value)); + DALI_TEST_EQUALS(uniform1Value, Color::RED, TEST_LOCATION); Vector4 uniform2Value(Vector4::ZERO); - DALI_TEST_CHECK( gl.GetUniformValue( "uUniform2", uniform2Value ) ); - DALI_TEST_EQUALS( uniform2Value, Color::GREEN, TEST_LOCATION ); + DALI_TEST_CHECK(gl.GetUniformValue("uUniform2", uniform2Value)); + DALI_TEST_EQUALS(uniform2Value, Color::GREEN, TEST_LOCATION); Vector4 uniform3Value(Vector4::ZERO); - DALI_TEST_CHECK( gl.GetUniformValue( "uUniform3", uniform3Value ) ); - DALI_TEST_EQUALS( uniform3Value, Color::MAGENTA, TEST_LOCATION ); + DALI_TEST_CHECK(gl.GetUniformValue("uUniform3", uniform3Value)); + DALI_TEST_EQUALS(uniform3Value, Color::MAGENTA, TEST_LOCATION); END_TEST; } @@ -1520,28 +1920,28 @@ int UtcDaliRendererUniformMapMultipleUniforms02(void) Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64); - Shader shader = Shader::New("VertexSource", "FragmentSource"); - TextureSet textureSet = CreateTextureSet( image ); + Shader shader = Shader::New("VertexSource", "FragmentSource"); + TextureSet textureSet = CreateTextureSet(image); Geometry geometry = CreateQuadGeometry(); - Renderer renderer = Renderer::New( geometry, shader ); - renderer.SetTextures( textureSet ); + Renderer renderer = Renderer::New(geometry, shader); + renderer.SetTextures(textureSet); Actor actor = Actor::New(); actor.AddRenderer(renderer); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); application.GetScene().Add(actor); application.SendNotification(); application.Render(0); Property::Value value1(Color::RED); - renderer.RegisterProperty( "uFadeColor", value1 ); + renderer.RegisterProperty("uFadeColor", value1); Property::Value value2(1.0f); - actor.RegisterProperty( "uFadeProgress", value2 ); + actor.RegisterProperty("uFadeProgress", value2); Property::Value value3(Matrix3::IDENTITY); - shader.RegisterProperty( "uANormalMatrix", value3 ); + shader.RegisterProperty("uANormalMatrix", value3); TestGlAbstraction& gl = application.GetGlAbstraction(); @@ -1550,68 +1950,41 @@ int UtcDaliRendererUniformMapMultipleUniforms02(void) // Expect that each of the object's uniforms are set Vector4 uniform1Value(Vector4::ZERO); - DALI_TEST_CHECK( gl.GetUniformValue( "uFadeColor", uniform1Value ) ); - DALI_TEST_EQUALS( uniform1Value, value1.Get(), TEST_LOCATION ); + DALI_TEST_CHECK(gl.GetUniformValue("uFadeColor", uniform1Value)); + DALI_TEST_EQUALS(uniform1Value, value1.Get(), TEST_LOCATION); float uniform2Value(0.0f); - DALI_TEST_CHECK( gl.GetUniformValue( "uFadeProgress", uniform2Value ) ); - DALI_TEST_EQUALS( uniform2Value, value2.Get(), TEST_LOCATION ); + DALI_TEST_CHECK(gl.GetUniformValue("uFadeProgress", uniform2Value)); + DALI_TEST_EQUALS(uniform2Value, value2.Get(), TEST_LOCATION); Matrix3 uniform3Value; - DALI_TEST_CHECK( gl.GetUniformValue( "uANormalMatrix", uniform3Value ) ); - DALI_TEST_EQUALS( uniform3Value, value3.Get(), TEST_LOCATION ); + DALI_TEST_CHECK(gl.GetUniformValue("uANormalMatrix", uniform3Value)); + DALI_TEST_EQUALS(uniform3Value, value3.Get(), TEST_LOCATION); END_TEST; } - -Renderer CreateRenderer( Actor actor, Geometry geometry, Shader shader, int depthIndex ) +int UtcDaliRendererRenderOrder2DLayer(void) { - Texture image0 = Texture::New(TextureType::TEXTURE_2D, Pixel::RGB888, 64, 64); - TextureSet textureSet0 = CreateTextureSet( image0 ); - Renderer renderer0 = Renderer::New( geometry, shader ); - renderer0.SetTextures( textureSet0 ); - renderer0.SetProperty( Renderer::Property::DEPTH_INDEX, depthIndex ); - actor.AddRenderer(renderer0); - return renderer0; -} + TestApplication application; + tet_infoline("Test the rendering order in a 2D layer is correct"); - -Actor CreateActor( Actor parent, int siblingOrder, const char* location ) -{ - Actor actor = Actor::New(); - actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER); - actor.SetProperty( Actor::Property::PARENT_ORIGIN,AnchorPoint::CENTER); - actor.SetProperty( Actor::Property::POSITION, Vector2(0.0f,0.0f)); - actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) ); - parent.Add(actor); - actor.SetProperty( Dali::DevelActor::Property::SIBLING_ORDER, siblingOrder ); - DALI_TEST_EQUALS( actor.GetProperty( Dali::DevelActor::Property::SIBLING_ORDER), siblingOrder, TEST_INNER_LOCATION(location) ); - - return actor; -} - -int UtcDaliRendererRenderOrder2DLayer(void) -{ - TestApplication application; - tet_infoline("Test the rendering order in a 2D layer is correct"); - - Shader shader = Shader::New("VertexSource", "FragmentSource"); - Geometry geometry = CreateQuadGeometry(); + Shader shader = Shader::New("VertexSource", "FragmentSource"); + Geometry geometry = CreateQuadGeometry(); Actor root = application.GetScene().GetRootLayer(); - Actor actor0 = CreateActor( root, 0, TEST_LOCATION ); - Renderer renderer0 = CreateRenderer( actor0, geometry, shader, 0 ); + Actor actor0 = CreateActor(root, 0, TEST_LOCATION); + Renderer renderer0 = CreateRenderer(actor0, geometry, shader, 0); - Actor actor1 = CreateActor( root, 0, TEST_LOCATION ); - Renderer renderer1 = CreateRenderer( actor1, geometry, shader, 0 ); + Actor actor1 = CreateActor(root, 0, TEST_LOCATION); + Renderer renderer1 = CreateRenderer(actor1, geometry, shader, 0); - Actor actor2 = CreateActor( root, 0, TEST_LOCATION ); - Renderer renderer2 = CreateRenderer( actor2, geometry, shader, 0 ); + Actor actor2 = CreateActor(root, 0, TEST_LOCATION); + Renderer renderer2 = CreateRenderer(actor2, geometry, shader, 0); - Actor actor3 = CreateActor( root, 0, TEST_LOCATION ); - Renderer renderer3 = CreateRenderer( actor3, geometry, shader, 0 ); + Actor actor3 = CreateActor(root, 0, TEST_LOCATION); + Renderer renderer3 = CreateRenderer(actor3, geometry, shader, 0); application.SendNotification(); application.Render(0); @@ -1639,26 +2012,27 @@ int UtcDaliRendererRenderOrder2DLayer(void) application.Render(0); TestGlAbstraction& gl = application.GetGlAbstraction(); + gl.GetTextureTrace().Reset(); gl.EnableTextureCallTrace(true); application.SendNotification(); application.Render(0); int textureBindIndex[4]; - for( unsigned int i(0); i<4; ++i ) + for(unsigned int i(0); i < 4; ++i) { std::stringstream params; - params << GL_TEXTURE_2D<<", "< -void CheckEnumerationProperty( TestApplication& application, Renderer& renderer, Property::Index propertyIndex, T initialValue, T firstCheckEnumeration, T secondCheckEnumeration, std::string secondCheckString ) +template +void CheckEnumerationProperty(TestApplication& application, Renderer& renderer, Property::Index propertyIndex, T initialValue, T firstCheckEnumeration, T secondCheckEnumeration, std::string secondCheckString) { application.SendNotification(); application.Render(); - DALI_TEST_CHECK( renderer.GetProperty( propertyIndex ) == static_cast( initialValue ) ); - DALI_TEST_CHECK( renderer.GetCurrentProperty< int >( propertyIndex ) == static_cast( initialValue ) ); - renderer.SetProperty( propertyIndex, firstCheckEnumeration ); - DALI_TEST_CHECK( renderer.GetProperty( propertyIndex ) == static_cast( firstCheckEnumeration ) ); - DALI_TEST_CHECK( renderer.GetCurrentProperty< int >( propertyIndex ) != static_cast( firstCheckEnumeration ) ); + DALI_TEST_CHECK(renderer.GetProperty(propertyIndex) == static_cast(initialValue)); + DALI_TEST_CHECK(renderer.GetCurrentProperty(propertyIndex) == static_cast(initialValue)); + renderer.SetProperty(propertyIndex, firstCheckEnumeration); + DALI_TEST_CHECK(renderer.GetProperty(propertyIndex) == static_cast(firstCheckEnumeration)); + DALI_TEST_CHECK(renderer.GetCurrentProperty(propertyIndex) != static_cast(firstCheckEnumeration)); application.SendNotification(); application.Render(); - DALI_TEST_CHECK( renderer.GetProperty( propertyIndex ) == static_cast( firstCheckEnumeration ) ); - DALI_TEST_CHECK( renderer.GetCurrentProperty< int >( propertyIndex ) == static_cast( firstCheckEnumeration ) ); + DALI_TEST_CHECK(renderer.GetProperty(propertyIndex) == static_cast(firstCheckEnumeration)); + DALI_TEST_CHECK(renderer.GetCurrentProperty(propertyIndex) == static_cast(firstCheckEnumeration)); - renderer.SetProperty( propertyIndex, secondCheckString ); - DALI_TEST_CHECK( renderer.GetProperty( propertyIndex ) == static_cast( secondCheckEnumeration ) ); - DALI_TEST_CHECK( renderer.GetCurrentProperty< int >( propertyIndex ) != static_cast( secondCheckEnumeration ) ); + renderer.SetProperty(propertyIndex, secondCheckString); + DALI_TEST_CHECK(renderer.GetProperty(propertyIndex) == static_cast(secondCheckEnumeration)); + DALI_TEST_CHECK(renderer.GetCurrentProperty(propertyIndex) != static_cast(secondCheckEnumeration)); application.SendNotification(); application.Render(); - DALI_TEST_CHECK( renderer.GetProperty( propertyIndex ) == static_cast( secondCheckEnumeration ) ); - DALI_TEST_CHECK( renderer.GetCurrentProperty< int >( propertyIndex ) == static_cast( secondCheckEnumeration ) ); + DALI_TEST_CHECK(renderer.GetProperty(propertyIndex) == static_cast(secondCheckEnumeration)); + DALI_TEST_CHECK(renderer.GetCurrentProperty(propertyIndex) == static_cast(secondCheckEnumeration)); } int UtcDaliRendererEnumProperties(void) { TestApplication application; - tet_infoline( "Test Renderer enumeration properties can be set with both integer and string values" ); + tet_infoline("Test Renderer enumeration properties can be set with both integer and string values"); Geometry geometry = CreateQuadGeometry(); - Shader shader = CreateShader(); - Renderer renderer = Renderer::New( geometry, shader ); + Shader shader = CreateShader(); + Renderer renderer = Renderer::New(geometry, shader); Actor actor = Actor::New(); actor.AddRenderer(renderer); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); application.GetScene().Add(actor); /* @@ -2261,38 +2655,53 @@ int UtcDaliRendererEnumProperties(void) * @see CheckEnumerationProperty for details of the checks performed. */ - CheckEnumerationProperty< FaceCullingMode::Type >( application, renderer, Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::NONE, FaceCullingMode::FRONT, FaceCullingMode::BACK, "BACK" ); - CheckEnumerationProperty< BlendMode::Type >( application, renderer, Renderer::Property::BLEND_MODE, BlendMode::AUTO, BlendMode::OFF, BlendMode::ON, "ON" ); - CheckEnumerationProperty< BlendEquation::Type >( application, renderer, Renderer::Property::BLEND_EQUATION_RGB, BlendEquation::ADD, BlendEquation::SUBTRACT, BlendEquation::REVERSE_SUBTRACT, "REVERSE_SUBTRACT" ); - CheckEnumerationProperty< BlendEquation::Type >( application, renderer, Renderer::Property::BLEND_EQUATION_ALPHA, BlendEquation::ADD, BlendEquation::SUBTRACT, BlendEquation::REVERSE_SUBTRACT, "REVERSE_SUBTRACT" ); - CheckEnumerationProperty< BlendFactor::Type >( application, renderer, Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::SRC_ALPHA, BlendFactor::ONE, BlendFactor::SRC_COLOR, "SRC_COLOR" ); - CheckEnumerationProperty< BlendFactor::Type >( application, renderer, Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::SRC_COLOR, "SRC_COLOR" ); - CheckEnumerationProperty< BlendFactor::Type >( application, renderer, Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::SRC_COLOR, "SRC_COLOR" ); - CheckEnumerationProperty< BlendFactor::Type >( application, renderer, Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::SRC_COLOR, "SRC_COLOR" ); - CheckEnumerationProperty< DepthWriteMode::Type >( application, renderer, Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::AUTO, DepthWriteMode::OFF, DepthWriteMode::ON, "ON" ); - CheckEnumerationProperty< DepthFunction::Type >( application, renderer, Renderer::Property::DEPTH_FUNCTION, DepthFunction::LESS, DepthFunction::ALWAYS, DepthFunction::GREATER, "GREATER" ); - CheckEnumerationProperty< DepthTestMode::Type >( application, renderer, Renderer::Property::DEPTH_TEST_MODE, DepthTestMode::AUTO, DepthTestMode::OFF, DepthTestMode::ON, "ON" ); - CheckEnumerationProperty< StencilFunction::Type >( application, renderer, Renderer::Property::STENCIL_FUNCTION, StencilFunction::ALWAYS, StencilFunction::LESS, StencilFunction::EQUAL, "EQUAL" ); - CheckEnumerationProperty< RenderMode::Type >( application, renderer, Renderer::Property::RENDER_MODE, RenderMode::AUTO, RenderMode::NONE, RenderMode::STENCIL, "STENCIL" ); - CheckEnumerationProperty< StencilOperation::Type >( application, renderer, Renderer::Property::STENCIL_OPERATION_ON_FAIL, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT" ); - CheckEnumerationProperty< StencilOperation::Type >( application, renderer, Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT" ); - CheckEnumerationProperty< StencilOperation::Type >( application, renderer, Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT" ); + CheckEnumerationProperty(application, renderer, Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::NONE, FaceCullingMode::FRONT, FaceCullingMode::BACK, "BACK"); + CheckEnumerationProperty(application, renderer, Renderer::Property::BLEND_MODE, BlendMode::AUTO, BlendMode::OFF, BlendMode::ON, "ON"); + CheckEnumerationProperty(application, renderer, Renderer::Property::BLEND_EQUATION_RGB, BlendEquation::ADD, BlendEquation::SUBTRACT, BlendEquation::REVERSE_SUBTRACT, "REVERSE_SUBTRACT"); + CheckEnumerationProperty(application, renderer, Renderer::Property::BLEND_EQUATION_ALPHA, BlendEquation::ADD, BlendEquation::SUBTRACT, BlendEquation::REVERSE_SUBTRACT, "REVERSE_SUBTRACT"); + CheckEnumerationProperty(application, renderer, Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::SRC_ALPHA, BlendFactor::ONE, BlendFactor::SRC_COLOR, "SRC_COLOR"); + CheckEnumerationProperty(application, renderer, Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::SRC_COLOR, "SRC_COLOR"); + CheckEnumerationProperty(application, renderer, Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::SRC_COLOR, "SRC_COLOR"); + CheckEnumerationProperty(application, renderer, Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::SRC_COLOR, "SRC_COLOR"); + CheckEnumerationProperty(application, renderer, Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::AUTO, DepthWriteMode::OFF, DepthWriteMode::ON, "ON"); + CheckEnumerationProperty(application, renderer, Renderer::Property::DEPTH_FUNCTION, DepthFunction::LESS, DepthFunction::ALWAYS, DepthFunction::GREATER, "GREATER"); + CheckEnumerationProperty(application, renderer, Renderer::Property::DEPTH_TEST_MODE, DepthTestMode::AUTO, DepthTestMode::OFF, DepthTestMode::ON, "ON"); + CheckEnumerationProperty(application, renderer, Renderer::Property::STENCIL_FUNCTION, StencilFunction::ALWAYS, StencilFunction::LESS, StencilFunction::EQUAL, "EQUAL"); + CheckEnumerationProperty(application, renderer, Renderer::Property::RENDER_MODE, RenderMode::AUTO, RenderMode::NONE, RenderMode::STENCIL, "STENCIL"); + CheckEnumerationProperty(application, renderer, Renderer::Property::STENCIL_OPERATION_ON_FAIL, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT"); + CheckEnumerationProperty(application, renderer, Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT"); + CheckEnumerationProperty(application, renderer, Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT"); + + if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::MAX) && + Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::MIN)) + { + application.SendNotification(); + application.Render(); + CheckEnumerationProperty(application, renderer, DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::REVERSE_SUBTRACT, DevelBlendEquation::MAX, DevelBlendEquation::MIN, "MIN"); + } + + if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN)) + { + application.SendNotification(); + application.Render(); + CheckEnumerationProperty(application, renderer, DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::MIN, DevelBlendEquation::MULTIPLY, DevelBlendEquation::SCREEN, "SCREEN"); + } END_TEST; } -Renderer RendererTestFixture( TestApplication& application ) +Renderer RendererTestFixture(TestApplication& application) { Geometry geometry = CreateQuadGeometry(); - Shader shader = CreateShader(); - Renderer renderer = Renderer::New( geometry, shader ); + Shader shader = CreateShader(); + Renderer renderer = Renderer::New(geometry, shader); Actor actor = Actor::New(); - actor.AddRenderer( renderer ); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); - Integration::Scene stage = application.GetScene(); - stage.GetRootLayer().SetProperty( Layer::Property::BEHAVIOR, Layer::LAYER_3D ); - stage.Add( actor ); + actor.AddRenderer(renderer); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); + Integration::Scene scene = application.GetScene(); + scene.GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D); + scene.Add(actor); return renderer; } @@ -2302,62 +2711,63 @@ int UtcDaliRendererSetDepthTestMode(void) TestApplication application; tet_infoline("Test setting the DepthTestMode"); - Renderer renderer = RendererTestFixture( application ); - TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); - glAbstraction.EnableEnableDisableCallTrace( true ); - TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace(); + Renderer renderer = RendererTestFixture(application); + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace(); + glEnableDisableStack.Enable(true); + glEnableDisableStack.EnableLogging(true); glEnableDisableStack.Reset(); application.SendNotification(); application.Render(); // Check depth-test is enabled by default. - DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetDepthTestString() ) ); - DALI_TEST_CHECK( !glEnableDisableStack.FindMethodAndParams( "Disable", GetDepthTestString() ) ); + DALI_TEST_CHECK(glEnableDisableStack.FindMethodAndParams("Enable", GetDepthTestString())); + DALI_TEST_CHECK(!glEnableDisableStack.FindMethodAndParams("Disable", GetDepthTestString())); // 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. - renderer.SetProperty( Renderer::Property::DEPTH_TEST_MODE, DepthTestMode::OFF ); - renderer.SetProperty( Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::OFF ); + renderer.SetProperty(Renderer::Property::DEPTH_TEST_MODE, DepthTestMode::OFF); + renderer.SetProperty(Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::OFF); glEnableDisableStack.Reset(); application.SendNotification(); application.Render(); // Check the depth buffer was disabled. - DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Disable", GetDepthTestString() ) ); + DALI_TEST_CHECK(glEnableDisableStack.FindMethodAndParams("Disable", GetDepthTestString())); // Turn on automatic mode depth-testing. // Layer behavior is currently set to LAYER_3D so AUTO should enable depth-testing. - renderer.SetProperty( Renderer::Property::DEPTH_TEST_MODE, DepthTestMode::AUTO ); + renderer.SetProperty(Renderer::Property::DEPTH_TEST_MODE, DepthTestMode::AUTO); glEnableDisableStack.Reset(); application.SendNotification(); application.Render(); // Check depth-test is now enabled. - DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetDepthTestString() ) ); - DALI_TEST_CHECK( !glEnableDisableStack.FindMethodAndParams( "Disable", GetDepthTestString() ) ); + DALI_TEST_CHECK(glEnableDisableStack.FindMethodAndParams("Enable", GetDepthTestString())); + DALI_TEST_CHECK(!glEnableDisableStack.FindMethodAndParams("Disable", GetDepthTestString())); // Change the layer behavior to LAYER_UI. // Note this will also disable depth testing for the layer by default, we test this first. - application.GetScene().GetRootLayer().SetProperty( Layer::Property::BEHAVIOR, Layer::LAYER_UI ); + application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_UI); glEnableDisableStack.Reset(); application.SendNotification(); application.Render(); // Check depth-test is disabled. - DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Disable", GetDepthTestString() ) ); + DALI_TEST_CHECK(glEnableDisableStack.FindMethodAndParams("Disable", GetDepthTestString())); // Turn the layer depth-test flag back on, and confirm that depth testing is now on. - application.GetScene().GetRootLayer().SetProperty(Layer::Property::DEPTH_TEST, true ); + application.GetScene().GetRootLayer().SetProperty(Layer::Property::DEPTH_TEST, true); glEnableDisableStack.Reset(); application.SendNotification(); application.Render(); // Check depth-test is *still* disabled. - DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetDepthTestString() ) ); + DALI_TEST_CHECK(glEnableDisableStack.FindMethodAndParams("Enable", GetDepthTestString())); END_TEST; } @@ -2367,43 +2777,100 @@ int UtcDaliRendererSetDepthWriteMode(void) TestApplication application; tet_infoline("Test setting the DepthWriteMode"); - Renderer renderer = RendererTestFixture( application ); + Renderer renderer = RendererTestFixture(application); TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); application.SendNotification(); application.Render(); // Check the default depth-write status first. - DALI_TEST_CHECK( glAbstraction.GetLastDepthMask() ); + DALI_TEST_CHECK(glAbstraction.GetLastDepthMask()); // Turn off depth-writing. - renderer.SetProperty( Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::OFF ); + renderer.SetProperty(Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::OFF); application.SendNotification(); application.Render(); // Check depth-write is now disabled. - DALI_TEST_CHECK( !glAbstraction.GetLastDepthMask() ); + DALI_TEST_CHECK(!glAbstraction.GetLastDepthMask()); // Test the AUTO mode for depth-writing. // As our renderer is opaque, depth-testing should be enabled. - renderer.SetProperty( Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::AUTO ); + renderer.SetProperty(Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::AUTO); application.SendNotification(); application.Render(); // Check depth-write is now enabled. - DALI_TEST_CHECK( glAbstraction.GetLastDepthMask() ); + DALI_TEST_CHECK(glAbstraction.GetLastDepthMask()); // Now make the renderer be treated as translucent by enabling blending. // The AUTO depth-write mode should turn depth-write off in this scenario. - renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON ); + renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON); + + application.SendNotification(); + application.Render(); + + // Check depth-write is now disabled. + DALI_TEST_CHECK(!glAbstraction.GetLastDepthMask()); + + END_TEST; +} + +int UtcDaliRendererBlendModeUseActorOpacity(void) +{ + TestApplication application; + tet_infoline("Test setting the UseActorOpacity"); + + Geometry geometry = CreateQuadGeometry(); + Shader shader = CreateShader(); + Renderer renderer = Renderer::New(geometry, shader); + + Actor actor = Actor::New(); + actor.AddRenderer(renderer); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); + Integration::Scene scene = application.GetScene(); + scene.GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D); + scene.Add(actor); + + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::USE_ACTOR_OPACITY); + actor.AddRenderer(renderer); + application.GetScene().Add(actor); + + application.SendNotification(); + application.Render(); + + // Check the default depth-write status first. + DALI_TEST_CHECK(glAbstraction.GetLastDepthMask()); + + // Turn off depth-writing. + actor.SetProperty(Dali::Actor::Property::COLOR, Vector4(1, 1, 1, 0.5)); application.SendNotification(); application.Render(); // Check depth-write is now disabled. - DALI_TEST_CHECK( !glAbstraction.GetLastDepthMask() ); + DALI_TEST_CHECK(!glAbstraction.GetLastDepthMask()); + + // Turn on depth-writing. + actor.SetProperty(Dali::Actor::Property::COLOR, Vector4(1, 1, 1, 1)); + + application.SendNotification(); + application.Render(); + + // Check depth-write is now enabled. + DALI_TEST_CHECK(glAbstraction.GetLastDepthMask()); + + // Turn off depth-writing. + actor.SetProperty(Dali::Actor::Property::COLOR, Vector4(1, 1, 1, 0.0)); + + application.SendNotification(); + application.Render(); + + // if actor alpha is 0, SetDepthWriteEnable is not called so GetLastDepthMask returns default value true; + DALI_TEST_CHECK(glAbstraction.GetLastDepthMask()); END_TEST; } @@ -2413,23 +2880,25 @@ int UtcDaliRendererCheckStencilDefaults(void) TestApplication application; tet_infoline("Test the stencil defaults"); - Renderer renderer = RendererTestFixture( application ); - TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); - glAbstraction.EnableEnableDisableCallTrace( true ); - glAbstraction.EnableStencilFunctionCallTrace( true ); - TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace(); - TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace(); + Renderer renderer = RendererTestFixture(application); + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace(); + TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace(); + glEnableDisableStack.Enable(true); + glEnableDisableStack.EnableLogging(true); + glStencilFunctionStack.Enable(true); + glStencilFunctionStack.EnableLogging(true); - ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack ); + ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack); // Check the defaults: - DALI_TEST_EQUALS( static_cast( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION ).Get() ), static_cast( StencilFunction::ALWAYS ), TEST_LOCATION ); - DALI_TEST_EQUALS( static_cast( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION_MASK ).Get() ), 0xFF, TEST_LOCATION ); - DALI_TEST_EQUALS( static_cast( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION_REFERENCE ).Get() ), 0x00, TEST_LOCATION ); - DALI_TEST_EQUALS( static_cast( renderer.GetProperty( Renderer::Property::STENCIL_MASK ).Get() ), 0xFF, TEST_LOCATION ); - DALI_TEST_EQUALS( static_cast( renderer.GetProperty( Renderer::Property::STENCIL_OPERATION_ON_FAIL ).Get() ), static_cast( StencilOperation::KEEP ), TEST_LOCATION ); - DALI_TEST_EQUALS( static_cast( renderer.GetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL ).Get() ), static_cast( StencilOperation::KEEP ), TEST_LOCATION ); - DALI_TEST_EQUALS( static_cast( renderer.GetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_PASS ).Get() ), static_cast( StencilOperation::KEEP ), TEST_LOCATION ); + DALI_TEST_EQUALS(static_cast(renderer.GetProperty(Renderer::Property::STENCIL_FUNCTION).Get()), static_cast(StencilFunction::ALWAYS), TEST_LOCATION); + DALI_TEST_EQUALS(static_cast(renderer.GetProperty(Renderer::Property::STENCIL_FUNCTION_MASK).Get()), 0xFF, TEST_LOCATION); + DALI_TEST_EQUALS(static_cast(renderer.GetProperty(Renderer::Property::STENCIL_FUNCTION_REFERENCE).Get()), 0x00, TEST_LOCATION); + DALI_TEST_EQUALS(static_cast(renderer.GetProperty(Renderer::Property::STENCIL_MASK).Get()), 0xFF, TEST_LOCATION); + DALI_TEST_EQUALS(static_cast(renderer.GetProperty(Renderer::Property::STENCIL_OPERATION_ON_FAIL).Get()), static_cast(StencilOperation::KEEP), TEST_LOCATION); + DALI_TEST_EQUALS(static_cast(renderer.GetProperty(Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL).Get()), static_cast(StencilOperation::KEEP), TEST_LOCATION); + DALI_TEST_EQUALS(static_cast(renderer.GetProperty(Renderer::Property::STENCIL_OPERATION_ON_Z_PASS).Get()), static_cast(StencilOperation::KEEP), TEST_LOCATION); END_TEST; } @@ -2439,72 +2908,75 @@ int UtcDaliRendererSetRenderModeToUseStencilBuffer(void) TestApplication application; tet_infoline("Test setting the RenderMode to use the stencil buffer"); - Renderer renderer = RendererTestFixture( application ); - TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); - glAbstraction.EnableEnableDisableCallTrace( true ); - glAbstraction.EnableStencilFunctionCallTrace( true ); - TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace(); - TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace(); + Renderer renderer = RendererTestFixture(application); + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace(); + TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace(); + glEnableDisableStack.Enable(true); + glEnableDisableStack.EnableLogging(true); + glStencilFunctionStack.Enable(true); + glStencilFunctionStack.EnableLogging(true); // Set the StencilFunction to something other than the default, to confirm it is set as a property, // but NO GL call has been made while the RenderMode is set to not use the stencil buffer. - renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::NONE ); - ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack ); + renderer.SetProperty(Renderer::Property::RENDER_MODE, RenderMode::NONE); + ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack); - renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION, StencilFunction::NEVER ); - DALI_TEST_EQUALS( static_cast( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION ).Get() ), static_cast( StencilFunction::NEVER ), TEST_LOCATION ); + renderer.SetProperty(Renderer::Property::STENCIL_FUNCTION, StencilFunction::NEVER); + DALI_TEST_EQUALS(static_cast(renderer.GetProperty(Renderer::Property::STENCIL_FUNCTION).Get()), static_cast(StencilFunction::NEVER), TEST_LOCATION); - ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack ); - std::string methodString( "StencilFunc" ); - DALI_TEST_CHECK( !glStencilFunctionStack.FindMethod( methodString ) ); + ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack); + std::string methodString("StencilFunc"); + DALI_TEST_CHECK(!glStencilFunctionStack.FindMethod(methodString)); // Test the other RenderModes that will not enable the stencil buffer. - renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::AUTO ); - ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack ); - DALI_TEST_CHECK( !glStencilFunctionStack.FindMethod( methodString ) ); + renderer.SetProperty(Renderer::Property::RENDER_MODE, RenderMode::AUTO); + ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack); + DALI_TEST_CHECK(!glStencilFunctionStack.FindMethod(methodString)); - renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR ); - ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack ); - DALI_TEST_CHECK( !glStencilFunctionStack.FindMethod( methodString ) ); + renderer.SetProperty(Renderer::Property::RENDER_MODE, RenderMode::COLOR); + ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack); + DALI_TEST_CHECK(!glStencilFunctionStack.FindMethod(methodString)); // Now set the RenderMode to modes that will use the stencil buffer, and check the StencilFunction has changed. - renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL ); - ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack ); + renderer.SetProperty(Renderer::Property::RENDER_MODE, RenderMode::STENCIL); + ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack); - DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetStencilTestString() ) ); - DALI_TEST_CHECK( glStencilFunctionStack.FindMethod( methodString ) ); + DALI_TEST_CHECK(glEnableDisableStack.FindMethodAndParams("Enable", GetStencilTestString())); + DALI_TEST_CHECK(glStencilFunctionStack.FindMethod(methodString)); // Test the COLOR_STENCIL RenderMode as it also enables the stencil buffer. // First set a mode to turn off the stencil buffer, so the enable is required. - renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR ); - ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack ); - renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR_STENCIL ); + renderer.SetProperty(Renderer::Property::RENDER_MODE, RenderMode::COLOR); + ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack); + renderer.SetProperty(Renderer::Property::RENDER_MODE, RenderMode::COLOR_STENCIL); // Set a different stencil function as the last one is cached. - renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION, StencilFunction::ALWAYS ); - ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack ); + renderer.SetProperty(Renderer::Property::STENCIL_FUNCTION, StencilFunction::ALWAYS); + ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack); - DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetStencilTestString() ) ); - DALI_TEST_CHECK( glStencilFunctionStack.FindMethod( methodString ) ); + DALI_TEST_CHECK(glEnableDisableStack.FindMethodAndParams("Enable", GetStencilTestString())); + DALI_TEST_CHECK(glStencilFunctionStack.FindMethod(methodString)); END_TEST; } // Helper function for the SetRenderModeToUseColorBuffer test. -void CheckRenderModeColorMask( TestApplication& application, Renderer& renderer, RenderMode::Type renderMode, bool expectedValue ) +void CheckRenderModeColorMask(TestApplication& application, Renderer& renderer, RenderMode::Type renderMode, bool expectedValue) { // Set the RenderMode property to a value that should not allow color buffer writes. - renderer.SetProperty( Renderer::Property::RENDER_MODE, renderMode ); + renderer.SetProperty(Renderer::Property::RENDER_MODE, renderMode); application.SendNotification(); application.Render(); // Check if ColorMask has been called, and that the values are correct. - TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); - const TestGlAbstraction::ColorMaskParams& colorMaskParams( glAbstraction.GetColorMaskParams() ); - - DALI_TEST_EQUALS( colorMaskParams.red, expectedValue, TEST_LOCATION ); - DALI_TEST_EQUALS( colorMaskParams.green, expectedValue, TEST_LOCATION ); - DALI_TEST_EQUALS( colorMaskParams.blue, expectedValue, TEST_LOCATION ); - DALI_TEST_EQUALS( colorMaskParams.alpha, expectedValue, TEST_LOCATION ); + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + const TestGlAbstraction::ColorMaskParams& colorMaskParams(glAbstraction.GetColorMaskParams()); + + DALI_TEST_EQUALS(colorMaskParams.red, expectedValue, TEST_LOCATION); + DALI_TEST_EQUALS(colorMaskParams.green, expectedValue, TEST_LOCATION); + DALI_TEST_EQUALS(colorMaskParams.blue, expectedValue, TEST_LOCATION); + // @todo Only check alpha if framebuffer supports it. + //DALI_TEST_EQUALS(colorMaskParams.alpha, expectedValue, TEST_LOCATION); } int UtcDaliRendererSetRenderModeToUseColorBuffer(void) @@ -2512,15 +2984,15 @@ int UtcDaliRendererSetRenderModeToUseColorBuffer(void) TestApplication application; tet_infoline("Test setting the RenderMode to use the color buffer"); - Renderer renderer = RendererTestFixture( application ); + Renderer renderer = RendererTestFixture(application); // Set the RenderMode property to a value that should not allow color buffer writes. // Then check if ColorMask has been called, and that the values are correct. - CheckRenderModeColorMask( application, renderer, RenderMode::AUTO, true ); - CheckRenderModeColorMask( application, renderer, RenderMode::NONE, false ); - CheckRenderModeColorMask( application, renderer, RenderMode::COLOR, true ); - CheckRenderModeColorMask( application, renderer, RenderMode::STENCIL, false ); - CheckRenderModeColorMask( application, renderer, RenderMode::COLOR_STENCIL, true ); + CheckRenderModeColorMask(application, renderer, RenderMode::AUTO, true); + CheckRenderModeColorMask(application, renderer, RenderMode::NONE, false); + CheckRenderModeColorMask(application, renderer, RenderMode::COLOR, true); + CheckRenderModeColorMask(application, renderer, RenderMode::STENCIL, false); + CheckRenderModeColorMask(application, renderer, RenderMode::COLOR_STENCIL, true); END_TEST; } @@ -2530,31 +3002,33 @@ int UtcDaliRendererSetStencilFunction(void) TestApplication application; tet_infoline("Test setting the StencilFunction"); - Renderer renderer = RendererTestFixture( application ); - TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); - glAbstraction.EnableEnableDisableCallTrace( true ); - glAbstraction.EnableStencilFunctionCallTrace( true ); - TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace(); - TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace(); + Renderer renderer = RendererTestFixture(application); + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace(); + TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace(); + glEnableDisableStack.Enable(true); + glEnableDisableStack.EnableLogging(true); + glStencilFunctionStack.Enable(true); + glStencilFunctionStack.EnableLogging(true); // RenderMode must use the stencil for StencilFunction to operate. - renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL ); - ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack ); + renderer.SetProperty(Renderer::Property::RENDER_MODE, RenderMode::STENCIL); + ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack); /* * Lookup table for testing StencilFunction. * Note: This MUST be in the same order as the Dali::StencilFunction enum. */ const int StencilFunctionLookupTable[] = { - GL_NEVER, - GL_LESS, - GL_EQUAL, - GL_LEQUAL, - GL_GREATER, - GL_NOTEQUAL, - GL_GEQUAL, - GL_ALWAYS - }; const int StencilFunctionLookupTableCount = sizeof( StencilFunctionLookupTable ) / sizeof( StencilFunctionLookupTable[0] ); + GL_NEVER, + GL_LESS, + GL_EQUAL, + GL_LEQUAL, + GL_GREATER, + GL_NOTEQUAL, + GL_GEQUAL, + GL_ALWAYS}; + const int StencilFunctionLookupTableCount = sizeof(StencilFunctionLookupTable) / sizeof(StencilFunctionLookupTable[0]); /* * Loop through all types of StencilFunction, checking: @@ -2563,58 +3037,57 @@ int UtcDaliRendererSetStencilFunction(void) * - Checks the correct parameters to "glStencilFunc" were used */ std::string nonChangingParameters = "0, 255"; - std::string methodString( "StencilFunc" ); - for( int i = 0; i < StencilFunctionLookupTableCount; ++i ) + std::string methodString("StencilFunc"); + for(int i = 0; i < StencilFunctionLookupTableCount; ++i) { // Set the property. - renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION, static_cast( i ) ); + renderer.SetProperty(Renderer::Property::STENCIL_FUNCTION, static_cast(i)); // Check GetProperty returns the same value. - DALI_TEST_EQUALS( static_cast( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION ).Get() ), i, TEST_LOCATION ); + DALI_TEST_EQUALS(static_cast(renderer.GetProperty(Renderer::Property::STENCIL_FUNCTION).Get()), i, TEST_LOCATION); // Reset the trace debug. - ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack ); + ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack); // Check the function is called and the parameters are correct. std::stringstream parameterStream; - parameterStream << StencilFunctionLookupTable[ i ] << ", " << nonChangingParameters; + parameterStream << StencilFunctionLookupTable[i] << ", " << nonChangingParameters; - DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterStream.str() ) ); + DALI_TEST_CHECK(glStencilFunctionStack.FindMethodAndParams(methodString, parameterStream.str())); } // Change the Function Reference only and check the behavior is correct: // 170 is 0xaa in hex / 10101010 in binary (every other bit set). int testValueReference = 170; - renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION_REFERENCE, testValueReference ); + renderer.SetProperty(Renderer::Property::STENCIL_FUNCTION_REFERENCE, testValueReference); - DALI_TEST_EQUALS( static_cast( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION_REFERENCE ).Get() ), testValueReference, TEST_LOCATION ); + DALI_TEST_EQUALS(static_cast(renderer.GetProperty(Renderer::Property::STENCIL_FUNCTION_REFERENCE).Get()), testValueReference, TEST_LOCATION); - ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack ); + ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack); - DALI_TEST_EQUALS( static_cast( renderer.GetCurrentProperty( Renderer::Property::STENCIL_FUNCTION_REFERENCE ).Get() ), testValueReference, TEST_LOCATION ); + DALI_TEST_EQUALS(static_cast(renderer.GetCurrentProperty(Renderer::Property::STENCIL_FUNCTION_REFERENCE).Get()), testValueReference, TEST_LOCATION); std::stringstream parameterStream; - parameterStream << StencilFunctionLookupTable[ StencilOperation::DECREMENT_WRAP ] << ", " << testValueReference << ", 255"; - - DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterStream.str() ) ); + parameterStream << StencilFunctionLookupTable[StencilOperation::DECREMENT_WRAP] << ", " << testValueReference << ", 255"; + DALI_TEST_CHECK(glStencilFunctionStack.FindMethodAndParams(methodString, parameterStream.str())); // Change the Function Mask only and check the behavior is correct: // 85 is 0x55 in hex / 01010101 in binary (every other bit set). int testValueMask = 85; - renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION_MASK, testValueMask ); + renderer.SetProperty(Renderer::Property::STENCIL_FUNCTION_MASK, testValueMask); - DALI_TEST_EQUALS( static_cast( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION_MASK ).Get() ), testValueMask, TEST_LOCATION ); + DALI_TEST_EQUALS(static_cast(renderer.GetProperty(Renderer::Property::STENCIL_FUNCTION_MASK).Get()), testValueMask, TEST_LOCATION); - ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack ); + ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack); - DALI_TEST_EQUALS( static_cast( renderer.GetCurrentProperty( Renderer::Property::STENCIL_FUNCTION_MASK ).Get() ), testValueMask, TEST_LOCATION ); + DALI_TEST_EQUALS(static_cast(renderer.GetCurrentProperty(Renderer::Property::STENCIL_FUNCTION_MASK).Get()), testValueMask, TEST_LOCATION); // Clear the stringstream. - parameterStream.str( std::string() ); - parameterStream << StencilFunctionLookupTable[ StencilOperation::DECREMENT_WRAP ] << ", " << testValueReference << ", " << testValueMask; + parameterStream.str(std::string()); + parameterStream << StencilFunctionLookupTable[StencilOperation::DECREMENT_WRAP] << ", " << testValueReference << ", " << testValueMask; - DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterStream.str() ) ); + DALI_TEST_CHECK(glStencilFunctionStack.FindMethodAndParams(methodString, parameterStream.str())); END_TEST; } @@ -2624,15 +3097,17 @@ int UtcDaliRendererSetStencilOperation(void) TestApplication application; tet_infoline("Test setting the StencilOperation"); - Renderer renderer = RendererTestFixture( application ); - TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); - glAbstraction.EnableEnableDisableCallTrace( true ); - glAbstraction.EnableStencilFunctionCallTrace( true ); - TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace(); - TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace(); + Renderer renderer = RendererTestFixture(application); + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace(); + TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace(); + glEnableDisableStack.Enable(true); + glEnableDisableStack.EnableLogging(true); + glStencilFunctionStack.Enable(true); + glStencilFunctionStack.EnableLogging(true); // RenderMode must use the stencil for StencilOperation to operate. - renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL ); + renderer.SetProperty(Renderer::Property::RENDER_MODE, RenderMode::STENCIL); /* * Lookup table for testing StencilOperation. @@ -2646,18 +3121,18 @@ int UtcDaliRendererSetStencilOperation(void) GL_DECR, GL_INVERT, GL_INCR_WRAP, - GL_DECR_WRAP - }; const int StencilOperationLookupTableCount = sizeof( StencilOperationLookupTable ) / sizeof( StencilOperationLookupTable[0] ); + GL_DECR_WRAP}; + const int StencilOperationLookupTableCount = sizeof(StencilOperationLookupTable) / sizeof(StencilOperationLookupTable[0]); // Set all 3 StencilOperation properties to a default. - renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_FAIL, StencilOperation::KEEP ); - renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, StencilOperation::ZERO ); - renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, StencilOperation::ZERO ); + renderer.SetProperty(Renderer::Property::STENCIL_OPERATION_ON_FAIL, StencilOperation::KEEP); + renderer.SetProperty(Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, StencilOperation::ZERO); + renderer.SetProperty(Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, StencilOperation::ZERO); // Set our expected parameter list to the equivalent result. - int parameters[] = { StencilOperationLookupTable[ StencilOperation::ZERO ], StencilOperationLookupTable[ StencilOperation::ZERO ], StencilOperationLookupTable[ StencilOperation::ZERO ] }; + int parameters[] = {StencilOperationLookupTable[StencilOperation::ZERO], StencilOperationLookupTable[StencilOperation::ZERO], StencilOperationLookupTable[StencilOperation::ZERO]}; - ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack ); + ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack); /* * Loop through all types of StencilOperation, checking: @@ -2666,47 +3141,47 @@ int UtcDaliRendererSetStencilOperation(void) * - Checks the correct parameters to "glStencilFunc" were used * - Checks the above for all 3 parameter placements of StencilOperation ( OnFail, OnZFail, OnPass ) */ - std::string methodString( "StencilOp" ); + std::string methodString("StencilOp"); - for( int i = 0; i < StencilOperationLookupTableCount; ++i ) + for(int i = 0; i < StencilOperationLookupTableCount; ++i) { - for( int j = 0; j < StencilOperationLookupTableCount; ++j ) + for(int j = 0; j < StencilOperationLookupTableCount; ++j) { - for( int k = 0; k < StencilOperationLookupTableCount; ++k ) + for(int k = 0; k < StencilOperationLookupTableCount; ++k) { // Set the property (outer loop causes all 3 different properties to be set separately). - renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_FAIL, static_cast( i ) ); - renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, static_cast( j ) ); - renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, static_cast( k ) ); + renderer.SetProperty(Renderer::Property::STENCIL_OPERATION_ON_FAIL, static_cast(i)); + renderer.SetProperty(Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, static_cast(j)); + renderer.SetProperty(Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, static_cast(k)); // Check GetProperty returns the same value. - DALI_TEST_EQUALS( static_cast( renderer.GetProperty( Renderer::Property::STENCIL_OPERATION_ON_FAIL ).Get() ), i, TEST_LOCATION ); - DALI_TEST_EQUALS( static_cast( renderer.GetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL ).Get() ), j, TEST_LOCATION ); - DALI_TEST_EQUALS( static_cast( renderer.GetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_PASS ).Get() ), k, TEST_LOCATION ); + DALI_TEST_EQUALS(static_cast(renderer.GetProperty(Renderer::Property::STENCIL_OPERATION_ON_FAIL).Get()), i, TEST_LOCATION); + DALI_TEST_EQUALS(static_cast(renderer.GetProperty(Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL).Get()), j, TEST_LOCATION); + DALI_TEST_EQUALS(static_cast(renderer.GetProperty(Renderer::Property::STENCIL_OPERATION_ON_Z_PASS).Get()), k, TEST_LOCATION); // Reset the trace debug. - ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack ); + ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack); // Check the function is called and the parameters are correct. // Set the expected parameter value at its correct index (only) - parameters[ 0u ] = StencilOperationLookupTable[ i ]; - parameters[ 1u ] = StencilOperationLookupTable[ j ]; - parameters[ 2u ] = StencilOperationLookupTable[ k ]; + parameters[0u] = StencilOperationLookupTable[i]; + parameters[1u] = StencilOperationLookupTable[j]; + parameters[2u] = StencilOperationLookupTable[k]; // Build the parameter list. std::stringstream parameterStream; - for( int parameterBuild = 0; parameterBuild < 3; ++parameterBuild ) + for(int parameterBuild = 0; parameterBuild < 3; ++parameterBuild) { - parameterStream << parameters[ parameterBuild ]; + parameterStream << parameters[parameterBuild]; // Comma-separate the parameters. - if( parameterBuild < 2 ) + if(parameterBuild < 2) { parameterStream << ", "; } } // Check the function was called and the parameters were correct. - DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterStream.str() ) ); + DALI_TEST_CHECK(glStencilFunctionStack.FindMethodAndParams(methodString, parameterStream.str())); } } } @@ -2719,46 +3194,48 @@ int UtcDaliRendererSetStencilMask(void) TestApplication application; tet_infoline("Test setting the StencilMask"); - Renderer renderer = RendererTestFixture( application ); - TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); - glAbstraction.EnableEnableDisableCallTrace( true ); - glAbstraction.EnableStencilFunctionCallTrace( true ); - TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace(); - TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace(); + Renderer renderer = RendererTestFixture(application); + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace(); + TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace(); + glEnableDisableStack.Enable(true); + glEnableDisableStack.EnableLogging(true); + glStencilFunctionStack.Enable(true); + glStencilFunctionStack.EnableLogging(true); // RenderMode must use the stencil for StencilMask to operate. - renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL ); + renderer.SetProperty(Renderer::Property::RENDER_MODE, RenderMode::STENCIL); // Set the StencilMask property to a value. - renderer.SetProperty( Renderer::Property::STENCIL_MASK, 0x00 ); + renderer.SetProperty(Renderer::Property::STENCIL_MASK, 0x00); // Check GetProperty returns the same value. - DALI_TEST_EQUALS( static_cast( renderer.GetProperty( Renderer::Property::STENCIL_MASK ).Get() ), 0x00, TEST_LOCATION ); + DALI_TEST_EQUALS(static_cast(renderer.GetProperty(Renderer::Property::STENCIL_MASK).Get()), 0x00, TEST_LOCATION); - ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack ); + ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack); - DALI_TEST_EQUALS( static_cast( renderer.GetCurrentProperty( Renderer::Property::STENCIL_MASK ).Get() ), 0x00, TEST_LOCATION ); + DALI_TEST_EQUALS(static_cast(renderer.GetCurrentProperty(Renderer::Property::STENCIL_MASK).Get()), 0x00, TEST_LOCATION); - std::string methodString( "StencilMask" ); + std::string methodString("StencilMask"); std::string parameterString = "0"; // Check the function was called and the parameters were correct. - DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterString ) ); + DALI_TEST_CHECK(glStencilFunctionStack.FindMethodAndParams(methodString, parameterString)); // Set the StencilMask property to another value to ensure it has changed. - renderer.SetProperty( Renderer::Property::STENCIL_MASK, 0xFF ); + renderer.SetProperty(Renderer::Property::STENCIL_MASK, 0xFF); // Check GetProperty returns the same value. - DALI_TEST_EQUALS( static_cast( renderer.GetProperty( Renderer::Property::STENCIL_MASK ).Get() ), 0xFF, TEST_LOCATION ); + DALI_TEST_EQUALS(static_cast(renderer.GetProperty(Renderer::Property::STENCIL_MASK).Get()), 0xFF, TEST_LOCATION); - ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack ); + ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack); - DALI_TEST_EQUALS( static_cast( renderer.GetCurrentProperty( Renderer::Property::STENCIL_MASK ).Get() ), 0xFF, TEST_LOCATION ); + DALI_TEST_EQUALS(static_cast(renderer.GetCurrentProperty(Renderer::Property::STENCIL_MASK).Get()), 0xFF, TEST_LOCATION); parameterString = "255"; // Check the function was called and the parameters were correct. - DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterString ) ); + DALI_TEST_CHECK(glStencilFunctionStack.FindMethodAndParams(methodString, parameterString)); END_TEST; } @@ -2770,45 +3247,46 @@ int UtcDaliRendererWrongNumberOfTextures(void) //Create a TextureSet with 4 textures (One more texture in the texture set than active samplers) //@note Shaders in the test suit have 3 active samplers. See TestGlAbstraction::GetActiveUniform() - Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 64u, 64u ); + Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64u, 64u); TextureSet textureSet = CreateTextureSet(); - textureSet.SetTexture(0, texture ); - textureSet.SetTexture(1, texture ); - textureSet.SetTexture(2, texture ); - textureSet.SetTexture(3, texture ); - Shader shader = Shader::New("VertexSource", "FragmentSource"); + textureSet.SetTexture(0, texture); + textureSet.SetTexture(1, texture); + textureSet.SetTexture(2, texture); + textureSet.SetTexture(3, texture); + Shader shader = Shader::New("VertexSource", "FragmentSource"); Geometry geometry = CreateQuadGeometry(); - Renderer renderer = Renderer::New( geometry, shader ); - renderer.SetTextures( textureSet ); + Renderer renderer = Renderer::New(geometry, shader); + renderer.SetTextures(textureSet); - Actor actor= Actor::New(); + Actor actor = Actor::New(); actor.AddRenderer(renderer); - actor.SetProperty( Actor::Property::POSITION, Vector2(0.0f,0.0f)); - actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) ); + actor.SetProperty(Actor::Property::POSITION, Vector2(0.0f, 0.0f)); + actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); application.GetScene().Add(actor); - TestGlAbstraction& gl = application.GetGlAbstraction(); - TraceCallStack& drawTrace = gl.GetDrawTrace(); + TestGlAbstraction& gl = application.GetGlAbstraction(); + TraceCallStack& drawTrace = gl.GetDrawTrace(); drawTrace.Reset(); drawTrace.Enable(true); + drawTrace.EnableLogging(true); application.SendNotification(); application.Render(0); //Test we do the drawcall when TextureSet has more textures than there are active samplers in the shader - DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION ); + DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION); //Create a TextureSet with 1 texture (two more active samplers than texture in the texture set) //@note Shaders in the test suit have 3 active samplers. See TestGlAbstraction::GetActiveUniform() textureSet = CreateTextureSet(); - renderer.SetTextures( textureSet ); - textureSet.SetTexture(0, texture ); + renderer.SetTextures(textureSet); + textureSet.SetTexture(0, texture); drawTrace.Reset(); application.SendNotification(); application.Render(0); //Test we do the drawcall when TextureSet has less textures than there are active samplers in the shader. - DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION ); + DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION); END_TEST; } @@ -2817,46 +3295,53 @@ int UtcDaliRendererOpacity(void) { TestApplication application; - tet_infoline( "Test OPACITY property" ); + tet_infoline("Test OPACITY property"); Geometry geometry = CreateQuadGeometry(); - Shader shader = Shader::New( "vertexSrc", "fragmentSrc" ); - Renderer renderer = Renderer::New( geometry, shader ); + Shader shader = Shader::New("vertexSrc", "fragmentSrc"); + Renderer renderer = Renderer::New(geometry, shader); Actor actor = Actor::New(); - actor.AddRenderer( renderer ); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); - actor.SetProperty( Actor::Property::COLOR, Vector4( 1.0f, 0.0f, 1.0f, 1.0f ) ); - application.GetScene().Add( actor ); + actor.AddRenderer(renderer); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); + actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 1.0f)); + application.GetScene().Add(actor); - Property::Value value = renderer.GetProperty( DevelRenderer::Property::OPACITY ); - float opacity; - DALI_TEST_CHECK( value.Get( opacity ) ); - DALI_TEST_EQUALS( opacity, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION ); + Property::Value value = renderer.GetProperty(DevelRenderer::Property::OPACITY); + float opacity; + DALI_TEST_CHECK(value.Get(opacity)); + DALI_TEST_EQUALS(opacity, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION); application.SendNotification(); application.Render(); - Vector4 actualValue; + Vector4 actualValue; + Vector4 actualActorColor; TestGlAbstraction& gl = application.GetGlAbstraction(); - DALI_TEST_CHECK( gl.GetUniformValue< Vector4 >( "uColor", actualValue ) ); - DALI_TEST_EQUALS( actualValue.a, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION ); + DALI_TEST_CHECK(gl.GetUniformValue("uColor", actualValue)); + DALI_TEST_EQUALS(actualValue.a, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION); + DALI_TEST_CHECK(gl.GetUniformValue("uActorColor", actualActorColor)); + DALI_TEST_EQUALS(actualActorColor.a, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION); - renderer.SetProperty( DevelRenderer::Property::OPACITY, 0.5f ); + renderer.SetProperty(DevelRenderer::Property::OPACITY, 0.5f); application.SendNotification(); application.Render(); - value = renderer.GetProperty( DevelRenderer::Property::OPACITY ); - DALI_TEST_CHECK( value.Get( opacity ) ); - DALI_TEST_EQUALS( opacity, 0.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION ); + value = renderer.GetProperty(DevelRenderer::Property::OPACITY); + DALI_TEST_CHECK(value.Get(opacity)); + DALI_TEST_EQUALS(opacity, 0.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION); + + value = renderer.GetCurrentProperty(DevelRenderer::Property::OPACITY); + DALI_TEST_CHECK(value.Get(opacity)); + DALI_TEST_EQUALS(opacity, 0.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION); - value = renderer.GetCurrentProperty( DevelRenderer::Property::OPACITY ); - DALI_TEST_CHECK( value.Get( opacity ) ); - DALI_TEST_EQUALS( opacity, 0.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION ); + DALI_TEST_CHECK(gl.GetUniformValue("uColor", actualValue)); + DALI_TEST_EQUALS(actualValue.a, 0.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION); - DALI_TEST_CHECK( gl.GetUniformValue< Vector4 >( "uColor", actualValue ) ); - DALI_TEST_EQUALS( actualValue.a, 0.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION ); + // Note : Renderer opacity doesn't apply to uActorColor. + DALI_TEST_CHECK(gl.GetUniformValue("uActorColor", actualActorColor)); + DALI_TEST_EQUALS(actualActorColor.a, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION); END_TEST; } @@ -2865,51 +3350,51 @@ int UtcDaliRendererOpacityAnimation(void) { TestApplication application; - tet_infoline( "Test OPACITY property animation" ); + tet_infoline("Test OPACITY property animation"); Geometry geometry = CreateQuadGeometry(); - Shader shader = Shader::New( "vertexSrc", "fragmentSrc" ); - Renderer renderer = Renderer::New( geometry, shader ); + Shader shader = Shader::New("vertexSrc", "fragmentSrc"); + Renderer renderer = Renderer::New(geometry, shader); Actor actor = Actor::New(); - actor.AddRenderer( renderer ); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); - actor.SetProperty( Actor::Property::COLOR, Vector4( 1.0f, 0.0f, 1.0f, 1.0f ) ); - application.GetScene().Add( actor ); + actor.AddRenderer(renderer); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); + actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 1.0f)); + application.GetScene().Add(actor); application.SendNotification(); application.Render(0); - Property::Value value = renderer.GetProperty( DevelRenderer::Property::OPACITY ); - float opacity; - DALI_TEST_CHECK( value.Get( opacity ) ); - DALI_TEST_EQUALS( opacity, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION ); + Property::Value value = renderer.GetProperty(DevelRenderer::Property::OPACITY); + float opacity; + DALI_TEST_CHECK(value.Get(opacity)); + DALI_TEST_EQUALS(opacity, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION); - Animation animation = Animation::New( 1.0f ); - animation.AnimateTo( Property( renderer, DevelRenderer::Property::OPACITY ), 0.0f ); + Animation animation = Animation::New(1.0f); + animation.AnimateTo(Property(renderer, DevelRenderer::Property::OPACITY), 0.0f); animation.Play(); application.SendNotification(); - application.Render( 1000 ); + application.Render(1000); - value = renderer.GetProperty( DevelRenderer::Property::OPACITY ); - DALI_TEST_CHECK( value.Get( opacity ) ); - DALI_TEST_EQUALS( opacity, 0.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION ); + value = renderer.GetProperty(DevelRenderer::Property::OPACITY); + DALI_TEST_CHECK(value.Get(opacity)); + DALI_TEST_EQUALS(opacity, 0.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION); // Need to clear the animation before setting the property as the animation value is baked and will override any previous setters animation.Clear(); - renderer.SetProperty( DevelRenderer::Property::OPACITY, 0.1f ); + renderer.SetProperty(DevelRenderer::Property::OPACITY, 0.1f); - animation.AnimateBy( Property( renderer, DevelRenderer::Property::OPACITY ), 0.5f ); + animation.AnimateBy(Property(renderer, DevelRenderer::Property::OPACITY), 0.5f); animation.Play(); application.SendNotification(); - application.Render( 1000 ); + application.Render(1000); - value = renderer.GetProperty( DevelRenderer::Property::OPACITY ); - DALI_TEST_CHECK( value.Get( opacity ) ); - DALI_TEST_EQUALS( opacity, 0.6f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION ); - DALI_TEST_EQUALS( opacity, renderer.GetCurrentProperty( DevelRenderer::Property::OPACITY ).Get< float >(), Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION ); + value = renderer.GetProperty(DevelRenderer::Property::OPACITY); + DALI_TEST_CHECK(value.Get(opacity)); + DALI_TEST_EQUALS(opacity, 0.6f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION); + DALI_TEST_EQUALS(opacity, renderer.GetCurrentProperty(DevelRenderer::Property::OPACITY).Get(), Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION); END_TEST; } @@ -2918,25 +3403,25 @@ int UtcDaliRendererInvalidProperty(void) { TestApplication application; - tet_infoline( "Test invalid property" ); + tet_infoline("Test invalid property"); Geometry geometry = CreateQuadGeometry(); - Shader shader = Shader::New( "vertexSrc", "fragmentSrc" ); - Renderer renderer = Renderer::New( geometry, shader ); + Shader shader = Shader::New("vertexSrc", "fragmentSrc"); + Renderer renderer = Renderer::New(geometry, shader); Actor actor = Actor::New(); - actor.AddRenderer( renderer ); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); - application.GetScene().Add( actor ); + actor.AddRenderer(renderer); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); + application.GetScene().Add(actor); application.SendNotification(); application.Render(0); - Property::Value value = renderer.GetProperty( Renderer::Property::DEPTH_INDEX + 100 ); - DALI_TEST_CHECK( value.GetType() == Property::Type::NONE ); + Property::Value value = renderer.GetProperty(Renderer::Property::DEPTH_INDEX + 100); + DALI_TEST_CHECK(value.GetType() == Property::Type::NONE); - value = renderer.GetCurrentProperty( Renderer::Property::DEPTH_INDEX + 100 ); - DALI_TEST_CHECK( value.GetType() == Property::Type::NONE ); + value = renderer.GetCurrentProperty(Renderer::Property::DEPTH_INDEX + 100); + DALI_TEST_CHECK(value.GetType() == Property::Type::NONE); END_TEST; } @@ -2945,35 +3430,40 @@ int UtcDaliRendererRenderingBehavior(void) { TestApplication application; - tet_infoline( "Test RENDERING_BEHAVIOR property" ); + tet_infoline("Test RENDERING_BEHAVIOR property"); Geometry geometry = CreateQuadGeometry(); - Shader shader = Shader::New( "vertexSrc", "fragmentSrc" ); - Renderer renderer = Renderer::New( geometry, shader ); + Shader shader = Shader::New("vertexSrc", "fragmentSrc"); + Renderer renderer = Renderer::New(geometry, shader); Actor actor = Actor::New(); - actor.AddRenderer( renderer ); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); - actor.SetProperty( Actor::Property::COLOR, Vector4( 1.0f, 0.0f, 1.0f, 1.0f ) ); - application.GetScene().Add( actor ); + actor.AddRenderer(renderer); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); + actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 1.0f)); + application.GetScene().Add(actor); - Property::Value value = renderer.GetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR ); - int renderingBehavior; - DALI_TEST_CHECK( value.Get( renderingBehavior ) ); - DALI_TEST_EQUALS( static_cast< DevelRenderer::Rendering::Type >( renderingBehavior ), DevelRenderer::Rendering::IF_REQUIRED, TEST_LOCATION ); + Property::Value value = renderer.GetProperty(DevelRenderer::Property::RENDERING_BEHAVIOR); + int renderingBehavior; + DALI_TEST_CHECK(value.Get(renderingBehavior)); + DALI_TEST_EQUALS(static_cast(renderingBehavior), DevelRenderer::Rendering::IF_REQUIRED, TEST_LOCATION); application.SendNotification(); application.Render(); uint32_t updateStatus = application.GetUpdateStatus(); - DALI_TEST_CHECK( !( updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING ) ); + DALI_TEST_CHECK(!(updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING)); + + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + TraceCallStack& drawTrace = glAbstraction.GetDrawTrace(); + drawTrace.Enable(true); + drawTrace.Reset(); - renderer.SetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::CONTINUOUSLY ); + renderer.SetProperty(DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::CONTINUOUSLY); - value = renderer.GetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR ); - DALI_TEST_CHECK( value.Get( renderingBehavior ) ); - DALI_TEST_EQUALS( static_cast< DevelRenderer::Rendering::Type >( renderingBehavior ), DevelRenderer::Rendering::CONTINUOUSLY, TEST_LOCATION ); + value = renderer.GetProperty(DevelRenderer::Property::RENDERING_BEHAVIOR); + DALI_TEST_CHECK(value.Get(renderingBehavior)); + DALI_TEST_EQUALS(static_cast(renderingBehavior), DevelRenderer::Rendering::CONTINUOUSLY, TEST_LOCATION); // Render and check the update status application.SendNotification(); @@ -2981,11 +3471,15 @@ int UtcDaliRendererRenderingBehavior(void) updateStatus = application.GetUpdateStatus(); - DALI_TEST_CHECK( updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING ); + DALI_TEST_CHECK(updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING); - value = renderer.GetCurrentProperty( DevelRenderer::Property::RENDERING_BEHAVIOR ); - DALI_TEST_CHECK( value.Get( renderingBehavior ) ); - DALI_TEST_EQUALS( static_cast< DevelRenderer::Rendering::Type >( renderingBehavior ), DevelRenderer::Rendering::CONTINUOUSLY, TEST_LOCATION ); + value = renderer.GetCurrentProperty(DevelRenderer::Property::RENDERING_BEHAVIOR); + DALI_TEST_CHECK(value.Get(renderingBehavior)); + DALI_TEST_EQUALS(static_cast(renderingBehavior), DevelRenderer::Rendering::CONTINUOUSLY, TEST_LOCATION); + + DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION); + + drawTrace.Reset(); // Render again and check the update status application.SendNotification(); @@ -2993,10 +3487,37 @@ int UtcDaliRendererRenderingBehavior(void) updateStatus = application.GetUpdateStatus(); - DALI_TEST_CHECK( updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING ); + DALI_TEST_CHECK(updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING); + + DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION); + + { + // Render again and check the update status + Animation animation = Animation::New(1.0f); + animation.AnimateTo(Property(renderer, DevelRenderer::Property::OPACITY), 0.0f, TimePeriod(0.5f, 0.5f)); + animation.Play(); + + drawTrace.Reset(); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION); + + drawTrace.Reset(); + + application.SendNotification(); + application.Render(100); + + updateStatus = application.GetUpdateStatus(); + + DALI_TEST_CHECK(updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING); + + DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION); + } // Change rendering behavior - renderer.SetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::IF_REQUIRED ); + renderer.SetProperty(DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::IF_REQUIRED); // Render and check the update status application.SendNotification(); @@ -3004,7 +3525,7 @@ int UtcDaliRendererRenderingBehavior(void) updateStatus = application.GetUpdateStatus(); - DALI_TEST_CHECK( !( updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING ) ); + DALI_TEST_CHECK(!(updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING)); END_TEST; } @@ -3013,27 +3534,27 @@ int UtcDaliRendererRegenerateUniformMap(void) { TestApplication application; - tet_infoline( "Test regenerating uniform map when attaching renderer to the node" ); + tet_infoline("Test regenerating uniform map when attaching renderer to the node"); Geometry geometry = CreateQuadGeometry(); - Shader shader = Shader::New( "vertexSrc", "fragmentSrc" ); - Renderer renderer = Renderer::New( geometry, shader ); + Shader shader = Shader::New("vertexSrc", "fragmentSrc"); + Renderer renderer = Renderer::New(geometry, shader); Actor actor = Actor::New(); - actor.AddRenderer( renderer ); - actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) ); - actor.SetProperty( Actor::Property::COLOR, Vector4( 1.0f, 0.0f, 1.0f, 1.0f ) ); - application.GetScene().Add( actor ); + actor.AddRenderer(renderer); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); + actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 1.0f)); + application.GetScene().Add(actor); application.SendNotification(); application.Render(); - actor.RemoveRenderer( renderer ); - shader = Shader::New( "vertexSrc", "fragmentSrc" ); - shader.RegisterProperty( "opacity", 0.5f ); - renderer.SetShader( shader ); + actor.RemoveRenderer(renderer); + shader = Shader::New("vertexSrc", "fragmentSrc"); + shader.RegisterProperty("opacity", 0.5f); + renderer.SetShader(shader); - Stage::GetCurrent().KeepRendering( 1.0f ); + Stage::GetCurrent().KeepRendering(1.0f); // Update for several frames application.SendNotification(); @@ -3046,13 +3567,691 @@ int UtcDaliRendererRegenerateUniformMap(void) application.Render(); // Add Renderer - actor.AddRenderer( renderer ); + actor.AddRenderer(renderer); application.SendNotification(); application.Render(); // Nothing to test here, the test must not crash auto updateStatus = application.GetUpdateStatus(); - DALI_TEST_CHECK( updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING ); + DALI_TEST_CHECK(updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING); + + END_TEST; +} + +int UtcDaliRendererRenderAfterAddShader(void) +{ + TestApplication application; + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + + tet_infoline("Test regenerating uniform map when shader changed"); + + Geometry geometry = CreateQuadGeometry(); + Shader shader1 = Shader::New("vertexSrc1", "fragmentSrc1"); + Shader shader2 = Shader::New("vertexSrc2", "fragmentSrc2"); + Renderer renderer = Renderer::New(geometry, shader1); + + // Register each shader1 and shader2 only had + shader1.RegisterProperty("uUniform1", Color::CRIMSON); + shader2.RegisterProperty("uShader2Only", Color::AQUA_MARINE); + + Actor actor = Actor::New(); + actor.AddRenderer(renderer); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); + actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 1.0f)); + application.GetScene().Add(actor); + + Property::Value value = renderer.GetProperty(DevelRenderer::Property::RENDERING_BEHAVIOR); + int renderingBehavior; + DALI_TEST_CHECK(value.Get(renderingBehavior)); + DALI_TEST_EQUALS(static_cast(renderingBehavior), DevelRenderer::Rendering::IF_REQUIRED, TEST_LOCATION); + + application.SendNotification(); + application.Render(0); + + // Check uUniform1 rendered and uUniform2 not rendered before + Vector4 actualValue(Vector4::ZERO); + DALI_TEST_CHECK(glAbstraction.GetUniformValue("uUniform1", actualValue)); + DALI_TEST_EQUALS(actualValue, Color::CRIMSON, TEST_LOCATION); + + uint32_t updateStatus = application.GetUpdateStatus(); + + DALI_TEST_CHECK(!(updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING)); + + // Update for several frames + application.SendNotification(); + application.Render(); + application.SendNotification(); + application.Render(); + application.SendNotification(); + application.Render(); + application.SendNotification(); + application.Render(); + application.SendNotification(); + application.Render(); + + TraceCallStack& drawTrace = glAbstraction.GetDrawTrace(); + drawTrace.Enable(true); + drawTrace.Reset(); + + std::vector customUniforms{{"uShader2Only", Property::VECTOR4}}; + + application.GetGraphicsController().AddCustomUniforms(customUniforms); + + // Change shader. + renderer.SetShader(shader2); + + // Render and check the update status + application.SendNotification(); + application.Render(0); + + updateStatus = application.GetUpdateStatus(); + + DALI_TEST_CHECK(!(updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING)); + + DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION); + + // Check uUniform2 rendered now + DALI_TEST_CHECK(glAbstraction.GetUniformValue("uShader2Only", actualValue)); + DALI_TEST_EQUALS(actualValue, Color::AQUA_MARINE, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliRendererAddDrawCommands(void) +{ + TestApplication application; + + tet_infoline("Test adding draw commands to the renderer"); + + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + glAbstraction.EnableEnableDisableCallTrace(true); + + Geometry geometry = CreateQuadGeometry(); + Shader shader = Shader::New("vertexSrc", "fragmentSrc"); + Renderer renderer = Renderer::New(geometry, shader); + + renderer.SetProperty(Renderer::Property::BLEND_MODE, Dali::BlendMode::ON); + Actor actor = Actor::New(); + actor.AddRenderer(renderer); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); + actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 1.0f)); + application.GetScene().Add(actor); + + // Expect delivering a single draw call + auto& drawTrace = glAbstraction.GetDrawTrace(); + drawTrace.Reset(); + drawTrace.Enable(true); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION); + + tet_infoline("\n\nTesting extension draw commands\n"); + auto drawCommand1 = DevelRenderer::DrawCommand{}; + drawCommand1.drawType = DevelRenderer::DrawType::INDEXED; + drawCommand1.firstIndex = 0; + drawCommand1.elementCount = 2; + drawCommand1.queue = DevelRenderer::RENDER_QUEUE_OPAQUE; + + auto drawCommand2 = DevelRenderer::DrawCommand{}; + drawCommand2.drawType = DevelRenderer::DrawType::INDEXED; + drawCommand2.firstIndex = 2; + drawCommand2.elementCount = 2; + drawCommand2.queue = DevelRenderer::RENDER_QUEUE_TRANSPARENT; + + auto drawCommand3 = DevelRenderer::DrawCommand{}; + drawCommand3.drawType = DevelRenderer::DrawType::ARRAY; + drawCommand3.firstIndex = 2; + drawCommand3.elementCount = 2; + drawCommand3.queue = DevelRenderer::RENDER_QUEUE_OPAQUE; + + DevelRenderer::AddDrawCommand(renderer, drawCommand1); + DevelRenderer::AddDrawCommand(renderer, drawCommand2); + DevelRenderer::AddDrawCommand(renderer, drawCommand3); + + drawTrace.Reset(); + drawTrace.Enable(true); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 3, TEST_LOCATION); + END_TEST; +} +int UtcDaliRendererSetGeometryNegative(void) +{ + TestApplication application; + Dali::Renderer instance; + try + { + Dali::Geometry arg1; + instance.SetGeometry(arg1); + DALI_TEST_CHECK(false); // Should not get here + } + catch(...) + { + DALI_TEST_CHECK(true); // We expect an assert + } + END_TEST; +} + +int UtcDaliRendererSetTexturesNegative(void) +{ + TestApplication application; + Dali::Renderer instance; + try + { + Dali::TextureSet arg1; + instance.SetTextures(arg1); + DALI_TEST_CHECK(false); // Should not get here + } + catch(...) + { + DALI_TEST_CHECK(true); // We expect an assert + } + END_TEST; +} + +int UtcDaliRendererSetShaderNegative(void) +{ + TestApplication application; + Dali::Renderer instance; + try + { + Dali::Shader arg1; + instance.SetShader(arg1); + DALI_TEST_CHECK(false); // Should not get here + } + catch(...) + { + DALI_TEST_CHECK(true); // We expect an assert + } + END_TEST; +} + +int UtcDaliRendererGetGeometryNegative(void) +{ + TestApplication application; + Dali::Renderer instance; + try + { + instance.GetGeometry(); + DALI_TEST_CHECK(false); // Should not get here + } + catch(...) + { + DALI_TEST_CHECK(true); // We expect an assert + } + END_TEST; +} + +int UtcDaliRendererGetTexturesNegative(void) +{ + TestApplication application; + Dali::Renderer instance; + try + { + instance.GetTextures(); + DALI_TEST_CHECK(false); // Should not get here + } + catch(...) + { + DALI_TEST_CHECK(true); // We expect an assert + } + END_TEST; +} + +int UtcDaliRendererGetShaderNegative(void) +{ + TestApplication application; + Dali::Renderer instance; + try + { + instance.GetShader(); + DALI_TEST_CHECK(false); // Should not get here + } + catch(...) + { + DALI_TEST_CHECK(true); // We expect an assert + } + END_TEST; +} + +int UtcDaliRendererCheckTextureBindingP(void) +{ + TestApplication application; + + tet_infoline("Test adding draw commands to the renderer"); + + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + glAbstraction.EnableEnableDisableCallTrace(true); + + Geometry geometry = CreateQuadGeometry(); + Shader shader = Shader::New("vertexSrc", "fragmentSrc"); + Renderer renderer = Renderer::New(geometry, shader); + + renderer.SetProperty(Renderer::Property::BLEND_MODE, Dali::BlendMode::ON); + Actor actor = Actor::New(); + actor.AddRenderer(renderer); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); + actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 1.0f)); + application.GetScene().Add(actor); + + TestGraphicsController& graphics = application.GetGraphicsController(); + TraceCallStack& cmdBufCallstack = graphics.mCommandBufferCallStack; + cmdBufCallstack.Enable(true); + + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(!cmdBufCallstack.FindMethod("BindTextures")); + + Texture image0 = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGB888, 64, 64); + TextureSet textureSet0 = CreateTextureSet(image0); + renderer.SetTextures(textureSet0); + + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(cmdBufCallstack.FindMethod("BindTextures")); + END_TEST; +} + +int UtcDaliRendererPreparePipeline(void) +{ + TestApplication application; + + tet_infoline("Test that rendering an actor binds the attributes locs from the reflection"); + + Property::Map vf = CreateModelVertexFormat(); + Geometry modelGeometry = CreateModelGeometry(vf); + Shader shader = Shader::New("vertexSrc", "fragmentSrc"); + Renderer renderer = Renderer::New(modelGeometry, shader); + Actor actor = Actor::New(); + + // Change the order up to get a fair test + Property::Map modelVF; + modelVF["aBoneIndex[0]"] = Property::INTEGER; + modelVF["aBoneIndex[1]"] = Property::INTEGER; + modelVF["aBoneIndex[2]"] = Property::INTEGER; + modelVF["aBoneIndex[3]"] = Property::INTEGER; + modelVF["aBoneWeights[0]"] = Property::FLOAT; + modelVF["aBoneWeights[1]"] = Property::FLOAT; + modelVF["aBoneWeights[2]"] = Property::FLOAT; + modelVF["aBoneWeights[3]"] = Property::FLOAT; + modelVF["aPosition"] = Property::VECTOR3; + modelVF["aNormal"] = Property::VECTOR3; + modelVF["aTexCoord1"] = Property::VECTOR3; + modelVF["aTexCoord2"] = Property::VECTOR3; + + Property::Array vfs; + vfs.PushBack(modelVF); + TestGraphicsController& graphics = application.GetGraphicsController(); + graphics.SetVertexFormats(vfs); + + actor.AddRenderer(renderer); + actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f)); + actor.SetProperty(Actor::Property::COLOR, Color::WHITE); + application.GetScene().Add(actor); + + TraceCallStack& cmdBufCallstack = graphics.mCommandBufferCallStack; + TraceCallStack& graphicsCallstack = graphics.mCallStack; + cmdBufCallstack.Enable(true); + graphicsCallstack.Enable(true); + + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(graphicsCallstack.FindMethod("SubmitCommandBuffers")); + std::vector& submissions = graphics.mSubmitStack; + DALI_TEST_CHECK(submissions.size() > 0); + + TestGraphicsCommandBuffer* cmdBuf = static_cast((submissions.back().cmdBuffer[0])); + + auto result = cmdBuf->GetChildCommandsByType(0 | CommandType::BIND_PIPELINE); + auto pipeline = result[0]->data.bindPipeline.pipeline; + + if(pipeline) + { + DALI_TEST_EQUALS(pipeline->vertexInputState.attributes.size(), 12, TEST_LOCATION); + DALI_TEST_EQUALS(pipeline->vertexInputState.attributes[3].location, // 4th requested attr: aTexCoord2 + 11, + TEST_LOCATION); + DALI_TEST_EQUALS(pipeline->vertexInputState.attributes[3].format, // 4th requested attr: aTexCoord2 + Graphics::VertexInputFormat::FVECTOR3, + TEST_LOCATION); + } + + END_TEST; +} + +int UtcDaliRendererUniformArrayOfStruct(void) +{ + TestApplication application; + tet_infoline("Test that uniforms that are elements of arrays of structs can be accessed"); + + std::vector customUniforms{{"arrayof[10].color", Property::VECTOR4}, + {"arrayof[10].position", Property::VECTOR2}, + {"arrayof[10].normal", Property::VECTOR3}}; + + application.GetGraphicsController().AddCustomUniforms(customUniforms); + + Geometry geometry = CreateQuadGeometry(); + Shader shader = Shader::New("vertexSrc", "fragmentSrc"); + Renderer renderer = Renderer::New(geometry, shader); + Actor actor = Actor::New(); + actor.AddRenderer(renderer); + actor[Actor::Property::SIZE] = Vector2(120, 120); + application.GetScene().Add(actor); + + // Define some properties to match the custom uniforms. + // Ensure they can be written & read back from the abstraction. + + struct UniformIndexPair + { + Property::Index index; + std::string name; + UniformIndexPair(Property::Index index, std::string name) + : index(index), + name(name) + { + } + }; + std::vector uniformIndices; + + std::ostringstream oss; + for(int i = 0; i < 10; ++i) + { + Property::Index index; + oss << "arrayof[" << i << "].color"; + Vector4 color = Color::WHITE; + color.r = 25.5f * i; + index = renderer.RegisterProperty(oss.str(), color); + uniformIndices.emplace_back(index, oss.str()); + + oss.str(""); + oss.clear(); + oss << "arrayof[" << i << "].position"; + Vector2 pos(i, 10 + i * 5); + index = renderer.RegisterProperty(oss.str(), pos); + uniformIndices.emplace_back(index, oss.str()); + + oss.str(""); + oss.clear(); + oss << "arrayof[" << i << "].normal"; + Vector3 normal(i, i * 10, i * 100); + index = renderer.RegisterProperty(oss.str(), normal); + uniformIndices.emplace_back(index, oss.str()); + oss.str(""); + oss.clear(); + } + auto& gl = application.GetGlAbstraction(); + TraceCallStack& callStack = gl.GetSetUniformTrace(); + gl.EnableSetUniformCallTrace(true); + + application.SendNotification(); + application.Render(); + + // Check that the uniforms match. + TraceCallStack::NamedParams params; + for(auto& uniformInfo : uniformIndices) + { + Property::Value value = renderer.GetProperty(uniformInfo.index); + switch(value.GetType()) + { + case Property::VECTOR2: + { + DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniformInfo.name, params)); + Vector2 setValue; + DALI_TEST_CHECK(gl.GetUniformValue(uniformInfo.name.c_str(), setValue)); + DALI_TEST_EQUALS(value.Get(), setValue, 0.001f, TEST_LOCATION); + break; + } + case Property::VECTOR3: + { + DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniformInfo.name, params)); + Vector3 setValue; + DALI_TEST_CHECK(gl.GetUniformValue(uniformInfo.name.c_str(), setValue)); + DALI_TEST_EQUALS(value.Get(), setValue, 0.001f, TEST_LOCATION); + break; + } + case Property::VECTOR4: + { + DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniformInfo.name, params)); + Vector4 setValue; + DALI_TEST_CHECK(gl.GetUniformValue(uniformInfo.name.c_str(), setValue)); + DALI_TEST_EQUALS(value.Get(), setValue, 0.001f, TEST_LOCATION); + break; + } + default: + break; + } + } + + // There is a hash in the property name's uniform map: check this in debugger + // There is a hash in the reflection. Check this in the debugger. + + // Check that the reflection contains individual locs for each array entry's struct element + // and that it hashes the whole string + + // Ensure that the property name's hash is also for the whole string. + + END_TEST; +} + +int utcDaliRendererPartialUpdateChangeUniform(void) +{ + TestApplication application( + TestApplication::DEFAULT_SURFACE_WIDTH, + TestApplication::DEFAULT_SURFACE_HEIGHT, + TestApplication::DEFAULT_HORIZONTAL_DPI, + TestApplication::DEFAULT_VERTICAL_DPI, + true, + true); + + tet_infoline("Check the damaged rect with changing uniform"); + + const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams()); + + std::vector> damagedRects; + Rect clippingRect; + application.SendNotification(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + + // First render pass, nothing to render, adaptor would just do swap buffer. + DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + Shader shader = Shader::New("VertexSource", "FragmentSource"); + Geometry geometry = CreateQuadGeometry(); + Renderer renderer = Renderer::New(geometry, shader); + + Property::Index colorIndex = renderer.RegisterProperty("uFadeColor", Color::WHITE); + + Actor actor = Actor::New(); + actor.AddRenderer(renderer); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f)); + actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f)); + actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + + // 1. Actor added, damaged rect is added size of actor + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + + // Aligned by 16 + clippingRect = Rect(16, 768, 32, 32); // in screen coordinates + DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + // Ensure the damaged rect is empty + DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); + + // 2. Change the uniform value + renderer.SetProperty(colorIndex, Color::RED); + application.SendNotification(); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + + // Aligned by 16 + clippingRect = Rect(16, 768, 32, 32); // in screen coordinates + DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + // 3. Change the uniform value and another property together + actor.SetProperty(Actor::Property::COLOR, Color::YELLOW); + renderer.SetProperty(colorIndex, Color::BLUE); + application.SendNotification(); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + + // Aligned by 16 + clippingRect = Rect(16, 768, 32, 32); // in screen coordinates + DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + // 4. Change the uniform value only + renderer.SetProperty(colorIndex, Color::RED); // Set the previous value (#2) + application.SendNotification(); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + + // Aligned by 16 + clippingRect = Rect(16, 768, 32, 32); // in screen coordinates + DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION); + + END_TEST; +} + +int utcDaliRendererPartialUpdateAddRemoveRenderer(void) +{ + TestApplication application( + TestApplication::DEFAULT_SURFACE_WIDTH, + TestApplication::DEFAULT_SURFACE_HEIGHT, + TestApplication::DEFAULT_HORIZONTAL_DPI, + TestApplication::DEFAULT_VERTICAL_DPI, + true, + true); + + tet_infoline("Check the damaged rect with adding / removing renderer"); + + const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams()); + + Shader shader = Shader::New("VertexSource", "FragmentSource"); + Geometry geometry = CreateQuadGeometry(); + Renderer renderer = Renderer::New(geometry, shader); + + Actor actor = Actor::New(); + actor.AddRenderer(renderer); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f)); + actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f)); + actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + + std::vector> damagedRects; + Rect clippingRect; + + // 1. Actor added, damaged rect is added size of actor + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + + // Aligned by 16 + clippingRect = Rect(16, 768, 32, 32); // in screen coordinates + DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION); + + // 2. Remove renderer + actor.RemoveRenderer(renderer); + application.SendNotification(); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + // 3. Change a property value of the Renderer + renderer.SetProperty(DevelRenderer::Property::OPACITY, 0.5f); + application.SendNotification(); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + + DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); + + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + // 4. Add renderer again + actor.AddRenderer(renderer); + application.SendNotification(); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + // 5. Remove renderer agin + actor.RemoveRenderer(renderer); + application.SendNotification(); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + + application.RenderWithPartialUpdate(damagedRects, clippingRect); END_TEST; }