Merge "FocusFinder use CalculateCurrentScreenExtents" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / graphics / shaders / gradient-visual-shader.frag
index febc776..5104f6b 100644 (file)
@@ -8,6 +8,9 @@ INPUT mediump vec4 vCornerRadius;
 #endif
 #endif
 
+// scale factor to fit start and end position of gradient.
+uniform mediump float uTextureCoordinateScaleFactor;
+
 uniform sampler2D sTexture; // sampler1D?
 uniform lowp vec4 uColor;
 uniform lowp vec3 mixColor;
@@ -69,7 +72,8 @@ void calculatePotential()
 
 void setupMinMaxPotential()
 {
-  gPotentialRange = 1.0;
+  // Set soft anti-alias range at most 2% of visual size
+  gPotentialRange = min(1.0, max(vRectSize.x, vRectSize.y) * 0.02);
 
   gMaxOutlinePotential = gRadius + gPotentialRange;
   gMinOutlinePotential = gRadius - gPotentialRange;
@@ -113,7 +117,7 @@ lowp vec4 convertBorderlineColor(lowp vec4 textureColor)
     borderlineOpacity = smoothstep(gMinInlinePotential, gMaxInlinePotential, potential);
 
     // Muliply borderlineWidth to resolve very thin borderline
-    borderlineOpacity *= min(1.0, borderlineWidth);
+    borderlineOpacity *= min(1.0, borderlineWidth / gPotentialRange);
   }
 
   lowp vec3  borderlineColorRGB   = borderlineColor.rgb * uActorColor.rgb;
@@ -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)
@@ -187,7 +191,8 @@ mediump float calculateCornerOpacity()
 void main()
 {
 #ifdef RADIAL
-  lowp vec4 textureColor = TEXTURE(sTexture, vec2(length(vTexCoord), 0.5)) * vec4(mixColor, 1.0) * uColor;
+  mediump float radialTexCoord = ((length(vTexCoord) - 0.5) * uTextureCoordinateScaleFactor) + 0.5;
+  lowp vec4 textureColor = TEXTURE(sTexture, vec2(radialTexCoord, 0.5)) * vec4(mixColor, 1.0) * uColor;
 #else
   lowp vec4 textureColor = TEXTURE(sTexture, vec2(vTexCoord.y, 0.5)) * vec4(mixColor, 1.0) * uColor;
 #endif