| 1 |
static constexpr char SKSL_MINIFIED_sksl_graphite_frag[] = |
| 2 |
"$pure half4 sk_error(){return half4(1.,0.,0.,1.);}$pure half4 sk_passthrough" |
| 3 |
"(half4 a){return a;}$pure half4 sk_rgb_opaque(float4 a){return half4(half3(" |
| 4 |
"a.xyz),1.);}$pure half4 sk_alpha_only(float4 a){return half4(0.,0.,0.,half(" |
| 5 |
"a.w));}$pure float3 $k(float3 a,float4 b,float3 c){return mix(pow(b.y*a+b.z" |
| 6 |
",b.x.xxx)+c.y,b.w*a+c.z,lessThan(a,c.x.xxx));}$pure float3 $l(float3 a,float3" |
| 7 |
" b,float3 c){float3 d=pow(a,b.z.xxx);return pow(max(b.x+b.y*d,0.)/(c.x+c.y*" |
| 8 |
"d),c.z.xxx);}$pure float3 $m(float3 a,float3 b,float3 c){return(c.z+1.)*mix" |
| 9 |
"(exp((a-c.y)*b.z)+c.x,pow(a*b.x,b.y.xxx),lessThanEqual(a*b.x,1..xxx));}$pure" |
| 10 |
" float3 $n(float3 a,float3 b,float3 c){a/=c.z+1.;return mix(b.z*log(a-c.x)+" |
| 11 |
"c.y,b.x*pow(a,b.y.xxx),lessThanEqual(a,1..xxx));}$pure half4 sk_color_space_transform" |
| 12 |
"(half4 a,half3x3 b,float4 c,float4 d,float4 e,float4 f,float4 g,float4 h){if" |
| 13 |
"(d.w<0.)a=unpremul(a);else{half i=1.-half(d.w);half j=half(d.w)*half(f.w);half" |
| 14 |
" k=half(d.w)-j;a.w=dot(half3(a.wx,1.),half3(i,k,j));}float3 i=float3(a.xyz)" |
| 15 |
";if(c.x>0.)i=sign(i)*$k(abs(i),c,d.xyz);else if(c.x<-1.)i=sign(i)*$l(abs(i)" |
| 16 |
",c.yzw,d.xyz);else if(c.x<0.)i=sign(i)*$m(abs(i),c.yzw,d.xyz);if(g.w!=0.){float" |
| 17 |
" j=dot(g.xyz,i);i*=sign(j)*pow(abs(j),g.w);}i=float3x3(b)*i;if(h.w!=0.){float" |
| 18 |
" j=dot(h.xyz,i);i*=sign(j)*pow(abs(j),h.w);}if(e.x>0.)i=sign(i)*$k(abs(i),e" |
| 19 |
",f.xyz);else if(e.x<-1.)i=sign(i)*$l(abs(i),e.yzw,f.xyz);else if(e.x<0.)i=sign" |
| 20 |
"(i)*$n(abs(i),e.yzw,f.xyz);half j=half(f.w);a.xyz=half3(i)*max(a.w,j);return" |
| 21 |
" a;}$pure half4 sk_color_space_transform_premul(half4 a,half2 b){if(b.x<0.)" |
| 22 |
"a=unpremul(a);else{half c=b.x;half d=b.y;a.w=max(a.w,c);a.xyz=a.xyz*max(a.w" |
| 23 |
",d);}return a;}$pure half4 sk_color_space_transform_srgb(half4 a,half3x3 b," |
| 24 |
"float4 c,float4 d,float4 e,float4 f){if(d.w<0.)a=unpremul(a);else{half g=1." |
| 25 |
"-half(d.w);half h=half(d.w)*half(f.w);half i=half(d.w)-h;a.w=dot(half3(a.wx" |
| 26 |
",1.),half3(g,i,h));}float3 g=float3(a.xyz);g=sign(g)*$k(abs(g),c,d.xyz);g=float3x3" |
| 27 |
"(b)*g;g=sign(g)*$k(abs(g),e,f.xyz);half h=half(f.w);a.xyz=half3(g)*max(a.w," |
| 28 |
"h);return a;}$pure half4 sk_analytic_clip(float2 a,float4 b,float2 c,half4 d" |
| 29 |
"){float2 e=abs(c.x).xx;float2 f=float2(d.xy)*((b.xy+e)-a);float2 g=float2(d" |
| 30 |
".zw)*(a-(b.zw-e));float2 h=max(max(f,g),0.);half i=half(saturate(e.x*(1.-length" |
| 31 |
"(h*c.y))));half4 j=saturate(half4(half2(a-b.xy),half2(b.zw-a)));j=mix(j,half4" |
| 32 |
"(1.),d);half k=(((i*j.x)*j.y)*j.z)*j.w;k=c.x<0.?1.-k:k;return k.xxxx;}$pure" |
| 33 |
" half4 sk_analytic_and_atlas_clip(float2 a,float4 b,float2 c,half4 d,float2" |
| 34 |
" e,float4 f,float2 g,sampler2D h){half4 i=sk_analytic_clip(a,b,c,d);float2 j" |
| 35 |
"=a+e;float2 k=clamp(j,f.xy,f.zw);half l=sample(h,k*g).x;return i*l;}$pure float" |
| 36 |
" $o(int a,float b,float c,float d){switch(a){case 0:return clamp(b,c,d);case" |
| 37 |
" 1:{float e=d-c;return mod(b-c,e)+c;}case 2:{float e=d-c;float g=2.*e;float" |
| 38 |
" h=mod(b-c,g);return mix(h,g-h,step(e,h))+c;}default:return b;}}$pure half4" |
| 39 |
" $p(float2 a,float2 b,sampler2D c){return sample(c,a*b);}$pure half4 $q(float2" |
| 40 |
" a,float2 b,float4 c,int d,int e,int f,float2 g,sampler2D h){if(d==3&&f==0)" |
| 41 |
"{float i=floor(a.x)+.5;if(i<c.x||i>c.z)return half4(0.);}if(e==3&&f==0){float" |
| 42 |
" i=floor(a.y)+.5;if(i<c.y||i>c.w)return half4(0.);}a.x=$o(d,a.x,c.x,c.z);a." |
| 43 |
"y=$o(e,a.y,c.y,c.w);float4 i;if(f==0)i=float4(floor(c.xy)+.50001,ceil(c.zw)" |
| 44 |
"-.50001);else i=float4(c.xy+g,c.zw-g);float2 j=clamp(a,i.xy,i.zw);half4 k=$p" |
| 45 |
"(j,b,h);if(f==1){half2 l=half2(a-j);half2 m=abs(l);bool n=d==1;bool o=e==1;" |
| 46 |
"if(n||o){float p;float q;half4 r;half4 t;if(n){p=l.x>0.?i.x:i.z;r=$p(float2" |
| 47 |
"(p,j.y),b,h);}if(o){q=l.y>0.?i.y:i.w;t=$p(float2(j.x,q),b,h);}if(n&&o){half4" |
| 48 |
" u=$p(float2(p,q),b,h);k=mix(mix(k,r,m.x),mix(t,u,m.x),m.y);}else if(n)k=mix" |
| 49 |
"(k,r,m.x);else if(o)k=mix(k,t,m.y);}if(d==3)k*=max(1.-m.x,0.);if(e==3)k*=max" |
| 50 |
"(1.-m.y,0.);}return k;}$pure half4 $r(float2 a,float2 b,float4 c,int d,int e" |
| 51 |
",half4x4 g,sampler2D h){float2 i=fract(a-.5);a-=1.5;a=floor(a)+.5;half4 j=g" |
| 52 |
"*half4(1.,half(i.x),half(i.x*i.x),half((i.x*i.x)*i.x));half4 k=g*half4(1.,half" |
| 53 |
"(i.y),half(i.y*i.y),half((i.y*i.y)*i.y));half4 l=half4(0.);for(int m=0;m<4;" |
| 54 |
"++m){half4 n=half4(0.);for(int o=0;o<4;++o)n+=j[o]*$q(a+float2(float(o),float" |
| 55 |
"(m)),b,c,d,e,0,.50001.xx,h);l+=k[m]*n;}l.w=saturate(l.w);l.xyz=clamp(l.xyz," |
| 56 |
"half3(0.),l.www);return l;}$pure half4 sk_image_shader(float2 a,float2 b,float4" |
| 57 |
" c,int d,int e,int f,sampler2D g){return $q(a,b,c,d,e,f,.50001.xx,g);}$pure" |
| 58 |
" half4 sk_image_shader_clamp(float2 a,float2 b,float4 c,sampler2D d){return" |
| 59 |
" $p(clamp(a,c.xy,c.zw),b,d);}$pure half4 sk_cubic_image_shader(float2 a,float2" |
| 60 |
" b,float4 c,int d,int e,half4x4 f,sampler2D g){return $r(a,b,c,d,e,f,g);}$pure" |
| 61 |
" half4 sk_hw_image_shader(float2 a,sampler2D b){return sample(b,a);}$pure half4" |
| 62 |
" $s(half a,half b,half c,half d,half3x3 e,half3 f){half3 g=half3(a,b,c);half4" |
| 63 |
" h;h.xyz=saturate(e*g+f);h.w=d;return h;}$pure half4 $t(half4 a,half4 b,half4" |
| 64 |
" c,half d,half4 e,half4 f,half4 g,half3x3 h,half3 i){half j=dot(e,a);half k" |
| 65 |
"=dot(f,b);half l=dot(g,c);return $s(j,k,l,d,h,i);}$pure half4 sk_yuv_image_shader" |
| 66 |
"(float2 a,float2 b,float2 c,float4 d,float2 e,int f,int g,int h,int i,half4" |
| 67 |
" j,half4 k,half4 l,half4 m,half3x3 n,half3 o,sampler2D p,sampler2D q,sampler2D" |
| 68 |
" r,sampler2D s){if(h!=i)a=floor(a)+.5;int t=f==3?0:f;int u=g==3?0:g;half4 v" |
| 69 |
";half4 w;half4 x;v=$q(a,b,d,f,g,h,.50001.xx,p);w=$q(a,c,d,t,u,i,e,q);x=$q(a" |
| 70 |
",c,d,t,u,i,e,r);half y;if(m==half4(1.))y=1.;else{half4 z=$q(a,b,d,f,g,h,.50001" |
| 71 |
".xx,s);y=dot(m,z);}return $t(v,w,x,y,j,k,l,n,o);}$pure half4 sk_cubic_yuv_image_shader" |
| 72 |
"(float2 a,float2 b,float2 c,float4 d,int e,int f,half4x4 g,half4 h,half4 i," |
| 73 |
"half4 j,half4 k,half3x3 l,half3 m,sampler2D n,sampler2D o,sampler2D p,sampler2D" |
| 74 |
" q){int r=e==3?0:e;int s=f==3?0:f;half4 t;half4 u;half4 v;t=$r(a,b,d,e,f,g," |
| 75 |
"n);u=$r(a,c,d,r,s,g,o);v=$r(a,c,d,r,s,g,p);half w;if(k==half4(1.))w=1.;else" |
| 76 |
"{half4 x=$r(a,b,d,e,f,g,q);w=dot(k,x);}return $t(t,u,v,w,h,i,j,l,m);}$pure half4" |
| 77 |
" sk_hw_yuv_image_shader(float2 a,float2 b,float2 c,float4 d,float2 e,half4 f" |
| 78 |
",half4 g,half4 h,half4 i,half3x3 j,half3 k,sampler2D l,sampler2D m,sampler2D" |
| 79 |
" n,sampler2D o){float4 p=d;if(e.x<0.){a=floor(a)+.5;d=float4(floor(d.xy),ceil" |
| 80 |
"(d.zw));}float2 q=a;if(e.y<0.){e=abs(e);q=clamp(a,p.xy+e,p.zw-e);a=clamp(a," |
| 81 |
"d.xy+.50001,d.zw-.50001);}half4 r;half4 s;half4 t;r=$p(a,b,l);s=$p(q,c,m);t" |
| 82 |
"=$p(q,c,n);half v;if(i==half4(1.))v=1.;else{half4 w=$p(a,b,o);v=dot(i,w);}return" |
| 83 |
" $t(r,s,t,v,f,g,h,j,k);}$pure half4 sk_hw_yuv_no_swizzle_image_shader(float2" |
| 84 |
" a,float2 b,float2 c,float4 d,float2 e,half3x3 f,half4 g,sampler2D h,sampler2D" |
| 85 |
" i,sampler2D j,sampler2D k){float4 l=d;if(e.x<0.){a=floor(a)+.5;d=float4(floor" |
| 86 |
"(d.xy),ceil(d.zw));}float2 m=a;if(e.y<0.){e=abs(e);m=clamp(a,l.xy+e,l.zw-e)" |
| 87 |
";a=clamp(a,d.xy+.50001,d.zw-.50001);}half r=$p(a,b,h).x;half s=$p(m,c,i).x;" |
| 88 |
"half t=$p(m,c,j).x;half u=saturate($p(a,b,k).x+g.w);return $s(r,s,t,u,f,g.xyz" |
| 89 |
");}$pure half4 sk_dither(half4 a,half b,sampler2D c){half e=sample(c,sk_FragCoord" |
| 90 |
".xy*.125).x-.5;return half4(clamp(a.xyz+e*b,0.,a.w),a.w);}$pure float2 $u(int" |
| 91 |
" a,float2 b){switch(a){case 0:b.x=saturate(b.x);break;case 1:b.x=fract(b.x)" |
| 92 |
";break;case 2:{float c=b.x-1.;b.x=(c-2.*floor(c*.5))-1.;if(sk_Caps.mustDoOpBetweenFloorAndAbs" |
| 93 |
")b.x=clamp(b.x,-1.,1.);b.x=abs(b.x);break;}case 3:if(b.x<0.||b.x>1.)return float2" |
| 94 |
"(0.,-1.);break;}return b;}$pure half4 $v(float4[4]a,float4 b,float2 c){if(c" |
| 95 |
".y<0.)return half4(0.);else if(c.x<=b.x)return half4(a[0]);else if(c.x<b.y)" |
| 96 |
"return half4(mix(a[0],a[1],(c.x-b.x)/(b.y-b.x)));else if(c.x<b.z)return half4" |
| 97 |
"(mix(a[1],a[2],(c.x-b.y)/(b.z-b.y)));else if(c.x<b.w)return half4(mix(a[2]," |
| 98 |
"a[3],(c.x-b.z)/(b.w-b.z)));else return half4(a[3]);}$pure half4 $w(float4[8" |
| 99 |
"]a,float4[2]b,float2 c){if(c.y<0.)return half4(0.);else if(c.x<b[1].x)if(c." |
| 100 |
"x<b[0].z)if(c.x<=b[0].x)return half4(a[0]);else if(c.x<b[0].y)return half4(" |
| 101 |
"mix(a[0],a[1],(c.x-b[0].x)/(b[0].y-b[0].x)));else return half4(mix(a[1],a[2" |
| 102 |
"],(c.x-b[0].y)/(b[0].z-b[0].y)));else if(c.x<b[0].w)return half4(mix(a[2],a" |
| 103 |
"[3],(c.x-b[0].z)/(b[0].w-b[0].z)));else return half4(mix(a[3],a[4],(c.x-b[0" |
| 104 |
"].w)/(b[1].x-b[0].w)));else if(c.x<b[1].z)if(c.x<b[1].y)return half4(mix(a[" |
| 105 |
"4],a[5],(c.x-b[1].x)/(b[1].y-b[1].x)));else return half4(mix(a[5],a[6],(c.x" |
| 106 |
"-b[1].y)/(b[1].z-b[1].y)));else if(c.x<b[1].w)return half4(mix(a[6],a[7],(c" |
| 107 |
".x-b[1].z)/(b[1].w-b[1].z)));else return half4(a[7]);}$pure half4 $x(sampler2D" |
| 108 |
" a,int b,float2 c){if(c.y<0.)return half4(0.);else if(c.x==0.)return sampleLod" |
| 109 |
"(a,float2(0.,.25),0.);else if(c.x==1.)return sampleLod(a,float2(1.,.25),0.)" |
| 110 |
";else{float f=0.;float g=float(b);float h=1./g;for(int i=1;i<b;i+=i){float j" |
| 111 |
"=floor((f+g)*.5);float k=(j+.5)*h;float2 l=float2(sampleLod(a,float2(k,.75)" |
| 112 |
",0.).xy);float m=ldexp(l.x,int(l.y));if(c.x<m)g=j;else f=j;}g=(f+1.5)*h;f=(" |
| 113 |
"f+.5)*h;half4 i=sampleLod(a,float2(f,.25),0.);half4 j=sampleLod(a,float2(g," |
| 114 |
".25),0.);float2 k=float2(sampleLod(a,float2(f,.75),0.).xy);float l=ldexp(k." |
| 115 |
"x,int(k.y));k=float2(sampleLod(a,float2(g,.75),0.).xy);float m=ldexp(k.x,int" |
| 116 |
"(k.y));return half4(mix(float4(i),float4(j),(c.x-l)/(m-l)));}}$pure half4 $y" |
| 117 |
"(float[]a,int b){return half4(half(a[b]),half(a[b+1]),half(a[b+2]),half(a[b" |
| 118 |
"+3]));}$pure half4 $z(float[]a,int b,int c,float2 d){int e=b+c;if(d.y<0.)return" |
| 119 |
" half4(0.);else if(d.x==0.)return $y(a,e);else if(d.x==1.){int f=e+(c-1)*4;" |
| 120 |
"return $y(a,f);}else{int f=b;int g=(f+c)-1;for(int h=1;h<c;h+=h){int j=(f+g" |
| 121 |
")/2;if(d.x<a[j])g=j;else f=j;}int h=e+(f-b)*4;float i=a[f];half4 j=$y(a,h);" |
| 122 |
"int k=e+(g-b)*4;float l=a[g];if(l==i)return j;else{half4 m=$y(a,k);return half4" |
| 123 |
"(mix(float4(j),float4(m),(d.x-i)/(l-i)));}}}$pure float2 $A(float2 a){return" |
| 124 |
" float2(a.x+1e-05,1.);}$pure float2 $B(float2 a){float b=length(a);return float2" |
| 125 |
"(b,1.);}$pure float2 $C(float a,float b,float2 c){float d;if(sk_Caps.atan2ImplementedAsAtanYOverX" |
| 126 |
")d=2.*atan(-c.y,length(c)-c.x);else d=c.x!=0.?atan(-c.y,-c.x):sign(c.y)*-1.57079637" |
| 127 |
";float e=((d*.159154937+.5)+a)*b;return float2(e,1.);}$pure float2 $D(float" |
| 128 |
" b,float c,float d,float e,float2 f){if(d==0.&&e==1.){float g=length(f)*c-b" |
| 129 |
";return float2(g,1.);}else{float g=dot(f,f)-b*b;float h=2.*(c*b+f.x);float i" |
| 130 |
";if(d==0.)i=g/h;else{float j=h*h-(4.*d)*g;if(j<0.)return float2(0.,-1.);float" |
| 131 |
" k=sign(1.-c);i=e*(h+k*sqrt(j));}float j=sign(i*c+b);return float2(i,j);}}$pure" |
| 132 |
" half4 sk_linear_grad_4_shader(float2 a,float4[4]b,float4 c,int d,int e,int" |
| 133 |
" f){float2 g=$A(a);g=$u(d,g);half4 h=$v(b,c,g);return $interpolated_to_rgb_unpremul" |
| 134 |
"(h,e,f);}$pure half4 sk_linear_grad_8_shader(float2 a,float4[8]b,float4[2]c" |
| 135 |
",int d,int e,int f){float2 g=$A(a);g=$u(d,g);half4 h=$w(b,c,g);return $interpolated_to_rgb_unpremul" |
| 136 |
"(h,e,f);}$pure half4 sk_linear_grad_tex_shader(float2 a,int b,int c,int d,int" |
| 137 |
" e,sampler2D f){float2 g=$A(a);g=$u(c,g);half4 h=$x(f,b,g);return $interpolated_to_rgb_unpremul" |
| 138 |
"(h,d,e);}$pure half4 sk_linear_grad_buf_shader(float2 a,int b,int c,int d,int" |
| 139 |
" e,int f,float[]g){float2 h=$A(a);h=$u(d,h);half4 i=$z(g,c,b,h);return $interpolated_to_rgb_unpremul" |
| 140 |
"(i,e,f);}$pure half4 sk_radial_grad_4_shader(float2 a,float4[4]b,float4 c,int" |
| 141 |
" d,int e,int f){float2 g=$B(a);g=$u(d,g);half4 h=$v(b,c,g);return $interpolated_to_rgb_unpremul" |
| 142 |
"(h,e,f);}$pure half4 sk_radial_grad_8_shader(float2 a,float4[8]b,float4[2]c" |
| 143 |
",int d,int e,int f){float2 g=$B(a);g=$u(d,g);half4 h=$w(b,c,g);return $interpolated_to_rgb_unpremul" |
| 144 |
"(h,e,f);}$pure half4 sk_radial_grad_tex_shader(float2 a,int b,int c,int d,int" |
| 145 |
" e,sampler2D f){float2 g=$B(a);g=$u(c,g);half4 h=$x(f,b,g);return $interpolated_to_rgb_unpremul" |
| 146 |
"(h,d,e);}$pure half4 sk_radial_grad_buf_shader(float2 a,int b,int c,int d,int" |
| 147 |
" e,int f,float[]g){float2 h=$B(a);h=$u(d,h);half4 i=$z(g,c,b,h);return $interpolated_to_rgb_unpremul" |
| 148 |
"(i,e,f);}$pure half4 sk_sweep_grad_4_shader(float2 a,float4[4]b,float4 c,float" |
| 149 |
" d,float e,int f,int g,int h){float2 i=$C(d,e,a);i=$u(f,i);half4 j=$v(b,c,i" |
| 150 |
");return $interpolated_to_rgb_unpremul(j,g,h);}$pure half4 sk_sweep_grad_8_shader" |
| 151 |
"(float2 a,float4[8]b,float4[2]c,float d,float e,int f,int g,int h){float2 i" |
| 152 |
"=$C(d,e,a);i=$u(f,i);half4 j=$w(b,c,i);return $interpolated_to_rgb_unpremul" |
| 153 |
"(j,g,h);}$pure half4 sk_sweep_grad_tex_shader(float2 a,float b,float c,int d" |
| 154 |
",int e,int f,int g,sampler2D h){float2 i=$C(b,c,a);i=$u(e,i);half4 j=$x(h,d" |
| 155 |
",i);return $interpolated_to_rgb_unpremul(j,f,g);}$pure half4 sk_sweep_grad_buf_shader" |
| 156 |
"(float2 a,float b,float c,int d,int e,int f,int g,int h,float[]i){float2 j=" |
| 157 |
"$C(b,c,a);j=$u(f,j);half4 k=$z(i,e,d,j);return $interpolated_to_rgb_unpremul" |
| 158 |
"(k,g,h);}$pure half4 sk_conical_grad_4_shader(float2 a,float4[4]b,float4 c," |
| 159 |
"float d,float e,float f,float g,int h,int i,int j){float2 k=$D(d,e,f,g,a);k" |
| 160 |
"=$u(h,k);half4 l=$v(b,c,k);return $interpolated_to_rgb_unpremul(l,i,j);}$pure" |
| 161 |
" half4 sk_conical_grad_8_shader(float2 a,float4[8]b,float4[2]c,float d,float" |
| 162 |
" e,float f,float g,int h,int i,int j){float2 k=$D(d,e,f,g,a);k=$u(h,k);half4" |
| 163 |
" l=$w(b,c,k);return $interpolated_to_rgb_unpremul(l,i,j);}$pure half4 sk_conical_grad_tex_shader" |
| 164 |
"(float2 a,float b,float c,float d,float e,int f,int g,int h,int i,sampler2D" |
| 165 |
" j){float2 k=$D(b,c,d,e,a);k=$u(g,k);half4 l=$x(j,f,k);return $interpolated_to_rgb_unpremul" |
| 166 |
"(l,h,i);}$pure half4 sk_conical_grad_buf_shader(float2 a,float b,float c,float" |
| 167 |
" d,float e,int f,int g,int h,int i,int j,float[]k){float2 l=$D(b,c,d,e,a);l" |
| 168 |
"=$u(h,l);half4 m=$z(k,g,f,l);return $interpolated_to_rgb_unpremul(m,i,j);}$pure" |
| 169 |
" half4 sk_hsl_matrix_colorfilter(half4 a,half4x4 b,half4 c){a=$rgb_to_hsl(a" |
| 170 |
".xyz,a.w);a=b*a+c;return $hsl_to_rgb(a.xyz,a.w);}$pure half4 sk_matrix_colorfilter" |
| 171 |
"(half4 a,half4x4 b,half4 c,half2 d){a=unpremul(a);a=b*a+c;a=clamp(a,half4(d" |
| 172 |
".xxx,0.),half4(d.yyy,1.));a.xyz*=a.w;return a;}$pure half4 $E(half2 a,half2" |
| 173 |
" b,int c,sampler2D d){half4 f;f.xy=floor(a);f.zw=f.xy+half2(1.);if(bool(c))" |
| 174 |
"f-=step(b.xyxy,f)*b.xyxy;half g=sample(d,float2(half2((f.x+.5)*.00390625,.5" |
| 175 |
"))).x;half h=sample(d,float2(half2((f.z+.5)*.00390625,.5))).x;half2 i=half2" |
| 176 |
"(g,h);if(sk_Caps.PerlinNoiseRoundingFix)i=floor(i*half2(255.)+half2(.5))*half2" |
| 177 |
"(.003921569);half4 j=256.*i.xyxy+f.yyww;j*=half4(.00390625);return j;}$pure" |
| 178 |
" half4 $F(half2 a,half4 b,sampler2D c){half2 d=fract(a);half2 e=smoothstep(" |
| 179 |
"0.,1.,d);const half f=.00390625;half4 g;for(int h=0;h<4;h++){half i=(half(h" |
| 180 |
")+.5)*.25;half4 j=sample(c,float2(float(b.x),float(i)));half4 k=sample(c,float2" |
| 181 |
"(float(b.y),float(i)));half4 l=sample(c,float2(float(b.w),float(i)));half4 m" |
| 182 |
"=sample(c,float2(float(b.z),float(i)));half2 n=d;half o=dot((j.yw+j.xz*f)*2." |
| 183 |
"-1.,n);n.x-=1.;half p=dot((k.yw+k.xz*f)*2.-1.,n);half q=mix(o,p,e.x);n.y-=1." |
| 184 |
";p=dot((l.yw+l.xz*f)*2.-1.,n);n.x+=1.;o=dot((m.yw+m.xz*f)*2.-1.,n);half r=mix" |
| 185 |
"(o,p,e.x);g[h]=mix(q,r,e.y);}return g;}$pure half4 sk_perlin_noise_shader(float2" |
| 186 |
" a,float2 b,float2 c,int d,int e,int f,sampler2D g,sampler2D h){half2 k=half2" |
| 187 |
"((a+.5)*b);half4 l=half4(0.);half2 m=half2(c);half n=1.;for(int o=0;o<e;++o" |
| 188 |
"){half4 p=$E(k,m,f,g);half4 q=$F(k,p,h);if(d!=0)q=abs(q);l+=q*n;k*=half2(2." |
| 189 |
");n*=.5;m*=half2(2.);}if(d==0)l=l*half4(.5)+half4(.5);l=saturate(l);return half4" |
| 190 |
"(l.xyz*l.w,l.w);}$pure half4 sk_porter_duff_blend(half4 a,half4 b,half4 c){" |
| 191 |
"return blend_porter_duff(c,a,b);}$pure half4 sk_hslc_blend(half4 a,half4 b," |
| 192 |
"half2 c){return blend_hslc(c,a,b);}$pure half4 sk_table_colorfilter(half4 a" |
| 193 |
",sampler2D b){half4 c=unpremul(a)*.99609375+.001953125;half4 d=half4(sample" |
| 194 |
"(b,float2(half2(c.x,.375))).x,sample(b,float2(half2(c.y,.625))).x,sample(b," |
| 195 |
"float2(half2(c.z,.875))).x,1.);return d*sample(b,float2(half2(c.w,.125))).x" |
| 196 |
";}$pure half4 sk_gaussian_colorfilter(half4 a){half b=1.-a.w;b=exp((-b*b)*4." |
| 197 |
")-.018;return b.xxxx;}$pure half4 sample_indexed_atlas(float2 a,int b,sampler2D" |
| 198 |
" c,sampler2D d,sampler2D e,sampler2D f){switch(b){case 1:return sample(d,a)" |
| 199 |
";case 2:return sample(e,a);case 3:return sample(f,a);default:return sample(" |
| 200 |
"c,a);}}$pure half3 $G(float2 a,int b,half2 c,sampler2D d,sampler2D e,sampler2D" |
| 201 |
" f,sampler2D g){half3 h=half3(1.);switch(b){case 1:h.x=sample(e,float2(half2" |
| 202 |
"(a)-c)).x;h.y=sample(e,a).x;h.z=sample(e,float2(half2(a)+c)).x;break;case 2" |
| 203 |
":h.x=sample(f,float2(half2(a)-c)).x;h.y=sample(f,a).x;h.z=sample(f,float2(half2" |
| 204 |
"(a)+c)).x;break;case 3:h.x=sample(g,float2(half2(a)-c)).x;h.y=sample(g,a).x" |
| 205 |
";h.z=sample(g,float2(half2(a)+c)).x;break;default:h.x=sample(d,float2(half2" |
| 206 |
"(a)-c)).x;h.y=sample(d,a).x;h.z=sample(d,float2(half2(a)+c)).x;break;}return" |
| 207 |
" h;}$pure half4 bitmap_text_coverage_fn(half4 a,int b){return b==0?a.xxxx:a" |
| 208 |
";}$pure half4 sdf_text_coverage_fn(half a,half2 b,float2 c){half d=7.96875*" |
| 209 |
"(a-.5019608);d-=b.x;half2 e=half2(dFdx(d),dFdy(d));half f=dot(e,e);e=f>=.0001" |
| 210 |
"?e*inversesqrt(f):half2(.7071);float2x2 g=float2x2(dFdx(c),dFdy(c));half2 h" |
| 211 |
"=half2(g*float2(e));half i=.65*length(h);if(b.y>0.)return saturate((d+i)/(2." |
| 212 |
"*i)).xxxx;else return smoothstep(-i,i,d).xxxx;}$pure half4 sdf_text_lcd_coverage_fn" |
| 213 |
"(float2 a,half2 b,half4 c,float2 d,float e,sampler2D f,sampler2D g,sampler2D" |
| 214 |
" h,sampler2D i){float2x2 j=float2x2(dFdx(d),dFdy(d));half2 k=half2(j*float2" |
| 215 |
"(b));half3 l=$G(a,int(e),k,f,g,h,i);half3 m=half3(7.96875)*(l-half3(.5019608" |
| 216 |
"));m-=c.xyz;half2 n=half2(dFdx(m.y),dFdy(m.y));half o=dot(n,n);n=o>=.0001?n" |
| 217 |
"*inversesqrt(o):half2(.7071);half2 p=half2(j*float2(n));half3 q=(.65*length" |
| 218 |
"(p)).xxx;if(c.w>0.)return half4(saturate(m+q/(2.*q)),1.);else return half4(" |
| 219 |
"smoothstep(-q,q,m),1.);}$pure float $H(float2 a,float2x2 b){float2 c=a*b;return" |
| 220 |
" inversesqrt(dot(c,c));}$pure float2 $I(float2 a,float2 b,float c,float2x2 d" |
| 221 |
"){float2 e=1./(b*b+c*c);float2 g=e*a;float h=$H(g,d);float i=(.5*h)*(dot(a," |
| 222 |
"g)-1.);float j=((b.x*c)*e.x)*h;return float2(j-i,j+i);}void $J(inout float2" |
| 223 |
" a,float2x2 b,float2 c,float2 d,float2 e,float2 f){float2 g=f-d;if(all(greaterThan" |
| 224 |
"(g,0..xx)))if(all(greaterThan(f,0..xx))||c.x>0.&&c.y<0.){float2 h=$I(g*e,f," |
| 225 |
"c.x,b);h.y=f.x-c.x<=0.?1.:-h.y;a=min(a,h);}else if(c.y==0.){float h=((c.x-g" |
| 226 |
".x)-g.y)*$H(e,b);a.x=min(a.x,h);}}void $K(inout float2 a,float2x2 b,float2 c" |
| 227 |
",float4 e,float4 f,float4 g){$J(a,b,c,e.xy,-1..xx,float2(f.x,g.x));$J(a,b,c" |
| 228 |
",e.zy,float2(1.,-1.),float2(f.y,g.y));$J(a,b,c,e.zw,1..xx,float2(f.z,g.z));" |
| 229 |
"$J(a,b,c,e.xw,float2(-1.,1.),float2(f.w,g.w));}$pure half4 analytic_rrect_coverage_fn" |
| 230 |
"(float4 a,float4 b,float4 c,float4 d,float4 e,float2 f,float2 g){if(g.x>0.)" |
| 231 |
"return half4(1.);else if(g.y>1.){float2 h=min(c.xy,c.zw);float i=min(h.x,h." |
| 232 |
"y)*a.w;float j=(g.y-1.)*a.w;float k=coverage_bias(j);return half(saturate(j" |
| 233 |
"*(i+k))).xxxx;}else{float2x2 h=float2x2(b)*(1./a.w);float2 i=float2($H(float2" |
| 234 |
"(1.,0.),h),$H(float2(0.,1.),h));float2 j=i*(f.x+min(c.xy,c.zw));float2 k=float2" |
| 235 |
"(min(j.x,j.y),-1.);float l;float m;if(g.x>-.95){float2 n=i*((c.xy+c.zw)+2.*" |
| 236 |
"f.xx);l=min(min(n.x,n.y),1.);m=coverage_bias(l);}else{float2 n=(2.*f.x)*i;float2" |
| 237 |
" o=n-j;k.y=-max(o.x,o.y);if(f.x>0.){float p=min(n.x,n.y);float2 q=mix(p.xx," |
| 238 |
"n,greaterThanEqual(o,-.5.xx));l=saturate(max(q.x,q.y));m=coverage_bias(l);}" |
| 239 |
"else l=(m=1.);}$K(k,h,f,c,d,e);float n=min(g.y,0.)*a.w;float o=l*(min(k.x+n" |
| 240 |
",-k.y)+m);return half(saturate(o)).xxxx;}}$pure half4 per_edge_aa_quad_coverage_fn" |
| 241 |
"(float4 a,float4 b){float2 d=min(b.xy,b.zw);float e=min(d.x,d.y)*a.w;return" |
| 242 |
" half(saturate(e)).xxxx;}$pure half4 circular_arc_coverage_fn(float4 a,float3" |
| 243 |
" b,float3 c,float3 e,float f,float4 g){float h=length(a.xy);half i=half(a.z" |
| 244 |
"*(1.-h));half j=saturate(i);half k=half(a.z*(h-a.w));half l=saturate(k);j*=" |
| 245 |
"l;half m=half(saturate(a.z*dot(a.xy,b.xy)+b.z));m*=half(saturate(a.z*dot(a." |
| 246 |
"xy,c.xy)+c.z));m=m+half(saturate(a.z*dot(a.xy,e.xy)+e.z));half n=half(a.z*(" |
| 247 |
"f-length(a.xy-g.xy)));half o=half(a.z*(f-length(a.xy-g.zw)));half p=max(n,0." |
| 248 |
")+max(o,0.);m=saturate(m+p);return(m*j).xxxx;}$pure half4 $L(float2 a,float4" |
| 249 |
" b,half c,half d,sampler2D e){half f;half g;if(c!=0.){half2 h=max(half2(b.xy" |
| 250 |
"-a),half2(a-b.zw));f=sample(e,float2(float(d*h.x),.5)).x;g=sample(e,float2(" |
| 251 |
"float(d*h.y),.5)).x;}else{half4 h=half4(half2(b.xy-a),half2(a-b.zw));f=(1.-" |
| 252 |
"sample(e,float2(float(d*h.x),.5)).x)-sample(e,float2(float(d*h.z),.5)).x;g=" |
| 253 |
"(1.-sample(e,float2(float(d*h.y),.5)).x)-sample(e,float2(float(d*h.w),.5))." |
| 254 |
"x;}return(f*g).xxxx;}$pure half4 $M(float2 a,float4 b,sampler2D c){float d=" |
| 255 |
"b.z;float e=b.w;half2 f=half2((a-b.xy)*d);float g=float(length(f))-e;return" |
| 256 |
" sample(c,float2(g,.5)).xxxx;}$pure half4 $N(float2 a,float4 b,half c,sampler2D" |
| 257 |
" d){float2 e=a-b.xy;float2 f=(b.zw-b.xy)*.5;e-=f;half2 g=half2(sign(e));e=abs" |
| 258 |
"(e);half2 h=half2(e-(f-float(c)));h=max(h,0.);h*=g;h+=c.xx;half2 i=(2.*c).xx" |
| 259 |
";half2 j=h/i;return sample(d,float2(j)).xxxx;}$pure half4 blur_coverage_fn(" |
| 260 |
"float2 a,float4 b,half2 c,int d,sampler2D e){switch(d){case 0:{return $L(a," |
| 261 |
"b,c.x,c.y,e);}case 2:{return $M(a,b,e);}case 1:{return $N(a,b,c.x,e);}}return" |
| 262 |
" half4(0.);}"; |