Fix visual defect when BorderlineOffset = 1.0f
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / graphics / shaders / color-visual-shader.frag
index db23361..36a4104 100644 (file)
@@ -9,15 +9,14 @@ INPUT mediump vec4 vCornerRadius;
 
 uniform lowp vec4 uColor;
 uniform lowp vec3 mixColor;
-#if !defined(IS_REQUIRED_BLUR) && defined(IS_REQUIRED_BORDERLINE)
+#ifdef IS_REQUIRED_BLUR
+uniform mediump float blurRadius;
+#elif defined(IS_REQUIRED_BORDERLINE)
 uniform mediump float borderlineWidth;
 uniform mediump float borderlineOffset;
 uniform lowp vec4 borderlineColor;
 uniform lowp vec4 uActorColor;
 #endif
-#ifdef IS_REQUIRED_BLUR
-uniform mediump float blurRadius;
-#endif
 
 
 #if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE) || defined(IS_REQUIRED_BLUR)
@@ -58,7 +57,8 @@ void calculatePosition()
 {
   gFragmentPosition = abs(vPosition) - vRectSize;
   gCenterPosition = -gRadius;
-#if !defined(IS_REQUIRED_BLUR) && defined(IS_REQUIRED_BORDERLINE)
+#ifdef IS_REQUIRED_BLUR
+#elif defined(IS_REQUIRED_BORDERLINE)
   gCenterPosition += borderlineWidth * (clamp(borderlineOffset, -1.0, 1.0) + 1.0) * 0.5;
 #endif
   gDiff = gFragmentPosition - gCenterPosition;
@@ -76,7 +76,10 @@ void setupMinMaxPotential()
   gMaxOutlinePotential = gRadius + gPotentialRange;
   gMinOutlinePotential = gRadius - gPotentialRange;
 
-#if !defined(IS_REQUIRED_BLUR) && defined(IS_REQUIRED_BORDERLINE)
+#ifdef IS_REQUIRED_BLUR
+  gMaxInlinePotential = gMaxOutlinePotential;
+  gMinInlinePotential = gMinOutlinePotential;
+#elif defined(IS_REQUIRED_BORDERLINE)
   gMaxInlinePotential = gMaxOutlinePotential - borderlineWidth;
   gMinInlinePotential = gMinOutlinePotential - borderlineWidth;
 #else
@@ -99,7 +102,8 @@ void PreprocessPotential()
 }
 #endif
 
-#if !defined(IS_REQUIRED_BLUR) && defined(IS_REQUIRED_BORDERLINE)
+#ifdef IS_REQUIRED_BLUR
+#elif defined(IS_REQUIRED_BORDERLINE)
 lowp vec4 convertBorderlineColor(lowp vec4 textureColor)
 {
   mediump float potential = gPotential;
@@ -126,7 +130,7 @@ lowp vec4 convertBorderlineColor(lowp vec4 textureColor)
   // But if borderlineOpacity > 0.0 and borderlineColor.a == 0.0, we need to apply tCornerRadius.
   if(borderlineOpacity > 0.0 && borderlineColor.a * borderlineOpacity < 1.0)
   {
-    mediump float tCornerRadius = -gCenterPosition;
+    mediump float tCornerRadius = -gCenterPosition + gPotentialRange;
     mediump float MaxTexturelinePotential = tCornerRadius + gPotentialRange;
     mediump float MinTexturelinePotential = tCornerRadius - gPotentialRange;
     if(potential > MaxTexturelinePotential)
@@ -163,7 +167,8 @@ lowp vec4 convertBorderlineColor(lowp vec4 textureColor)
 }
 #endif
 
-#if !defined(IS_REQUIRED_BLUR) && defined(IS_REQUIRED_ROUNDED_CORNER)
+#ifdef IS_REQUIRED_BLUR
+#elif defined(IS_REQUIRED_ROUNDED_CORNER)
 mediump float calculateCornerOpacity()
 {
   mediump float potential = gPotential;
@@ -269,7 +274,8 @@ void main()
     PreprocessPotential();
 #endif
 
-#if !defined(IS_REQUIRED_BLUR) && defined(IS_REQUIRED_BORDERLINE)
+#ifdef IS_REQUIRED_BLUR
+#elif defined(IS_REQUIRED_BORDERLINE)
     targetColor = convertBorderlineColor(targetColor);
 #endif
     OUT_COLOR = targetColor;