Add epsilon to linear gradient

Related bug in Ganesh: https://crbug.com/40616713

Change-Id: I8f50660ece8ddcb420d27f5cfaa60190d6bbb12a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/864156
Reviewed-by: James Godfrey-Kittle <jamesgk@google.com>
Commit-Queue: Nathan Sanchez <nathanasanchez@google.com>
diff --git a/src/sksl/generated/sksl_graphite_frag.minified.sksl b/src/sksl/generated/sksl_graphite_frag.minified.sksl
index 9e107c3..393f0cb 100644
--- a/src/sksl/generated/sksl_graphite_frag.minified.sksl
+++ b/src/sksl/generated/sksl_graphite_frag.minified.sksl
@@ -87,8 +87,8 @@
 " k=float2(sampleLod(a,float2(f,.75),0.).xy);float l=ldexp(k.x,int(k.y));k=float2"
 "(sampleLod(a,float2(g,.75),0.).xy);float m=ldexp(k.x,int(k.y));return half4"
 "(mix(float4(i),float4(j),(c.x-l)/(m-l)));}}$pure float2 $v(float2 a){return"
-" float2(a.x,1.);}$pure float2 $w(float2 a){float b=length(a);return float2("
-"b,1.);}$pure float2 $x(float a,float b,float2 c){float d;if(sk_Caps.atan2ImplementedAsAtanYOverX"
+" float2(a.x+1e-05,1.);}$pure float2 $w(float2 a){float b=length(a);return float2"
+"(b,1.);}$pure float2 $x(float a,float b,float2 c){float d;if(sk_Caps.atan2ImplementedAsAtanYOverX"
 ")d=2.*atan(-c.y,length(c)-c.x);else d=c.x!=0.?atan(-c.y,-c.x):sign(c.y)*-1.57079637"
 ";float e=((d*.159154937+.5)+a)*b;return float2(e,1.);}$pure float2 $y(float"
 " b,float c,float d,float e,float2 f){if(d==0.&&e==1.){float g=length(f)*c-b"
diff --git a/src/sksl/generated/sksl_graphite_frag.unoptimized.sksl b/src/sksl/generated/sksl_graphite_frag.unoptimized.sksl
index c7bf5b6..53f19e6 100644
--- a/src/sksl/generated/sksl_graphite_frag.unoptimized.sksl
+++ b/src/sksl/generated/sksl_graphite_frag.unoptimized.sksl
@@ -170,8 +170,8 @@
 "int(tmp.y));tmp=float2(sampleLod(colorsAndOffsetsSampler,float2(high,.75),0."
 ").xy);float offset1=ldexp(tmp.x,int(tmp.y));return half4(mix(float4(color0)"
 ",float4(color1),(t.x-offset0)/(offset1-offset0)));}}$pure float2 $linear_grad_layout"
-"(float2 pos){return float2(pos.x,1.);}$pure float2 $radial_grad_layout(float2"
-" pos){float t=length(pos);return float2(t,1.);}$pure float2 $sweep_grad_layout"
+"(float2 pos){return float2(pos.x+1e-05,1.);}$pure float2 $radial_grad_layout"
+"(float2 pos){float t=length(pos);return float2(t,1.);}$pure float2 $sweep_grad_layout"
 "(float biasParam,float scaleParam,float2 pos){float angle;if(sk_Caps.atan2ImplementedAsAtanYOverX"
 ")angle=2.*atan(-pos.y,length(pos)-pos.x);else angle=pos.x!=0.?atan(-pos.y,-"
 "pos.x):sign(pos.y)*-1.57079637;float t=((angle*.159154937+.5)+biasParam)*scaleParam"
diff --git a/src/sksl/sksl_graphite_frag.sksl b/src/sksl/sksl_graphite_frag.sksl
index db90954..959baba 100644
--- a/src/sksl/sksl_graphite_frag.sksl
+++ b/src/sksl/sksl_graphite_frag.sksl
@@ -604,7 +604,11 @@
 }
 
 $pure float2 $linear_grad_layout(float2 pos) {
-    return float2(pos.x, 1);
+    // Add small epsilon since when the gradient is horizontally or vertically aligned,
+    // pixels along the same column or row can have slightly different interpolated t values
+    // causing pixels to choose the wrong offset when colorizing. This helps ensure pixels 
+    // along the same column or row choose the same gradient offsets.
+    return float2(pos.x + 0.00001, 1);
 }
 
 $pure float2 $radial_grad_layout(float2 pos) {