| 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" |
| " $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_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 float3 $apply_srgb_xfer_fn(float3 x,float4 gabc" |
| ",float3 def){return mix(pow(gabc.y*x+gabc.z,gabc.x.xxx)+def.y,gabc.w*x+def." |
| "z,lessThan(x,def.x.xxx));}$pure float3 $apply_pq_xfer_fn(float3 x,float3 abc" |
| ",float3 def){float3 x_C=pow(x,abc.z.xxx);return pow(max(abc.x+abc.y*x_C,0.)" |
| "/(def.x+def.y*x_C),def.z.xxx);}$pure float3 $apply_hlg_xfer_fn(float3 x,float3" |
| " abc,float3 def){return(def.z+1.)*mix(exp((x-def.y)*abc.z)+def.x,pow(x*abc." |
| "x,abc.y.xxx),lessThanEqual(x*abc.x,1..xxx));}$pure float3 $apply_hlg_inv_xfer_fn" |
| "(float3 x,float3 abc,float3 def){x/=def.z+1.;return mix(abc.z*log(x-def.x)+" |
| "def.y,abc.x*pow(x,abc.y.xxx),lessThanEqual(x,1..xxx));}$pure half4 sk_color_space_transform" |
| "(half4 color,half3x3 gamut,float4 srcGABC,float4 srcDEF_args,float4 dstGABC" |
| ",float4 dstDEF_args,float4 srcOOTF_args,float4 dstOOTF_args){if(srcDEF_args" |
| ".w<0.)color=unpremul(color);else{half alphaSwizzleA=1.-half(srcDEF_args.w);" |
| "half alphaSwizzle1=half(srcDEF_args.w)*half(dstDEF_args.w);half alphaSwizzleR" |
| "=half(srcDEF_args.w)-alphaSwizzle1;color.w=dot(half3(color.wx,1.),half3(alphaSwizzleA" |
| ",alphaSwizzleR,alphaSwizzle1));}float3 colorF=float3(color.xyz);if(srcGABC." |
| "x>0.)colorF=sign(colorF)*$apply_srgb_xfer_fn(abs(colorF),srcGABC,srcDEF_args" |
| ".xyz);else if(srcGABC.x<-1.)colorF=sign(colorF)*$apply_pq_xfer_fn(abs(colorF" |
| "),srcGABC.yzw,srcDEF_args.xyz);else if(srcGABC.x<0.)colorF=sign(colorF)*$apply_hlg_xfer_fn" |
| "(abs(colorF),srcGABC.yzw,srcDEF_args.xyz);if(srcOOTF_args.w!=0.){float Y=dot" |
| "(srcOOTF_args.xyz,colorF);colorF*=sign(Y)*pow(abs(Y),srcOOTF_args.w);}colorF" |
| "=float3x3(gamut)*colorF;if(dstOOTF_args.w!=0.){float Y=dot(dstOOTF_args.xyz" |
| ",colorF);colorF*=sign(Y)*pow(abs(Y),dstOOTF_args.w);}if(dstGABC.x>0.)colorF" |
| "=sign(colorF)*$apply_srgb_xfer_fn(abs(colorF),dstGABC,dstDEF_args.xyz);else" |
| " if(dstGABC.x<-1.)colorF=sign(colorF)*$apply_pq_xfer_fn(abs(colorF),dstGABC" |
| ".yzw,dstDEF_args.xyz);else if(dstGABC.x<0.)colorF=sign(colorF)*$apply_hlg_inv_xfer_fn" |
| "(abs(colorF),dstGABC.yzw,dstDEF_args.xyz);half noPremul=half(dstDEF_args.w)" |
| ";color.xyz=half3(colorF)*max(color.w,noPremul);return color;}$pure half4 sk_color_space_transform_premul" |
| "(half4 color,half2 args){if(args.x<0.)color=unpremul(color);else{half opaque" |
| "=args.x;half noPremul=args.y;color.w=max(color.w,opaque);color.xyz=color.xyz" |
| "*max(color.w,noPremul);}return color;}$pure half4 sk_color_space_transform_srgb" |
| "(half4 color,half3x3 gamut,float4 srcGABC,float4 srcDEF_args,float4 dstGABC" |
| ",float4 dstDEF_args){if(srcDEF_args.w<0.)color=unpremul(color);else{half alphaSwizzleA" |
| "=1.-half(srcDEF_args.w);half alphaSwizzle1=half(srcDEF_args.w)*half(dstDEF_args" |
| ".w);half alphaSwizzleR=half(srcDEF_args.w)-alphaSwizzle1;color.w=dot(half3(" |
| "color.wx,1.),half3(alphaSwizzleA,alphaSwizzleR,alphaSwizzle1));}float3 colorF" |
| "=float3(color.xyz);colorF=sign(colorF)*$apply_srgb_xfer_fn(abs(colorF),srcGABC" |
| ",srcDEF_args.xyz);colorF=float3x3(gamut)*colorF;colorF=sign(colorF)*$apply_srgb_xfer_fn" |
| "(abs(colorF),dstGABC,dstDEF_args.xyz);half noPremul=half(dstDEF_args.w);color" |
| ".xyz=half3(colorF)*max(color.w,noPremul);return color;}$pure half4 sk_analytic_clip" |
| "(float2 coords,float4 rect,float2 radiusPlusHalf,half4 edgeSelect){float2 radius" |
| "=abs(radiusPlusHalf.x).xx;float2 dxy0=float2(edgeSelect.xy)*((rect.xy+radius" |
| ")-coords);float2 dxy1=float2(edgeSelect.zw)*(coords-(rect.zw-radius));float2" |
| " dxy=max(max(dxy0,dxy1),0.);half circleCornerAlpha=half(saturate(radius.x*(" |
| "1.-length(dxy*radiusPlusHalf.y))));half4 rectEdgeAlphas=saturate(half4(half2" |
| "(coords-rect.xy),half2(rect.zw-coords)));rectEdgeAlphas=mix(rectEdgeAlphas," |
| "half4(1.),edgeSelect);half alpha=(((circleCornerAlpha*rectEdgeAlphas.x)*rectEdgeAlphas" |
| ".y)*rectEdgeAlphas.z)*rectEdgeAlphas.w;alpha=radiusPlusHalf.x<0.?1.-alpha:alpha" |
| ";return alpha.xxxx;}$pure half4 sk_analytic_and_atlas_clip(float2 coords,float4" |
| " rect,float2 radiusPlusHalf,half4 edgeSelect,float2 texCoordOffset,float4 maskBounds" |
| ",float2 invAtlasSize,sampler2D atlasSampler){half4 analyticClip=sk_analytic_clip" |
| "(coords,rect,radiusPlusHalf,edgeSelect);float2 texCoord=coords+texCoordOffset" |
| ";float2 clampedTexCoord=clamp(texCoord,maskBounds.xy,maskBounds.zw);half atlasClip" |
| "=sample(atlasSampler,clampedTexCoord*invAtlasSize).x;return analyticClip*atlasClip" |
| ";}$pure float $tile(int tileMode,float f,float low,float high){switch(tileMode" |
| "){case 0:return clamp(f,low,high);case 1:{float length=high-low;return mod(" |
| "f-low,length)+low;}case 2:{float length=high-low;float length2=2.*length;float" |
| " tmp=mod(f-low,length2);return mix(tmp,length2-tmp,step(length,tmp))+low;}default" |
| ":return f;}}$pure half4 $sample_image(float2 pos,float2 invImgSize,sampler2D" |
| " s){return sample(s,pos*invImgSize);}$pure half4 $sample_image_subset(float2" |
| " pos,float2 invImgSize,float4 subset,int tileModeX,int tileModeY,int filterMode" |
| ",float2 linearFilterInset,sampler2D s){if(tileModeX==$kTileModeDecal&&filterMode" |
| "==$kFilterModeNearest){float snappedX=floor(pos.x)+.5;if(snappedX<subset.x||" |
| "snappedX>subset.z)return half4(0.);}if(tileModeY==$kTileModeDecal&&filterMode" |
| "==$kFilterModeNearest){float snappedY=floor(pos.y)+.5;if(snappedY<subset.y||" |
| "snappedY>subset.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" |
| ",subset.zw-linearFilterInset);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_image_shader_clamp(float2 coords,float2 invImgSize,float4 subsetInsetClamp" |
| ",sampler2D s){return $sample_image(clamp(coords,subsetInsetClamp.xy,subsetInsetClamp" |
| ".zw),invImgSize,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,sampler2D s){return sample" |
| "(s,coords);}$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,float4 subset,float2 linearFilterUVInset" |
| ",half4 channelSelectY,half4 channelSelectU,half4 channelSelectV,half4 channelSelectA" |
| ",half3x3 yuvToRGBMatrix,half3 yuvToRGBTranslate,sampler2D sY,sampler2D sU,sampler2D" |
| " sV,sampler2D sA){float4 subsetUV=subset;if(linearFilterUVInset.x<0.){coords" |
| "=floor(coords)+.5;subset=float4(floor(subset.xy),ceil(subset.zw));}float2 coordsUV" |
| "=coords;if(linearFilterUVInset.y<0.){linearFilterUVInset=abs(linearFilterUVInset" |
| ");coordsUV=clamp(coords,subsetUV.xy+linearFilterUVInset,subsetUV.zw-linearFilterUVInset" |
| ");coords=clamp(coords,subset.xy+$kLinearInset,subset.zw-$kLinearInset);}half4" |
| " sampleColorY;half4 sampleColorU;half4 sampleColorV;sampleColorY=$sample_image" |
| "(coords,invImgSizeY,sY);sampleColorU=$sample_image(coordsUV,invImgSizeUV,sU" |
| ");sampleColorV=$sample_image(coordsUV,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,float4 subset,float2 linearFilterUVInset" |
| ",half3x3 yuvToRGBMatrix,half4 yuvToRGBXlateAlphaParam,sampler2D sY,sampler2D" |
| " sU,sampler2D sV,sampler2D sA){float4 subsetUV=subset;if(linearFilterUVInset" |
| ".x<0.){coords=floor(coords)+.5;subset=float4(floor(subset.xy),ceil(subset.zw" |
| "));}float2 coordsUV=coords;if(linearFilterUVInset.y<0.){linearFilterUVInset" |
| "=abs(linearFilterUVInset);coordsUV=clamp(coords,subsetUV.xy+linearFilterUVInset" |
| ",subsetUV.zw-linearFilterUVInset);coords=clamp(coords,subset.xy+$kLinearInset" |
| ",subset.zw-$kLinearInset);}half Y=$sample_image(coords,invImgSizeY,sY).x;half" |
| " U=$sample_image(coordsUV,invImgSizeUV,sU).x;half V=$sample_image(coordsUV," |
| "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<offsetsParam.y)return half4(mix(colorsParam[0],colorsParam" |
| "[1],(t.x-offsetsParam.x)/(offsetsParam.y-offsetsParam.x)));else if(t.x<offsetsParam" |
| ".z)return half4(mix(colorsParam[1],colorsParam[2],(t.x-offsetsParam.y)/(offsetsParam" |
| ".z-offsetsParam.y)));else if(t.x<offsetsParam.w)return half4(mix(colorsParam" |
| "[2],colorsParam[3],(t.x-offsetsParam.z)/(offsetsParam.w-offsetsParam.z)));else" |
| " return half4(colorsParam[3]);}$pure half4 $colorize_grad_8(float4[8]colorsParam" |
| ",float4[2]offsetsParam,float2 t){if(t.y<0.)return half4(0.);else if(t.x<offsetsParam" |
| "[1].x)if(t.x<offsetsParam[0].z)if(t.x<=offsetsParam[0].x)return half4(colorsParam" |
| "[0]);else if(t.x<offsetsParam[0].y)return half4(mix(colorsParam[0],colorsParam" |
| "[1],(t.x-offsetsParam[0].x)/(offsetsParam[0].y-offsetsParam[0].x)));else return" |
| " half4(mix(colorsParam[1],colorsParam[2],(t.x-offsetsParam[0].y)/(offsetsParam" |
| "[0].z-offsetsParam[0].y)));else if(t.x<offsetsParam[0].w)return half4(mix(colorsParam" |
| "[2],colorsParam[3],(t.x-offsetsParam[0].z)/(offsetsParam[0].w-offsetsParam[" |
| "0].z)));else return half4(mix(colorsParam[3],colorsParam[4],(t.x-offsetsParam" |
| "[0].w)/(offsetsParam[1].x-offsetsParam[0].w)));else if(t.x<offsetsParam[1]." |
| "z)if(t.x<offsetsParam[1].y)return half4(mix(colorsParam[4],colorsParam[5],(" |
| "t.x-offsetsParam[1].x)/(offsetsParam[1].y-offsetsParam[1].x)));else return half4" |
| "(mix(colorsParam[5],colorsParam[6],(t.x-offsetsParam[1].y)/(offsetsParam[1]" |
| ".z-offsetsParam[1].y)));else if(t.x<offsetsParam[1].w)return half4(mix(colorsParam" |
| "[6],colorsParam[7],(t.x-offsetsParam[1].z)/(offsetsParam[1].w-offsetsParam[" |
| "1].z)));else return half4(colorsParam[7]);}$pure half4 $colorize_grad_tex(sampler2D" |
| " colorsAndOffsetsSampler,int numStops,float2 t){if(t.y<0.)return half4(0.);" |
| "else if(t.x==0.)return sampleLod(colorsAndOffsetsSampler,float2(0.,.25),0.)" |
| ";else if(t.x==1.)return sampleLod(colorsAndOffsetsSampler,float2(1.,.25),0." |
| ");else{float low=0.;float high=float(numStops);float invNumStops=1./high;for" |
| "(int loop=1;loop<numStops;loop+=loop){float mid=floor((low+high)*.5);float samplePos" |
| "=(mid+.5)*invNumStops;float2 tmp=float2(sampleLod(colorsAndOffsetsSampler,float2" |
| "(samplePos,.75),0.).xy);float offset=ldexp(tmp.x,int(tmp.y));if(t.x<offset)" |
| "high=mid;else low=mid;}high=(low+1.5)*invNumStops;low=(low+.5)*invNumStops;" |
| "half4 color0=sampleLod(colorsAndOffsetsSampler,float2(low,.25),0.);half4 color1" |
| "=sampleLod(colorsAndOffsetsSampler,float2(high,.25),0.);float2 tmp=float2(sampleLod" |
| "(colorsAndOffsetsSampler,float2(low,.75),0.).xy);float offset0=ldexp(tmp.x," |
| "int(tmp.y));tmp=float2(sampleLod(colorsAndOffsetsSampler,float2(high,.75),0." |
| ").xy);float offset1=ldexp(tmp.x,int(tmp.y));return half4(mix(float4(color0)" |
| ",float4(color1),(t.x-offset0)/(offset1-offset0)));}}$pure half4 $half4_from_array" |
| "(float[]arr,int offset){return half4(half(arr[offset]),half(arr[offset+1])," |
| "half(arr[offset+2]),half(arr[offset+3]));}$pure half4 $colorize_grad_buf(float" |
| "[]colorAndOffsetData,int offsetsBaseIndex,int numStops,float2 t){int colorsBaseIndex" |
| "=offsetsBaseIndex+numStops;if(t.y<0.)return half4(0.);else if(t.x==0.)return" |
| " $half4_from_array(colorAndOffsetData,colorsBaseIndex);else if(t.x==1.){int" |
| " lastColorIndex=colorsBaseIndex+(numStops-1)*4;return $half4_from_array(colorAndOffsetData" |
| ",lastColorIndex);}else{int lowOffsetIndex=offsetsBaseIndex;int highOffsetIndex" |
| "=(lowOffsetIndex+numStops)-1;for(int i=1;i<numStops;i+=i){int middleOffsetIndex" |
| "=(lowOffsetIndex+highOffsetIndex)/2;if(t.x<colorAndOffsetData[middleOffsetIndex" |
| "])highOffsetIndex=middleOffsetIndex;else lowOffsetIndex=middleOffsetIndex;}" |
| "int lowColorIndex=colorsBaseIndex+(lowOffsetIndex-offsetsBaseIndex)*4;float" |
| " lowOffset=colorAndOffsetData[lowOffsetIndex];half4 lowColor=$half4_from_array" |
| "(colorAndOffsetData,lowColorIndex);int highColorIndex=colorsBaseIndex+(highOffsetIndex" |
| "-offsetsBaseIndex)*4;float highOffset=colorAndOffsetData[highOffsetIndex];if" |
| "(highOffset==lowOffset)return lowColor;else{half4 highColor=$half4_from_array" |
| "(colorAndOffsetData,highColorIndex);return half4(mix(float4(lowColor),float4" |
| "(highColor),(t.x-lowOffset)/(highOffset-lowOffset)));}}}$pure float2 $linear_grad_layout" |
| "(float2 pos){return float2(pos.x+1e-05,1.);}$pure float2 $radial_grad_layout" |
| "(float2 pos){float t=length(pos);return float2(t,1.);}$pure float2 $sweep_grad_layout" |
| "(float biasParam,float scaleParam,float2 pos){float angle;if(sk_Caps.atan2ImplementedAsAtanYOverX" |
| ")angle=2.*atan(-pos.y,length(pos)-pos.x);else angle=pos.x!=0.?atan(-pos.y,-" |
| "pos.x):sign(pos.y)*-1.57079637;float t=((angle*.159154937+.5)+biasParam)*scaleParam" |
| ";return float2(t,1.);}$pure float2 $conical_grad_layout(float radius0,float" |
| " dRadius,float a,float invA,float2 pos){if(a==0.&&invA==1.){float t=length(" |
| "pos)*dRadius-radius0;return float2(t,1.);}else{float c=dot(pos,pos)-radius0" |
| "*radius0;float negB=2.*(dRadius*radius0+pos.x);float t;if(a==0.)t=c/negB;else" |
| "{float d=negB*negB-(4.*a)*c;if(d<0.)return float2(0.,-1.);float quadSign=sign" |
| "(1.-dRadius);t=invA*(negB+quadSign*sqrt(d));}float isValid=sign(t*dRadius+radius0" |
| ");return float2(t,isValid);}}$pure half4 sk_linear_grad_4_shader(float2 coords" |
| ",float4[4]colorsParam,float4 offsetsParam,int tileMode,int colorSpace,int doUnpremul" |
| "){float2 t=$linear_grad_layout(coords);t=$tile_grad(tileMode,t);half4 color" |
| "=$colorize_grad_4(colorsParam,offsetsParam,t);return $interpolated_to_rgb_unpremul" |
| "(color,colorSpace,doUnpremul);}$pure half4 sk_linear_grad_8_shader(float2 coords" |
| ",float4[8]colorsParam,float4[2]offsetsParam,int tileMode,int colorSpace,int" |
| " doUnpremul){float2 t=$linear_grad_layout(coords);t=$tile_grad(tileMode,t);" |
| "half4 color=$colorize_grad_8(colorsParam,offsetsParam,t);return $interpolated_to_rgb_unpremul" |
| "(color,colorSpace,doUnpremul);}$pure half4 sk_linear_grad_tex_shader(float2" |
| " coords,int numStops,int tileMode,int colorSpace,int doUnpremul,sampler2D colorAndOffsetSampler" |
| "){float2 t=$linear_grad_layout(coords);t=$tile_grad(tileMode,t);half4 color" |
| "=$colorize_grad_tex(colorAndOffsetSampler,numStops,t);return $interpolated_to_rgb_unpremul" |
| "(color,colorSpace,doUnpremul);}$pure half4 sk_linear_grad_buf_shader(float2" |
| " coords,int numStops,int bufferOffset,int tileMode,int colorSpace,int doUnpremul" |
| ",float[]colorAndOffsetData){float2 t=$linear_grad_layout(coords);t=$tile_grad" |
| "(tileMode,t);half4 color=$colorize_grad_buf(colorAndOffsetData,bufferOffset" |
| ",numStops,t);return $interpolated_to_rgb_unpremul(color,colorSpace,doUnpremul" |
| ");}$pure half4 sk_radial_grad_4_shader(float2 coords,float4[4]colorsParam,float4" |
| " offsetsParam,int tileMode,int colorSpace,int doUnpremul){float2 t=$radial_grad_layout" |
| "(coords);t=$tile_grad(tileMode,t);half4 color=$colorize_grad_4(colorsParam," |
| "offsetsParam,t);return $interpolated_to_rgb_unpremul(color,colorSpace,doUnpremul" |
| ");}$pure half4 sk_radial_grad_8_shader(float2 coords,float4[8]colorsParam,float4" |
| "[2]offsetsParam,int tileMode,int colorSpace,int doUnpremul){float2 t=$radial_grad_layout" |
| "(coords);t=$tile_grad(tileMode,t);half4 color=$colorize_grad_8(colorsParam," |
| "offsetsParam,t);return $interpolated_to_rgb_unpremul(color,colorSpace,doUnpremul" |
| ");}$pure half4 sk_radial_grad_tex_shader(float2 coords,int numStops,int tileMode" |
| ",int colorSpace,int doUnpremul,sampler2D colorAndOffsetSampler){float2 t=$radial_grad_layout" |
| "(coords);t=$tile_grad(tileMode,t);half4 color=$colorize_grad_tex(colorAndOffsetSampler" |
| ",numStops,t);return $interpolated_to_rgb_unpremul(color,colorSpace,doUnpremul" |
| ");}$pure half4 sk_radial_grad_buf_shader(float2 coords,int numStops,int bufferOffset" |
| ",int tileMode,int colorSpace,int doUnpremul,float[]colorAndOffsetData){float2" |
| " t=$radial_grad_layout(coords);t=$tile_grad(tileMode,t);half4 color=$colorize_grad_buf" |
| "(colorAndOffsetData,bufferOffset,numStops,t);return $interpolated_to_rgb_unpremul" |
| "(color,colorSpace,doUnpremul);}$pure half4 sk_sweep_grad_4_shader(float2 coords" |
| ",float4[4]colorsParam,float4 offsetsParam,float biasParam,float scaleParam," |
| "int tileMode,int colorSpace,int doUnpremul){float2 t=$sweep_grad_layout(biasParam" |
| ",scaleParam,coords);t=$tile_grad(tileMode,t);half4 color=$colorize_grad_4(colorsParam" |
| ",offsetsParam,t);return $interpolated_to_rgb_unpremul(color,colorSpace,doUnpremul" |
| ");}$pure half4 sk_sweep_grad_8_shader(float2 coords,float4[8]colorsParam,float4" |
| "[2]offsetsParam,float biasParam,float scaleParam,int tileMode,int colorSpace" |
| ",int doUnpremul){float2 t=$sweep_grad_layout(biasParam,scaleParam,coords);t" |
| "=$tile_grad(tileMode,t);half4 color=$colorize_grad_8(colorsParam,offsetsParam" |
| ",t);return $interpolated_to_rgb_unpremul(color,colorSpace,doUnpremul);}$pure" |
| " half4 sk_sweep_grad_tex_shader(float2 coords,float biasParam,float scaleParam" |
| ",int numStops,int tileMode,int colorSpace,int doUnpremul,sampler2D colorAndOffsetSampler" |
| "){float2 t=$sweep_grad_layout(biasParam,scaleParam,coords);t=$tile_grad(tileMode" |
| ",t);half4 color=$colorize_grad_tex(colorAndOffsetSampler,numStops,t);return" |
| " $interpolated_to_rgb_unpremul(color,colorSpace,doUnpremul);}$pure half4 sk_sweep_grad_buf_shader" |
| "(float2 coords,float biasParam,float scaleParam,int numStops,int bufferOffset" |
| ",int tileMode,int colorSpace,int doUnpremul,float[]colorAndOffsetData){float2" |
| " t=$sweep_grad_layout(biasParam,scaleParam,coords);t=$tile_grad(tileMode,t)" |
| ";half4 color=$colorize_grad_buf(colorAndOffsetData,bufferOffset,numStops,t)" |
| ";return $interpolated_to_rgb_unpremul(color,colorSpace,doUnpremul);}$pure half4" |
| " sk_conical_grad_4_shader(float2 coords,float4[4]colorsParam,float4 offsetsParam" |
| ",float radius0Param,float dRadiusParam,float aParam,float invAParam,int tileMode" |
| ",int colorSpace,int doUnpremul){float2 t=$conical_grad_layout(radius0Param," |
| "dRadiusParam,aParam,invAParam,coords);t=$tile_grad(tileMode,t);half4 color=" |
| "$colorize_grad_4(colorsParam,offsetsParam,t);return $interpolated_to_rgb_unpremul" |
| "(color,colorSpace,doUnpremul);}$pure half4 sk_conical_grad_8_shader(float2 coords" |
| ",float4[8]colorsParam,float4[2]offsetsParam,float radius0Param,float dRadiusParam" |
| ",float aParam,float invAParam,int tileMode,int colorSpace,int doUnpremul){float2" |
| " t=$conical_grad_layout(radius0Param,dRadiusParam,aParam,invAParam,coords);" |
| "t=$tile_grad(tileMode,t);half4 color=$colorize_grad_8(colorsParam,offsetsParam" |
| ",t);return $interpolated_to_rgb_unpremul(color,colorSpace,doUnpremul);}$pure" |
| " half4 sk_conical_grad_tex_shader(float2 coords,float radius0Param,float dRadiusParam" |
| ",float aParam,float invAParam,int numStops,int tileMode,int colorSpace,int doUnpremul" |
| ",sampler2D colorAndOffsetSampler){float2 t=$conical_grad_layout(radius0Param" |
| ",dRadiusParam,aParam,invAParam,coords);t=$tile_grad(tileMode,t);half4 color" |
| "=$colorize_grad_tex(colorAndOffsetSampler,numStops,t);return $interpolated_to_rgb_unpremul" |
| "(color,colorSpace,doUnpremul);}$pure half4 sk_conical_grad_buf_shader(float2" |
| " coords,float radius0Param,float dRadiusParam,float aParam,float invAParam," |
| "int numStops,int bufferOffset,int tileMode,int colorSpace,int doUnpremul,float" |
| "[]colorAndOffsetData){float2 t=$conical_grad_layout(radius0Param,dRadiusParam" |
| ",aParam,invAParam,coords);t=$tile_grad(tileMode,t);half4 color=$colorize_grad_buf" |
| "(colorAndOffsetData,bufferOffset,numStops,t);return $interpolated_to_rgb_unpremul" |
| "(color,colorSpace,doUnpremul);}$pure half4 sk_hsl_matrix_colorfilter(half4 color" |
| ",half4x4 m,half4 v){color=$rgb_to_hsl(color.xyz,color.w);color=m*color+v;return" |
| " $hsl_to_rgb(color.xyz,color.w);}$pure half4 sk_matrix_colorfilter(half4 color" |
| ",half4x4 m,half4 v,half2 minMaxRGB){color=unpremul(color);color=m*color+v;color" |
| "=clamp(color,half4(minMaxRGB.xxx,0.),half4(minMaxRGB.yyy,1.));color.xyz*=color" |
| ".w;return color;}$pure half4 $noise_helper(half2 noiseVec,half2 stitchData," |
| "int stitching,sampler2D permutationSampler){const half kBlockSize=256.;half4" |
| " floorVal;floorVal.xy=floor(noiseVec);floorVal.zw=floorVal.xy+half2(1.);if(" |
| "bool(stitching))floorVal-=step(stitchData.xyxy,floorVal)*stitchData.xyxy;half" |
| " sampleX=sample(permutationSampler,float2(half2((floorVal.x+.5)*.00390625,.5" |
| "))).x;half sampleY=sample(permutationSampler,float2(half2((floorVal.z+.5)*.00390625" |
| ",.5))).x;half2 latticeIdx=half2(sampleX,sampleY);if(sk_Caps.PerlinNoiseRoundingFix" |
| ")latticeIdx=floor(latticeIdx*half2(255.)+half2(.5))*half2(.003921569);half4" |
| " noiseXCoords=kBlockSize*latticeIdx.xyxy+floorVal.yyww;noiseXCoords*=half4(" |
| ".00390625);return noiseXCoords;}$pure half4 $noise_function(half2 noiseVec," |
| "half4 noiseXCoords,sampler2D noiseSampler){half2 fractVal=fract(noiseVec);half2" |
| " noiseSmooth=smoothstep(0.,1.,fractVal);const half kInv256=.00390625;half4 result" |
| ";for(int channel=0;channel<4;channel++){half chanCoord=(half(channel)+.5)*.25" |
| ";half4 sampleA=sample(noiseSampler,float2(float(noiseXCoords.x),float(chanCoord" |
| ")));half4 sampleB=sample(noiseSampler,float2(float(noiseXCoords.y),float(chanCoord" |
| ")));half4 sampleC=sample(noiseSampler,float2(float(noiseXCoords.w),float(chanCoord" |
| ")));half4 sampleD=sample(noiseSampler,float2(float(noiseXCoords.z),float(chanCoord" |
| ")));half2 tmpFractVal=fractVal;half u=dot((sampleA.yw+sampleA.xz*kInv256)*2." |
| "-1.,tmpFractVal);tmpFractVal.x-=1.;half v=dot((sampleB.yw+sampleB.xz*kInv256" |
| ")*2.-1.,tmpFractVal);half a=mix(u,v,noiseSmooth.x);tmpFractVal.y-=1.;v=dot(" |
| "(sampleC.yw+sampleC.xz*kInv256)*2.-1.,tmpFractVal);tmpFractVal.x+=1.;u=dot(" |
| "(sampleD.yw+sampleD.xz*kInv256)*2.-1.,tmpFractVal);half b=mix(u,v,noiseSmooth" |
| ".x);result[channel]=mix(a,b,noiseSmooth.y);}return result;}$pure half4 sk_perlin_noise_shader" |
| "(float2 coords,float2 baseFrequency,float2 stitchDataIn,int noiseType,int numOctaves" |
| ",int stitching,sampler2D permutationSampler,sampler2D noiseSampler){const int" |
| " kFractalNoise=0;half2 noiseVec=half2((coords+.5)*baseFrequency);half4 color" |
| "=half4(0.);half2 stitchData=half2(stitchDataIn);half ratio=1.;for(int octave" |
| "=0;octave<numOctaves;++octave){half4 noiseXCoords=$noise_helper(noiseVec,stitchData" |
| ",stitching,permutationSampler);half4 tmp=$noise_function(noiseVec,noiseXCoords" |
| ",noiseSampler);if(noiseType!=kFractalNoise)tmp=abs(tmp);color+=tmp*ratio;noiseVec" |
| "*=half2(2.);ratio*=.5;stitchData*=half2(2.);}if(noiseType==kFractalNoise)color" |
| "=color*half4(.5)+half4(.5);color=saturate(color);return half4(color.xyz*color" |
| ".w,color.w);}$pure half4 sk_porter_duff_blend(half4 src,half4 dst,half4 coeffs" |
| "){return blend_porter_duff(coeffs,src,dst);}$pure half4 sk_hslc_blend(half4" |
| " src,half4 dst,half2 flipSat){return blend_hslc(flipSat,src,dst);}$pure half4" |
| " sk_table_colorfilter(half4 inColor,sampler2D s){half4 coords=unpremul(inColor" |
| ")*.99609375+.001953125;half4 color=half4(sample(s,float2(half2(coords.x,.375" |
| "))).x,sample(s,float2(half2(coords.y,.625))).x,sample(s,float2(half2(coords" |
| ".z,.875))).x,1.);return color*sample(s,float2(half2(coords.w,.125))).x;}$pure" |
| " half4 sk_gaussian_colorfilter(half4 inColor){half factor=1.-inColor.w;factor" |
| "=exp((-factor*factor)*4.)-.018;return factor.xxxx;}$pure half4 sample_indexed_atlas" |
| "(float2 textureCoords,int atlasIndex,sampler2D atlas0,sampler2D atlas1,sampler2D" |
| " atlas2,sampler2D atlas3){switch(atlasIndex){case 1:return sample(atlas1,textureCoords" |
| ");case 2:return sample(atlas2,textureCoords);case 3:return sample(atlas3,textureCoords" |
| ");default:return sample(atlas0,textureCoords);}}$pure half3 $sample_indexed_atlas_lcd" |
| "(float2 textureCoords,int atlasIndex,float2 offset,sampler2D atlas0,sampler2D" |
| " atlas1,sampler2D atlas2,sampler2D atlas3){half3 distance=half3(1.);switch(" |
| "atlasIndex){case 1:distance.x=sample(atlas1,textureCoords-offset).x;distance" |
| ".y=sample(atlas1,textureCoords).x;distance.z=sample(atlas1,textureCoords+offset" |
| ").x;break;case 2:distance.x=sample(atlas2,textureCoords-offset).x;distance." |
| "y=sample(atlas2,textureCoords).x;distance.z=sample(atlas2,textureCoords+offset" |
| ").x;break;case 3:distance.x=sample(atlas3,textureCoords-offset).x;distance." |
| "y=sample(atlas3,textureCoords).x;distance.z=sample(atlas3,textureCoords+offset" |
| ").x;break;default:distance.x=sample(atlas0,textureCoords-offset).x;distance" |
| ".y=sample(atlas0,textureCoords).x;distance.z=sample(atlas0,textureCoords+offset" |
| ").x;break;}return distance;}$pure half4 bitmap_text_coverage_fn(half4 texColor" |
| ",int maskFormat){return maskFormat==$kMaskFormatA8?texColor.xxxx:texColor;}" |
| "$pure half4 sdf_text_coverage_fn(half texColor,float2 unormTexCoords,half2 gammaParams" |
| "){half dist=7.96875*(texColor-.5019608);dist-=gammaParams.x;half2 dist_grad" |
| "=half2(dFdx(dist),dFdy(dist));half dg_len2=dot(dist_grad,dist_grad);dist_grad" |
| "=dg_len2>=.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" |
| "(half2 pixelGeometryDelta,half4 gammaParams,float2 unormTexCoords,float2 textureCoords" |
| ",float texIndex,sampler2D atlas0,sampler2D atlas1,sampler2D atlas2,sampler2D" |
| " atlas3){float2x2 jacobian=float2x2(dFdx(unormTexCoords),dFdy(unormTexCoords" |
| "));float2 offset=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.);}"; |