[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / graphics / shaders / gradient-visual-shader.frag
index c2b9c5d..0a574ce 100644 (file)
@@ -1,27 +1,23 @@
 INPUT mediump vec2 vTexCoord;
 #if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
-INPUT mediump vec2 vPosition;
-INPUT mediump vec2 vRectSize;
-INPUT mediump vec2 vOptRectSize;
+INPUT highp vec2 vPosition;
+INPUT highp vec2 vRectSize;
+INPUT highp vec2 vOptRectSize;
+INPUT highp float vAliasMargin;
 #ifdef IS_REQUIRED_ROUNDED_CORNER
-INPUT mediump vec4 vCornerRadius;
+INPUT highp vec4 vCornerRadius;
 #endif
 #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;
 #ifdef IS_REQUIRED_BORDERLINE
-uniform mediump float borderlineWidth;
-uniform mediump float borderlineOffset;
+uniform highp float borderlineWidth;
+uniform highp float borderlineOffset;
 uniform lowp vec4 borderlineColor;
 uniform lowp vec4 uActorColor;
 #endif
@@ -30,23 +26,23 @@ uniform lowp vec4 uActorColor;
 // Global values both rounded corner and borderline use
 
 // radius of rounded corner on this quadrant
-mediump float gRadius = 0.0;
+highp float gRadius = 0.0;
 
 // fragment coordinate. NOTE : vec2(0.0, 0.0) is vRectSize, the corner of visual
-mediump vec2 gFragmentPosition = vec2(0.0, 0.0);
+highp vec2 gFragmentPosition = vec2(0.0, 0.0);
 // center coordinate of rounded corner circle. vec2(gCenterPosition, gCenterPosition).
-mediump float gCenterPosition = 0.0;
+highp float gCenterPosition = 0.0;
 // relative coordinate of gFragmentPosition from gCenterPosition.
-mediump vec2 gDiff = vec2(0.0, 0.0);
+highp vec2 gDiff = vec2(0.0, 0.0);
 // potential value what our algorithm use.
-mediump float gPotential = 0.0;
+highp float gPotential = 0.0;
 
 // threshold of potential
-mediump float gPotentialRange = 0.0;
-mediump float gMaxOutlinePotential = 0.0;
-mediump float gMinOutlinePotential = 0.0;
-mediump float gMaxInlinePotential = 0.0;
-mediump float gMinInlinePotential = 0.0;
+highp float gPotentialRange = 0.0;
+highp float gMaxOutlinePotential = 0.0;
+highp float gMinOutlinePotential = 0.0;
+highp float gMaxInlinePotential = 0.0;
+highp float gMinInlinePotential = 0.0;
 
 void calculateCornerRadius()
 {
@@ -77,10 +73,7 @@ void calculatePotential()
 
 void setupMinMaxPotential()
 {
-  // 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));
+  gPotentialRange = vAliasMargin;
 
   gMaxOutlinePotential = gRadius + gPotentialRange;
   gMinOutlinePotential = gRadius - gPotentialRange;
@@ -112,7 +105,7 @@ void PreprocessPotential()
 #ifdef IS_REQUIRED_BORDERLINE
 lowp vec4 convertBorderlineColor(lowp vec4 textureColor)
 {
-  mediump float potential = gPotential;
+  highp float potential = gPotential;
 
   // default opacity of borderline is 0.0
   mediump float borderlineOpacity = 0.0;
@@ -137,9 +130,9 @@ 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 + gPotentialRange;
-    mediump float MaxTexturelinePotential = tCornerRadius + gPotentialRange;
-    mediump float MinTexturelinePotential = tCornerRadius - gPotentialRange;
+    highp float tCornerRadius = -gCenterPosition + gPotentialRange;
+    highp float MaxTexturelinePotential = tCornerRadius + gPotentialRange;
+    highp float MinTexturelinePotential = tCornerRadius - gPotentialRange;
     if(potential > MaxTexturelinePotential)
     {
       // potential is out of texture range.
@@ -176,7 +169,7 @@ lowp vec4 convertBorderlineColor(lowp vec4 textureColor)
 #ifdef IS_REQUIRED_ROUNDED_CORNER
 mediump float calculateCornerOpacity()
 {
-  mediump float potential = gPotential;
+  highp float potential = gPotential;
 
   // default opacity is 1.0
   mediump float opacity = 1.0;