/*
- * 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.
// EXTERNAL INCLUDES
#include <dali/devel-api/actors/actor-devel.h>
+#include <dali/devel-api/common/capabilities.h>
#include <dali/devel-api/common/stage.h>
#include <dali/devel-api/rendering/renderer-devel.h>
#include <dali/integration-api/render-task-list-integ.h>
#include <dali/public-api/dali-core.h>
-
#include <cstdio>
#include <string>
#include <dali-test-suite-utils.h>
#include <mesh-builder.h>
#include <test-trace-call-stack.h>
+#include "test-graphics-command-buffer.h"
using namespace Dali;
std::string GetStencilTestString(void)
{
std::stringstream stream;
- stream << GL_STENCIL_TEST;
+ stream << std::hex << GL_STENCIL_TEST;
return stream.str();
}
std::string GetDepthTestString(void)
{
std::stringstream stream;
- stream << GL_DEPTH_TEST;
+ stream << std::hex << GL_DEPTH_TEST;
return stream.str();
}
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<int>(Dali::DevelActor::Property::SIBLING_ORDER), siblingOrder, TEST_INNER_LOCATION(location));
+
+ return actor;
+}
+
} // unnamed namespace
void renderer_test_startup(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();
Renderer renderer = Renderer::New(geometry, shader);
- DALI_TEST_EQUALS(renderer.GetPropertyCount(), 26, 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, "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;
}
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<int>(Renderer::Property::FACE_CULLING_MODE);
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<int>(Renderer::Property::FACE_CULLING_MODE);
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<int>(Renderer::Property::FACE_CULLING_MODE);
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<int>(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<int>(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<int>(DevelRenderer::Property::BLEND_EQUATION_RGB);
+ int equationAlpha = renderer.GetProperty<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_EQUALS(glAbstraction.GetLastBlendEquationRgb(), GL_HSL_LUMINOSITY, TEST_LOCATION);
+ }
+
+ END_TEST;
+}
+
int UtcDaliRendererSetBlendMode01(void)
{
TestApplication application;
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));
application.GetScene().Add(actor);
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;
}
application.SendNotification();
application.Render();
- TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
- std::ostringstream blendStr;
- blendStr << GL_BLEND;
+ TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
DALI_TEST_CHECK(!glEnableStack.FindMethod("Enable"));
DALI_TEST_CHECK(!glAbstraction.GetDrawTrace().FindMethod("DrawElements"));
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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");
+
+ 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));
+ application.GetScene().Add(actor);
+
+ 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;
}
mode = renderer.GetProperty<int>(Renderer::Property::BLEND_MODE);
DALI_TEST_EQUALS(static_cast<BlendMode::Type>(mode), BlendMode::OFF, TEST_LOCATION);
+ // ON_WITHOUT_CULL
+ renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON_WITHOUT_CULL);
+ mode = renderer.GetProperty<int>(Renderer::Property::BLEND_MODE);
+ DALI_TEST_EQUALS(static_cast<BlendMode::Type>(mode), BlendMode::ON_WITHOUT_CULL, TEST_LOCATION);
+
END_TEST;
}
application.Render();
Vector4 actualValue(Vector4::ZERO);
+ Vector4 actualActorColor(Vector4::ZERO);
TestGlAbstraction& gl = application.GetGlAbstraction();
DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uColor", actualValue));
DALI_TEST_EQUALS(actualValue, Vector4(1.0f, 0.0f, 1.0f, 0.5f), TEST_LOCATION);
+ DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("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);
DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("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<Vector4>("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);
DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uColor", actualValue));
DALI_TEST_EQUALS(actualValue, Vector4(1.0f, 0.0f, 1.0f, 0.5f), TEST_LOCATION);
+ DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uActorColor", actualActorColor));
+ DALI_TEST_EQUALS(actualActorColor, Vector4(1.0f, 0.0f, 1.0f, 0.5f), TEST_LOCATION);
END_TEST;
}
END_TEST;
}
-Renderer CreateRenderer(Actor actor, Geometry geometry, Shader shader, int depthIndex)
-{
- 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;
-}
-
-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<int>(Dali::DevelActor::Property::SIBLING_ORDER), siblingOrder, TEST_INNER_LOCATION(location));
-
- return actor;
-}
-
int UtcDaliRendererRenderOrder2DLayer(void)
{
TestApplication application;
application.Render(0);
TestGlAbstraction& gl = application.GetGlAbstraction();
+ gl.GetTextureTrace().Reset();
gl.EnableTextureCallTrace(true);
application.SendNotification();
application.Render(0);
for(unsigned int i(0); i < 4; ++i)
{
std::stringstream params;
- params << GL_TEXTURE_2D << ", " << i + 1;
+ params << std::hex << GL_TEXTURE_2D << std::dec << ", " << i + 1;
textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str());
}
application.Render(0);
TestGlAbstraction& gl = application.GetGlAbstraction();
+ gl.GetTextureTrace().Reset();
gl.EnableTextureCallTrace(true);
application.SendNotification();
application.Render(0);
for(unsigned int i(0); i < 6; ++i)
{
std::stringstream params;
- params << GL_TEXTURE_2D << ", " << i + 1;
+ params << std::hex << GL_TEXTURE_2D << std::dec << ", " << i + 1;
textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str());
}
application.Render();
TestGlAbstraction& gl = application.GetGlAbstraction();
+ gl.GetTextureTrace().Reset();
gl.EnableTextureCallTrace(true);
application.SendNotification();
application.Render(0);
for(unsigned int i(0); i < 6; ++i)
{
std::stringstream params;
- params << GL_TEXTURE_2D << ", " << i + 1;
+ params << std::hex << GL_TEXTURE_2D << std::dec << ", " << i + 1;
textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str());
}
for(unsigned int i(0); i < 6; ++i)
{
std::stringstream params;
- params << GL_TEXTURE_2D << ", " << i + 1;
+ params << std::hex << GL_TEXTURE_2D << std::dec << ", " << i + 1;
textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str());
}
actor0.Add(actor3);
TestGlAbstraction& gl = application.GetGlAbstraction();
+ gl.GetTextureTrace().Reset();
gl.EnableTextureCallTrace(true);
application.SendNotification();
application.Render(0);
for(unsigned int i(0); i < 5; ++i)
{
std::stringstream params;
- params << GL_TEXTURE_2D << ", " << i + 1;
+ params << std::hex << GL_TEXTURE_2D << std::dec << ", " << i + 1;
textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str());
}
scene.GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
scene.Add(actor);
- TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
- glAbstraction.EnableEnableDisableCallTrace(true);
- glAbstraction.EnableDepthFunctionCallTrace(true);
+ TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+ TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
+ TraceCallStack& glDepthFunctionStack = glAbstraction.GetDepthFunctionTrace();
- TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
- TraceCallStack& glDepthFunctionStack = glAbstraction.GetDepthFunctionTrace();
+ glEnableDisableStack.Enable(true);
+ glDepthFunctionStack.Enable(true);
+ glEnableDisableStack.EnableLogging(true);
+ glDepthFunctionStack.EnableLogging(true);
std::ostringstream depthTestStr;
- depthTestStr << GL_DEPTH_TEST;
+ depthTestStr << std::hex << GL_DEPTH_TEST;
//GL_NEVER
{
DALI_TEST_CHECK(glEnableDisableStack.FindMethodAndParams("Enable", depthTestStr.str().c_str()));
std::ostringstream depthFunctionStr;
- depthFunctionStr << GL_NEVER;
+ depthFunctionStr << std::hex << GL_NEVER;
DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
}
application.Render();
std::ostringstream depthFunctionStr;
- depthFunctionStr << GL_ALWAYS;
+ depthFunctionStr << std::hex << GL_ALWAYS;
DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
}
application.Render();
std::ostringstream depthFunctionStr;
- depthFunctionStr << GL_LESS;
+ depthFunctionStr << std::hex << GL_LESS;
DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
}
application.Render();
std::ostringstream depthFunctionStr;
- depthFunctionStr << GL_GREATER;
+ depthFunctionStr << std::hex << GL_GREATER;
DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
}
application.Render();
std::ostringstream depthFunctionStr;
- depthFunctionStr << GL_EQUAL;
+ depthFunctionStr << std::hex << GL_EQUAL;
DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
}
application.Render();
std::ostringstream depthFunctionStr;
- depthFunctionStr << GL_NOTEQUAL;
+ depthFunctionStr << std::hex << GL_NOTEQUAL;
DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
}
application.Render();
std::ostringstream depthFunctionStr;
- depthFunctionStr << GL_LEQUAL;
+ depthFunctionStr << std::hex << GL_LEQUAL;
DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
}
application.Render();
std::ostringstream depthFunctionStr;
- depthFunctionStr << GL_GEQUAL;
+ depthFunctionStr << std::hex << GL_GEQUAL;
DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
}
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");
+ if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::MAX) &&
+ Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::MIN))
+ {
+ application.SendNotification();
+ application.Render();
+ CheckEnumerationProperty<DevelBlendEquation::Type>(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<DevelBlendEquation::Type>(application, renderer, DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::MIN, DevelBlendEquation::MULTIPLY, DevelBlendEquation::SCREEN, "SCREEN");
+ }
+
END_TEST;
}
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();
END_TEST;
}
-int UtcDaliRendererCheckStencilDefaults(void)
+int UtcDaliRendererBlendModeUseActorOpacity(void)
{
TestApplication application;
- tet_infoline("Test the stencil defaults");
+ tet_infoline("Test setting the UseActorOpacity");
- Renderer renderer = RendererTestFixture(application);
- TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
- glAbstraction.EnableEnableDisableCallTrace(true);
- glAbstraction.EnableStencilFunctionCallTrace(true);
- TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
- TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
+ Geometry geometry = CreateQuadGeometry();
+ Shader shader = CreateShader();
+ Renderer renderer = Renderer::New(geometry, shader);
- ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
+ 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);
- // Check the defaults:
- DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetProperty(Renderer::Property::STENCIL_FUNCTION).Get<int>()), static_cast<int>(StencilFunction::ALWAYS), TEST_LOCATION);
+ 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());
+
+ // 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;
+}
+
+int UtcDaliRendererCheckStencilDefaults(void)
+{
+ TestApplication application;
+ tet_infoline("Test the stencil defaults");
+
+ 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);
+
+ // Check the defaults:
+ DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetProperty(Renderer::Property::STENCIL_FUNCTION).Get<int>()), static_cast<int>(StencilFunction::ALWAYS), TEST_LOCATION);
DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetProperty(Renderer::Property::STENCIL_FUNCTION_MASK).Get<int>()), 0xFF, TEST_LOCATION);
DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetProperty(Renderer::Property::STENCIL_FUNCTION_REFERENCE).Get<int>()), 0x00, TEST_LOCATION);
DALI_TEST_EQUALS<int>(static_cast<int>(renderer.GetProperty(Renderer::Property::STENCIL_MASK).Get<int>()), 0xFF, TEST_LOCATION);
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.
DALI_TEST_EQUALS<bool>(colorMaskParams.red, expectedValue, TEST_LOCATION);
DALI_TEST_EQUALS<bool>(colorMaskParams.green, expectedValue, TEST_LOCATION);
DALI_TEST_EQUALS<bool>(colorMaskParams.blue, expectedValue, TEST_LOCATION);
- DALI_TEST_EQUALS<bool>(colorMaskParams.alpha, expectedValue, TEST_LOCATION);
+ // @todo Only check alpha if framebuffer supports it.
+ //DALI_TEST_EQUALS<bool>(colorMaskParams.alpha, expectedValue, TEST_LOCATION);
}
int UtcDaliRendererSetRenderModeToUseColorBuffer(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);
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);
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);
TraceCallStack& drawTrace = gl.GetDrawTrace();
drawTrace.Reset();
drawTrace.Enable(true);
+ drawTrace.EnableLogging(true);
application.SendNotification();
application.Render(0);
application.Render();
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<Vector4>("uActorColor", actualActorColor));
+ DALI_TEST_EQUALS(actualActorColor.a, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
renderer.SetProperty(DevelRenderer::Property::OPACITY, 0.5f);
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<Vector4>("uActorColor", actualActorColor));
+ DALI_TEST_EQUALS(actualActorColor.a, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+
END_TEST;
}
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);
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);
+ DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
+
+ drawTrace.Reset();
+
// Render again and check the update status
application.SendNotification();
application.Render();
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);
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<DevelRenderer::Rendering::Type>(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<Vector4>("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<UniformData> 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<Vector4>("uShader2Only", actualValue));
+ DALI_TEST_EQUALS(actualValue, Color::AQUA_MARINE, TEST_LOCATION);
+
+ END_TEST;
+}
+
int UtcDaliRendererAddDrawCommands(void)
{
TestApplication application;
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;
application.Render();
DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 3, TEST_LOCATION);
-
END_TEST;
}
int UtcDaliRendererSetGeometryNegative(void)
}
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<Graphics::SubmitInfo>& submissions = graphics.mSubmitStack;
+ DALI_TEST_CHECK(submissions.size() > 0);
+
+ TestGraphicsCommandBuffer* cmdBuf = static_cast<TestGraphicsCommandBuffer*>((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<UniformData> 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<UniformIndexPair> 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<Vector2>(uniformInfo.name.c_str(), setValue));
+ DALI_TEST_EQUALS(value.Get<Vector2>(), setValue, 0.001f, TEST_LOCATION);
+ break;
+ }
+ case Property::VECTOR3:
+ {
+ DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniformInfo.name, params));
+ Vector3 setValue;
+ DALI_TEST_CHECK(gl.GetUniformValue<Vector3>(uniformInfo.name.c_str(), setValue));
+ DALI_TEST_EQUALS(value.Get<Vector3>(), setValue, 0.001f, TEST_LOCATION);
+ break;
+ }
+ case Property::VECTOR4:
+ {
+ DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniformInfo.name, params));
+ Vector4 setValue;
+ DALI_TEST_CHECK(gl.GetUniformValue<Vector4>(uniformInfo.name.c_str(), setValue));
+ DALI_TEST_EQUALS(value.Get<Vector4>(), 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<Rect<int>> damagedRects;
+ Rect<int> 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<int>(16, 768, 32, 32); // in screen coordinates
+ DALI_TEST_EQUALS<Rect<int>>(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<int>(16, 768, 32, 32); // in screen coordinates
+ DALI_TEST_EQUALS<Rect<int>>(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<int>(16, 768, 32, 32); // in screen coordinates
+ DALI_TEST_EQUALS<Rect<int>>(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<int>(16, 768, 32, 32); // in screen coordinates
+ DALI_TEST_EQUALS<Rect<int>>(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<Rect<int>> damagedRects;
+ Rect<int> 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<int>(16, 768, 32, 32); // in screen coordinates
+ DALI_TEST_EQUALS<Rect<int>>(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<Rect<int>>(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<Rect<int>>(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<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
+
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
+
+ END_TEST;
+}