INPUT mediump vec2 vPosition;
INPUT mediump vec2 vRectSize;
INPUT mediump vec2 vOptRectSize;
-INPUT mediump float vAliasMargin;
#ifdef IS_REQUIRED_ROUNDED_CORNER
INPUT mediump vec4 vCornerRadius;
#endif
#endif
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE) || defined(IS_REQUIRED_BLUR)
+// Be used when we calculate anti-alias range near 1 pixel.
+uniform highp vec3 uScale;
+#endif
+
uniform lowp vec4 uColor;
uniform lowp vec3 mixColor;
#ifdef IS_REQUIRED_BLUR
void setupMinMaxPotential()
{
- gPotentialRange = vAliasMargin;
+ // Set soft anti-alias range at most 10% of visual size.
+ // The range should be inverse proportion with scale of view.
+ // To avoid divid-by-zero, let we allow minimum scale value is 0.001 (0.1%)
+ gPotentialRange = min(1.0, max(vRectSize.x, vRectSize.y) * 0.2) / max(0.001, max(uScale.x, uScale.y));
gMaxOutlinePotential = gRadius + gPotentialRange;
gMinOutlinePotential = gRadius - gPotentialRange;
OUTPUT mediump vec2 vPosition;
OUTPUT mediump vec2 vRectSize;
OUTPUT mediump vec2 vOptRectSize;
-OUTPUT mediump float vAliasMargin;
#ifdef IS_REQUIRED_ROUNDED_CORNER
OUTPUT mediump vec4 vCornerRadius;
#endif
uniform highp mat4 uMvpMatrix;
uniform highp vec3 uSize;
-#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE) || defined(IS_REQUIRED_BLUR)
-// Be used when we calculate anti-alias range near 1 pixel.
-uniform highp vec3 uScale;
-#endif
-
//Visual size and offset
uniform mediump vec2 offset;
uniform highp vec2 size;
#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE) || defined(IS_REQUIRED_BLUR)
vRectSize = visualSize * 0.5;
vOptRectSize = vRectSize;
-
- // Set soft anti-alias range at most 10% of visual size.
- // The range should be inverse proportion with scale of view.
- // To avoid divid-by-zero, let we allow minimum scale value is 0.001 (0.1%)
- vAliasMargin = min(1.0, max(visualSize.x, visualSize.y) * 0.1) / max(0.001, max(uScale.x, uScale.y));
-
- mediump float vertexMargin = 0.0;
#endif
#ifdef IS_REQUIRED_ROUNDED_CORNER
#ifdef IS_REQUIRED_BLUR
- mediump float maxSize = max(visualSize.x, visualSize.y);
mediump float minSize = min(visualSize.x, visualSize.y);
#elif defined(IS_REQUIRED_BORDERLINE)
- mediump float maxSize = max(visualSize.x, visualSize.y) + (1.0 + clamp(borderlineOffset, -1.0, 1.0)) * borderlineWidth;
mediump float minSize = min(visualSize.x, visualSize.y) + (1.0 + clamp(borderlineOffset, -1.0, 1.0)) * borderlineWidth;
#else
- mediump float maxSize = max(visualSize.x, visualSize.y);
mediump float minSize = min(visualSize.x, visualSize.y);
#endif
vCornerRadius = mix(cornerRadius * minSize, cornerRadius, cornerRadiusPolicy);
vCornerRadius = min(vCornerRadius, minSize * 0.5);
// Optimize fragment shader. 0.2929 ~= 1.0 - sqrt(0.5)
mediump float maxRadius = max(max(vCornerRadius.x, vCornerRadius.y), max(vCornerRadius.z, vCornerRadius.w));
- mediump float minRadius = min(min(vCornerRadius.x, vCornerRadius.y), min(vCornerRadius.z, vCornerRadius.w));
vOptRectSize -= 0.2929 * maxRadius + 1.0;
-
- // Set vertex margin as vAliasMargin if we need to make some more fragments for alias.
-#ifdef IS_REQUIRED_BLUR
- // Let we always increase alias margin for blur case
- vertexMargin = 2.0 * vAliasMargin;
-#else
- // Do not increase margin if the minRadius is small enough rather than maxSize.
- // TODO : We should change the magic parameter, 0.49
- vertexMargin = 2.0 * vAliasMargin * smoothstep(maxSize * 0.49, maxSize * 0.5, minRadius);
-#endif
#endif
#ifdef IS_REQUIRED_BLUR
- vPosition = aPosition * (visualSize + 2.0 * blurRadius + vertexMargin);
+ vPosition = aPosition * (visualSize + 2.0 * blurRadius);
vOptRectSize -= blurRadius + 1.0;
#elif defined(IS_REQUIRED_BORDERLINE)
- vPosition = aPosition * (visualSize + (1.0 + clamp(borderlineOffset, -1.0, 1.0))* borderlineWidth + vertexMargin);
+ vPosition = aPosition * (visualSize + (1.0 + clamp(borderlineOffset, -1.0, 1.0))* borderlineWidth);
vOptRectSize -= (1.0 - clamp(borderlineOffset, -1.0, 1.0)) * 0.5 * borderlineWidth + 1.0;
#elif defined(IS_REQUIRED_ROUNDED_CORNER)
- vPosition = aPosition * (visualSize + vertexMargin);
+ vPosition = aPosition * visualSize;
#else
mediump vec2 vPosition = aPosition * visualSize;
#endif
INPUT mediump vec2 vPosition;
INPUT mediump vec2 vRectSize;
INPUT mediump vec2 vOptRectSize;
-INPUT mediump float vAliasMargin;
#ifdef IS_REQUIRED_ROUNDED_CORNER
INPUT mediump vec4 vCornerRadius;
#endif
// scale factor to fit start and end position of gradient.
uniform mediump float uTextureCoordinateScaleFactor;
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
+// Be used when we calculate anti-alias range near 1 pixel.
+uniform highp vec3 uScale;
+#endif
+
uniform sampler2D sTexture; // sampler1D?
uniform lowp vec4 uColor;
uniform lowp vec3 mixColor;
void setupMinMaxPotential()
{
- gPotentialRange = vAliasMargin;
+ // Set soft anti-alias range at most 10% of visual size.
+ // The range should be inverse proportion with scale of view.
+ // To avoid divid-by-zero, let we allow minimum scale value is 0.001 (0.1%)
+ gPotentialRange = min(1.0, max(vRectSize.x, vRectSize.y) * 0.2) / max(0.001, max(uScale.x, uScale.y));
gMaxOutlinePotential = gRadius + gPotentialRange;
gMinOutlinePotential = gRadius - gPotentialRange;
OUTPUT mediump vec2 vPosition;
OUTPUT mediump vec2 vRectSize;
OUTPUT mediump vec2 vOptRectSize;
-OUTPUT mediump float vAliasMargin;
#ifdef IS_REQUIRED_ROUNDED_CORNER
OUTPUT mediump vec4 vCornerRadius;
#endif
uniform highp vec3 uSize;
uniform mediump mat3 uAlignmentMatrix;
-#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
-// Be used when we calculate anti-alias range near 1 pixel.
-uniform highp vec3 uScale;
-#endif
-
//Visual size and offset
uniform mediump vec2 offset;
uniform highp vec2 size;
#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
vRectSize = visualSize * 0.5;
vOptRectSize = vRectSize;
-
- // Set soft anti-alias range at most 10% of visual size.
- // The range should be inverse proportion with scale of view.
- // To avoid divid-by-zero, let we allow minimum scale value is 0.001 (0.1%)
- vAliasMargin = min(1.0, max(visualSize.x, visualSize.y) * 0.1) / max(0.001, max(uScale.x, uScale.y));
-
- mediump float vertexMargin = 0.0;
#endif
#ifdef IS_REQUIRED_ROUNDED_CORNER
#ifdef IS_REQUIRED_BORDERLINE
- mediump float maxSize = max(visualSize.x, visualSize.y) + (1.0 + clamp(borderlineOffset, -1.0, 1.0)) * borderlineWidth;
mediump float minSize = min(visualSize.x, visualSize.y) + (1.0 + clamp(borderlineOffset, -1.0, 1.0)) * borderlineWidth;
#else
- mediump float maxSize = max(visualSize.x, visualSize.y);
mediump float minSize = min(visualSize.x, visualSize.y);
#endif
vCornerRadius = mix(cornerRadius * minSize, cornerRadius, cornerRadiusPolicy);
vCornerRadius = min(vCornerRadius, minSize * 0.5);
// Optimize fragment shader. 0.2929 ~= 1.0 - sqrt(0.5)
mediump float maxRadius = max(max(vCornerRadius.x, vCornerRadius.y), max(vCornerRadius.z, vCornerRadius.w));
- mediump float minRadius = min(min(vCornerRadius.x, vCornerRadius.y), min(vCornerRadius.z, vCornerRadius.w));
vOptRectSize -= 0.2929 * maxRadius + 1.0;
-
- // Set vertex margin as vAliasMargin if we need to make some more fragments for alias.
- // Do not increase margin if the minRadius is small enough rather than maxSize.
- // TODO : We should change the magic parameter, 0.49
- vertexMargin = 2.0 * vAliasMargin * smoothstep(maxSize * 0.49, maxSize * 0.5, minRadius);
#endif
mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);
#ifdef IS_REQUIRED_BORDERLINE
- vPosition = aPosition * (visualSize + (1.0 + clamp(borderlineOffset, -1.0, 1.0)) * borderlineWidth + vertexMargin);
- vertexPosition.xy *= (1.0 + ((1.0 + clamp(borderlineOffset, -1.0, 1.0)) * borderlineWidth + vertexMargin) / visualSize);
+ vPosition = aPosition * (visualSize + (1.0 + clamp(borderlineOffset, -1.0, 1.0)) * borderlineWidth);
+ vertexPosition.xy *= (1.0 + (1.0 + clamp(borderlineOffset, -1.0, 1.0)) * borderlineWidth / visualSize);
vOptRectSize -= (1.0 - clamp(borderlineOffset, -1.0, 1.0)) * 0.5 * borderlineWidth + 1.0;
#elif defined(IS_REQUIRED_ROUNDED_CORNER)
- vPosition = aPosition * (visualSize + vertexMargin);
+ vPosition = aPosition * visualSize;
#else
mediump vec2 vPosition = aPosition * visualSize;
#endif
INPUT mediump vec2 vPosition;
INPUT mediump vec2 vRectSize;
INPUT mediump vec2 vOptRectSize;
-INPUT mediump float vAliasMargin;
#ifdef IS_REQUIRED_ROUNDED_CORNER
INPUT mediump vec4 vCornerRadius;
#endif
uniform lowp vec2 wrapMode;
#endif
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
+// Be used when we calculate anti-alias range near 1 pixel.
+uniform highp vec3 uScale;
+#endif
+
uniform lowp vec4 uColor;
uniform lowp vec3 mixColor;
uniform lowp float preMultipliedAlpha;
void setupMinMaxPotential()
{
- gPotentialRange = vAliasMargin;
+ // Set soft anti-alias range at most 10% of visual size.
+ // The range should be inverse proportion with scale of view.
+ // To avoid divid-by-zero, let we allow minimum scale value is 0.001 (0.1%)
+ gPotentialRange = min(1.0, max(vRectSize.x, vRectSize.y) * 0.2) / max(0.001, max(uScale.x, uScale.y));
gMaxOutlinePotential = gRadius + gPotentialRange;
gMinOutlinePotential = gRadius - gPotentialRange;
OUTPUT mediump vec2 vPosition;
OUTPUT mediump vec2 vRectSize;
OUTPUT mediump vec2 vOptRectSize;
-OUTPUT mediump float vAliasMargin;
#ifdef IS_REQUIRED_ROUNDED_CORNER
OUTPUT mediump vec4 vCornerRadius;
#endif
uniform highp vec3 uSize;
uniform mediump vec4 pixelArea;
-#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
-// Be used when we calculate anti-alias range near 1 pixel.
-uniform highp vec3 uScale;
-#endif
-
//Visual size and offset
uniform mediump vec2 offset;
uniform highp vec2 size;
#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
vRectSize = visualSize * 0.5;
vOptRectSize = vRectSize;
-
- // Set soft anti-alias range at most 10% of visual size.
- // The range should be inverse proportion with scale of view.
- // To avoid divid-by-zero, let we allow minimum scale value is 0.001 (0.1%)
- vAliasMargin = min(1.0, max(visualSize.x, visualSize.y) * 0.1) / max(0.001, max(uScale.x, uScale.y));
-
- mediump float vertexMargin = 0.0;
#endif
#ifdef IS_REQUIRED_BORDERLINE
#ifdef IS_REQUIRED_ROUNDED_CORNER
#ifdef IS_REQUIRED_BORDERLINE
- mediump float maxSize = max(visualSize.x, visualSize.y) + outerBorderlineSize;
mediump float minSize = min(visualSize.x, visualSize.y) + outerBorderlineSize;
#else
- mediump float maxSize = max(visualSize.x, visualSize.y);
mediump float minSize = min(visualSize.x, visualSize.y);
#endif
vCornerRadius = mix(cornerRadius * minSize, cornerRadius, cornerRadiusPolicy);
vCornerRadius = min(vCornerRadius, minSize * 0.5);
// Optimize fragment shader. 0.2929 ~= 1.0 - sqrt(0.5)
mediump float maxRadius = max(max(vCornerRadius.x, vCornerRadius.y), max(vCornerRadius.z, vCornerRadius.w));
- mediump float minRadius = min(min(vCornerRadius.x, vCornerRadius.y), min(vCornerRadius.z, vCornerRadius.w));
vOptRectSize -= 0.2929 * maxRadius + 1.0;
-
- // Set vertex margin as vAliasMargin if we need to make some more fragments for alias.
- // Do not increase margin if the minRadius is small enough rather than maxSize.
- // TODO : We should change the magic parameter, 0.49
- vertexMargin = 2.0 * vAliasMargin * smoothstep(maxSize * 0.49, maxSize * 0.5, minRadius);
#endif
#ifdef IS_REQUIRED_BORDERLINE
- vPosition = aPosition * (visualSize + outerBorderlineSize + vertexMargin);
+ vPosition = aPosition * (visualSize + outerBorderlineSize);
vOptRectSize -= (borderlineWidth - outerBorderlineSize * 0.5) + 1.0;
#elif defined(IS_REQUIRED_ROUNDED_CORNER)
- vPosition = aPosition * (visualSize + vertexMargin);
+ vPosition = aPosition * visualSize;
#else
mediump vec2 vPosition = aPosition * visualSize;
#endif
cropToMask);
vMaskTexCoord = pixelArea.xy + pixelArea.zw * (vec2(0.5) + aPosition.xy
#ifdef IS_REQUIRED_BORDERLINE
- * (1.0 + (outerBorderlineSize + vertexMargin) / visualSize)
-#elif defined(IS_REQUIRED_ROUNDED_CORNER)
- * (1.0 + vertexMargin / visualSize)
+ * (1.0 + outerBorderlineSize / visualSize)
#endif
);
#endif
vTexCoord = finalPixelArea.xy + finalPixelArea.zw * (vec2(0.5) + aPosition.xy
#ifdef IS_REQUIRED_BORDERLINE
- * (1.0 + (outerBorderlineSize + vertexMargin) / visualSize)
-#elif defined(IS_REQUIRED_ROUNDED_CORNER)
- * (1.0 + vertexMargin / visualSize)
+ * (1.0 + outerBorderlineSize / visualSize)
#endif
);