blob: 03a99f556f07c0eb41d71dfdd37f6e3277776ee6 [file] [log] [blame]
static constexpr char SKSL_MINIFIED_sksl_graphite_frag[] =
"$pure half4 sk_error(){return half4(1.,0.,1.,1.);}$pure half4 sk_passthrough"
"(half4 a){return a;}$pure half4 sk_solid_shader(float4 a){return half4(a);}"
"$pure half $k(int a,half b,half[7]c){half d=c[0];half e=c[1];half f=c[2];half"
" g=c[3];half h=c[4];half i=c[5];half j=c[6];half k=sign(b);b=abs(b);switch("
"a){case 1:b=b<h?g*b+j:pow(e*b+f,d)+i;break;case 2:b=pow(max(e+f*pow(b,g),0."
")/(h+i*pow(b,g)),j);break;case 3:b=b*e<=1.?pow(b*e,f):exp((b-i)*g)+h;b*=j+1."
";break;case 4:b/=j+1.;b=b<=1.?e*pow(b,f):g*log(b-h)+i;break;}return k*b;}$pure"
" half4 sk_color_space_transform(half4 a,int b,int c,int d,half[7]e,half[7]f"
",half3x3 g){if(bool(b&1)){a=unpremul(a);}if(bool(b&2)){a.x=$k(c,a.x,e);a.y="
"$k(c,a.y,e);a.z=$k(c,a.z,e);}if(bool(b&4)){a.xyz=g*a.xyz;}if(bool(b&8)){a.x"
"=$k(d,a.x,f);a.y=$k(d,a.y,f);a.z=$k(d,a.z,f);}if(bool(b&16)){a.xyz*=a.w;}return"
" a;}$pure float $l(int a,float b,float c,float d){switch(a){case 0:return clamp"
"(b,c,d);case 1:{float e=d-c;return mod(b-c,e)+c;}case 2:{float e=d-c;float g"
"=2.*e;float h=mod(b-c,g);return mix(h,g-h,step(e,h))+c;}default:return b;}}"
"$pure half4 $m(float2 a,float2 b,float4 c,int d,int e,int f,sampler2D g){if"
"(d==3&&f==0){float h=floor(a.x)+.5;if(h<c.x||h>c.z){return half4(0.);}}if(e"
"==3&&f==0){float h=floor(a.y)+.5;if(h<c.y||h>c.w){return half4(0.);}}a.x=$l"
"(d,a.x,c.x,c.z);a.y=$l(e,a.y,c.y,c.w);float4 h;if(f==0){h=float4(floor(c.xy"
")+.5,ceil(c.zw)-.5);}else{h=float4(c.xy+.5,c.zw-.5);}float2 i=clamp(a,h.xy,"
"h.zw);half4 j=sample(g,i/b);if(f==1){half2 k=half2(a-i);half2 l=abs(k);bool"
" m=d==1;bool n=e==1;if(m||n){float o;float p;half4 q;half4 r;if(m){o=k.x>0."
"?h.x:h.z;q=sample(g,float2(o,i.y)/b);}if(n){p=k.y>0.?h.y:h.w;r=sample(g,float2"
"(i.x,p)/b);}if(m&&n){half4 t=sample(g,float2(o,p)/b);j=mix(mix(j,q,l.x),mix"
"(r,t,l.x),l.y);}else if(m){j=mix(j,q,l.x);}else if(n){j=mix(j,r,l.y);}}if(d"
"==3){j*=max(1.-l.x,0.);}if(e==3){j*=max(1.-l.y,0.);}}return j;}$pure half4 $n"
"(float2 a,float2 b,float4 c,int d,int e,float4x4 g,sampler2D h){float2 i=fract"
"(a-.5);a-=1.5;a=floor(a)+.5;float4 j=g*float4(1.,i.x,i.x*i.x,(i.x*i.x)*i.x)"
";float4 k=g*float4(1.,i.y,i.y*i.y,(i.y*i.y)*i.y);float4 l=float4(0.);for(int"
" m=0;m<4;++m){float4 n=float4(0.);for(int o=0;o<4;++o){n+=j[o]*float4($m(a+"
"float2(float(o),float(m)),b,c,d,e,0,h));}l+=k[m]*n;}return half4(l);}$pure half4"
" sk_image_shader(float2 a,float2 b,float4 c,int d,int e,int f,int g,float4x4"
" h,int i,int j,int k,half[7]l,half[7]m,half3x3 n,sampler2D o){half4 p=g!=0?"
"$n(a,b,c,d,e,h,o):$m(a,b,c,d,e,f,o);return sk_color_space_transform(p,i,j,k"
",l,m,n);}$pure float2 $o(int a,float2 b){switch(a){case 0:b.x=clamp(b.x,0.,"
"1.);break;case 1:b.x=fract(b.x);break;case 2:{float c=b.x-1.;b.x=(c-2.*floor"
"(c*.5))-1.;if(sk_Caps.mustDoOpBetweenFloorAndAbs){b.x=clamp(b.x,-1.,1.);}b."
"x=abs(b.x);break;}case 3:if(b.x<0.||b.x>1.){return float2(0.,-1.);}break;}return"
" b;}$pure half4 $p(float4[4]a,float[4]b,float2 c){if(c.y<0.){return half4(0."
");}else if(c.x<=b[0]){return half4(a[0]);}else if(c.x<b[1]){return half4(mix"
"(a[0],a[1],(c.x-b[0])/(b[1]-b[0])));}else if(c.x<b[2]){return half4(mix(a[1"
"],a[2],(c.x-b[1])/(b[2]-b[1])));}else if(c.x<b[3]){return half4(mix(a[2],a["
"3],(c.x-b[2])/(b[3]-b[2])));}else{return half4(a[3]);}}$pure half4 $q(float4"
"[8]a,float[8]b,float2 c){if(c.y<0.){return half4(0.);}else if(c.x<b[4]){if("
"c.x<b[2]){if(c.x<=b[0]){return half4(a[0]);}else if(c.x<b[1]){return half4("
"mix(a[0],a[1],(c.x-b[0])/(b[1]-b[0])));}else{return half4(mix(a[1],a[2],(c."
"x-b[1])/(b[2]-b[1])));}}else{if(c.x<b[3]){return half4(mix(a[2],a[3],(c.x-b"
"[2])/(b[3]-b[2])));}else{return half4(mix(a[3],a[4],(c.x-b[3])/(b[4]-b[3]))"
");}}}else{if(c.x<b[6]){if(c.x<b[5]){return half4(mix(a[4],a[5],(c.x-b[4])/("
"b[5]-b[4])));}else{return half4(mix(a[5],a[6],(c.x-b[5])/(b[6]-b[5])));}}else"
"{if(c.x<b[7]){return half4(mix(a[6],a[7],(c.x-b[6])/(b[7]-b[6])));}else{return"
" half4(a[7]);}}}}$pure float2 $r(float2 a,float2 b,float2 c){c-=a;float2 d="
"b-a;float e=dot(c,d)/dot(d,d);return float2(e,1.);}$pure float2 $s(float2 a"
",float b,float2 c){float d=distance(c,a)/b;return float2(d,1.);}$pure float2"
" $t(float2 a,float b,float c,float2 d){d-=a;float e=sk_Caps.atan2ImplementedAsAtanYOverX"
"?2.*atan(-d.y,length(d)-d.x):atan(-d.y,-d.x);float f=((e*.159154937+.5)+b)*"
"c;return float2(f,1.);}$pure float3x3 $u(float2 a,float2 b){return float3x3"
"(0.,-1.,0.,1.,0.,0.,0.,0.,1.)*inverse(float3x3(b.y-a.y,a.x-b.x,0.,b.x-a.x,b"
".y-a.y,0.,a.x,a.y,1.));}$pure float2 $v(float2 a,float2 b,float c,float d,float2"
" e){const float f=.000244140625;float g=distance(a,b);float h=d-c;bool i=g<"
"f;bool j=abs(h)<f;if(i){if(j){return float2(0.,-1.);}float k=1./h;float l=sign"
"(h);float m=c/h;float2 n=(e-a)*k;float o=length(n)*l-m;return float2(o,1.);"
"}else if(j){float3x3 k=$u(a,b);float l=c/g;float m=l*l;float2 n=(k*float3(e"
",1.)).xy;float o=m-n.y*n.y;if(o<0.){return float2(0.,-1.);}o=n.x+sqrt(o);return"
" float2(o,1.);}else{float k=c/(c-d);bool l=abs(k-1.)<f;if(l){float2 m=a;a=b"
";b=m;k=0.;}float2 m=a*(1.-k)+b*k;float3x3 n=$u(m,b);float o=abs(1.-k);float"
" p=o;float q=abs(d-c)/g;bool r=abs(q-1.)<f;if(r){o*=.5;p*=.5;}else{o*=q/(q*"
"q-1.);p/=sqrt(abs(q*q-1.));}n=float3x3(o,0.,0.,0.,p,0.,0.,0.,1.)*n;float2 s"
"=(n*float3(e,1.)).xy;float u=1./q;float v=sign(1.-k);bool w=!r&&q>1.;float x"
"=-1.;if(r){x=dot(s,s)/s.x;}else if(w){x=length(s)-s.x*u;}else{float y=s.x*s"
".x-s.y*s.y;if(y>=0.){if(l||v<0.){x=-sqrt(y)-s.x*u;}else{x=sqrt(y)-s.x*u;}}}"
"if(!w&&x<0.){return float2(0.,-1.);}float y=k+v*x;if(l){y=1.-y;}return float2"
"(y,1.);}}$pure half4 sk_linear_grad_4_shader(float2 a,float4[4]b,float[4]c,"
"float2 d,float2 e,int f){float2 g=$r(d,e,a);g=$o(f,g);return $p(b,c,g);}$pure"
" half4 sk_linear_grad_8_shader(float2 a,float4[8]b,float[8]c,float2 d,float2"
" e,int f){float2 g=$r(d,e,a);g=$o(f,g);return $q(b,c,g);}$pure half4 sk_radial_grad_4_shader"
"(float2 a,float4[4]b,float[4]c,float2 d,float e,int f){float2 g=$s(d,e,a);g"
"=$o(f,g);return $p(b,c,g);}$pure half4 sk_radial_grad_8_shader(float2 a,float4"
"[8]b,float[8]c,float2 d,float e,int f){float2 g=$s(d,e,a);g=$o(f,g);return $q"
"(b,c,g);}$pure half4 sk_sweep_grad_4_shader(float2 a,float4[4]b,float[4]c,float2"
" d,float e,float f,int g){float2 h=$t(d,e,f,a);h=$o(g,h);return $p(b,c,h);}"
"$pure half4 sk_sweep_grad_8_shader(float2 a,float4[8]b,float[8]c,float2 d,float"
" e,float f,int g){float2 h=$t(d,e,f,a);h=$o(g,h);return $q(b,c,h);}$pure half4"
" sk_conical_grad_4_shader(float2 a,float4[4]b,float[4]c,float2 d,float2 e,float"
" f,float g,int h){float2 i=$v(d,e,f,g,a);i=$o(h,i);return $p(b,c,i);}$pure half4"
" sk_conical_grad_8_shader(float2 a,float4[8]b,float[8]c,float2 d,float2 e,float"
" f,float g,int h){float2 i=$v(d,e,f,g,a);i=$o(h,i);return $q(b,c,i);}$pure half4"
" sk_matrix_colorfilter(half4 a,float4x4 b,float4 c,int d){if(bool(d)){a=$rgb_to_hsl"
"(a.xyz,a.w);}else{a=unpremul(a);}half4 e=half4(b*float4(a)+c);if(bool(d)){e"
"=$hsl_to_rgb(e.xyz,e.w);}else{e=saturate(e);e.xyz*=e.w;}return e;}$pure half4"
" sk_blend(int a,half4 b,half4 c){switch(a){case 0:{return blend_clear(b,c);"
"}case 1:{return blend_src(b,c);}case 2:{return blend_dst(b,c);}case 3:{return"
" blend_porter_duff(half4(1.,0.,0.,-1.),b,c);}case 4:{return blend_porter_duff"
"(half4(0.,1.,-1.,0.),b,c);}case 5:{return blend_porter_duff(half4(0.,0.,1.,"
"0.),b,c);}case 6:{return blend_porter_duff(half4(0.,0.,0.,1.),b,c);}case 7:"
"{return blend_porter_duff(half4(0.,0.,-1.,0.),b,c);}case 8:{return blend_porter_duff"
"(half4(0.,0.,0.,-1.),b,c);}case 9:{return blend_porter_duff(half4(0.,0.,1.,"
"-1.),b,c);}case 10:{return blend_porter_duff(half4(0.,0.,-1.,1.),b,c);}case"
" 11:{return blend_porter_duff(half4(0.,0.,-1.,-1.),b,c);}case 12:{return blend_porter_duff"
"(half4(1.,1.,0.,0.),b,c);}case 13:{return blend_modulate(b,c);}case 14:{return"
" blend_screen(b,c);}case 15:{return blend_overlay(0.,b,c);}case 16:{return blend_darken"
"(1.,b,c);}case 17:{return blend_darken(-1.,b,c);}case 18:{return blend_color_dodge"
"(b,c);}case 19:{return blend_color_burn(b,c);}case 20:{return blend_overlay"
"(1.,b,c);}case 21:{return blend_soft_light(b,c);}case 22:{return blend_difference"
"(b,c);}case 23:{return blend_exclusion(b,c);}case 24:{return blend_multiply"
"(b,c);}case 25:{return blend_hslc(half2(0.,1.),b,c);}case 26:{return blend_hslc"
"(half2(1.),b,c);}case 27:{return blend_hslc(half2(0.),b,c);}case 28:{return"
" blend_hslc(half2(1.,0.),b,c);}default:return half4(0.);}}$pure half4 sk_blend_shader"
"(int a,half4 b,half4 c){return sk_blend(a,c,b);}$pure half4 porter_duff_blend_shader"
"(half4 a,half4 b,half4 c){return blend_porter_duff(a,c,b);}$pure half4 sk_blend_colorfilter"
"(half4 a,int b,float4 c){return sk_blend(b,half4(c),a);}$pure half4 sk_table_colorfilter"
"(half4 a,sampler2D b){half4 c=(unpremul(a)*255.)/256.+.001953125;half4 d=half4"
"(sample(b,float2(half2(c.x,.375))).x,sample(b,float2(half2(c.y,.625))).x,sample"
"(b,float2(half2(c.z,.875))).x,1.);return d*sample(b,float2(half2(c.w,.125))"
").x;}$pure half4 sk_gaussian_colorfilter(half4 a){half b=1.-a.w;b=exp((-b*b"
")*4.)-.018;return half4(b);}";