static constexpr char SKSL_MINIFIED_sksl_graphite_frag[] = "const int $kTileModeClamp=0;const int $kTileModeRepeat=1;const int $kTileModeDecal" "=3;const int $kFilterModeNearest=0;const int $kFilterModeLinear=1;const int" " $kColorSpaceXformFlagUnpremul=1;const int $kColorSpaceXformFlagLinearize=2" ";const int $kColorSpaceXformFlagGamutTransform=4;const int $kColorSpaceXformFlagEncode" "=8;const int $kColorSpaceXformFlagPremul=16;const int $kColorSpaceXformFlagAlphaSwizzle" "=32;const int $kMaskFormatA8=0;const float $kLinearInset=.50001;$pure half4" " sk_error(){return half4(1.,0.,0.,1.);}$pure half4 sk_passthrough(half4 color" "){return color;}$pure half4 sk_solid_shader(float4 colorParam){return half4" "(colorParam);}$pure half4 sk_rgb_opaque(float4 colorParam){return half4(half3" "(colorParam.xyz),1.);}$pure half4 sk_alpha_only(float4 colorParam){return half4" "(0.,0.,0.,half(colorParam.w));}$pure float $apply_xfer_fn(int kind,float x," "half4[2]cs){float G=float(cs[0].x);float A=float(cs[0].y);float B=float(cs[" "0].z);float C=float(cs[0].w);float D=float(cs[1].x);float E=float(cs[1].y);" "float F=float(cs[1].z);float s=sign(x);x=abs(x);{float x_C;switch(kind){case" " 1:x=xsubset.z)return half4(0.);}" "if(tileModeY==$kTileModeDecal&&filterMode==$kFilterModeNearest){float snappedY" "=floor(pos.y)+.5;if(snappedYsubset.w)return half4(0.);}" "pos.x=$tile(tileModeX,pos.x,subset.x,subset.z);pos.y=$tile(tileModeY,pos.y," "subset.y,subset.w);float4 insetClamp;if(filterMode==$kFilterModeNearest)insetClamp" "=float4(floor(subset.xy)+$kLinearInset,ceil(subset.zw)-$kLinearInset);else insetClamp" "=float4(subset.xy+linearFilterInset.x,subset.zw-linearFilterInset.y);float2" " clampedPos=clamp(pos,insetClamp.xy,insetClamp.zw);half4 color=$sample_image" "(clampedPos,invImgSize,s);if(filterMode==$kFilterModeLinear){half2 error=half2" "(pos-clampedPos);half2 absError=abs(error);bool sampleExtraX=tileModeX==$kTileModeRepeat" ";bool sampleExtraY=tileModeY==$kTileModeRepeat;if(sampleExtraX||sampleExtraY" "){float extraCoordX;float extraCoordY;half4 extraColorX;half4 extraColorY;if" "(sampleExtraX){extraCoordX=error.x>0.?insetClamp.x:insetClamp.z;extraColorX" "=$sample_image(float2(extraCoordX,clampedPos.y),invImgSize,s);}if(sampleExtraY" "){extraCoordY=error.y>0.?insetClamp.y:insetClamp.w;extraColorY=$sample_image" "(float2(clampedPos.x,extraCoordY),invImgSize,s);}if(sampleExtraX&&sampleExtraY" "){half4 extraColorXY=$sample_image(float2(extraCoordX,extraCoordY),invImgSize" ",s);color=mix(mix(color,extraColorX,absError.x),mix(extraColorY,extraColorXY" ",absError.x),absError.y);}else if(sampleExtraX)color=mix(color,extraColorX," "absError.x);else if(sampleExtraY)color=mix(color,extraColorY,absError.y);}if" "(tileModeX==$kTileModeDecal)color*=max(1.-absError.x,0.);if(tileModeY==$kTileModeDecal" ")color*=max(1.-absError.y,0.);}return color;}$pure half4 $cubic_filter_image" "(float2 pos,float2 invImgSize,float4 subset,int tileModeX,int tileModeY,half4x4" " coeffs,sampler2D s){float2 f=fract(pos-.5);pos-=1.5;pos=floor(pos)+.5;half4" " wx=coeffs*half4(1.,half(f.x),half(f.x*f.x),half((f.x*f.x)*f.x));half4 wy=coeffs" "*half4(1.,half(f.y),half(f.y*f.y),half((f.y*f.y)*f.y));half4 color=half4(0." ");for(int y=0;y<4;++y){half4 rowColor=half4(0.);for(int x=0;x<4;++x)rowColor" "+=wx[x]*$sample_image_subset(pos+float2(float(x),float(y)),invImgSize,subset" ",tileModeX,tileModeY,$kFilterModeNearest,.50001.xx,s);color+=wy[y]*rowColor" ";}color.w=saturate(color.w);color.xyz=clamp(color.xyz,half3(0.),color.www);" "return color;}$pure half4 sk_image_shader(float2 coords,float2 invImgSize,float4" " subset,int tileModeX,int tileModeY,int filterMode,sampler2D s){return $sample_image_subset" "(coords,invImgSize,subset,tileModeX,tileModeY,filterMode,.50001.xx,s);}$pure" " half4 sk_cubic_image_shader(float2 coords,float2 invImgSize,float4 subset," "int tileModeX,int tileModeY,half4x4 cubicCoeffs,sampler2D s){return $cubic_filter_image" "(coords,invImgSize,subset,tileModeX,tileModeY,cubicCoeffs,s);}$pure half4 sk_hw_image_shader" "(float2 coords,float2 invImgSize,sampler2D s){return $sample_image(coords,invImgSize" ",s);}$pure half4 $yuv_to_rgb_no_swizzle(half Y,half U,half V,half alpha,half3x3" " yuvToRGBMatrix,half3 yuvToRGBTranslate){half3 preColor=half3(Y,U,V);half4 sampleColor" ";sampleColor.xyz=saturate(yuvToRGBMatrix*preColor+yuvToRGBTranslate);sampleColor" ".w=alpha;return sampleColor;}$pure half4 $yuv_to_rgb(half4 sampleColorY,half4" " sampleColorU,half4 sampleColorV,half alpha,half4 channelSelectY,half4 channelSelectU" ",half4 channelSelectV,half3x3 yuvToRGBMatrix,half3 yuvToRGBTranslate){half Y" "=dot(channelSelectY,sampleColorY);half U=dot(channelSelectU,sampleColorU);half" " V=dot(channelSelectV,sampleColorV);return $yuv_to_rgb_no_swizzle(Y,U,V,alpha" ",yuvToRGBMatrix,yuvToRGBTranslate);}$pure half4 sk_yuv_image_shader(float2 coords" ",float2 invImgSizeY,float2 invImgSizeUV,float4 subset,float2 linearFilterUVInset" ",int tileModeX,int tileModeY,int filterModeY,int filterModeUV,half4 channelSelectY" ",half4 channelSelectU,half4 channelSelectV,half4 channelSelectA,half3x3 yuvToRGBMatrix" ",half3 yuvToRGBTranslate,sampler2D sY,sampler2D sU,sampler2D sV,sampler2D sA" "){if(filterModeY!=filterModeUV)coords=floor(coords)+.5;int tileModeX_UV=tileModeX" "==$kTileModeDecal?$kTileModeClamp:tileModeX;int tileModeY_UV=tileModeY==$kTileModeDecal" "?$kTileModeClamp:tileModeY;half4 sampleColorY;half4 sampleColorU;half4 sampleColorV" ";sampleColorY=$sample_image_subset(coords,invImgSizeY,subset,tileModeX,tileModeY" ",filterModeY,.50001.xx,sY);sampleColorU=$sample_image_subset(coords,invImgSizeUV" ",subset,tileModeX_UV,tileModeY_UV,filterModeUV,linearFilterUVInset,sU);sampleColorV" "=$sample_image_subset(coords,invImgSizeUV,subset,tileModeX_UV,tileModeY_UV," "filterModeUV,linearFilterUVInset,sV);half alpha;if(channelSelectA==half4(1." "))alpha=1.;else{half4 sampleColorA=$sample_image_subset(coords,invImgSizeY," "subset,tileModeX,tileModeY,filterModeY,.50001.xx,sA);alpha=dot(channelSelectA" ",sampleColorA);}return $yuv_to_rgb(sampleColorY,sampleColorU,sampleColorV,alpha" ",channelSelectY,channelSelectU,channelSelectV,yuvToRGBMatrix,yuvToRGBTranslate" ");}$pure half4 sk_cubic_yuv_image_shader(float2 coords,float2 invImgSizeY,float2" " invImgSizeUV,float4 subset,int tileModeX,int tileModeY,half4x4 cubicCoeffs" ",half4 channelSelectY,half4 channelSelectU,half4 channelSelectV,half4 channelSelectA" ",half3x3 yuvToRGBMatrix,half3 yuvToRGBTranslate,sampler2D sY,sampler2D sU,sampler2D" " sV,sampler2D sA){int tileModeX_UV=tileModeX==$kTileModeDecal?$kTileModeClamp" ":tileModeX;int tileModeY_UV=tileModeY==$kTileModeDecal?$kTileModeClamp:tileModeY" ";half4 sampleColorY;half4 sampleColorU;half4 sampleColorV;sampleColorY=$cubic_filter_image" "(coords,invImgSizeY,subset,tileModeX,tileModeY,cubicCoeffs,sY);sampleColorU" "=$cubic_filter_image(coords,invImgSizeUV,subset,tileModeX_UV,tileModeY_UV,cubicCoeffs" ",sU);sampleColorV=$cubic_filter_image(coords,invImgSizeUV,subset,tileModeX_UV" ",tileModeY_UV,cubicCoeffs,sV);half alpha;if(channelSelectA==half4(1.))alpha" "=1.;else{half4 sampleColorA=$cubic_filter_image(coords,invImgSizeY,subset,tileModeX" ",tileModeY,cubicCoeffs,sA);alpha=dot(channelSelectA,sampleColorA);}return $yuv_to_rgb" "(sampleColorY,sampleColorU,sampleColorV,alpha,channelSelectY,channelSelectU" ",channelSelectV,yuvToRGBMatrix,yuvToRGBTranslate);}$pure half4 sk_hw_yuv_image_shader" "(float2 coords,float2 invImgSizeY,float2 invImgSizeUV,half4 channelSelectY," "half4 channelSelectU,half4 channelSelectV,half4 channelSelectA,half3x3 yuvToRGBMatrix" ",half3 yuvToRGBTranslate,sampler2D sY,sampler2D sU,sampler2D sV,sampler2D sA" "){half4 sampleColorY;half4 sampleColorU;half4 sampleColorV;sampleColorY=$sample_image" "(coords,invImgSizeY,sY);sampleColorU=$sample_image(coords,invImgSizeUV,sU);" "sampleColorV=$sample_image(coords,invImgSizeUV,sV);half alpha;if(channelSelectA" "==half4(1.))alpha=1.;else{half4 sampleColorA=$sample_image(coords,invImgSizeY" ",sA);alpha=dot(channelSelectA,sampleColorA);}return $yuv_to_rgb(sampleColorY" ",sampleColorU,sampleColorV,alpha,channelSelectY,channelSelectU,channelSelectV" ",yuvToRGBMatrix,yuvToRGBTranslate);}$pure half4 sk_hw_yuv_no_swizzle_image_shader" "(float2 coords,float2 invImgSizeY,float2 invImgSizeUV,half3x3 yuvToRGBMatrix" ",half4 yuvToRGBXlateAlphaParam,sampler2D sY,sampler2D sU,sampler2D sV,sampler2D" " sA){half Y=$sample_image(coords,invImgSizeY,sY).x;half U=$sample_image(coords" ",invImgSizeUV,sU).x;half V=$sample_image(coords,invImgSizeUV,sV).x;half alpha" "=saturate($sample_image(coords,invImgSizeY,sA).x+yuvToRGBXlateAlphaParam.w)" ";return $yuv_to_rgb_no_swizzle(Y,U,V,alpha,yuvToRGBMatrix,yuvToRGBXlateAlphaParam" ".xyz);}$pure half4 sk_dither(half4 colorIn,half range,sampler2D lut){half value" "=sample(lut,sk_FragCoord.xy*.125).x-.5;return half4(clamp(colorIn.xyz+value" "*range,0.,colorIn.w),colorIn.w);}$pure float2 $tile_grad(int tileMode,float2" " t){switch(tileMode){case 0:t.x=saturate(t.x);break;case 1:t.x=fract(t.x);break" ";case 2:{float t_1=t.x-1.;t.x=(t_1-2.*floor(t_1*.5))-1.;if(sk_Caps.mustDoOpBetweenFloorAndAbs" ")t.x=clamp(t.x,-1.,1.);t.x=abs(t.x);break;}case 3:if(t.x<0.||t.x>1.)return float2" "(0.,-1.);break;}return t;}$pure half4 $colorize_grad_4(float4[4]colorsParam" ",float4 offsetsParam,float2 t){if(t.y<0.)return half4(0.);else if(t.x<=offsetsParam" ".x)return half4(colorsParam[0]);else if(t.x=.0001?dist_grad*inversesqrt(dg_len2):half2(.7071);float2x2 jacobian" "=float2x2(dFdx(unormTexCoords),dFdy(unormTexCoords));half2 grad=half2(jacobian" "*float2(dist_grad));half approxFragWidth=.65*length(grad);if(gammaParams.y>" "0.)return saturate((dist+approxFragWidth)/(2.*approxFragWidth)).xxxx;else return" " smoothstep(-approxFragWidth,approxFragWidth,dist).xxxx;}$pure half4 sdf_text_lcd_coverage_fn" "(float2 textureCoords,half2 pixelGeometryDelta,half4 gammaParams,float2 unormTexCoords" ",float texIndex,sampler2D atlas0,sampler2D atlas1,sampler2D atlas2,sampler2D" " atlas3){float2x2 jacobian=float2x2(dFdx(unormTexCoords),dFdy(unormTexCoords" "));half2 offset=half2(jacobian*float2(pixelGeometryDelta));half3 distance=$sample_indexed_atlas_lcd" "(textureCoords,int(texIndex),offset,atlas0,atlas1,atlas2,atlas3);half3 dist" "=half3(7.96875)*(distance-half3(.5019608));dist-=gammaParams.xyz;half2 dist_grad" "=half2(dFdx(dist.y),dFdy(dist.y));half dg_len2=dot(dist_grad,dist_grad);dist_grad" "=dg_len2>=.0001?dist_grad*inversesqrt(dg_len2):half2(.7071);half2 grad=half2" "(jacobian*float2(dist_grad));half3 approxFragWidth=(.65*length(grad)).xxx;if" "(gammaParams.w>0.)return half4(saturate(dist+approxFragWidth/(2.*approxFragWidth" ")),1.);else return half4(smoothstep(-approxFragWidth,approxFragWidth,dist)," "1.);}$pure float $inverse_grad_len(float2 localGrad,float2x2 jacobian){float2" " devGrad=localGrad*jacobian;return inversesqrt(dot(devGrad,devGrad));}$pure" " float2 $elliptical_distance(float2 uv,float2 radii,float strokeRadius,float2x2" " jacobian){float2 invR2=1./(radii*radii+strokeRadius*strokeRadius);float2 normUV" "=invR2*uv;float invGradLength=$inverse_grad_len(normUV,jacobian);float f=(.5" "*invGradLength)*(dot(uv,normUV)-1.);float width=((radii.x*strokeRadius)*invR2" ".x)*invGradLength;return float2(width-f,width+f);}void $corner_distance(inout" " float2 dist,float2x2 jacobian,float2 strokeParams,float2 cornerEdgeDist,float2" " xyFlip,float2 radii){float2 uv=radii-cornerEdgeDist;if(all(greaterThan(uv," "0..xx)))if(all(greaterThan(radii,0..xx))||strokeParams.x>0.&&strokeParams.y" "<0.){float2 d=$elliptical_distance(uv*xyFlip,radii,strokeParams.x,jacobian)" ";d.y=radii.x-strokeParams.x<=0.?1.:-d.y;dist=min(dist,d);}else if(strokeParams" ".y==0.){float bevelDist=((strokeParams.x-uv.x)-uv.y)*$inverse_grad_len(xyFlip" ",jacobian);dist.x=min(dist.x,bevelDist);}}void $corner_distances(inout float2" " d,float2x2 J,float2 stroke,float4 edgeDists,float4 xRadii,float4 yRadii){$corner_distance" "(d,J,stroke,edgeDists.xy,-1..xx,float2(xRadii.x,yRadii.x));$corner_distance" "(d,J,stroke,edgeDists.zy,float2(1.,-1.),float2(xRadii.y,yRadii.y));$corner_distance" "(d,J,stroke,edgeDists.zw,1..xx,float2(xRadii.z,yRadii.z));$corner_distance(" "d,J,stroke,edgeDists.xw,float2(-1.,1.),float2(xRadii.w,yRadii.w));}$pure half4" " analytic_rrect_coverage_fn(float4 coords,float4 jacobian,float4 edgeDistances" ",float4 xRadii,float4 yRadii,float2 strokeParams,float2 perPixelControl){if" "(perPixelControl.x>0.)return half4(1.);else if(perPixelControl.y>1.){float2" " outerDist=min(edgeDistances.xy,edgeDistances.zw);float c=min(outerDist.x,outerDist" ".y)*coords.w;float scale=(perPixelControl.y-1.)*coords.w;float bias=coverage_bias" "(scale);return half(saturate(scale*(c+bias))).xxxx;}else{float2x2 J=float2x2" "(jacobian)*(1./coords.w);float2 invGradLen=float2($inverse_grad_len(float2(" "1.,0.),J),$inverse_grad_len(float2(0.,1.),J));float2 outerDist=invGradLen*(" "strokeParams.x+min(edgeDistances.xy,edgeDistances.zw));float2 d=float2(min(" "outerDist.x,outerDist.y),-1.);float scale;float bias;if(perPixelControl.x>-" ".95){float2 dim=invGradLen*((edgeDistances.xy+edgeDistances.zw)+2.*strokeParams" ".xx);scale=min(min(dim.x,dim.y),1.);bias=coverage_bias(scale);}else{float2 strokeWidth" "=(2.*strokeParams.x)*invGradLen;float2 innerDist=strokeWidth-outerDist;d.y=" "-max(innerDist.x,innerDist.y);if(strokeParams.x>0.){float narrowStroke=min(" "strokeWidth.x,strokeWidth.y);float2 strokeDim=mix(narrowStroke.xx,strokeWidth" ",greaterThanEqual(innerDist,-.5.xx));scale=saturate(max(strokeDim.x,strokeDim" ".y));bias=coverage_bias(scale);}else scale=(bias=1.);}$corner_distances(d,J" ",strokeParams,edgeDistances,xRadii,yRadii);float outsetDist=min(perPixelControl" ".y,0.)*coords.w;float finalCoverage=scale*(min(d.x+outsetDist,-d.y)+bias);return" " half(saturate(finalCoverage)).xxxx;}}$pure half4 per_edge_aa_quad_coverage_fn" "(float4 coords,float4 edgeDistances){float2 outerDist=min(edgeDistances.xy," "edgeDistances.zw);float c=min(outerDist.x,outerDist.y)*coords.w;return half" "(saturate(c)).xxxx;}$pure half4 circular_arc_coverage_fn(float4 circleEdge," "float3 clipPlane,float3 isectPlane,float3 unionPlane,float roundCapRadius,float4" " roundCapPos){float d=length(circleEdge.xy);half distanceToOuterEdge=half(circleEdge" ".z*(1.-d));half edgeAlpha=saturate(distanceToOuterEdge);half distanceToInnerEdge" "=half(circleEdge.z*(d-circleEdge.w));half innerAlpha=saturate(distanceToInnerEdge" ");edgeAlpha*=innerAlpha;half clip=half(saturate(circleEdge.z*dot(circleEdge" ".xy,clipPlane.xy)+clipPlane.z));clip*=half(saturate(circleEdge.z*dot(circleEdge" ".xy,isectPlane.xy)+isectPlane.z));clip=clip+half(saturate(circleEdge.z*dot(" "circleEdge.xy,unionPlane.xy)+unionPlane.z));half dcap1=half(circleEdge.z*(roundCapRadius" "-length(circleEdge.xy-roundCapPos.xy)));half dcap2=half(circleEdge.z*(roundCapRadius" "-length(circleEdge.xy-roundCapPos.zw)));half capAlpha=max(dcap1,0.)+max(dcap2" ",0.);clip=saturate(clip+capAlpha);return(clip*edgeAlpha).xxxx;}$pure half4 $rect_blur_coverage_fn" "(float2 coords,float4 rect,half isFast,half invSixSigma,sampler2D integral)" "{half xCoverage;half yCoverage;if(isFast!=0.){half2 pos=max(half2(rect.xy-coords" "),half2(coords-rect.zw));xCoverage=sample(integral,float2(float(invSixSigma" "*pos.x),.5)).x;yCoverage=sample(integral,float2(float(invSixSigma*pos.y),.5" ")).x;}else{half4 rect=half4(half2(rect.xy-coords),half2(coords-rect.zw));xCoverage" "=(1.-sample(integral,float2(float(invSixSigma*rect.x),.5)).x)-sample(integral" ",float2(float(invSixSigma*rect.z),.5)).x;yCoverage=(1.-sample(integral,float2" "(float(invSixSigma*rect.y),.5)).x)-sample(integral,float2(float(invSixSigma" "*rect.w),.5)).x;}return(xCoverage*yCoverage).xxxx;}$pure half4 $circle_blur_coverage_fn" "(float2 coords,float4 circle,sampler2D blurProfile){float invTextureRadius=" "circle.z;float normSolidRadius=circle.w;half2 vec=half2((coords-circle.xy)*" "invTextureRadius);float dist=float(length(vec))-normSolidRadius;return sample" "(blurProfile,float2(dist,.5)).xxxx;}$pure half4 $rrect_blur_coverage_fn(float2" " coords,float4 proxyRect,half edgeSize,sampler2D ninePatch){float2 translatedFragPosFloat" "=coords-proxyRect.xy;float2 proxyCenter=(proxyRect.zw-proxyRect.xy)*.5;translatedFragPosFloat" "-=proxyCenter;half2 fragDirection=half2(sign(translatedFragPosFloat));translatedFragPosFloat" "=abs(translatedFragPosFloat);half2 translatedFragPosHalf=half2(translatedFragPosFloat" "-(proxyCenter-float(edgeSize)));translatedFragPosHalf=max(translatedFragPosHalf" ",0.);translatedFragPosHalf*=fragDirection;translatedFragPosHalf+=edgeSize.xx" ";half2 proxyDims=(2.*edgeSize).xx;half2 texCoord=translatedFragPosHalf/proxyDims" ";return sample(ninePatch,float2(texCoord)).xxxx;}$pure half4 blur_coverage_fn" "(float2 coords,float4 shapeData,half2 blurData,int shapeType,sampler2D s){switch" "(shapeType){case 0:{return $rect_blur_coverage_fn(coords,shapeData,blurData" ".x,blurData.y,s);}case 2:{return $circle_blur_coverage_fn(coords,shapeData," "s);}case 1:{return $rrect_blur_coverage_fn(coords,shapeData,blurData.x,s);}" "}return half4(0.);}";