blob: d240fff971d51e0c23c30a74ab7930acb09aa99e [file] [log] [blame]
static constexpr char SKSL_MINIFIED_sksl_graphite_vert[] =
"$pure float $k(float2 a,float2 b,float2 c,float2 d,float2x2 e){float2 f=e*("
"fma(float2(-2.),b,c)+a);float2 g=e*(fma(float2(-2.),c,d)+b);return max(dot("
"f,f),dot(g,g));}$pure float $l(float2 a,float2 b,float2 c,float2 d,float2x2"
" e){float f=$k(a,b,c,d,e);return max(ceil(sqrt(3.*sqrt(f))),1.);}$pure float"
" $m(float2 a,float2 b,float2 c,float2 d,float2x2 e){float f=$k(a,b,c,d,e);return"
" ceil(log2(max(9.*f,1.))*.25);}$pure float $n(float2 a,float2 b,float2 c,float"
" d){float2 e=(min(min(a,b),c)+max(max(a,b),c))*.5;a-=e;b-=e;c-=e;float f=sqrt"
"(max(max(dot(a,a),dot(b,b)),dot(c,c)));float2 g=fma(float2(-2.*d),b,a)+c;float"
" h=abs(fma(-2.,d,2.));float i=max(0.,fma(f,4.,-1.));float j=length(g)*4.+i*"
"h;float k=4.*min(d,1.);return j/k;}$pure float $o(float2 a,float2 b,float2 c"
",float d){float e=$n(a,b,c,d);return max(ceil(sqrt(e)),1.);}$pure float $p("
"float2 a,float2 b,float2 c,float d){float e=$n(a,b,c,d);return ceil(log2(max"
"(e,1.))*.5);}$pure float2 $q(float2 c,float2 d){float2 e=c-d;if(e==float2(0."
")){return float2(0.);}else{float f=1./max(abs(e.x),abs(e.y));return normalize"
"(f*e);}}$pure float $r(float2 c,float2 d){return clamp(dot(c,d),-1.,1.);}$pure"
" float $s(float a,float b){float c=fma(a,.5,.5);return(c*b)*b>=1.?inversesqrt"
"(c):sqrt(c);}$pure float $t(float a){return.5/acos(max(1.-.25/a,-1.));}$pure"
" float $u(float c,float d,float e){return fma(d-c,e,c);}$pure float2 $u(float2"
" c,float2 d,float e){return fma(d-c,float2(e),c);}$pure float4 $u(float4 c,"
"float4 d,float4 e){return fma(d-c,e,c);}$pure float2 tessellate_filled_curve"
"(float2x2 a,float b,float c,float4 d,float4 e){float2 f;if(isinf(e.z)){f=b!="
"0.?d.zw:(c!=0.?e.xy:d.xy);}else{float2 g=d.xy;float2 h=d.zw;float2 i=e.xy;float2"
" j=e.zw;float k=-1.;float l;if(isinf(e.w)){k=j.x;l=$p(a*g,a*h,a*i,k);h*=k;j"
"=i;}else{l=$m(g,h,i,j,a);}if(b>l){c=floor(ldexp(c,int(l-b)));b=l;}float m=floor"
"(.5+ldexp(c,int(5.-b)));if(0.<m&&m<32.){float n=m*.03125;float2 o=mix(g,h,n"
");float2 p=mix(h,i,n);float2 q=mix(i,j,n);float2 r=mix(o,p,n);float2 s=mix("
"p,q,n);float2 t=mix(r,s,n);float x=mix(1.,k,n);float y=(k+1.)-x;float z=mix"
"(x,y,n);f=k<0.?t:r/z;}else{f=m==0.?g:j;}}return f;}$pure float4 tessellate_stroked_curve"
"(float a,float b,float2x2 c,float2 d,float e,float4 f,float4 g,float2 h,float2"
" i){float2 j=f.xy;float2 k=f.zw;float2 l=g.xy;float2 m=g.zw;float n=-1.;if("
"isinf(g.w)){n=m.x;m=l;}float o;if(n<0.){if(j==k&&l==m){o=1.;}else{o=$l(j,k,"
"l,m,c);}}else{o=$o(c*j,c*k,c*l,n);}float p=i.x;float q=i.y;bool r=i.x==0.;float"
" s;if(r){s=$t(1.);p=.5;}else{s=$t(e*i.x);}if(r){j=c*j;k=c*k;l=c*l;m=c*m;h=c"
"*h;}float2 t=$q(j==k?(k==l?m:l):k,j);float2 u=$q(m,m==l?(l==k?j:k):l);if(t=="
"float2(0.)){t=float2(1.,0.);u=float2(-1.,0.);}float v;if(q>=0.){v=(sign(q)+"
"1.)+2.;}else{float2 x=$q(j,h);float y=acos($r(x,t));float z=max(ceil(y*s),1."
");v=z+2.;v=min(v,b-2.);}float x=cross_length_2d(l-j,m-k);float y=abs(a)-v;if"
"(y<0.){u=t;if(h!=j){t=$q(j,h);}x=cross_length_2d(t,u);}float z=$r(t,u);float"
" A=acos(z);if(x<0.){A=-A;}float B;float C=sign(a);if(y<0.){B=v-2.;o=1.;m=(l"
"=(k=j));y+=B+1.;float D=.01;bool E=abs(x)*inversesqrt(dot(t,t)*dot(u,u))<D;"
"if(!E||dot(t,u)<0.){if(y>=0.){C=x<0.?min(C,0.):max(C,0.);}}y=max(y,0.);}else"
"{float D=(b-v)-1.;B=max(ceil(abs(A)*s),1.);B=min(B,D);o=min(o,(D-B)+1.);}float"
" D=A/B;float E=(o+B)-1.;bool F=y>=E;if(y>E){C=0.;}if(abs(a)==2.&&q>0.){C*=$s"
"(z,q);}float2 G;float2 H;if(y!=0.&&!F){float2 I;float2 J;float2 K=k-j;float2"
" L=m-j;if(n>=0.){K*=n;J=.5*L-K;I=(n-1.)*L;k*=n;}else{float2 M=l-k;J=M-K;I=fma"
"(float2(-3.),M,L);}float2 M=J*(o*2.);float2 N=K*(o*o);float O=0.;float P=min"
"(o-1.,y);float Q=-abs(D);float R=(1.+y)*abs(D);for(int S=4;S>=0;--S){float U"
"=O+exp2(float(S));if(U<=P){float2 V=fma(float2(U),I,M);V=fma(float2(U),V,N)"
";float W=dot(normalize(V),t);float X=fma(U,Q,R);X=min(X,3.14159274);if(W>=cos"
"(X)){O=U;}}}float S=O/o;float U=y-O;float V=acos(clamp(t.x,-1.,1.));V=t.y>="
"0.?V:-V;float W=fma(U,D,V);G=float2(cos(W),sin(W));float2 X=float2(-G.y,G.x"
");float Y=dot(X,I);float Z=dot(X,J);float aa=dot(X,K);float ac=max(Z*Z-Y*aa"
",0.);float ad=sqrt(ac);if(Z>0.){ad=-ad;}ad-=Z;float ae=(-.5*ad)*Y;float2 af"
"=abs(fma(ad,ad,ae))<abs(fma(Y,aa,ae))?float2(ad,Y):float2(aa,ad);float ag=af"
".y!=0.?af.x/af.y:0.;ag=clamp(ag,0.,1.);if(U==0.){ag=0.;}float ah=max(S,ag);"
"float2 ai=$u(j,k,ah);float2 aj=$u(k,l,ah);float2 ak=$u(l,m,ah);float2 al=$u"
"(ai,aj,ah);float2 am=$u(aj,ak,ah);float2 an=$u(al,am,ah);float ao=$u(1.,n,ah"
");float ap=(n+1.)-ao;float aq=$u(ao,ap,ah);if(ah!=ag){G=n>=0.?$q(aj*ao,ai*ap"
"):$q(am,al);}H=n>=0.?al/aq:an;}else{G=y==0.?t:u;H=y==0.?j:m;}float2 I=float2"
"(G.y,-G.x);H+=I*(p*C);if(r){return float4(H+d,inverse(c)*H);}else{return float4"
"(c*H+d,H);}}float2 ortho(float2 a){return float2(-a.y,a.x);}float3 calc_line_eq"
"(float2 a,float2 b){float2 c=ortho(a);return float3(c,-dot(c,b));}";