DALI_TEST_CHECK( value );
DALI_TEST_CHECK( value->Get<std::string>() == TEST_GIF_FILE_NAME );
- value = resultMap.Find( DevelVisual::Property::CORNER_RADIUS, Property::FLOAT );
+ value = resultMap.Find( DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4 );
DALI_TEST_CHECK( value );
- DALI_TEST_EQUALS( value->Get<float>(), 22.2f, TEST_LOCATION );
+ DALI_TEST_EQUALS( value->Get<Vector4>(), Vector4(22.2f, 22.2f, 22.2f, 22.2f), TEST_LOCATION );
value = resultMap.Find( Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY, Property::INTEGER );
DALI_TEST_CHECK( value );
.Add( "pixelArea", Vector4() )
.Add( "wrapModeU", WrapMode::REPEAT )
.Add( "wrapModeV", WrapMode::DEFAULT )
- .Add( "cornerRadius", 50.0f )
+ .Add( "cornerRadius", Vector4(50.0f, 25.0f, 12.5f, 33.0f) )
.Add( "cornerRadiusPolicy", Visual::Transform::Policy::RELATIVE ));
Property::Map resultMap;
value = resultMap.Find( Toolkit::DevelVisual::Property::CORNER_RADIUS, "cornerRadius" );
DALI_TEST_CHECK( value );
- DALI_TEST_EQUALS( value->Get<float>(), 50.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( value->Get<Vector4>(), Vector4(50.0f, 25.0f, 12.5f, 33.0f), TEST_LOCATION );
value = resultMap.Find( Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy" );
DALI_TEST_CHECK( value );
value = resultMap.Find( Toolkit::DevelVisual::Property::CORNER_RADIUS, "cornerRadius" );
DALI_TEST_CHECK( value );
- DALI_TEST_EQUALS( value->Get<float>(), 50.5f, TEST_LOCATION );
+ DALI_TEST_EQUALS( value->Get<Vector4>(), Vector4(50.5f, 50.5f, 50.5f, 50.5f), TEST_LOCATION );
value = resultMap.Find( Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy" );
DALI_TEST_CHECK( value );
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
tet_infoline( "UtcDaliVisualFactoryGetAnimatedVectorImageVisual04: Request animated vector image visual with a Property::Map" );
int startFrame = 1, endFrame = 3;
- float cornerRadius = 50.0f;
+ float cornerRadius = 22.0f;
Property::Array playRange;
playRange.PushBack( startFrame );
playRange.PushBack( endFrame );
DALI_TEST_CHECK( value );
DALI_TEST_CHECK( value->Get< bool >() == false );
- value = resultMap.Find( DevelVisual::Property::CORNER_RADIUS, Property::FLOAT );
+ value = resultMap.Find( DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4 );
DALI_TEST_CHECK( value );
- DALI_TEST_EQUALS( value->Get< float >(), cornerRadius, TEST_LOCATION );
+ DALI_TEST_EQUALS( value->Get< Vector4 >(), Vector4(cornerRadius, cornerRadius, cornerRadius, cornerRadius), TEST_LOCATION );
value = resultMap.Find( DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy" );
DALI_TEST_CHECK( value );
tet_infoline( "UtcDaliAnimatedVectorImageVisualGetPropertyMap01" );
int startFrame = 1, endFrame = 3;
- float cornerRadius = 50.0f;
+ Vector4 cornerRadius(50.0f, 22.0f, 0.0f, 3.0f);
Property::Array playRange;
playRange.PushBack( startFrame );
playRange.PushBack( endFrame );
DALI_TEST_CHECK( value );
DALI_TEST_CHECK( value->Get< bool >() == true ); // Check default value
- value = resultMap.Find( DevelVisual::Property::CORNER_RADIUS, Property::FLOAT );
+ value = resultMap.Find( DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4 );
DALI_TEST_CHECK( value );
- DALI_TEST_EQUALS( value->Get< float >(), cornerRadius, TEST_LOCATION );
+ DALI_TEST_EQUALS( value->Get< Vector4 >(), cornerRadius, TEST_LOCATION );
value = resultMap.Find( DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy" );
DALI_TEST_CHECK( value );
DALI_TEST_CHECK( colorValue );
DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::BLUE );
- Property::Value* cornerRadiusValue = resultMap.Find( DevelVisual::Property::CORNER_RADIUS, Property::FLOAT );
+ Property::Value* cornerRadiusValue = resultMap.Find( DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4 );
DALI_TEST_CHECK( cornerRadiusValue );
- DALI_TEST_CHECK( cornerRadiusValue->Get< float >() == 10.0f );
+ DALI_TEST_CHECK( cornerRadiusValue->Get< Vector4 >() == Vector4(10.0f, 10.0f, 10.0f, 10.0f) );
Property::Value* cornerRadiusPolicyValue = resultMap.Find( DevelVisual::Property::CORNER_RADIUS_POLICY, Property::INTEGER );
DALI_TEST_CHECK( cornerRadiusPolicyValue );
static std::vector<UniformData> customUniforms =
{
- UniformData("cornerRadius", Property::Type::FLOAT),
+ UniformData("cornerRadius", Property::Type::VECTOR4),
UniformData("cornerRadiusPolicy", Property::Type::FLOAT),
};
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< Vector4 >( "cornerRadius", Vector4(cornerRadius, cornerRadius, cornerRadius, cornerRadius) ), true, TEST_LOCATION );
// Default corner radius policy is absolute.
DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::ABSOLUTE ), true, TEST_LOCATION );
}
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< Vector4 >( "cornerRadius", Vector4(cornerRadius, cornerRadius, cornerRadius, cornerRadius) ), true, TEST_LOCATION );
DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::ABSOLUTE ), true, TEST_LOCATION );
}
{
VisualFactory factory = VisualFactory::Get();
Property::Map properties;
- float cornerRadius = 0.5f;
+ Vector4 cornerRadius(0.5f, 0.5f, 0.5f, 0.3f);
properties[Visual::Property::TYPE] = Visual::COLOR;
properties[ColorVisual::Property::MIX_COLOR] = Color::BLUE;
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< Vector4 >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::RELATIVE ), true, TEST_LOCATION );
}
{
VisualFactory factory = VisualFactory::Get();
Property::Map properties;
- float cornerRadius = 30.0f;
+ Vector4 cornerRadius(30.0f, 30.0f, 30.0f, 20.0f);
properties[Visual::Property::TYPE] = Visual::COLOR;
properties[ColorVisual::Property::MIX_COLOR] = Color::BLUE;
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< Vector4 >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
// Default corner radius policy is absolute.
DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::ABSOLUTE ), true, TEST_LOCATION );
}
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< Vector4 >( "cornerRadius", Vector4(cornerRadius, cornerRadius, cornerRadius, cornerRadius) ), true, TEST_LOCATION );
// Default corner radius policy is absolute.
DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::ABSOLUTE ), true, TEST_LOCATION );
}
{
VisualFactory factory = VisualFactory::Get();
Property::Map properties;
- float cornerRadius = 24.0f;
+ Vector4 cornerRadius(24.0f, 23.0f, 22.0f, 21.0f);
properties[Visual::Property::TYPE] = Visual::ANIMATED_IMAGE;
properties[ImageVisual::Property::URL] = TEST_GIF_FILE_NAME;
- properties[DevelVisual::Property::CORNER_RADIUS] = cornerRadius + 10.0f; // Dummy Input
+ properties[DevelVisual::Property::CORNER_RADIUS] = cornerRadius.x + 10.0f; // Dummy Input
properties[DevelVisual::Property::CORNER_RADIUS] = cornerRadius;
properties["cornerRadiusPolicy"] = Toolkit::Visual::Transform::Policy::ABSOLUTE;
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< Vector4 >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::ABSOLUTE ), true, TEST_LOCATION );
}
{
VisualFactory factory = VisualFactory::Get();
Property::Map properties;
- float cornerRadius = 27.0f;
+ Vector4 cornerRadius(27.0f, 72.0f, 11.0f, 500.5f);
properties[Visual::Property::TYPE] = Visual::SVG;
properties[ImageVisual::Property::URL] = TEST_SVG_FILE_NAME;
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< Vector4 >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
// Default corner radius policy is absolute.
DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::ABSOLUTE ), true, TEST_LOCATION );
}
properties[Visual::Property::TYPE] = DevelVisual::ANIMATED_VECTOR_IMAGE;
properties[ImageVisual::Property::URL] = TEST_VECTOR_IMAGE_FILE_NAME;
+ properties["cornerRadius"] = Vector4(1.0f, 100.0f, 10.0f, 0.1f); // Dummy Input
properties["cornerRadius"] = cornerRadius;
properties[DevelVisual::Property::CORNER_RADIUS_POLICY] = Toolkit::Visual::Transform::Policy::RELATIVE;
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< Vector4 >( "cornerRadius", Vector4(cornerRadius, cornerRadius, cornerRadius, cornerRadius) ), true, TEST_LOCATION );
DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::RELATIVE ), true, TEST_LOCATION );
}
#else
UniformData("mixColor", Property::Type::VECTOR3),
UniformData("offset", Property::Type::VECTOR2),
UniformData("size", Property::Type::VECTOR2),
- UniformData("cornerRadius", Property::Type::FLOAT),
+ UniformData("cornerRadius", Property::Type::VECTOR4),
UniformData("blurRadius", Property::Type::FLOAT),
};
Property::Map propertyMap;
propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
propertyMap.Insert(Visual::Property::MIX_COLOR, Color::BLUE);
- propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS, 10.0f);
+ propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS, Vector4(10.0f, 0.0f, 2.0f, 4.0f));
propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS_POLICY, Toolkit::Visual::Transform::Policy::RELATIVE);
propertyMap.Insert(DevelColorVisual::Property::BLUR_RADIUS, 20.0f);
Visual::Base colorVisual = factory.CreateVisual(propertyMap);
Vector2 targetOffset(0.05f, 0.05f);
Vector2 targetSize(1.1f, 1.1f);
float targetOpacity = 0.5f;
- float targetCornerRadius = 20.0f;
+ Vector4 targetCornerRadius(0.0f, 0.0f, 0.0f, 0.0f);
float targetBlurRadius = 10.0f;
Animation animation = Animation::New(1.0f);
DALI_TEST_CHECK(sizeValue);
DALI_TEST_EQUALS(sizeValue->Get<Vector2>(), targetSize, TEST_LOCATION);
- Property::Value* cornerRadiusValue = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::FLOAT);
+ Property::Value* cornerRadiusValue = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
DALI_TEST_CHECK(cornerRadiusValue);
- DALI_TEST_EQUALS(cornerRadiusValue->Get< float >(), targetCornerRadius, TEST_LOCATION);
+ DALI_TEST_EQUALS(cornerRadiusValue->Get< Vector4 >(), targetCornerRadius, TEST_LOCATION);
Property::Value* blurRadiusValue = resultMap.Find(DevelColorVisual::Property::BLUR_RADIUS, Property::FLOAT);
DALI_TEST_CHECK(blurRadiusValue);
DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", targetColor), true, TEST_LOCATION);
DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector2>("offset", targetOffset), true, TEST_LOCATION);
DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector2>("size", targetSize), true, TEST_LOCATION);
- DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<float>("cornerRadius", targetCornerRadius), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector4>("cornerRadius", targetCornerRadius), true, TEST_LOCATION);
DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<float>("blurRadius", targetBlurRadius), true, TEST_LOCATION);
// Test not-supported property
int UtcDaliVisualGetVisualProperty02(void)
{
-#ifdef OLD_GRAPHICS_TEST
ToolkitTestApplication application;
tet_infoline( "UtcDaliVisualGetVisualProperty02: Test animatable property" );
UniformData("mixColor", Property::Type::VECTOR3),
UniformData("offset", Property::Type::VECTOR2),
UniformData("size", Property::Type::VECTOR2),
- UniformData("cornerRadius", Property::Type::FLOAT),
+ UniformData("cornerRadius", Property::Type::VECTOR4),
UniformData("blurRadius", Property::Type::FLOAT),
};
Vector2 targetOffset(0.05f, 0.05f);
Vector2 targetSize(1.1f, 1.1f);
float targetOpacity = 0.5f;
- float targetCornerRadius = 20.0f;
+ Vector4 targetCornerRadius(20.0f, 0.0f, 20.0f, 0.0f);
float targetBlurRadius = 10.0f;
// Should work when the properties are not set before
DALI_TEST_CHECK(sizeValue);
DALI_TEST_EQUALS(sizeValue->Get<Vector2>(), targetSize, TEST_LOCATION);
- Property::Value* cornerRadiusValue = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::FLOAT);
+ Property::Value* cornerRadiusValue = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
DALI_TEST_CHECK(cornerRadiusValue);
- DALI_TEST_EQUALS(cornerRadiusValue->Get< float >(), targetCornerRadius, TEST_LOCATION);
+ DALI_TEST_EQUALS(cornerRadiusValue->Get< Vector4 >(), targetCornerRadius, TEST_LOCATION);
Property::Value* blurRadiusValue = resultMap.Find(DevelColorVisual::Property::BLUR_RADIUS, Property::FLOAT);
DALI_TEST_CHECK(blurRadiusValue);
DALI_TEST_EQUALS(blurRadiusValue->Get< float >(), targetBlurRadius, TEST_LOCATION);
+#ifdef OLD_GRAPHICS_TEST
// Test uniform values
DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", targetColor), true, TEST_LOCATION);
DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector2>("offset", targetOffset), true, TEST_LOCATION);
DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector2>("size", targetSize), true, TEST_LOCATION);
- DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<float>("cornerRadius", targetCornerRadius), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector4>("cornerRadius", targetCornerRadius), true, TEST_LOCATION);
DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<float>("blurRadius", targetBlurRadius), true, TEST_LOCATION);
-#else
- tet_result(TET_PASS);
#endif
END_TEST;
static std::vector<UniformData> customUniforms =
{
- UniformData("cornerRadius", Property::Type::FLOAT),
+ UniformData("cornerRadius", Property::Type::VECTOR4),
};
TestGraphicsController& graphics = application.GetGraphicsController();
application.Render();
float targetOpacity = 0.5f;
- float targetCornerRadius = 20.0f;
+ Vector4 targetCornerRadius(20.0f, 20.0f, 0.0f, 0.0f);
Animation animation = Animation::New(1.0f);
animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, Visual::Property::OPACITY), targetOpacity);
DALI_TEST_CHECK(colorValue);
DALI_TEST_EQUALS(colorValue->Get<Vector4>(), Vector4(1.0f, 1.0f, 1.0f, targetOpacity), TEST_LOCATION);
- Property::Value* cornerRadiusValue = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::FLOAT);
+ Property::Value* cornerRadiusValue = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
DALI_TEST_CHECK(cornerRadiusValue);
- DALI_TEST_EQUALS(cornerRadiusValue->Get< float >(), targetCornerRadius, TEST_LOCATION);
+ DALI_TEST_EQUALS(cornerRadiusValue->Get< Vector4 >(), targetCornerRadius, TEST_LOCATION);
// Test uniform value
- DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<float>("cornerRadius", targetCornerRadius), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector4>("cornerRadius", targetCornerRadius), true, TEST_LOCATION);
#else
tet_result(TET_PASS);
#endif
static std::vector<UniformData> customUniforms =
{
- UniformData("cornerRadius", Property::Type::FLOAT),
+ UniformData("cornerRadius", Property::Type::VECTOR4),
};
TestGraphicsController& graphics = application.GetGraphicsController();
application.Render();
float targetOpacity = 0.5f;
- float targetCornerRadius = 20.0f;
+ Vector4 targetCornerRadius(20.0f, 30.0f, 10.0f, 20.0f);
Animation animation = Animation::New(1.0f);
animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, Visual::Property::OPACITY), targetOpacity);
DALI_TEST_CHECK(colorValue);
DALI_TEST_EQUALS(colorValue->Get<Vector4>(), Vector4(1.0f, 1.0f, 1.0f, targetOpacity), TEST_LOCATION);
- Property::Value* cornerRadiusValue = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::FLOAT);
+ Property::Value* cornerRadiusValue = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
DALI_TEST_CHECK(cornerRadiusValue);
- DALI_TEST_EQUALS(cornerRadiusValue->Get< float >(), targetCornerRadius, TEST_LOCATION);
+ DALI_TEST_EQUALS(cornerRadiusValue->Get< Vector4 >(), targetCornerRadius, TEST_LOCATION);
// Test uniform value
- DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<float>("cornerRadius", targetCornerRadius), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector4>("cornerRadius", targetCornerRadius), true, TEST_LOCATION);
#else
tet_result(TET_PASS);
#endif
#define DALI_TOOLKIT_DEVEL_API_VISUALS_VISUAL_PROPERTIES_DEVEL_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
/**
* @brief The radius for the rounded corners of the visual
- * @details Name "cornerRadius", type Property::FLOAT, animatable
- * @note Optional.
+ * @details Name "cornerRadius", type Property::FLOAT or Prooperty::VECTOR4, animatable
+ * @note By default, it is Vector::ZERO.
+ * @note Only Property::Vector4 can be animated.
+ * @note Radius value are used in clockwise order from top-left-corner to bottom-left-corner.
+ * When radius is Vector4(x, y, z, w)
+ * x y
+ * +--+
+ * | |
+ * +--+
+ * w z
*/
CORNER_RADIUS = OPACITY + 2,
INPUT mediump vec2 vPosition;
INPUT mediump vec2 vRectSize;
+INPUT mediump vec2 vOptRectSize;
+INPUT mediump vec4 vCornerRadius;
uniform lowp vec4 uColor;
uniform lowp vec3 mixColor;
void main()
{
- mediump vec2 blur = 1.0 - smoothstep( vRectSize - blurRadius * 2.0, vRectSize, abs( vPosition ) );
OUT_COLOR = vec4(mixColor, 1.0) * uColor;
- OUT_COLOR.a *= blur.x * blur.y;
-}
\ No newline at end of file
+ if(abs(vPosition.x) < vOptRectSize.x && abs(vPosition.y) < vOptRectSize.y)
+ {
+ return;
+ }
+
+ mediump float radius =
+ mix(
+ mix(vCornerRadius.x, vCornerRadius.y, sign(vPosition.x) * 0.5 + 0.5),
+ mix(vCornerRadius.w, vCornerRadius.z, sign(vPosition.x) * 0.5 + 0.5),
+ sign(vPosition.y) * 0.5 + 0.5
+ );
+
+ mediump vec2 v = abs(vPosition) - vRectSize + radius;
+ mediump float cy = radius + blurRadius;
+ mediump float cr = radius + blurRadius;
+
+ cy = min(cy, min(vRectSize.x, vRectSize.y) - radius);
+ v = vec2(min(v.x, v.y), max(v.x, v.y));
+ v = v + cy;
+
+ mediump float blur = 1.0;
+ mediump float potential = 0.0;
+ mediump float alias = min(radius, 1.0);
+ mediump float potentialMin = cy + radius - blurRadius - alias;
+ mediump float potentialMax = cy + radius + blurRadius + alias;
+
+ // move center of circles for reduce defact
+ mediump float cyDiff = min(cy, 0.2 * blurRadius);
+ cy -= cyDiff;
+ cr += cyDiff;
+
+ mediump float diffFromBaseline = cy * v.y - (cy + cr) * v.x;
+
+ if(diffFromBaseline > 0.0)
+ {
+ // out of calculation bound.
+ potential = v.y;
+
+ // for anti-alias when blurRaidus = 0.0
+ mediump float heuristicBaselineScale = max(1.0 , cr * (cr + cy));
+ mediump float potentialDiff = min(alias, diffFromBaseline / heuristicBaselineScale);
+ potentialMin += potentialDiff;
+ potentialMax -= potentialDiff;
+ }
+ else
+ {
+ // get some circle centered (x, x) and radius (r = cr / cy * x)
+ // s.t. point v is on that circle
+ // highest point of that circle is (x, x + r) and potential is x + r
+
+ // solve (v.x - x)^2 + (v.y - x)^2 = (cr / cy * x)^2
+
+ mediump float A = (cr * cr - 2.0 * cy * cy);
+ mediump float B = cy * (v.x + v.y);
+ mediump float V = dot(v,v);
+ mediump float D = B * B + A * V;
+ potential = V * (cr + cy) / (sqrt(D) + B);
+ }
+
+ blur = 1.0 - smoothstep(potentialMin, potentialMax, potential);
+ OUT_COLOR.a *= blur;
+}
INPUT mediump vec2 aPosition;
OUTPUT mediump vec2 vPosition;
OUTPUT mediump vec2 vRectSize;
+OUTPUT mediump vec2 vOptRectSize;
+OUTPUT mediump vec4 vCornerRadius;
-uniform highp mat4 uMvpMatrix;
+uniform highp mat4 uMvpMatrix;
uniform highp vec3 uSize;
//Visual size and offset
uniform mediump vec2 origin;
uniform mediump vec2 anchorPoint;
uniform mediump float blurRadius;
+uniform mediump vec4 cornerRadius;
+uniform mediump float cornerRadiusPolicy;
vec4 ComputeVertexPosition()
{
- vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize + blurRadius * 2.0;
+ vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize;
vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+ mediump float minSize = min( visualSize.x, visualSize.y );
+ vCornerRadius = mix( cornerRadius * minSize, cornerRadius, cornerRadiusPolicy );
+ vCornerRadius = min( vCornerRadius, minSize * 0.5 );
vRectSize = visualSize / 2.0;
- vPosition = aPosition* visualSize;
+ // optimize fragment shader
+ mediump float maxRadius = max(max(vCornerRadius.x, vCornerRadius.y), max(vCornerRadius.z, vCornerRadius.w));
+ vOptRectSize = vRectSize - 0.2929 * maxRadius - 1.0 - blurRadius;
+
+ vPosition = aPosition * (visualSize + 2.0 * blurRadius);
return vec4( vPosition + anchorPoint*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
}
void main()
{
gl_Position = uMvpMatrix * ComputeVertexPosition();
-}
\ No newline at end of file
+}
INPUT mediump vec2 vPosition;
INPUT mediump vec2 vRectSize;
-INPUT mediump float vCornerRadius;
+INPUT mediump vec2 vOptRectSize;
+INPUT mediump vec4 vCornerRadius;
uniform lowp vec4 uColor;
uniform lowp vec3 mixColor;
void main()
{
OUT_COLOR = vec4(mixColor, 1.0) * uColor;
- mediump vec2 diff = abs( vPosition ) - vRectSize;
- mediump float dist = length( max( diff, vec2( 0.0 ) ) ) - vCornerRadius;
- if( dist > 1.0 )
+ if(abs(vPosition.x) < vOptRectSize.x && abs(vPosition.y) < vOptRectSize.y)
+ {
+ return;
+ }
+ mediump float radius =
+ mix(
+ mix(vCornerRadius.x, vCornerRadius.y, sign(vPosition.x) * 0.5 + 0.5),
+ mix(vCornerRadius.w, vCornerRadius.z, sign(vPosition.x) * 0.5 + 0.5),
+ sign(vPosition.y) * 0.5 + 0.5
+ );
+
+ mediump vec2 diff = abs(vPosition) - vRectSize + radius;
+ mediump float dist = length(max(diff, vec2(0.0))) - radius;
+ if(dist > 1.0)
{
OUT_COLOR.a = 0.0;
}
- else if( dist > -1.0 )
+ else if(dist > -1.0)
{
- if( min( diff.x, diff.y ) < 0.0)
+ if(min(diff.x, diff.y) < 0.0)
{
- dist += min( diff.x, diff.y ) / vCornerRadius;
+ dist += min(diff.x, diff.y) / max(radius, 1.0);
}
- OUT_COLOR.a *= 1.0 - smoothstep( -1.0, 1.0, dist );
+ OUT_COLOR.a *= 1.0 - smoothstep(-1.0, 1.0, dist);
}
}
INPUT mediump vec2 aPosition;
OUTPUT mediump vec2 vPosition;
OUTPUT mediump vec2 vRectSize;
-OUTPUT mediump float vCornerRadius;
+OUTPUT mediump vec2 vOptRectSize;
+OUTPUT mediump vec4 vCornerRadius;
uniform highp mat4 uMvpMatrix;
uniform highp vec3 uSize;
uniform mediump vec4 offsetSizeMode;
uniform mediump vec2 origin;
uniform mediump vec2 anchorPoint;
-uniform mediump float cornerRadius;
+uniform mediump vec4 cornerRadius;
uniform mediump float cornerRadiusPolicy;
vec4 ComputeVertexPosition()
mediump float minSize = min( visualSize.x, visualSize.y );
vCornerRadius = mix( cornerRadius * minSize, cornerRadius, cornerRadiusPolicy);
vCornerRadius = min( vCornerRadius, minSize * 0.5 );
- vRectSize = visualSize / 2.0 - vCornerRadius;
- vCornerRadius = max( vCornerRadius, 1.0 );
+ vRectSize = visualSize / 2.0;
+ // optimize fragment shader
+ mediump float maxRadius = max(max(vCornerRadius.x, vCornerRadius.y), max(vCornerRadius.z, vCornerRadius.w));
+ vOptRectSize = vRectSize - 0.2929 * maxRadius - 1.0;
vPosition = aPosition* visualSize;
return vec4( vPosition + anchorPoint*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
}
varying mediump vec2 vTexCoord;
varying mediump vec2 vPosition;
varying mediump vec2 vRectSize;
-varying mediump float vCornerRadius;
+varying mediump vec2 vOptRectSize;
+varying mediump vec4 vCornerRadius;
//Visual size and offset
uniform mediump vec2 offset;
uniform mediump vec4 offsetSizeMode;
uniform mediump vec2 origin;
uniform mediump vec2 anchorPoint;
-uniform mediump float cornerRadius;
+uniform mediump vec4 cornerRadius;
uniform mediump float cornerRadiusPolicy;
vec4 ComputeVertexPosition()
{
- vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
- vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
- mediump float minSize = min( visualSize.x, visualSize.y );
- vCornerRadius = mix( cornerRadius * minSize, cornerRadius, cornerRadiusPolicy);
- vCornerRadius = min( vCornerRadius, minSize * 0.5 );
- vRectSize = visualSize * 0.5 - vCornerRadius;
- vCornerRadius = max( vCornerRadius, 1.0 );
+ vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw);
+ vec2 visualOffset = mix(offset, offset/uSize.xy, offsetSizeMode.xy);
+ mediump float minSize = min(visualSize.x, visualSize.y);
+ vCornerRadius = mix(cornerRadius * minSize, cornerRadius, cornerRadiusPolicy);
+ vCornerRadius = min(vCornerRadius, minSize * 0.5);
+ vRectSize = visualSize * 0.5;
+ // Optimize fragment shader
+ mediump float maxRadius = max(max(vCornerRadius.x, vCornerRadius.y), max(vCornerRadius.z, vCornerRadius.w));
+ vOptRectSize = vRectSize - 0.2929 * maxRadius - 1.0;
vPosition = aPosition * visualSize;
- return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+ return vec4((aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0);
}
void main()
varying mediump vec2 vTexCoord;
varying mediump vec2 vPosition;
varying mediump vec2 vRectSize;
-varying mediump float vCornerRadius;
+varying mediump vec2 vOptRectSize;
+varying mediump vec4 vCornerRadius;
void main()
{
gl_FragColor = texture2D( sTexture, vec2( vTexCoord.y, 0.5 ) ) * vec4(mixColor, 1.0) * uColor;
- mediump vec2 diff = abs( vPosition ) - vRectSize;
- mediump float dist = length( max( diff, vec2( 0.0 ) ) ) - vCornerRadius;
- if( dist > 1.0 )
+ if(abs(vPosition.x) < vOptRectSize.x && abs(vPosition.y) < vOptRectSize.y)
{
- gl_FragColor = vec4( 0.0 );
+ return;
}
- else if( dist > -1.0 )
+ mediump float radius =
+ mix(
+ mix(vCornerRadius.x, vCornerRadius.y, sign(vPosition.x) * 0.5 + 0.5),
+ mix(vCornerRadius.w, vCornerRadius.z, sign(vPosition.x) * 0.5 + 0.5),
+ sign(vPosition.y) * 0.5 + 0.5
+ );
+
+ mediump vec2 diff = abs(vPosition) - vRectSize + radius;
+ mediump float dist = length(max(diff, vec2(0.0))) - radius;
+ if(dist > 1.0)
+ {
+ gl_FragColor = vec4(0.0);
+ }
+ else if(dist > -1.0)
{
- if( min( diff.x, diff.y ) < 0.0 )
+ if(min(diff.x, diff.y) < 0.0)
{
- dist += min( diff.x, diff.y ) / vCornerRadius;
+ dist += min(diff.x, diff.y) / max(radius, 1.0);
}
- gl_FragColor *= 1.0 - smoothstep( -1.0, 1.0, dist );
+ gl_FragColor *= 1.0 - smoothstep(-1.0, 1.0, dist);
}
}
varying mediump vec2 vTexCoord;
varying mediump vec2 vPosition;
varying mediump vec2 vRectSize;
-varying mediump float vCornerRadius;
+varying mediump vec2 vOptRectSize;
+varying mediump vec4 vCornerRadius;
void main()
{
gl_FragColor = texture2D( sTexture, vec2( length(vTexCoord), 0.5 ) ) * vec4(mixColor, 1.0) * uColor;
- mediump vec2 diff = abs( vPosition ) - vRectSize;
- mediump float dist = length( max( diff, vec2( 0.0 ) ) ) - vCornerRadius;
- if( dist > 1.0 )
+ if(abs(vPosition.x) < vOptRectSize.x && abs(vPosition.y) < vOptRectSize.y)
{
- gl_FragColor = vec4( 0.0 );
+ return;
}
- else if( dist > -1.0 )
+ mediump float radius =
+ mix(
+ mix(vCornerRadius.x, vCornerRadius.y, sign(vPosition.x) * 0.5 + 0.5),
+ mix(vCornerRadius.w, vCornerRadius.z, sign(vPosition.x) * 0.5 + 0.5),
+ sign(vPosition.y) * 0.5 + 0.5
+ );
+
+ mediump vec2 diff = abs(vPosition) - vRectSize + radius;
+ mediump float dist = length(max(diff, vec2(0.0))) - radius;
+ if(dist > 1.0)
+ {
+ gl_FragColor = vec4(0.0);
+ }
+ else if(dist > -1.0)
{
- if( min( diff.x, diff.y ) < 0.0)
+ if(min(diff.x, diff.y) < 0.0)
{
- dist += min( diff.x, diff.y ) / vCornerRadius;
+ dist += min(diff.x, diff.y) / max(radius, 1.0);
}
- gl_FragColor *= 1.0 - smoothstep( -1.0, 1.0, dist );
+ gl_FragColor *= 1.0 - smoothstep(-1.0, 1.0, dist);
}
}
varying mediump vec2 vTexCoord;
varying mediump vec2 vPosition;
varying mediump vec2 vRectSize;
-varying mediump float vCornerRadius;
+varying mediump vec2 vOptRectSize;
+varying mediump vec4 vCornerRadius;
//Visual size and offset
uniform mediump vec2 offset;
uniform mediump vec4 offsetSizeMode;
uniform mediump vec2 origin;
uniform mediump vec2 anchorPoint;
-uniform mediump float cornerRadius;
+uniform mediump vec4 cornerRadius;
uniform mediump float cornerRadiusPolicy;
vec4 ComputeVertexPosition()
{
- vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
- vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
- mediump float minSize = min( visualSize.x, visualSize.y );
- vCornerRadius = mix( cornerRadius * minSize, cornerRadius, cornerRadiusPolicy);
- vCornerRadius = min( vCornerRadius, minSize * 0.5 );
- vRectSize = visualSize * 0.5 - vCornerRadius;
- vCornerRadius = max( vCornerRadius, 1.0 );
+ vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw);
+ vec2 visualOffset = mix(offset, offset/uSize.xy, offsetSizeMode.xy);
+ mediump float minSize = min(visualSize.x, visualSize.y);
+ vCornerRadius = mix(cornerRadius * minSize, cornerRadius, cornerRadiusPolicy);
+ vCornerRadius = min(vCornerRadius, minSize * 0.5);
+ vRectSize = visualSize * 0.5;
+ // Optimze fragment shader
+ mediump float maxRadius = max(max(vCornerRadius.x, vCornerRadius.y), max(vCornerRadius.z, vCornerRadius.w));
+ vOptRectSize = vRectSize - 0.2929 * maxRadius - 1.0;
+ vCornerRadius = max(vCornerRadius, 1.0);
vPosition = aPosition * visualSize;
- return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+ return vec4((aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0);
}
void main()
INPUT mediump vec2 vTexCoord;
INPUT mediump vec2 vPosition;
INPUT mediump vec2 vRectSize;
-INPUT mediump float vCornerRadius;
+INPUT mediump vec2 vOptRectSize;
+INPUT mediump vec4 vCornerRadius;
uniform sampler2D sTexture;
uniform lowp vec4 uColor;
void main()
{
- mediump vec2 diff = abs( vPosition ) - vRectSize;
- mediump float dist = length( max( diff, vec2( 0.0 ) ) ) - vCornerRadius;
+ if(abs(vPosition.x) < vOptRectSize.x && abs(vPosition.y) < vOptRectSize.y)
+ {
+ OUT_COLOR = TEXTURE(sTexture, vTexCoord) * uColor * vec4(mixColor, 1.0);
+ return;
+ }
+ mediump float radius =
+ mix(
+ mix(vCornerRadius.x, vCornerRadius.y, sign(vPosition.x) * 0.5 + 0.5),
+ mix(vCornerRadius.w, vCornerRadius.z, sign(vPosition.x) * 0.5 + 0.5),
+ sign(vPosition.y) * 0.5 + 0.5
+ );
+
+ mediump vec2 diff = abs(vPosition) - vRectSize + radius;
+ mediump float dist = length(max(diff, vec2(0.0))) - radius;
mediump float opacity = 1.0;
- if( dist > 1.0 )
+ if(dist > 1.0)
{
opacity = 0.0;
}
- else if( dist > -1.0 )
+ else if(dist > -1.0)
{
- if( min( diff.x, diff.y ) < 0.0 )
+ if(min(diff.x, diff.y) < 0.0)
{
- dist += min( diff.x, diff.y ) / vCornerRadius;
+ dist += min(diff.x, diff.y) / max(radius, 1.0);
}
- opacity = 1.0 - smoothstep( -1.0, 1.0, dist );
+ opacity = 1.0 - smoothstep(-1.0, 1.0, dist);
}
- OUT_COLOR = TEXTURE( sTexture, vTexCoord ) * uColor * vec4( mixColor, 1.0 );
+ OUT_COLOR = TEXTURE(sTexture, vTexCoord) * uColor * vec4(mixColor, 1.0);
OUT_COLOR.a *= opacity;
- OUT_COLOR.rgb *= mix( 1.0, opacity, preMultipliedAlpha );
+ OUT_COLOR.rgb *= mix(1.0, opacity, preMultipliedAlpha);
}
OUTPUT mediump vec2 vTexCoord;
OUTPUT mediump vec2 vPosition;
OUTPUT mediump vec2 vRectSize;
-OUTPUT mediump float vCornerRadius;
+OUTPUT mediump vec2 vOptRectSize;
+OUTPUT mediump vec4 vCornerRadius;
uniform highp mat4 uMvpMatrix;
uniform highp vec3 uSize;
uniform mediump vec4 offsetSizeMode;
uniform mediump vec2 origin;
uniform mediump vec2 anchorPoint;
-uniform mediump float cornerRadius;
+uniform mediump vec4 cornerRadius;
uniform mediump float cornerRadiusPolicy;
uniform mediump vec2 extraSize;
vec4 ComputeVertexPosition()
{
- vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize;
- vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
- mediump float minSize = min( visualSize.x, visualSize.y );
- vCornerRadius = mix( cornerRadius * minSize, cornerRadius, cornerRadiusPolicy);
- vCornerRadius = min( vCornerRadius, minSize * 0.5 );
- vRectSize = visualSize * 0.5 - vCornerRadius;
- vCornerRadius = max( vCornerRadius, 1.0 );
+ vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw) + extraSize;
+ vec2 visualOffset = mix(offset, offset/uSize.xy, offsetSizeMode.xy);
+ mediump float minSize = min(visualSize.x, visualSize.y);
+ vCornerRadius = mix(cornerRadius * minSize, cornerRadius, cornerRadiusPolicy);
+ vCornerRadius = min(vCornerRadius, minSize * 0.5);
+ vRectSize = visualSize * 0.5;
+ // Optimize fragment shader
+ mediump float maxRadius = max(max(vCornerRadius.x, vCornerRadius.y), max(vCornerRadius.z, vCornerRadius.w));
+ vOptRectSize = vRectSize - 0.2929 * maxRadius - 1.0;
vPosition = aPosition* visualSize;
- return vec4( vPosition + anchorPoint*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+ return vec4(vPosition + anchorPoint*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0);
}
void main()
{
gl_Position = uMvpMatrix * ComputeVertexPosition();
- vTexCoord = pixelArea.xy+pixelArea.zw*(aPosition + vec2(0.5) );
+ vTexCoord = pixelArea.xy+pixelArea.zw*(aPosition + vec2(0.5));
}
mTransform(),
mMixColor(Color::WHITE),
mControlSize(Vector2::ZERO),
- mCornerRadius(0.0f),
+ mCornerRadius(Vector4::ZERO),
mCornerRadiusPolicy(1.0f),
mDepthIndex(0.0f),
mMixColorIndex(Property::INVALID_INDEX),
Transform mTransform;
Vector4 mMixColor;
Size mControlSize;
- float mCornerRadius;
+ Vector4 mCornerRadius;
float mCornerRadiusPolicy;
int mDepthIndex;
Property::Index mMixColorIndex;
}
case Toolkit::DevelVisual::Property::CORNER_RADIUS:
{
- float radius;
- if(value.Get(radius))
+ if(value.GetType() == Property::VECTOR4)
{
- mImpl->mCornerRadius = radius;
+ // If CORNER_RADIUS Property is Vector4,
+ // Each values mean the radius of
+ // (top-left, top-right, bottom-right, bottom-left)
+ Vector4 radius;
+ if(value.Get(radius))
+ {
+ mImpl->mCornerRadius = radius;
+ }
+ }
+ else
+ {
+ // If CORNER_RADIUS Property is float,
+ // Every corner radius have same value
+ float radius;
+ if(value.Get(radius))
+ {
+ mImpl->mCornerRadius = Vector4(radius, radius, radius, radius);
+ }
}
break;
}
}
if(mImpl->mCornerRadiusIndex != Property::INVALID_INDEX)
{
- mImpl->mCornerRadius = mImpl->mRenderer.GetProperty<float>(mImpl->mCornerRadiusIndex);
+ mImpl->mCornerRadius = mImpl->mRenderer.GetProperty<Vector4>(mImpl->mCornerRadiusIndex);
}
}
if(mImpl->mRenderer && mImpl->mCornerRadiusIndex != Property::INVALID_INDEX)
{
// Update values from Renderer
- mImpl->mCornerRadius = mImpl->mRenderer.GetProperty<float>(mImpl->mCornerRadiusIndex);
+ mImpl->mCornerRadius = mImpl->mRenderer.GetProperty<Vector4>(mImpl->mCornerRadiusIndex);
}
- return !EqualsZero(mImpl->mCornerRadius) || mImpl->mNeedCornerRadius;
+ return !(mImpl->mCornerRadius == Vector4::ZERO) || mImpl->mNeedCornerRadius;
}
void Visual::Base::OnDoAction(const Property::Index actionId, const Property::Value& attributes)