xref: /aosp_15_r20/external/skia/resources/sksl/intrinsics/Step.sksl (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1uniform half4 testInputs;
2uniform half4 colorGreen, colorRed;
3
4half4 main(float2 coords) {
5    const half4 constVal   = half4(-1.25, 0, 0.75, 2.25);
6    const half4 constGreen = half4(0, 1, 0, 1);
7    const half4 constRed   = half4(1, 0, 0, 1);
8    half4 expectedA = half4(0, 0, 1, 1);
9    half4 expectedB = half4(1, 1, 0, 0);
10    half4 expectedC = half4(0, 1, 1, 1);
11
12    return (step(0.5, testInputs.x)                == expectedA.x     &&
13            step(0.5, testInputs.xy)               == expectedA.xy    &&
14            step(0.5, testInputs.xyz)              == expectedA.xyz   &&
15            step(0.5, testInputs.xyzw)             == expectedA.xyzw  &&
16            step(0.5, constVal.x)                  == expectedA.x     &&
17            step(0.5, constVal.xy)                 == expectedA.xy    &&
18            step(0.5, constVal.xyz)                == expectedA.xyz   &&
19            step(0.5, constVal.xyzw)               == expectedA.xyzw  &&
20            step(testInputs.x,    constGreen.x)    == expectedB.x     &&
21            step(testInputs.xy,   constGreen.xy)   == expectedB.xy    &&
22            step(testInputs.xyz,  constGreen.xyz)  == expectedB.xyz   &&
23            step(testInputs.xyzw, constGreen.xyzw) == expectedB.xyzw  &&
24            step(constVal.x,      constGreen.x)    == expectedB.x     &&
25            step(constVal.xy,     constGreen.xy)   == expectedB.xy    &&
26            step(constVal.xyz,    constGreen.xyz)  == expectedB.xyz   &&
27            step(constVal.xyzw,   constGreen.xyzw) == expectedB.xyzw  &&
28            step(colorRed.x,      colorGreen.x)    == expectedC.x     &&
29            step(colorRed.xy,     colorGreen.xy)   == expectedC.xy    &&
30            step(colorRed.xyz,    colorGreen.xyz)  == expectedC.xyz   &&
31            step(colorRed.xyzw,   colorGreen.xyzw) == expectedC.xyzw  &&
32            step(constRed.x,      constGreen.x)    == expectedC.x     &&
33            step(constRed.xy,     constGreen.xy)   == expectedC.xy    &&
34            step(constRed.xyz,    constGreen.xyz)  == expectedC.xyz   &&
35            step(constRed.xyzw,   constGreen.xyzw) == expectedC.xyzw)
36            ? colorGreen : colorRed;
37}
38