Debian Codegraph @

src/sksl/generated/sksl_graphite_frag.unoptimized.sksl

raw
1 static constexpr char SKSL_MINIFIED_sksl_graphite_frag[] =
2 "const int $kTileModeClamp=0;const int $kTileModeRepeat=1;const int $kTileModeDecal"
3 "=3;const int $kFilterModeNearest=0;const int $kFilterModeLinear=1;const int"
4 " $kMaskFormatA8=0;const float $kLinearInset=.50001;$pure half4 sk_error(){return"
5 " half4(1.,0.,0.,1.);}$pure half4 sk_passthrough(half4 color){return color;}"
6 "$pure half4 sk_rgb_opaque(float4 colorParam){return half4(half3(colorParam."
7 "xyz),1.);}$pure half4 sk_alpha_only(float4 colorParam){return half4(0.,0.,0."
8 ",half(colorParam.w));}$pure float3 $apply_srgb_xfer_fn(float3 x,float4 gabc"
9 ",float3 def){return mix(pow(gabc.y*x+gabc.z,gabc.x.xxx)+def.y,gabc.w*x+def."
10 "z,lessThan(x,def.x.xxx));}$pure float3 $apply_pq_xfer_fn(float3 x,float3 abc"
11 ",float3 def){float3 x_C=pow(x,abc.z.xxx);return pow(max(abc.x+abc.y*x_C,0.)"
12 "/(def.x+def.y*x_C),def.z.xxx);}$pure float3 $apply_hlg_xfer_fn(float3 x,float3"
13 " abc,float3 def){return(def.z+1.)*mix(exp((x-def.y)*abc.z)+def.x,pow(x*abc."
14 "x,abc.y.xxx),lessThanEqual(x*abc.x,1..xxx));}$pure float3 $apply_hlg_inv_xfer_fn"
15 "(float3 x,float3 abc,float3 def){x/=def.z+1.;return mix(abc.z*log(x-def.x)+"
16 "def.y,abc.x*pow(x,abc.y.xxx),lessThanEqual(x,1..xxx));}$pure half4 sk_color_space_transform"
17 "(half4 color,half3x3 gamut,float4 srcGABC,float4 srcDEF_args,float4 dstGABC"
18 ",float4 dstDEF_args,float4 srcOOTF_args,float4 dstOOTF_args){if(srcDEF_args"
19 ".w<0.)color=unpremul(color);else{half alphaSwizzleA=1.-half(srcDEF_args.w);"
20 "half alphaSwizzle1=half(srcDEF_args.w)*half(dstDEF_args.w);half alphaSwizzleR"
21 "=half(srcDEF_args.w)-alphaSwizzle1;color.w=dot(half3(color.wx,1.),half3(alphaSwizzleA"
22 ",alphaSwizzleR,alphaSwizzle1));}float3 colorF=float3(color.xyz);if(srcGABC."
23 "x>0.)colorF=sign(colorF)*$apply_srgb_xfer_fn(abs(colorF),srcGABC,srcDEF_args"
24 ".xyz);else if(srcGABC.x<-1.)colorF=sign(colorF)*$apply_pq_xfer_fn(abs(colorF"
25 "),srcGABC.yzw,srcDEF_args.xyz);else if(srcGABC.x<0.)colorF=sign(colorF)*$apply_hlg_xfer_fn"
26 "(abs(colorF),srcGABC.yzw,srcDEF_args.xyz);if(srcOOTF_args.w!=0.){float Y=dot"
27 "(srcOOTF_args.xyz,colorF);colorF*=sign(Y)*pow(abs(Y),srcOOTF_args.w);}colorF"
28 "=float3x3(gamut)*colorF;if(dstOOTF_args.w!=0.){float Y=dot(dstOOTF_args.xyz"
29 ",colorF);colorF*=sign(Y)*pow(abs(Y),dstOOTF_args.w);}if(dstGABC.x>0.)colorF"
30 "=sign(colorF)*$apply_srgb_xfer_fn(abs(colorF),dstGABC,dstDEF_args.xyz);else"
31 " if(dstGABC.x<-1.)colorF=sign(colorF)*$apply_pq_xfer_fn(abs(colorF),dstGABC"
32 ".yzw,dstDEF_args.xyz);else if(dstGABC.x<0.)colorF=sign(colorF)*$apply_hlg_inv_xfer_fn"
33 "(abs(colorF),dstGABC.yzw,dstDEF_args.xyz);half noPremul=half(dstDEF_args.w)"
34 ";color.xyz=half3(colorF)*max(color.w,noPremul);return color;}$pure half4 sk_color_space_transform_premul"
35 "(half4 color,half2 args){if(args.x<0.)color=unpremul(color);else{half opaque"
36 "=args.x;half noPremul=args.y;color.w=max(color.w,opaque);color.xyz=color.xyz"
37 "*max(color.w,noPremul);}return color;}$pure half4 sk_color_space_transform_srgb"
38 "(half4 color,half3x3 gamut,float4 srcGABC,float4 srcDEF_args,float4 dstGABC"
39 ",float4 dstDEF_args){if(srcDEF_args.w<0.)color=unpremul(color);else{half alphaSwizzleA"
40 "=1.-half(srcDEF_args.w);half alphaSwizzle1=half(srcDEF_args.w)*half(dstDEF_args"
41 ".w);half alphaSwizzleR=half(srcDEF_args.w)-alphaSwizzle1;color.w=dot(half3("
42 "color.wx,1.),half3(alphaSwizzleA,alphaSwizzleR,alphaSwizzle1));}float3 colorF"
43 "=float3(color.xyz);colorF=sign(colorF)*$apply_srgb_xfer_fn(abs(colorF),srcGABC"
44 ",srcDEF_args.xyz);colorF=float3x3(gamut)*colorF;colorF=sign(colorF)*$apply_srgb_xfer_fn"
45 "(abs(colorF),dstGABC,dstDEF_args.xyz);half noPremul=half(dstDEF_args.w);color"
46 ".xyz=half3(colorF)*max(color.w,noPremul);return color;}$pure half4 sk_analytic_clip"
47 "(float2 coords,float4 rect,float2 radiusPlusHalf,half4 edgeSelect){float2 radius"
48 "=abs(radiusPlusHalf.x).xx;float2 dxy0=float2(edgeSelect.xy)*((rect.xy+radius"
49 ")-coords);float2 dxy1=float2(edgeSelect.zw)*(coords-(rect.zw-radius));float2"
50 " dxy=max(max(dxy0,dxy1),0.);half circleCornerAlpha=half(saturate(radius.x*("
51 "1.-length(dxy*radiusPlusHalf.y))));half4 rectEdgeAlphas=saturate(half4(half2"
52 "(coords-rect.xy),half2(rect.zw-coords)));rectEdgeAlphas=mix(rectEdgeAlphas,"
53 "half4(1.),edgeSelect);half alpha=(((circleCornerAlpha*rectEdgeAlphas.x)*rectEdgeAlphas"
54 ".y)*rectEdgeAlphas.z)*rectEdgeAlphas.w;alpha=radiusPlusHalf.x<0.?1.-alpha:alpha"
55 ";return alpha.xxxx;}$pure half4 sk_analytic_and_atlas_clip(float2 coords,float4"
56 " rect,float2 radiusPlusHalf,half4 edgeSelect,float2 texCoordOffset,float4 maskBounds"
57 ",float2 invAtlasSize,sampler2D atlasSampler){half4 analyticClip=sk_analytic_clip"
58 "(coords,rect,radiusPlusHalf,edgeSelect);float2 texCoord=coords+texCoordOffset"
59 ";float2 clampedTexCoord=clamp(texCoord,maskBounds.xy,maskBounds.zw);half atlasClip"
60 "=sample(atlasSampler,clampedTexCoord*invAtlasSize).x;return analyticClip*atlasClip"
61 ";}$pure float $tile(int tileMode,float f,float low,float high){switch(tileMode"
62 "){case 0:return clamp(f,low,high);case 1:{float length=high-low;return mod("
63 "f-low,length)+low;}case 2:{float length=high-low;float length2=2.*length;float"
64 " tmp=mod(f-low,length2);return mix(tmp,length2-tmp,step(length,tmp))+low;}default"
65 ":return f;}}$pure half4 $sample_image(float2 pos,float2 invImgSize,sampler2D"
66 " s){return sample(s,pos*invImgSize);}$pure half4 $sample_image_subset(float2"
67 " pos,float2 invImgSize,float4 subset,int tileModeX,int tileModeY,int filterMode"
68 ",float2 linearFilterInset,sampler2D s){if(tileModeX==$kTileModeDecal&&filterMode"
69 "==$kFilterModeNearest){float snappedX=floor(pos.x)+.5;if(snappedX<subset.x||"
70 "snappedX>subset.z)return half4(0.);}if(tileModeY==$kTileModeDecal&&filterMode"
71 "==$kFilterModeNearest){float snappedY=floor(pos.y)+.5;if(snappedY<subset.y||"
72 "snappedY>subset.w)return half4(0.);}pos.x=$tile(tileModeX,pos.x,subset.x,subset"
73 ".z);pos.y=$tile(tileModeY,pos.y,subset.y,subset.w);float4 insetClamp;if(filterMode"
74 "==$kFilterModeNearest)insetClamp=float4(floor(subset.xy)+$kLinearInset,ceil"
75 "(subset.zw)-$kLinearInset);else insetClamp=float4(subset.xy+linearFilterInset"
76 ",subset.zw-linearFilterInset);float2 clampedPos=clamp(pos,insetClamp.xy,insetClamp"
77 ".zw);half4 color=$sample_image(clampedPos,invImgSize,s);if(filterMode==$kFilterModeLinear"
78 "){half2 error=half2(pos-clampedPos);half2 absError=abs(error);bool sampleExtraX"
79 "=tileModeX==$kTileModeRepeat;bool sampleExtraY=tileModeY==$kTileModeRepeat;"
80 "if(sampleExtraX||sampleExtraY){float extraCoordX;float extraCoordY;half4 extraColorX"
81 ";half4 extraColorY;if(sampleExtraX){extraCoordX=error.x>0.?insetClamp.x:insetClamp"
82 ".z;extraColorX=$sample_image(float2(extraCoordX,clampedPos.y),invImgSize,s)"
83 ";}if(sampleExtraY){extraCoordY=error.y>0.?insetClamp.y:insetClamp.w;extraColorY"
84 "=$sample_image(float2(clampedPos.x,extraCoordY),invImgSize,s);}if(sampleExtraX"
85 "&&sampleExtraY){half4 extraColorXY=$sample_image(float2(extraCoordX,extraCoordY"
86 "),invImgSize,s);color=mix(mix(color,extraColorX,absError.x),mix(extraColorY"
87 ",extraColorXY,absError.x),absError.y);}else if(sampleExtraX)color=mix(color"
88 ",extraColorX,absError.x);else if(sampleExtraY)color=mix(color,extraColorY,absError"
89 ".y);}if(tileModeX==$kTileModeDecal)color*=max(1.-absError.x,0.);if(tileModeY"
90 "==$kTileModeDecal)color*=max(1.-absError.y,0.);}return color;}$pure half4 $cubic_filter_image"
91 "(float2 pos,float2 invImgSize,float4 subset,int tileModeX,int tileModeY,half4x4"
92 " coeffs,sampler2D s){float2 f=fract(pos-.5);pos-=1.5;pos=floor(pos)+.5;half4"
93 " wx=coeffs*half4(1.,half(f.x),half(f.x*f.x),half((f.x*f.x)*f.x));half4 wy=coeffs"
94 "*half4(1.,half(f.y),half(f.y*f.y),half((f.y*f.y)*f.y));half4 color=half4(0."
95 ");for(int y=0;y<4;++y){half4 rowColor=half4(0.);for(int x=0;x<4;++x)rowColor"
96 "+=wx[x]*$sample_image_subset(pos+float2(float(x),float(y)),invImgSize,subset"
97 ",tileModeX,tileModeY,$kFilterModeNearest,.50001.xx,s);color+=wy[y]*rowColor"
98 ";}color.w=saturate(color.w);color.xyz=clamp(color.xyz,half3(0.),color.www);"
99 "return color;}$pure half4 sk_image_shader(float2 coords,float2 invImgSize,float4"
100 " subset,int tileModeX,int tileModeY,int filterMode,sampler2D s){return $sample_image_subset"
101 "(coords,invImgSize,subset,tileModeX,tileModeY,filterMode,.50001.xx,s);}$pure"
102 " half4 sk_image_shader_clamp(float2 coords,float2 invImgSize,float4 subsetInsetClamp"
103 ",sampler2D s){return $sample_image(clamp(coords,subsetInsetClamp.xy,subsetInsetClamp"
104 ".zw),invImgSize,s);}$pure half4 sk_cubic_image_shader(float2 coords,float2 invImgSize"
105 ",float4 subset,int tileModeX,int tileModeY,half4x4 cubicCoeffs,sampler2D s)"
106 "{return $cubic_filter_image(coords,invImgSize,subset,tileModeX,tileModeY,cubicCoeffs"
107 ",s);}$pure half4 sk_hw_image_shader(float2 coords,sampler2D s){return sample"
108 "(s,coords);}$pure half4 $yuv_to_rgb_no_swizzle(half Y,half U,half V,half alpha"
109 ",half3x3 yuvToRGBMatrix,half3 yuvToRGBTranslate){half3 preColor=half3(Y,U,V"
110 ");half4 sampleColor;sampleColor.xyz=saturate(yuvToRGBMatrix*preColor+yuvToRGBTranslate"
111 ");sampleColor.w=alpha;return sampleColor;}$pure half4 $yuv_to_rgb(half4 sampleColorY"
112 ",half4 sampleColorU,half4 sampleColorV,half alpha,half4 channelSelectY,half4"
113 " channelSelectU,half4 channelSelectV,half3x3 yuvToRGBMatrix,half3 yuvToRGBTranslate"
114 "){half Y=dot(channelSelectY,sampleColorY);half U=dot(channelSelectU,sampleColorU"
115 ");half V=dot(channelSelectV,sampleColorV);return $yuv_to_rgb_no_swizzle(Y,U"
116 ",V,alpha,yuvToRGBMatrix,yuvToRGBTranslate);}$pure half4 sk_yuv_image_shader"
117 "(float2 coords,float2 invImgSizeY,float2 invImgSizeUV,float4 subset,float2 linearFilterUVInset"
118 ",int tileModeX,int tileModeY,int filterModeY,int filterModeUV,half4 channelSelectY"
119 ",half4 channelSelectU,half4 channelSelectV,half4 channelSelectA,half3x3 yuvToRGBMatrix"
120 ",half3 yuvToRGBTranslate,sampler2D sY,sampler2D sU,sampler2D sV,sampler2D sA"
121 "){if(filterModeY!=filterModeUV)coords=floor(coords)+.5;int tileModeX_UV=tileModeX"
122 "==$kTileModeDecal?$kTileModeClamp:tileModeX;int tileModeY_UV=tileModeY==$kTileModeDecal"
123 "?$kTileModeClamp:tileModeY;half4 sampleColorY;half4 sampleColorU;half4 sampleColorV"
124 ";sampleColorY=$sample_image_subset(coords,invImgSizeY,subset,tileModeX,tileModeY"
125 ",filterModeY,.50001.xx,sY);sampleColorU=$sample_image_subset(coords,invImgSizeUV"
126 ",subset,tileModeX_UV,tileModeY_UV,filterModeUV,linearFilterUVInset,sU);sampleColorV"
127 "=$sample_image_subset(coords,invImgSizeUV,subset,tileModeX_UV,tileModeY_UV,"
128 "filterModeUV,linearFilterUVInset,sV);half alpha;if(channelSelectA==half4(1."
129 "))alpha=1.;else{half4 sampleColorA=$sample_image_subset(coords,invImgSizeY,"
130 "subset,tileModeX,tileModeY,filterModeY,.50001.xx,sA);alpha=dot(channelSelectA"
131 ",sampleColorA);}return $yuv_to_rgb(sampleColorY,sampleColorU,sampleColorV,alpha"
132 ",channelSelectY,channelSelectU,channelSelectV,yuvToRGBMatrix,yuvToRGBTranslate"
133 ");}$pure half4 sk_cubic_yuv_image_shader(float2 coords,float2 invImgSizeY,float2"
134 " invImgSizeUV,float4 subset,int tileModeX,int tileModeY,half4x4 cubicCoeffs"
135 ",half4 channelSelectY,half4 channelSelectU,half4 channelSelectV,half4 channelSelectA"
136 ",half3x3 yuvToRGBMatrix,half3 yuvToRGBTranslate,sampler2D sY,sampler2D sU,sampler2D"
137 " sV,sampler2D sA){int tileModeX_UV=tileModeX==$kTileModeDecal?$kTileModeClamp"
138 ":tileModeX;int tileModeY_UV=tileModeY==$kTileModeDecal?$kTileModeClamp:tileModeY"
139 ";half4 sampleColorY;half4 sampleColorU;half4 sampleColorV;sampleColorY=$cubic_filter_image"
140 "(coords,invImgSizeY,subset,tileModeX,tileModeY,cubicCoeffs,sY);sampleColorU"
141 "=$cubic_filter_image(coords,invImgSizeUV,subset,tileModeX_UV,tileModeY_UV,cubicCoeffs"
142 ",sU);sampleColorV=$cubic_filter_image(coords,invImgSizeUV,subset,tileModeX_UV"
143 ",tileModeY_UV,cubicCoeffs,sV);half alpha;if(channelSelectA==half4(1.))alpha"
144 "=1.;else{half4 sampleColorA=$cubic_filter_image(coords,invImgSizeY,subset,tileModeX"
145 ",tileModeY,cubicCoeffs,sA);alpha=dot(channelSelectA,sampleColorA);}return $yuv_to_rgb"
146 "(sampleColorY,sampleColorU,sampleColorV,alpha,channelSelectY,channelSelectU"
147 ",channelSelectV,yuvToRGBMatrix,yuvToRGBTranslate);}$pure half4 sk_hw_yuv_image_shader"
148 "(float2 coords,float2 invImgSizeY,float2 invImgSizeUV,float4 subset,float2 linearFilterUVInset"
149 ",half4 channelSelectY,half4 channelSelectU,half4 channelSelectV,half4 channelSelectA"
150 ",half3x3 yuvToRGBMatrix,half3 yuvToRGBTranslate,sampler2D sY,sampler2D sU,sampler2D"
151 " sV,sampler2D sA){float4 subsetUV=subset;if(linearFilterUVInset.x<0.){coords"
152 "=floor(coords)+.5;subset=float4(floor(subset.xy),ceil(subset.zw));}float2 coordsUV"
153 "=coords;if(linearFilterUVInset.y<0.){linearFilterUVInset=abs(linearFilterUVInset"
154 ");coordsUV=clamp(coords,subsetUV.xy+linearFilterUVInset,subsetUV.zw-linearFilterUVInset"
155 ");coords=clamp(coords,subset.xy+$kLinearInset,subset.zw-$kLinearInset);}half4"
156 " sampleColorY;half4 sampleColorU;half4 sampleColorV;sampleColorY=$sample_image"
157 "(coords,invImgSizeY,sY);sampleColorU=$sample_image(coordsUV,invImgSizeUV,sU"
158 ");sampleColorV=$sample_image(coordsUV,invImgSizeUV,sV);half alpha;if(channelSelectA"
159 "==half4(1.))alpha=1.;else{half4 sampleColorA=$sample_image(coords,invImgSizeY"
160 ",sA);alpha=dot(channelSelectA,sampleColorA);}return $yuv_to_rgb(sampleColorY"
161 ",sampleColorU,sampleColorV,alpha,channelSelectY,channelSelectU,channelSelectV"
162 ",yuvToRGBMatrix,yuvToRGBTranslate);}$pure half4 sk_hw_yuv_no_swizzle_image_shader"
163 "(float2 coords,float2 invImgSizeY,float2 invImgSizeUV,float4 subset,float2 linearFilterUVInset"
164 ",half3x3 yuvToRGBMatrix,half4 yuvToRGBXlateAlphaParam,sampler2D sY,sampler2D"
165 " sU,sampler2D sV,sampler2D sA){float4 subsetUV=subset;if(linearFilterUVInset"
166 ".x<0.){coords=floor(coords)+.5;subset=float4(floor(subset.xy),ceil(subset.zw"
167 "));}float2 coordsUV=coords;if(linearFilterUVInset.y<0.){linearFilterUVInset"
168 "=abs(linearFilterUVInset);coordsUV=clamp(coords,subsetUV.xy+linearFilterUVInset"
169 ",subsetUV.zw-linearFilterUVInset);coords=clamp(coords,subset.xy+$kLinearInset"
170 ",subset.zw-$kLinearInset);}half Y=$sample_image(coords,invImgSizeY,sY).x;half"
171 " U=$sample_image(coordsUV,invImgSizeUV,sU).x;half V=$sample_image(coordsUV,"
172 "invImgSizeUV,sV).x;half alpha=saturate($sample_image(coords,invImgSizeY,sA)"
173 ".x+yuvToRGBXlateAlphaParam.w);return $yuv_to_rgb_no_swizzle(Y,U,V,alpha,yuvToRGBMatrix"
174 ",yuvToRGBXlateAlphaParam.xyz);}$pure half4 sk_dither(half4 colorIn,half range"
175 ",sampler2D lut){half value=sample(lut,sk_FragCoord.xy*.125).x-.5;return half4"
176 "(clamp(colorIn.xyz+value*range,0.,colorIn.w),colorIn.w);}$pure float2 $tile_grad"
177 "(int tileMode,float2 t){switch(tileMode){case 0:t.x=saturate(t.x);break;case"
178 " 1:t.x=fract(t.x);break;case 2:{float t_1=t.x-1.;t.x=(t_1-2.*floor(t_1*.5))"
179 "-1.;if(sk_Caps.mustDoOpBetweenFloorAndAbs)t.x=clamp(t.x,-1.,1.);t.x=abs(t.x"
180 ");break;}case 3:if(t.x<0.||t.x>1.)return float2(0.,-1.);break;}return t;}$pure"
181 " half4 $colorize_grad_4(float4[4]colorsParam,float4 offsetsParam,float2 t){"
182 "if(t.y<0.)return half4(0.);else if(t.x<=offsetsParam.x)return half4(colorsParam"
183 "[0]);else if(t.x<offsetsParam.y)return half4(mix(colorsParam[0],colorsParam"
184 "[1],(t.x-offsetsParam.x)/(offsetsParam.y-offsetsParam.x)));else if(t.x<offsetsParam"
185 ".z)return half4(mix(colorsParam[1],colorsParam[2],(t.x-offsetsParam.y)/(offsetsParam"
186 ".z-offsetsParam.y)));else if(t.x<offsetsParam.w)return half4(mix(colorsParam"
187 "[2],colorsParam[3],(t.x-offsetsParam.z)/(offsetsParam.w-offsetsParam.z)));else"
188 " return half4(colorsParam[3]);}$pure half4 $colorize_grad_8(float4[8]colorsParam"
189 ",float4[2]offsetsParam,float2 t){if(t.y<0.)return half4(0.);else if(t.x<offsetsParam"
190 "[1].x)if(t.x<offsetsParam[0].z)if(t.x<=offsetsParam[0].x)return half4(colorsParam"
191 "[0]);else if(t.x<offsetsParam[0].y)return half4(mix(colorsParam[0],colorsParam"
192 "[1],(t.x-offsetsParam[0].x)/(offsetsParam[0].y-offsetsParam[0].x)));else return"
193 " half4(mix(colorsParam[1],colorsParam[2],(t.x-offsetsParam[0].y)/(offsetsParam"
194 "[0].z-offsetsParam[0].y)));else if(t.x<offsetsParam[0].w)return half4(mix(colorsParam"
195 "[2],colorsParam[3],(t.x-offsetsParam[0].z)/(offsetsParam[0].w-offsetsParam["
196 "0].z)));else return half4(mix(colorsParam[3],colorsParam[4],(t.x-offsetsParam"
197 "[0].w)/(offsetsParam[1].x-offsetsParam[0].w)));else if(t.x<offsetsParam[1]."
198 "z)if(t.x<offsetsParam[1].y)return half4(mix(colorsParam[4],colorsParam[5],("
199 "t.x-offsetsParam[1].x)/(offsetsParam[1].y-offsetsParam[1].x)));else return half4"
200 "(mix(colorsParam[5],colorsParam[6],(t.x-offsetsParam[1].y)/(offsetsParam[1]"
201 ".z-offsetsParam[1].y)));else if(t.x<offsetsParam[1].w)return half4(mix(colorsParam"
202 "[6],colorsParam[7],(t.x-offsetsParam[1].z)/(offsetsParam[1].w-offsetsParam["
203 "1].z)));else return half4(colorsParam[7]);}$pure half4 $colorize_grad_tex(sampler2D"
204 " colorsAndOffsetsSampler,int numStops,float2 t){if(t.y<0.)return half4(0.);"
205 "else if(t.x==0.)return sampleLod(colorsAndOffsetsSampler,float2(0.,.25),0.)"
206 ";else if(t.x==1.)return sampleLod(colorsAndOffsetsSampler,float2(1.,.25),0."
207 ");else{float low=0.;float high=float(numStops);float invNumStops=1./high;for"
208 "(int loop=1;loop<numStops;loop+=loop){float mid=floor((low+high)*.5);float samplePos"
209 "=(mid+.5)*invNumStops;float2 tmp=float2(sampleLod(colorsAndOffsetsSampler,float2"
210 "(samplePos,.75),0.).xy);float offset=ldexp(tmp.x,int(tmp.y));if(t.x<offset)"
211 "high=mid;else low=mid;}high=(low+1.5)*invNumStops;low=(low+.5)*invNumStops;"
212 "half4 color0=sampleLod(colorsAndOffsetsSampler,float2(low,.25),0.);half4 color1"
213 "=sampleLod(colorsAndOffsetsSampler,float2(high,.25),0.);float2 tmp=float2(sampleLod"
214 "(colorsAndOffsetsSampler,float2(low,.75),0.).xy);float offset0=ldexp(tmp.x,"
215 "int(tmp.y));tmp=float2(sampleLod(colorsAndOffsetsSampler,float2(high,.75),0."
216 ").xy);float offset1=ldexp(tmp.x,int(tmp.y));return half4(mix(float4(color0)"
217 ",float4(color1),(t.x-offset0)/(offset1-offset0)));}}$pure half4 $half4_from_array"
218 "(float[]arr,int offset){return half4(half(arr[offset]),half(arr[offset+1]),"
219 "half(arr[offset+2]),half(arr[offset+3]));}$pure half4 $colorize_grad_buf(float"
220 "[]colorAndOffsetData,int offsetsBaseIndex,int numStops,float2 t){int colorsBaseIndex"
221 "=offsetsBaseIndex+numStops;if(t.y<0.)return half4(0.);else if(t.x==0.)return"
222 " $half4_from_array(colorAndOffsetData,colorsBaseIndex);else if(t.x==1.){int"
223 " lastColorIndex=colorsBaseIndex+(numStops-1)*4;return $half4_from_array(colorAndOffsetData"
224 ",lastColorIndex);}else{int lowOffsetIndex=offsetsBaseIndex;int highOffsetIndex"
225 "=(lowOffsetIndex+numStops)-1;for(int i=1;i<numStops;i+=i){int middleOffsetIndex"
226 "=(lowOffsetIndex+highOffsetIndex)/2;if(t.x<colorAndOffsetData[middleOffsetIndex"
227 "])highOffsetIndex=middleOffsetIndex;else lowOffsetIndex=middleOffsetIndex;}"
228 "int lowColorIndex=colorsBaseIndex+(lowOffsetIndex-offsetsBaseIndex)*4;float"
229 " lowOffset=colorAndOffsetData[lowOffsetIndex];half4 lowColor=$half4_from_array"
230 "(colorAndOffsetData,lowColorIndex);int highColorIndex=colorsBaseIndex+(highOffsetIndex"
231 "-offsetsBaseIndex)*4;float highOffset=colorAndOffsetData[highOffsetIndex];if"
232 "(highOffset==lowOffset)return lowColor;else{half4 highColor=$half4_from_array"
233 "(colorAndOffsetData,highColorIndex);return half4(mix(float4(lowColor),float4"
234 "(highColor),(t.x-lowOffset)/(highOffset-lowOffset)));}}}$pure float2 $linear_grad_layout"
235 "(float2 pos){return float2(pos.x+1e-05,1.);}$pure float2 $radial_grad_layout"
236 "(float2 pos){float t=length(pos);return float2(t,1.);}$pure float2 $sweep_grad_layout"
237 "(float biasParam,float scaleParam,float2 pos){float angle;if(sk_Caps.atan2ImplementedAsAtanYOverX"
238 ")angle=2.*atan(-pos.y,length(pos)-pos.x);else angle=pos.x!=0.?atan(-pos.y,-"
239 "pos.x):sign(pos.y)*-1.57079637;float t=((angle*.159154937+.5)+biasParam)*scaleParam"
240 ";return float2(t,1.);}$pure float2 $conical_grad_layout(float radius0,float"
241 " dRadius,float a,float invA,float2 pos){if(a==0.&&invA==1.){float t=length("
242 "pos)*dRadius-radius0;return float2(t,1.);}else{float c=dot(pos,pos)-radius0"
243 "*radius0;float negB=2.*(dRadius*radius0+pos.x);float t;if(a==0.)t=c/negB;else"
244 "{float d=negB*negB-(4.*a)*c;if(d<0.)return float2(0.,-1.);float quadSign=sign"
245 "(1.-dRadius);t=invA*(negB+quadSign*sqrt(d));}float isValid=sign(t*dRadius+radius0"
246 ");return float2(t,isValid);}}$pure half4 sk_linear_grad_4_shader(float2 coords"
247 ",float4[4]colorsParam,float4 offsetsParam,int tileMode,int colorSpace,int doUnpremul"
248 "){float2 t=$linear_grad_layout(coords);t=$tile_grad(tileMode,t);half4 color"
249 "=$colorize_grad_4(colorsParam,offsetsParam,t);return $interpolated_to_rgb_unpremul"
250 "(color,colorSpace,doUnpremul);}$pure half4 sk_linear_grad_8_shader(float2 coords"
251 ",float4[8]colorsParam,float4[2]offsetsParam,int tileMode,int colorSpace,int"
252 " doUnpremul){float2 t=$linear_grad_layout(coords);t=$tile_grad(tileMode,t);"
253 "half4 color=$colorize_grad_8(colorsParam,offsetsParam,t);return $interpolated_to_rgb_unpremul"
254 "(color,colorSpace,doUnpremul);}$pure half4 sk_linear_grad_tex_shader(float2"
255 " coords,int numStops,int tileMode,int colorSpace,int doUnpremul,sampler2D colorAndOffsetSampler"
256 "){float2 t=$linear_grad_layout(coords);t=$tile_grad(tileMode,t);half4 color"
257 "=$colorize_grad_tex(colorAndOffsetSampler,numStops,t);return $interpolated_to_rgb_unpremul"
258 "(color,colorSpace,doUnpremul);}$pure half4 sk_linear_grad_buf_shader(float2"
259 " coords,int numStops,int bufferOffset,int tileMode,int colorSpace,int doUnpremul"
260 ",float[]colorAndOffsetData){float2 t=$linear_grad_layout(coords);t=$tile_grad"
261 "(tileMode,t);half4 color=$colorize_grad_buf(colorAndOffsetData,bufferOffset"
262 ",numStops,t);return $interpolated_to_rgb_unpremul(color,colorSpace,doUnpremul"
263 ");}$pure half4 sk_radial_grad_4_shader(float2 coords,float4[4]colorsParam,float4"
264 " offsetsParam,int tileMode,int colorSpace,int doUnpremul){float2 t=$radial_grad_layout"
265 "(coords);t=$tile_grad(tileMode,t);half4 color=$colorize_grad_4(colorsParam,"
266 "offsetsParam,t);return $interpolated_to_rgb_unpremul(color,colorSpace,doUnpremul"
267 ");}$pure half4 sk_radial_grad_8_shader(float2 coords,float4[8]colorsParam,float4"
268 "[2]offsetsParam,int tileMode,int colorSpace,int doUnpremul){float2 t=$radial_grad_layout"
269 "(coords);t=$tile_grad(tileMode,t);half4 color=$colorize_grad_8(colorsParam,"
270 "offsetsParam,t);return $interpolated_to_rgb_unpremul(color,colorSpace,doUnpremul"
271 ");}$pure half4 sk_radial_grad_tex_shader(float2 coords,int numStops,int tileMode"
272 ",int colorSpace,int doUnpremul,sampler2D colorAndOffsetSampler){float2 t=$radial_grad_layout"
273 "(coords);t=$tile_grad(tileMode,t);half4 color=$colorize_grad_tex(colorAndOffsetSampler"
274 ",numStops,t);return $interpolated_to_rgb_unpremul(color,colorSpace,doUnpremul"
275 ");}$pure half4 sk_radial_grad_buf_shader(float2 coords,int numStops,int bufferOffset"
276 ",int tileMode,int colorSpace,int doUnpremul,float[]colorAndOffsetData){float2"
277 " t=$radial_grad_layout(coords);t=$tile_grad(tileMode,t);half4 color=$colorize_grad_buf"
278 "(colorAndOffsetData,bufferOffset,numStops,t);return $interpolated_to_rgb_unpremul"
279 "(color,colorSpace,doUnpremul);}$pure half4 sk_sweep_grad_4_shader(float2 coords"
280 ",float4[4]colorsParam,float4 offsetsParam,float biasParam,float scaleParam,"
281 "int tileMode,int colorSpace,int doUnpremul){float2 t=$sweep_grad_layout(biasParam"
282 ",scaleParam,coords);t=$tile_grad(tileMode,t);half4 color=$colorize_grad_4(colorsParam"
283 ",offsetsParam,t);return $interpolated_to_rgb_unpremul(color,colorSpace,doUnpremul"
284 ");}$pure half4 sk_sweep_grad_8_shader(float2 coords,float4[8]colorsParam,float4"
285 "[2]offsetsParam,float biasParam,float scaleParam,int tileMode,int colorSpace"
286 ",int doUnpremul){float2 t=$sweep_grad_layout(biasParam,scaleParam,coords);t"
287 "=$tile_grad(tileMode,t);half4 color=$colorize_grad_8(colorsParam,offsetsParam"
288 ",t);return $interpolated_to_rgb_unpremul(color,colorSpace,doUnpremul);}$pure"
289 " half4 sk_sweep_grad_tex_shader(float2 coords,float biasParam,float scaleParam"
290 ",int numStops,int tileMode,int colorSpace,int doUnpremul,sampler2D colorAndOffsetSampler"
291 "){float2 t=$sweep_grad_layout(biasParam,scaleParam,coords);t=$tile_grad(tileMode"
292 ",t);half4 color=$colorize_grad_tex(colorAndOffsetSampler,numStops,t);return"
293 " $interpolated_to_rgb_unpremul(color,colorSpace,doUnpremul);}$pure half4 sk_sweep_grad_buf_shader"
294 "(float2 coords,float biasParam,float scaleParam,int numStops,int bufferOffset"
295 ",int tileMode,int colorSpace,int doUnpremul,float[]colorAndOffsetData){float2"
296 " t=$sweep_grad_layout(biasParam,scaleParam,coords);t=$tile_grad(tileMode,t)"
297 ";half4 color=$colorize_grad_buf(colorAndOffsetData,bufferOffset,numStops,t)"
298 ";return $interpolated_to_rgb_unpremul(color,colorSpace,doUnpremul);}$pure half4"
299 " sk_conical_grad_4_shader(float2 coords,float4[4]colorsParam,float4 offsetsParam"
300 ",float radius0Param,float dRadiusParam,float aParam,float invAParam,int tileMode"
301 ",int colorSpace,int doUnpremul){float2 t=$conical_grad_layout(radius0Param,"
302 "dRadiusParam,aParam,invAParam,coords);t=$tile_grad(tileMode,t);half4 color="
303 "$colorize_grad_4(colorsParam,offsetsParam,t);return $interpolated_to_rgb_unpremul"
304 "(color,colorSpace,doUnpremul);}$pure half4 sk_conical_grad_8_shader(float2 coords"
305 ",float4[8]colorsParam,float4[2]offsetsParam,float radius0Param,float dRadiusParam"
306 ",float aParam,float invAParam,int tileMode,int colorSpace,int doUnpremul){float2"
307 " t=$conical_grad_layout(radius0Param,dRadiusParam,aParam,invAParam,coords);"
308 "t=$tile_grad(tileMode,t);half4 color=$colorize_grad_8(colorsParam,offsetsParam"
309 ",t);return $interpolated_to_rgb_unpremul(color,colorSpace,doUnpremul);}$pure"
310 " half4 sk_conical_grad_tex_shader(float2 coords,float radius0Param,float dRadiusParam"
311 ",float aParam,float invAParam,int numStops,int tileMode,int colorSpace,int doUnpremul"
312 ",sampler2D colorAndOffsetSampler){float2 t=$conical_grad_layout(radius0Param"
313 ",dRadiusParam,aParam,invAParam,coords);t=$tile_grad(tileMode,t);half4 color"
314 "=$colorize_grad_tex(colorAndOffsetSampler,numStops,t);return $interpolated_to_rgb_unpremul"
315 "(color,colorSpace,doUnpremul);}$pure half4 sk_conical_grad_buf_shader(float2"
316 " coords,float radius0Param,float dRadiusParam,float aParam,float invAParam,"
317 "int numStops,int bufferOffset,int tileMode,int colorSpace,int doUnpremul,float"
318 "[]colorAndOffsetData){float2 t=$conical_grad_layout(radius0Param,dRadiusParam"
319 ",aParam,invAParam,coords);t=$tile_grad(tileMode,t);half4 color=$colorize_grad_buf"
320 "(colorAndOffsetData,bufferOffset,numStops,t);return $interpolated_to_rgb_unpremul"
321 "(color,colorSpace,doUnpremul);}$pure half4 sk_hsl_matrix_colorfilter(half4 color"
322 ",half4x4 m,half4 v){color=$rgb_to_hsl(color.xyz,color.w);color=m*color+v;return"
323 " $hsl_to_rgb(color.xyz,color.w);}$pure half4 sk_matrix_colorfilter(half4 color"
324 ",half4x4 m,half4 v,half2 minMaxRGB){color=unpremul(color);color=m*color+v;color"
325 "=clamp(color,half4(minMaxRGB.xxx,0.),half4(minMaxRGB.yyy,1.));color.xyz*=color"
326 ".w;return color;}$pure half4 $noise_helper(half2 noiseVec,half2 stitchData,"
327 "int stitching,sampler2D permutationSampler){const half kBlockSize=256.;half4"
328 " floorVal;floorVal.xy=floor(noiseVec);floorVal.zw=floorVal.xy+half2(1.);if("
329 "bool(stitching))floorVal-=step(stitchData.xyxy,floorVal)*stitchData.xyxy;half"
330 " sampleX=sample(permutationSampler,float2(half2((floorVal.x+.5)*.00390625,.5"
331 "))).x;half sampleY=sample(permutationSampler,float2(half2((floorVal.z+.5)*.00390625"
332 ",.5))).x;half2 latticeIdx=half2(sampleX,sampleY);if(sk_Caps.PerlinNoiseRoundingFix"
333 ")latticeIdx=floor(latticeIdx*half2(255.)+half2(.5))*half2(.003921569);half4"
334 " noiseXCoords=kBlockSize*latticeIdx.xyxy+floorVal.yyww;noiseXCoords*=half4("
335 ".00390625);return noiseXCoords;}$pure half4 $noise_function(half2 noiseVec,"
336 "half4 noiseXCoords,sampler2D noiseSampler){half2 fractVal=fract(noiseVec);half2"
337 " noiseSmooth=smoothstep(0.,1.,fractVal);const half kInv256=.00390625;half4 result"
338 ";for(int channel=0;channel<4;channel++){half chanCoord=(half(channel)+.5)*.25"
339 ";half4 sampleA=sample(noiseSampler,float2(float(noiseXCoords.x),float(chanCoord"
340 ")));half4 sampleB=sample(noiseSampler,float2(float(noiseXCoords.y),float(chanCoord"
341 ")));half4 sampleC=sample(noiseSampler,float2(float(noiseXCoords.w),float(chanCoord"
342 ")));half4 sampleD=sample(noiseSampler,float2(float(noiseXCoords.z),float(chanCoord"
343 ")));half2 tmpFractVal=fractVal;half u=dot((sampleA.yw+sampleA.xz*kInv256)*2."
344 "-1.,tmpFractVal);tmpFractVal.x-=1.;half v=dot((sampleB.yw+sampleB.xz*kInv256"
345 ")*2.-1.,tmpFractVal);half a=mix(u,v,noiseSmooth.x);tmpFractVal.y-=1.;v=dot("
346 "(sampleC.yw+sampleC.xz*kInv256)*2.-1.,tmpFractVal);tmpFractVal.x+=1.;u=dot("
347 "(sampleD.yw+sampleD.xz*kInv256)*2.-1.,tmpFractVal);half b=mix(u,v,noiseSmooth"
348 ".x);result[channel]=mix(a,b,noiseSmooth.y);}return result;}$pure half4 sk_perlin_noise_shader"
349 "(float2 coords,float2 baseFrequency,float2 stitchDataIn,int noiseType,int numOctaves"
350 ",int stitching,sampler2D permutationSampler,sampler2D noiseSampler){const int"
351 " kFractalNoise=0;half2 noiseVec=half2((coords+.5)*baseFrequency);half4 color"
352 "=half4(0.);half2 stitchData=half2(stitchDataIn);half ratio=1.;for(int octave"
353 "=0;octave<numOctaves;++octave){half4 noiseXCoords=$noise_helper(noiseVec,stitchData"
354 ",stitching,permutationSampler);half4 tmp=$noise_function(noiseVec,noiseXCoords"
355 ",noiseSampler);if(noiseType!=kFractalNoise)tmp=abs(tmp);color+=tmp*ratio;noiseVec"
356 "*=half2(2.);ratio*=.5;stitchData*=half2(2.);}if(noiseType==kFractalNoise)color"
357 "=color*half4(.5)+half4(.5);color=saturate(color);return half4(color.xyz*color"
358 ".w,color.w);}$pure half4 sk_porter_duff_blend(half4 src,half4 dst,half4 coeffs"
359 "){return blend_porter_duff(coeffs,src,dst);}$pure half4 sk_hslc_blend(half4"
360 " src,half4 dst,half2 flipSat){return blend_hslc(flipSat,src,dst);}$pure half4"
361 " sk_table_colorfilter(half4 inColor,sampler2D s){half4 coords=unpremul(inColor"
362 ")*.99609375+.001953125;half4 color=half4(sample(s,float2(half2(coords.x,.375"
363 "))).x,sample(s,float2(half2(coords.y,.625))).x,sample(s,float2(half2(coords"
364 ".z,.875))).x,1.);return color*sample(s,float2(half2(coords.w,.125))).x;}$pure"
365 " half4 sk_gaussian_colorfilter(half4 inColor){half factor=1.-inColor.w;factor"
366 "=exp((-factor*factor)*4.)-.018;return factor.xxxx;}$pure half4 sample_indexed_atlas"
367 "(float2 textureCoords,int atlasIndex,sampler2D atlas0,sampler2D atlas1,sampler2D"
368 " atlas2,sampler2D atlas3){switch(atlasIndex){case 1:return sample(atlas1,textureCoords"
369 ");case 2:return sample(atlas2,textureCoords);case 3:return sample(atlas3,textureCoords"
370 ");default:return sample(atlas0,textureCoords);}}$pure half3 $sample_indexed_atlas_lcd"
371 "(float2 textureCoords,int atlasIndex,half2 offset,sampler2D atlas0,sampler2D"
372 " atlas1,sampler2D atlas2,sampler2D atlas3){half3 distance=half3(1.);switch("
373 "atlasIndex){case 1:distance.x=sample(atlas1,float2(half2(textureCoords)-offset"
374 ")).x;distance.y=sample(atlas1,textureCoords).x;distance.z=sample(atlas1,float2"
375 "(half2(textureCoords)+offset)).x;break;case 2:distance.x=sample(atlas2,float2"
376 "(half2(textureCoords)-offset)).x;distance.y=sample(atlas2,textureCoords).x;"
377 "distance.z=sample(atlas2,float2(half2(textureCoords)+offset)).x;break;case 3"
378 ":distance.x=sample(atlas3,float2(half2(textureCoords)-offset)).x;distance.y"
379 "=sample(atlas3,textureCoords).x;distance.z=sample(atlas3,float2(half2(textureCoords"
380 ")+offset)).x;break;default:distance.x=sample(atlas0,float2(half2(textureCoords"
381 ")-offset)).x;distance.y=sample(atlas0,textureCoords).x;distance.z=sample(atlas0"
382 ",float2(half2(textureCoords)+offset)).x;break;}return distance;}$pure half4"
383 " bitmap_text_coverage_fn(half4 texColor,int maskFormat){return maskFormat=="
384 "$kMaskFormatA8?texColor.xxxx:texColor;}$pure half4 sdf_text_coverage_fn(half"
385 " texColor,half2 gammaParams,float2 unormTexCoords){half dist=7.96875*(texColor"
386 "-.5019608);dist-=gammaParams.x;half2 dist_grad=half2(dFdx(dist),dFdy(dist))"
387 ";half dg_len2=dot(dist_grad,dist_grad);dist_grad=dg_len2>=.0001?dist_grad*inversesqrt"
388 "(dg_len2):half2(.7071);float2x2 jacobian=float2x2(dFdx(unormTexCoords),dFdy"
389 "(unormTexCoords));half2 grad=half2(jacobian*float2(dist_grad));half approxFragWidth"
390 "=.65*length(grad);if(gammaParams.y>0.)return saturate((dist+approxFragWidth"
391 ")/(2.*approxFragWidth)).xxxx;else return smoothstep(-approxFragWidth,approxFragWidth"
392 ",dist).xxxx;}$pure half4 sdf_text_lcd_coverage_fn(float2 textureCoords,half2"
393 " pixelGeometryDelta,half4 gammaParams,float2 unormTexCoords,float texIndex,"
394 "sampler2D atlas0,sampler2D atlas1,sampler2D atlas2,sampler2D atlas3){float2x2"
395 " jacobian=float2x2(dFdx(unormTexCoords),dFdy(unormTexCoords));half2 offset="
396 "half2(jacobian*float2(pixelGeometryDelta));half3 distance=$sample_indexed_atlas_lcd"
397 "(textureCoords,int(texIndex),offset,atlas0,atlas1,atlas2,atlas3);half3 dist"
398 "=half3(7.96875)*(distance-half3(.5019608));dist-=gammaParams.xyz;half2 dist_grad"
399 "=half2(dFdx(dist.y),dFdy(dist.y));half dg_len2=dot(dist_grad,dist_grad);dist_grad"
400 "=dg_len2>=.0001?dist_grad*inversesqrt(dg_len2):half2(.7071);half2 grad=half2"
401 "(jacobian*float2(dist_grad));half3 approxFragWidth=(.65*length(grad)).xxx;if"
402 "(gammaParams.w>0.)return half4(saturate(dist+approxFragWidth/(2.*approxFragWidth"
403 ")),1.);else return half4(smoothstep(-approxFragWidth,approxFragWidth,dist),"
404 "1.);}$pure float $inverse_grad_len(float2 localGrad,float2x2 jacobian){float2"
405 " devGrad=localGrad*jacobian;return inversesqrt(dot(devGrad,devGrad));}$pure"
406 " float2 $elliptical_distance(float2 uv,float2 radii,float strokeRadius,float2x2"
407 " jacobian){float2 invR2=1./(radii*radii+strokeRadius*strokeRadius);float2 normUV"
408 "=invR2*uv;float invGradLength=$inverse_grad_len(normUV,jacobian);float f=(.5"
409 "*invGradLength)*(dot(uv,normUV)-1.);float width=((radii.x*strokeRadius)*invR2"
410 ".x)*invGradLength;return float2(width-f,width+f);}void $corner_distance(inout"
411 " float2 dist,float2x2 jacobian,float2 strokeParams,float2 cornerEdgeDist,float2"
412 " xyFlip,float2 radii){float2 uv=radii-cornerEdgeDist;if(all(greaterThan(uv,"
413 "0..xx)))if(all(greaterThan(radii,0..xx))||strokeParams.x>0.&&strokeParams.y"
414 "<0.){float2 d=$elliptical_distance(uv*xyFlip,radii,strokeParams.x,jacobian)"
415 ";d.y=radii.x-strokeParams.x<=0.?1.:-d.y;dist=min(dist,d);}else if(strokeParams"
416 ".y==0.){float bevelDist=((strokeParams.x-uv.x)-uv.y)*$inverse_grad_len(xyFlip"
417 ",jacobian);dist.x=min(dist.x,bevelDist);}}void $corner_distances(inout float2"
418 " d,float2x2 J,float2 stroke,float4 edgeDists,float4 xRadii,float4 yRadii){$corner_distance"
419 "(d,J,stroke,edgeDists.xy,-1..xx,float2(xRadii.x,yRadii.x));$corner_distance"
420 "(d,J,stroke,edgeDists.zy,float2(1.,-1.),float2(xRadii.y,yRadii.y));$corner_distance"
421 "(d,J,stroke,edgeDists.zw,1..xx,float2(xRadii.z,yRadii.z));$corner_distance("
422 "d,J,stroke,edgeDists.xw,float2(-1.,1.),float2(xRadii.w,yRadii.w));}$pure half4"
423 " analytic_rrect_coverage_fn(float4 coords,float4 jacobian,float4 edgeDistances"
424 ",float4 xRadii,float4 yRadii,float2 strokeParams,float2 perPixelControl){if"
425 "(perPixelControl.x>0.)return half4(1.);else if(perPixelControl.y>1.){float2"
426 " outerDist=min(edgeDistances.xy,edgeDistances.zw);float c=min(outerDist.x,outerDist"
427 ".y)*coords.w;float scale=(perPixelControl.y-1.)*coords.w;float bias=coverage_bias"
428 "(scale);return half(saturate(scale*(c+bias))).xxxx;}else{float2x2 J=float2x2"
429 "(jacobian)*(1./coords.w);float2 invGradLen=float2($inverse_grad_len(float2("
430 "1.,0.),J),$inverse_grad_len(float2(0.,1.),J));float2 outerDist=invGradLen*("
431 "strokeParams.x+min(edgeDistances.xy,edgeDistances.zw));float2 d=float2(min("
432 "outerDist.x,outerDist.y),-1.);float scale;float bias;if(perPixelControl.x>-"
433 ".95){float2 dim=invGradLen*((edgeDistances.xy+edgeDistances.zw)+2.*strokeParams"
434 ".xx);scale=min(min(dim.x,dim.y),1.);bias=coverage_bias(scale);}else{float2 strokeWidth"
435 "=(2.*strokeParams.x)*invGradLen;float2 innerDist=strokeWidth-outerDist;d.y="
436 "-max(innerDist.x,innerDist.y);if(strokeParams.x>0.){float narrowStroke=min("
437 "strokeWidth.x,strokeWidth.y);float2 strokeDim=mix(narrowStroke.xx,strokeWidth"
438 ",greaterThanEqual(innerDist,-.5.xx));scale=saturate(max(strokeDim.x,strokeDim"
439 ".y));bias=coverage_bias(scale);}else scale=(bias=1.);}$corner_distances(d,J"
440 ",strokeParams,edgeDistances,xRadii,yRadii);float outsetDist=min(perPixelControl"
441 ".y,0.)*coords.w;float finalCoverage=scale*(min(d.x+outsetDist,-d.y)+bias);return"
442 " half(saturate(finalCoverage)).xxxx;}}$pure half4 per_edge_aa_quad_coverage_fn"
443 "(float4 coords,float4 edgeDistances){float2 outerDist=min(edgeDistances.xy,"
444 "edgeDistances.zw);float c=min(outerDist.x,outerDist.y)*coords.w;return half"
445 "(saturate(c)).xxxx;}$pure half4 circular_arc_coverage_fn(float4 circleEdge,"
446 "float3 clipPlane,float3 isectPlane,float3 unionPlane,float roundCapRadius,float4"
447 " roundCapPos){float d=length(circleEdge.xy);half distanceToOuterEdge=half(circleEdge"
448 ".z*(1.-d));half edgeAlpha=saturate(distanceToOuterEdge);half distanceToInnerEdge"
449 "=half(circleEdge.z*(d-circleEdge.w));half innerAlpha=saturate(distanceToInnerEdge"
450 ");edgeAlpha*=innerAlpha;half clip=half(saturate(circleEdge.z*dot(circleEdge"
451 ".xy,clipPlane.xy)+clipPlane.z));clip*=half(saturate(circleEdge.z*dot(circleEdge"
452 ".xy,isectPlane.xy)+isectPlane.z));clip=clip+half(saturate(circleEdge.z*dot("
453 "circleEdge.xy,unionPlane.xy)+unionPlane.z));half dcap1=half(circleEdge.z*(roundCapRadius"
454 "-length(circleEdge.xy-roundCapPos.xy)));half dcap2=half(circleEdge.z*(roundCapRadius"
455 "-length(circleEdge.xy-roundCapPos.zw)));half capAlpha=max(dcap1,0.)+max(dcap2"
456 ",0.);clip=saturate(clip+capAlpha);return(clip*edgeAlpha).xxxx;}$pure half4 $rect_blur_coverage_fn"
457 "(float2 coords,float4 rect,half isFast,half invSixSigma,sampler2D integral)"
458 "{half xCoverage;half yCoverage;if(isFast!=0.){half2 pos=max(half2(rect.xy-coords"
459 "),half2(coords-rect.zw));xCoverage=sample(integral,float2(float(invSixSigma"
460 "*pos.x),.5)).x;yCoverage=sample(integral,float2(float(invSixSigma*pos.y),.5"
461 ")).x;}else{half4 rect=half4(half2(rect.xy-coords),half2(coords-rect.zw));xCoverage"
462 "=(1.-sample(integral,float2(float(invSixSigma*rect.x),.5)).x)-sample(integral"
463 ",float2(float(invSixSigma*rect.z),.5)).x;yCoverage=(1.-sample(integral,float2"
464 "(float(invSixSigma*rect.y),.5)).x)-sample(integral,float2(float(invSixSigma"
465 "*rect.w),.5)).x;}return(xCoverage*yCoverage).xxxx;}$pure half4 $circle_blur_coverage_fn"
466 "(float2 coords,float4 circle,sampler2D blurProfile){float invTextureRadius="
467 "circle.z;float normSolidRadius=circle.w;half2 vec=half2((coords-circle.xy)*"
468 "invTextureRadius);float dist=float(length(vec))-normSolidRadius;return sample"
469 "(blurProfile,float2(dist,.5)).xxxx;}$pure half4 $rrect_blur_coverage_fn(float2"
470 " coords,float4 proxyRect,half edgeSize,sampler2D ninePatch){float2 translatedFragPosFloat"
471 "=coords-proxyRect.xy;float2 proxyCenter=(proxyRect.zw-proxyRect.xy)*.5;translatedFragPosFloat"
472 "-=proxyCenter;half2 fragDirection=half2(sign(translatedFragPosFloat));translatedFragPosFloat"
473 "=abs(translatedFragPosFloat);half2 translatedFragPosHalf=half2(translatedFragPosFloat"
474 "-(proxyCenter-float(edgeSize)));translatedFragPosHalf=max(translatedFragPosHalf"
475 ",0.);translatedFragPosHalf*=fragDirection;translatedFragPosHalf+=edgeSize.xx"
476 ";half2 proxyDims=(2.*edgeSize).xx;half2 texCoord=translatedFragPosHalf/proxyDims"
477 ";return sample(ninePatch,float2(texCoord)).xxxx;}$pure half4 blur_coverage_fn"
478 "(float2 coords,float4 shapeData,half2 blurData,int shapeType,sampler2D s){switch"
479 "(shapeType){case 0:{return $rect_blur_coverage_fn(coords,shapeData,blurData"
480 ".x,blurData.y,s);}case 2:{return $circle_blur_coverage_fn(coords,shapeData,"
481 "s);}case 1:{return $rrect_blur_coverage_fn(coords,shapeData,blurData.x,s);}"
482 "}return half4(0.);}";