• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1static constexpr char SKSL_MINIFIED_sksl_graphite_frag[] =
2"const int $kTileModeClamp=0;const int $kTileModeRepeat=1;const int $kTileModeMirror"
3"=2;const int $kTileModeDecal=3;const int $kReadSwizzleNormalRGBA=0;const int"
4" $kReadSwizzleRGB1=1;const int $kReadSwizzleRRRR=2;const int $kReadSwizzleRRR1"
5"=3;const int $kReadSwizzleBGRA=4;const int $kFilterModeNearest=0;const int $kFilterModeLinear"
6"=1;const int $kTFTypeSRGB=1;const int $kTFTypePQ=2;const int $kTFTypeHLG=3;"
7"const int $kTFTypeHLGinv=4;const int $kColorSpaceXformFlagUnpremul=1;const int"
8" $kColorSpaceXformFlagLinearize=2;const int $kColorSpaceXformFlagGamutTransform"
9"=4;const int $kColorSpaceXformFlagEncode=8;const int $kColorSpaceXformFlagPremul"
10"=16;$pure half4 sk_error(){return half4(1.,0.,1.,1.);}$pure half4 sk_passthrough"
11"(half4 color){return color;}$pure half4 sk_solid_shader(float4 colorParam){"
12"return half4(colorParam);}$pure half4 $apply_swizzle(int swizzleType,half4 color"
13"){half4 resultantColor=color;switch(swizzleType){case 0:break;case 1:resultantColor"
14"=half4(color.xyz,1.);break;case 2:resultantColor=color.xxxx;break;case 3:resultantColor"
15"=half4(color.xxx,1.);break;case 4:resultantColor=color.zyxw;break;}return resultantColor"
16";}$pure half $apply_xfer_fn(int kind,half x,half[7]cs){half G=cs[0];half A="
17"cs[1];half B=cs[2];half C=cs[3];half D=cs[4];half E=cs[5];half F=cs[6];half"
18" s=sign(x);x=abs(x);switch(kind){case 1:x=x<D?C*x+F:pow(A*x+B,G)+E;break;case"
19" 2:x=pow(max(A+B*pow(x,C),0.)/(D+E*pow(x,C)),F);break;case 3:x=x*A<=1.?pow("
20"x*A,B):exp((x-E)*C)+D;x*=F+1.;break;case 4:x/=F+1.;x=x<=1.?A*pow(x,B):C*log"
21"(x-D)+E;break;}return s*x;}$pure half4 sk_color_space_transform(half4 color"
22",int flags,int srcKind,int dstKind,half[7]srcCoeffs,half[7]dstCoeffs,half3x3"
23" gamutTransform){if(bool(flags&$kColorSpaceXformFlagUnpremul)){color=unpremul"
24"(color);}if(bool(flags&$kColorSpaceXformFlagLinearize)){color.x=$apply_xfer_fn"
25"(srcKind,color.x,srcCoeffs);color.y=$apply_xfer_fn(srcKind,color.y,srcCoeffs"
26");color.z=$apply_xfer_fn(srcKind,color.z,srcCoeffs);}if(bool(flags&$kColorSpaceXformFlagGamutTransform"
27")){color.xyz=gamutTransform*color.xyz;}if(bool(flags&$kColorSpaceXformFlagEncode"
28")){color.x=$apply_xfer_fn(dstKind,color.x,dstCoeffs);color.y=$apply_xfer_fn"
29"(dstKind,color.y,dstCoeffs);color.z=$apply_xfer_fn(dstKind,color.z,dstCoeffs"
30");}if(bool(flags&$kColorSpaceXformFlagPremul)){color.xyz*=color.w;}return color"
31";}$pure float $tile(int tileMode,float f,float low,float high){switch(tileMode"
32"){case 0:return clamp(f,low,high);case 1:{float length=high-low;return mod("
33"f-low,length)+low;}case 2:{float length=high-low;float length2=2.*length;float"
34" tmp=mod(f-low,length2);return mix(tmp,length2-tmp,step(length,tmp))+low;}default"
35":return f;}}$pure half4 $sample_image(float2 pos,float2 imgSize,float4 subset"
36",int tileModeX,int tileModeY,int filterMode,int readSwizzle,sampler2D s){if"
37"(tileModeX==$kTileModeDecal&&filterMode==$kFilterModeNearest){float snappedX"
38"=floor(pos.x)+.5;if(snappedX<subset.x||snappedX>subset.z){return half4(0.);"
39"}}if(tileModeY==$kTileModeDecal&&filterMode==$kFilterModeNearest){float snappedY"
40"=floor(pos.y)+.5;if(snappedY<subset.y||snappedY>subset.w){return half4(0.);"
41"}}pos.x=$tile(tileModeX,pos.x,subset.x,subset.z);pos.y=$tile(tileModeY,pos."
42"y,subset.y,subset.w);float4 insetClamp;if(filterMode==$kFilterModeNearest){"
43"insetClamp=float4(floor(subset.xy)+.5,ceil(subset.zw)-.5);}else{insetClamp="
44"float4(subset.xy+.5,subset.zw-.5);}float2 clampedPos=clamp(pos,insetClamp.xy"
45",insetClamp.zw);half4 color=sample(s,clampedPos/imgSize);color=$apply_swizzle"
46"(readSwizzle,color);if(filterMode==$kFilterModeLinear){half2 error=half2(pos"
47"-clampedPos);half2 absError=abs(error);bool sampleExtraX=tileModeX==$kTileModeRepeat"
48";bool sampleExtraY=tileModeY==$kTileModeRepeat;if(sampleExtraX||sampleExtraY"
49"){float extraCoordX;float extraCoordY;half4 extraColorX;half4 extraColorY;if"
50"(sampleExtraX){extraCoordX=error.x>0.?insetClamp.x:insetClamp.z;extraColorX"
51"=sample(s,float2(extraCoordX,clampedPos.y)/imgSize);extraColorX=$apply_swizzle"
52"(readSwizzle,extraColorX);}if(sampleExtraY){extraCoordY=error.y>0.?insetClamp"
53".y:insetClamp.w;extraColorY=sample(s,float2(clampedPos.x,extraCoordY)/imgSize"
54");extraColorY=$apply_swizzle(readSwizzle,extraColorY);}if(sampleExtraX&&sampleExtraY"
55"){half4 extraColorXY=sample(s,float2(extraCoordX,extraCoordY)/imgSize);extraColorXY"
56"=$apply_swizzle(readSwizzle,extraColorXY);color=mix(mix(color,extraColorX,absError"
57".x),mix(extraColorY,extraColorXY,absError.x),absError.y);}else if(sampleExtraX"
58"){color=mix(color,extraColorX,absError.x);}else if(sampleExtraY){color=mix("
59"color,extraColorY,absError.y);}}if(tileModeX==$kTileModeDecal){color*=max(1."
60"-absError.x,0.);}if(tileModeY==$kTileModeDecal){color*=max(1.-absError.y,0."
61");}}return color;}$pure half4 $cubic_filter_image(float2 pos,float2 imgSize"
62",float4 subset,int tileModeX,int tileModeY,float4x4 coeffs,int readSwizzle,"
63"sampler2D s){float2 f=fract(pos-.5);pos-=1.5;pos=floor(pos)+.5;float4 wx=coeffs"
64"*float4(1.,f.x,f.x*f.x,(f.x*f.x)*f.x);float4 wy=coeffs*float4(1.,f.y,f.y*f."
65"y,(f.y*f.y)*f.y);float4 color=float4(0.);for(int y=0;y<4;++y){float4 rowColor"
66"=float4(0.);for(int x=0;x<4;++x){rowColor+=wx[x]*float4($sample_image(pos+float2"
67"(float(x),float(y)),imgSize,subset,tileModeX,tileModeY,$kFilterModeNearest,"
68"readSwizzle,s));}color+=wy[y]*rowColor;}return half4(color);}$pure half4 sk_image_shader"
69"(float2 coords,float2 imgSize,float4 subset,int tileModeX,int tileModeY,int"
70" filterMode,int useCubic,float4x4 cubicCoeffs,int readSwizzle,int csXformFlags"
71",int csXformSrcKind,int csXformDstKind,half[7]csXformSrcCoeffs,half[7]csXformDstCoeffs"
72",half3x3 csXformGamutTransform,sampler2D s){half4 sampleColor=useCubic!=0?$cubic_filter_image"
73"(coords,imgSize,subset,tileModeX,tileModeY,cubicCoeffs,readSwizzle,s):$sample_image"
74"(coords,imgSize,subset,tileModeX,tileModeY,filterMode,readSwizzle,s);return"
75" sk_color_space_transform(sampleColor,csXformFlags,csXformSrcKind,csXformDstKind"
76",csXformSrcCoeffs,csXformDstCoeffs,csXformGamutTransform);}$pure float2 $tile_grad"
77"(int tileMode,float2 t){switch(tileMode){case 0:t.x=clamp(t.x,0.,1.);break;"
78"case 1:t.x=fract(t.x);break;case 2:{float t_1=t.x-1.;t.x=(t_1-2.*floor(t_1*"
79".5))-1.;if(sk_Caps.mustDoOpBetweenFloorAndAbs){t.x=clamp(t.x,-1.,1.);}t.x=abs"
80"(t.x);break;}case 3:if(t.x<0.||t.x>1.){return float2(0.,-1.);}break;}return"
81" t;}$pure half4 $colorize_grad_4(float4[4]colorsParam,float[4]offsetsParam,"
82"float2 t){if(t.y<0.){return half4(0.);}else if(t.x<=offsetsParam[0]){return"
83" half4(colorsParam[0]);}else if(t.x<offsetsParam[1]){return half4(mix(colorsParam"
84"[0],colorsParam[1],(t.x-offsetsParam[0])/(offsetsParam[1]-offsetsParam[0]))"
85");}else if(t.x<offsetsParam[2]){return half4(mix(colorsParam[1],colorsParam"
86"[2],(t.x-offsetsParam[1])/(offsetsParam[2]-offsetsParam[1])));}else if(t.x<"
87"offsetsParam[3]){return half4(mix(colorsParam[2],colorsParam[3],(t.x-offsetsParam"
88"[2])/(offsetsParam[3]-offsetsParam[2])));}else{return half4(colorsParam[3])"
89";}}$pure half4 $colorize_grad_8(float4[8]colorsParam,float[8]offsetsParam,float2"
90" t){if(t.y<0.){return half4(0.);}else if(t.x<offsetsParam[4]){if(t.x<offsetsParam"
91"[2]){if(t.x<=offsetsParam[0]){return half4(colorsParam[0]);}else if(t.x<offsetsParam"
92"[1]){return half4(mix(colorsParam[0],colorsParam[1],(t.x-offsetsParam[0])/("
93"offsetsParam[1]-offsetsParam[0])));}else{return half4(mix(colorsParam[1],colorsParam"
94"[2],(t.x-offsetsParam[1])/(offsetsParam[2]-offsetsParam[1])));}}else{if(t.x"
95"<offsetsParam[3]){return half4(mix(colorsParam[2],colorsParam[3],(t.x-offsetsParam"
96"[2])/(offsetsParam[3]-offsetsParam[2])));}else{return half4(mix(colorsParam"
97"[3],colorsParam[4],(t.x-offsetsParam[3])/(offsetsParam[4]-offsetsParam[3]))"
98");}}}else{if(t.x<offsetsParam[6]){if(t.x<offsetsParam[5]){return half4(mix("
99"colorsParam[4],colorsParam[5],(t.x-offsetsParam[4])/(offsetsParam[5]-offsetsParam"
100"[4])));}else{return half4(mix(colorsParam[5],colorsParam[6],(t.x-offsetsParam"
101"[5])/(offsetsParam[6]-offsetsParam[5])));}}else{if(t.x<offsetsParam[7]){return"
102" half4(mix(colorsParam[6],colorsParam[7],(t.x-offsetsParam[6])/(offsetsParam"
103"[7]-offsetsParam[6])));}else{return half4(colorsParam[7]);}}}}$pure float2 $linear_grad_layout"
104"(float2 point0Param,float2 point1Param,float2 pos){pos-=point0Param;float2 delta"
105"=point1Param-point0Param;float t=dot(pos,delta)/dot(delta,delta);return float2"
106"(t,1.);}$pure float2 $radial_grad_layout(float2 centerParam,float radiusParam"
107",float2 pos){float t=distance(pos,centerParam)/radiusParam;return float2(t,"
108"1.);}$pure float2 $sweep_grad_layout(float2 centerParam,float biasParam,float"
109" scaleParam,float2 pos){pos-=centerParam;float angle=sk_Caps.atan2ImplementedAsAtanYOverX"
110"?2.*atan(-pos.y,length(pos)-pos.x):atan(-pos.y,-pos.x);float t=((angle*.159154937"
111"+.5)+biasParam)*scaleParam;return float2(t,1.);}$pure float3x3 $map_to_unit_x"
112"(float2 p0,float2 p1){return float3x3(0.,-1.,0.,1.,0.,0.,0.,0.,1.)*inverse("
113"float3x3(p1.y-p0.y,p0.x-p1.x,0.,p1.x-p0.x,p1.y-p0.y,0.,p0.x,p0.y,1.));}$pure"
114" float2 $conical_grad_layout(float2 point0Param,float2 point1Param,float radius0Param"
115",float radius1Param,float2 pos){const float SK_ScalarNearlyZero=.000244140625"
116";float dCenter=distance(point0Param,point1Param);float dRadius=radius1Param"
117"-radius0Param;bool radial=dCenter<SK_ScalarNearlyZero;bool strip=abs(dRadius"
118")<SK_ScalarNearlyZero;if(radial){if(strip){return float2(0.,-1.);}float scale"
119"=1./dRadius;float scaleSign=sign(dRadius);float bias=radius0Param/dRadius;float2"
120" pt=(pos-point0Param)*scale;float t=length(pt)*scaleSign-bias;return float2"
121"(t,1.);}else if(strip){float3x3 transform=$map_to_unit_x(point0Param,point1Param"
122");float r=radius0Param/dCenter;float r_2=r*r;float2 pt=(transform*float3(pos"
123",1.)).xy;float t=r_2-pt.y*pt.y;if(t<0.){return float2(0.,-1.);}t=pt.x+sqrt("
124"t);return float2(t,1.);}else{float f=radius0Param/(radius0Param-radius1Param"
125");bool isSwapped=abs(f-1.)<SK_ScalarNearlyZero;if(isSwapped){float2 tmpPt=point0Param"
126";point0Param=point1Param;point1Param=tmpPt;f=0.;}float2 Cf=point0Param*(1.-"
127"f)+point1Param*f;float3x3 transform=$map_to_unit_x(Cf,point1Param);float scaleX"
128"=abs(1.-f);float scaleY=scaleX;float r1=abs(radius1Param-radius0Param)/dCenter"
129";bool isFocalOnCircle=abs(r1-1.)<SK_ScalarNearlyZero;if(isFocalOnCircle){scaleX"
130"*=.5;scaleY*=.5;}else{scaleX*=r1/(r1*r1-1.);scaleY/=sqrt(abs(r1*r1-1.));}transform"
131"=float3x3(scaleX,0.,0.,0.,scaleY,0.,0.,0.,1.)*transform;float2 pt=(transform"
132"*float3(pos,1.)).xy;float invR1=1./r1;float dRadiusSign=sign(1.-f);bool isWellBehaved"
133"=!isFocalOnCircle&&r1>1.;float x_t=-1.;if(isFocalOnCircle){x_t=dot(pt,pt)/pt"
134".x;}else if(isWellBehaved){x_t=length(pt)-pt.x*invR1;}else{float temp=pt.x*"
135"pt.x-pt.y*pt.y;if(temp>=0.){if(isSwapped||dRadiusSign<0.){x_t=-sqrt(temp)-pt"
136".x*invR1;}else{x_t=sqrt(temp)-pt.x*invR1;}}}if(!isWellBehaved&&x_t<0.){return"
137" float2(0.,-1.);}float t=f+dRadiusSign*x_t;if(isSwapped){t=1.-t;}return float2"
138"(t,1.);}}$pure half4 sk_linear_grad_4_shader(float2 coords,float4[4]colorsParam"
139",float[4]offsetsParam,float2 point0Param,float2 point1Param,int tileMode,int"
140" colorSpace,int doUnpremul){float2 t=$linear_grad_layout(point0Param,point1Param"
141",coords);t=$tile_grad(tileMode,t);half4 color=$colorize_grad_4(colorsParam,"
142"offsetsParam,t);return $interpolated_to_rgb_unpremul(color,colorSpace,doUnpremul"
143");}$pure half4 sk_linear_grad_8_shader(float2 coords,float4[8]colorsParam,float"
144"[8]offsetsParam,float2 point0Param,float2 point1Param,int tileMode,int colorSpace"
145",int doUnpremul){float2 t=$linear_grad_layout(point0Param,point1Param,coords"
146");t=$tile_grad(tileMode,t);half4 color=$colorize_grad_8(colorsParam,offsetsParam"
147",t);return $interpolated_to_rgb_unpremul(color,colorSpace,doUnpremul);}$pure"
148" half4 sk_radial_grad_4_shader(float2 coords,float4[4]colorsParam,float[4]offsetsParam"
149",float2 centerParam,float radiusParam,int tileMode,int colorSpace,int doUnpremul"
150"){float2 t=$radial_grad_layout(centerParam,radiusParam,coords);t=$tile_grad"
151"(tileMode,t);half4 color=$colorize_grad_4(colorsParam,offsetsParam,t);return"
152" $interpolated_to_rgb_unpremul(color,colorSpace,doUnpremul);}$pure half4 sk_radial_grad_8_shader"
153"(float2 coords,float4[8]colorsParam,float[8]offsetsParam,float2 centerParam"
154",float radiusParam,int tileMode,int colorSpace,int doUnpremul){float2 t=$radial_grad_layout"
155"(centerParam,radiusParam,coords);t=$tile_grad(tileMode,t);half4 color=$colorize_grad_8"
156"(colorsParam,offsetsParam,t);return $interpolated_to_rgb_unpremul(color,colorSpace"
157",doUnpremul);}$pure half4 sk_sweep_grad_4_shader(float2 coords,float4[4]colorsParam"
158",float[4]offsetsParam,float2 centerParam,float biasParam,float scaleParam,int"
159" tileMode,int colorSpace,int doUnpremul){float2 t=$sweep_grad_layout(centerParam"
160",biasParam,scaleParam,coords);t=$tile_grad(tileMode,t);half4 color=$colorize_grad_4"
161"(colorsParam,offsetsParam,t);return $interpolated_to_rgb_unpremul(color,colorSpace"
162",doUnpremul);}$pure half4 sk_sweep_grad_8_shader(float2 coords,float4[8]colorsParam"
163",float[8]offsetsParam,float2 centerParam,float biasParam,float scaleParam,int"
164" tileMode,int colorSpace,int doUnpremul){float2 t=$sweep_grad_layout(centerParam"
165",biasParam,scaleParam,coords);t=$tile_grad(tileMode,t);half4 color=$colorize_grad_8"
166"(colorsParam,offsetsParam,t);return $interpolated_to_rgb_unpremul(color,colorSpace"
167",doUnpremul);}$pure half4 sk_conical_grad_4_shader(float2 coords,float4[4]colorsParam"
168",float[4]offsetsParam,float2 point0Param,float2 point1Param,float radius0Param"
169",float radius1Param,int tileMode,int colorSpace,int doUnpremul){float2 t=$conical_grad_layout"
170"(point0Param,point1Param,radius0Param,radius1Param,coords);t=$tile_grad(tileMode"
171",t);half4 color=$colorize_grad_4(colorsParam,offsetsParam,t);return $interpolated_to_rgb_unpremul"
172"(color,colorSpace,doUnpremul);}$pure half4 sk_conical_grad_8_shader(float2 coords"
173",float4[8]colorsParam,float[8]offsetsParam,float2 point0Param,float2 point1Param"
174",float radius0Param,float radius1Param,int tileMode,int colorSpace,int doUnpremul"
175"){float2 t=$conical_grad_layout(point0Param,point1Param,radius0Param,radius1Param"
176",coords);t=$tile_grad(tileMode,t);half4 color=$colorize_grad_8(colorsParam,"
177"offsetsParam,t);return $interpolated_to_rgb_unpremul(color,colorSpace,doUnpremul"
178");}$pure half4 sk_matrix_colorfilter(half4 colorIn,float4x4 m,float4 v,int inHSLA"
179"){if(bool(inHSLA)){colorIn=$rgb_to_hsl(colorIn.xyz,colorIn.w);}else{colorIn"
180"=unpremul(colorIn);}half4 colorOut=half4(m*float4(colorIn)+v);if(bool(inHSLA"
181")){colorOut=$hsl_to_rgb(colorOut.xyz,colorOut.w);}else{colorOut=saturate(colorOut"
182");colorOut.xyz*=colorOut.w;}return colorOut;}$pure half4 sk_blend(int blendMode"
183",half4 src,half4 dst){const int kClear=0;const int kSrc=1;const int kDst=2;"
184"const int kSrcOver=3;const int kDstOver=4;const int kSrcIn=5;const int kDstIn"
185"=6;const int kSrcOut=7;const int kDstOut=8;const int kSrcATop=9;const int kDstATop"
186"=10;const int kXor=11;const int kPlus=12;const int kModulate=13;const int kScreen"
187"=14;const int kOverlay=15;const int kDarken=16;const int kLighten=17;const int"
188" kColorDodge=18;const int kColorBurn=19;const int kHardLight=20;const int kSoftLight"
189"=21;const int kDifference=22;const int kExclusion=23;const int kMultiply=24"
190";const int kHue=25;const int kSaturation=26;const int kColor=27;const int kLuminosity"
191"=28;switch(blendMode){case 0:{return blend_clear(src,dst);}case 1:{return blend_src"
192"(src,dst);}case 2:{return blend_dst(src,dst);}case 3:{return blend_porter_duff"
193"(half4(1.,0.,0.,-1.),src,dst);}case 4:{return blend_porter_duff(half4(0.,1."
194",-1.,0.),src,dst);}case 5:{return blend_porter_duff(half4(0.,0.,1.,0.),src,"
195"dst);}case 6:{return blend_porter_duff(half4(0.,0.,0.,1.),src,dst);}case 7:"
196"{return blend_porter_duff(half4(0.,0.,-1.,0.),src,dst);}case 8:{return blend_porter_duff"
197"(half4(0.,0.,0.,-1.),src,dst);}case 9:{return blend_porter_duff(half4(0.,0."
198",1.,-1.),src,dst);}case 10:{return blend_porter_duff(half4(0.,0.,-1.,1.),src"
199",dst);}case 11:{return blend_porter_duff(half4(0.,0.,-1.,-1.),src,dst);}case"
200" 12:{return blend_porter_duff(half4(1.,1.,0.,0.),src,dst);}case 13:{return blend_modulate"
201"(src,dst);}case 14:{return blend_screen(src,dst);}case 15:{return blend_overlay"
202"(0.,src,dst);}case 16:{return blend_darken(1.,src,dst);}case 17:{return blend_darken"
203"(-1.,src,dst);}case 18:{return blend_color_dodge(src,dst);}case 19:{return blend_color_burn"
204"(src,dst);}case 20:{return blend_overlay(1.,src,dst);}case 21:{return blend_soft_light"
205"(src,dst);}case 22:{return blend_difference(src,dst);}case 23:{return blend_exclusion"
206"(src,dst);}case 24:{return blend_multiply(src,dst);}case 25:{return blend_hslc"
207"(half2(0.,1.),src,dst);}case 26:{return blend_hslc(half2(1.),src,dst);}case"
208" 27:{return blend_hslc(half2(0.),src,dst);}case 28:{return blend_hslc(half2"
209"(1.,0.),src,dst);}default:return half4(0.);}}$pure half4 sk_blend_shader(int"
210" blendMode,half4 dst,half4 src){return sk_blend(blendMode,src,dst);}$pure half4"
211" porter_duff_blend_shader(half4 blendOp,half4 dst,half4 src){return blend_porter_duff"
212"(blendOp,src,dst);}$pure half4 sk_blend_colorfilter(half4 dstColor,int blendMode"
213",float4 srcColor){return sk_blend(blendMode,half4(srcColor),dstColor);}$pure"
214" half4 sk_table_colorfilter(half4 inColor,sampler2D s){half4 coords=(unpremul"
215"(inColor)*255.)*.00390625+.001953125;half4 color=half4(sample(s,float2(half2"
216"(coords.x,.375))).x,sample(s,float2(half2(coords.y,.625))).x,sample(s,float2"
217"(half2(coords.z,.875))).x,1.);return color*sample(s,float2(half2(coords.w,.125"
218"))).x;}$pure half4 sk_gaussian_colorfilter(half4 inColor){half factor=1.-inColor"
219".w;factor=exp((-factor*factor)*4.)-.018;return half4(factor);}$pure float2 coverage_scale_and_bias"
220"(float minDim){float width=min(1.,minDim);return float2(width,1.-.5*width);"
221"}$pure float inverse_grad_len(float2 localGrad,float2x2 jacobian){float2 devGrad"
222"=localGrad*jacobian;return inversesqrt(dot(devGrad,devGrad));}$pure float2 elliptical_distance"
223"(float2 uv,float2 radii,float strokeRadius,float2x2 jacobian){float2 invR2="
224"1./(radii*radii+strokeRadius*strokeRadius);float2 normUV=invR2*uv;float invGradLength"
225"=inverse_grad_len(normUV,jacobian);float f=(.5*invGradLength)*(dot(uv,normUV"
226")-1.);float width=((radii.x*strokeRadius)*invR2.x)*invGradLength;return float2"
227"(width-f,width+f);}void corner_distance(inout float2 dist,float2x2 jacobian"
228",float2 strokeParams,float2 cornerEdgeDist,float2 xyFlip,float2 radii){float2"
229" uv=radii-cornerEdgeDist;if(uv.x>0.&&uv.y>0.){if(radii.x>0.&&radii.y>0.||strokeParams"
230".x>0.&&strokeParams.y<0.){float2 d=elliptical_distance(uv*xyFlip,radii,strokeParams"
231".x,jacobian);if(radii.x-strokeParams.x<=0.){d.y=1.;}else{d.y*=-1.;}dist=min"
232"(dist,d);}else if(strokeParams.y==0.){float bevelDist=((strokeParams.x-uv.x"
233")-uv.y)*inverse_grad_len(xyFlip,jacobian);dist.x=min(dist.x,bevelDist);}}}void"
234" corner_distances(inout float2 d,float2x2 J,float2 stroke,float4 edgeDists,"
235"float4 xRadii,float4 yRadii){corner_distance(d,J,stroke,edgeDists.xy,float2"
236"(-1.),float2(xRadii.x,yRadii.x));corner_distance(d,J,stroke,edgeDists.zy,float2"
237"(1.,-1.),float2(xRadii.y,yRadii.y));corner_distance(d,J,stroke,edgeDists.zw"
238",float2(1.),float2(xRadii.z,yRadii.z));corner_distance(d,J,stroke,edgeDists"
239".xw,float2(-1.,1.),float2(xRadii.w,yRadii.w));}";
240