xref: /aosp_15_r20/external/skia/src/sksl/generated/sksl_rt_shader.unoptimized.sksl (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1static constexpr char SKSL_MINIFIED_sksl_rt_shader[] =
2"layout(builtin=15)float4 sk_FragCoord;half4 sk_luma(half3 color){return half4"
3"(0.,0.,0.,saturate(dot(half3(.2126,.7152,.0722),color)));}half4 sk_decal(shader"
4" image,float2 coord,float4 decalBounds){half4 d=half4(decalBounds-coord.xyxy"
5")*half4(-1.,-1.,1.,1.);d=saturate(d+.5);return(((d.x*d.y)*d.z)*d.w)*image.eval"
6"(coord);}half4 sk_displacement(shader displMap,shader colorMap,float2 coord"
7",half2 scale,half4 xSelect,half4 ySelect){half4 displColor=unpremul(displMap"
8".eval(coord));half2 displ=half2(dot(displColor,xSelect),dot(displColor,ySelect"
9"));displ=scale*(displ-.5);return colorMap.eval(coord+float2(displ));}half4 sk_magnifier"
10"(shader src,float2 coord,float4 lensBounds,float4 zoomXform,float2 invInset"
11"){float2 zoomCoord=zoomXform.xy+zoomXform.zw*coord;float2 edgeInset=min(coord"
12"-lensBounds.xy,lensBounds.zw-coord)*invInset;float weight=all(lessThan(edgeInset"
13",2..xx))?2.-length(2.-edgeInset):min(edgeInset.x,edgeInset.y);weight=saturate"
14"(weight);return src.eval(mix(coord,zoomCoord,weight*weight));}$pure half3 $high_contrast_rgb_to_hsl"
15"(half3 c){half mx=max(max(c.x,c.y),c.z);half mn=min(min(c.x,c.y),c.z);half d"
16"=mx-mn;half invd=1./d;half g_lt_b=half(c.y<c.z?6.:0.);half h=.166666672*(mx"
17"==mn?0.:(c.x>=c.y&&c.x>=c.z?invd*(c.y-c.z)+g_lt_b:(c.y>=c.z?invd*(c.z-c.x)+"
18"2.:invd*(c.x-c.y)+4.)));half sum=mx+mn;half l=sum*.5;half s=mx==mn?0.:d/(l>"
19".5?2.-sum:sum);return half3(h,s,l);}half3 sk_high_contrast(half3 color,half"
20" grayscale,half invertStyle,half contrast){if(grayscale==1.)color=dot(half3"
21"(.2126,.7152,.0722),color).xxx;if(invertStyle==1.)color=1.-color;else if(invertStyle"
22"==2.){color=$high_contrast_rgb_to_hsl(color);color.z=1.-color.z;color=$hsl_to_rgb"
23"(color);}return saturate(mix(half3(.5),color,contrast));}$pure half3 $normal_filter"
24"(half3 alphaC0,half3 alphaC1,half3 alphaC2,half negSurfaceDepth){const half3"
25" kSobel=half3(.25,.5,.25);half3 alphaR0=half3(alphaC0.x,alphaC1.x,alphaC2.x"
26");half3 alphaR2=half3(alphaC0.z,alphaC1.z,alphaC2.z);half nx=dot(kSobel,alphaC2"
27")-dot(kSobel,alphaC0);half ny=dot(kSobel,alphaR2)-dot(kSobel,alphaR0);return"
28" normalize(half3(negSurfaceDepth*half2(nx,ny),1.));}half4 sk_normal(shader alphaMap"
29",float2 coord,float4 edgeBounds,half negSurfaceDepth){half3 alphaC0=half3(alphaMap"
30".eval(clamp(coord+ -1..xx,edgeBounds.xy,edgeBounds.zw)).w,alphaMap.eval(clamp"
31"(coord+float2(-1.,0.),edgeBounds.xy,edgeBounds.zw)).w,alphaMap.eval(clamp(coord"
32"+float2(-1.,1.),edgeBounds.xy,edgeBounds.zw)).w);half3 alphaC1=half3(alphaMap"
33".eval(clamp(coord+float2(0.,-1.),edgeBounds.xy,edgeBounds.zw)).w,alphaMap.eval"
34"(clamp(coord,edgeBounds.xy,edgeBounds.zw)).w,alphaMap.eval(clamp(coord+float2"
35"(0.,1.),edgeBounds.xy,edgeBounds.zw)).w);half3 alphaC2=half3(alphaMap.eval("
36"clamp(coord+float2(1.,-1.),edgeBounds.xy,edgeBounds.zw)).w,alphaMap.eval(clamp"
37"(coord+float2(1.,0.),edgeBounds.xy,edgeBounds.zw)).w,alphaMap.eval(clamp(coord"
38"+1..xx,edgeBounds.xy,edgeBounds.zw)).w);half mainAlpha=alphaC1.y;return half4"
39"($normal_filter(alphaC0,alphaC1,alphaC2,negSurfaceDepth),mainAlpha);}$pure half3"
40" $surface_to_light(half lightType,half3 lightPos,half3 lightDir,half3 coord"
41"){return lightType>=0.?normalize(lightPos-coord):lightDir;}$pure half $spotlight_scale"
42"(half3 lightDir,half3 surfaceToLight,half cosCutoffAngle,half spotFalloff){"
43"const half kConeAAThreshold=.016;const half kConeScale=62.4999962;half cosAngle"
44"=-dot(surfaceToLight,lightDir);if(cosAngle<cosCutoffAngle)return 0.;else{half"
45" scale=pow(cosAngle,spotFalloff);return cosAngle<cosCutoffAngle+kConeAAThreshold"
46"?(scale*(cosAngle-cosCutoffAngle))*kConeScale:scale;}}$pure half4 $compute_lighting"
47"(half3 color,half shininess,half materialType,half lightType,half3 normal,half3"
48" lightDir,half3 surfaceToLight,half cosCutoffAngle,half spotFalloff){if(lightType"
49">0.)color*=$spotlight_scale(lightDir,surfaceToLight,cosCutoffAngle,spotFalloff"
50");if(materialType==0.){half coeff=dot(normal,surfaceToLight);color=saturate"
51"(coeff*color);return half4(color,1.);}else{half3 halfDir=normalize(surfaceToLight"
52"+half3(0.,0.,1.));half coeff=pow(dot(normal,halfDir),shininess);color=saturate"
53"(coeff*color);return half4(color,max(max(color.x,color.y),color.z));}}half4"
54" sk_lighting(shader normalMap,float2 coord,half depth,half shininess,half materialType"
55",half lightType,half3 lightPos,half spotFalloff,half3 lightDir,half cosCutoffAngle"
56",half3 lightColor){half4 normalAndA=normalMap.eval(coord);half3 surfaceToLight"
57"=$surface_to_light(lightType,lightPos,lightDir,half3(half2(coord),depth*normalAndA"
58".w));return $compute_lighting(lightColor,shininess,materialType,lightType,normalAndA"
59".xyz,lightDir,surfaceToLight,cosCutoffAngle,spotFalloff);}half4 sk_arithmetic_blend"
60"(half4 src,half4 dst,half4 k,half pmClamp){half4 color=saturate((((k.x*src)"
61"*dst+k.y*src)+k.z*dst)+k.w);color.xyz=min(color.xyz,max(color.w,pmClamp));return"
62" color;}half4 sk_sparse_morphology(shader child,float2 coord,half2 offset,half"
63" flip){half4 aggregate=max(flip*child.eval(coord+float2(offset)),flip*child"
64".eval(coord-float2(offset)));return flip*aggregate;}half4 sk_linear_morphology"
65"(shader child,float2 coord,half2 offset,half flip,int radius){const int kMaxLinearRadius"
66"=14;half4 aggregate=flip*child.eval(coord);half2 delta=offset;for(int i=1;i"
67"<=kMaxLinearRadius;++i){if(i>radius)break;aggregate=max(aggregate,max(flip*"
68"child.eval(coord+float2(delta)),flip*child.eval(coord-float2(delta))));delta"
69"+=offset;}return flip*aggregate;}half4 sk_overdraw(half alpha,half4 color0,"
70"half4 color1,half4 color2,half4 color3,half4 color4,half4 color5){return alpha"
71"<.00196078443?color0:(alpha<.005882353?color1:(alpha<.009803922?color2:(alpha"
72"<.01372549?color3:(alpha<.01764706?color4:color5))));}";
73