xref: /aosp_15_r20/external/skia/resources/sksl/shared/TernaryExpression.sksl (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1uniform half4 colorGreen, colorRed;
2
3half4 main(float2 coords) {
4    const bool TRUE = true;
5    const bool FALSE = false;
6
7    int check = 0;
8
9    // Literal test
10    check += (true ? 0 : 1);
11    check += (false ? 1 : 0);
12
13    // Constant boolean test
14    check += (TRUE ? 0 : 1);
15    check += (FALSE ? 1 : 0);
16
17    // Constant-foldable test
18    check += (1 == 1 ? 0 : 1);
19    check += (0 == 1 ? 1 : 0);
20
21    // Unknown-value test
22    check += (colorGreen.g == 1 ? 0 : 1);
23    check += (colorGreen.r == 1 ? 1 : 0);
24
25    // Composite comparison test.
26    check += (colorGreen.gr == colorRed.rg ? 0 : 1);
27    check += (colorGreen.gr != colorRed.rg ? 1 : 0);
28
29    return check == 0 ? colorGreen : colorRed;
30}
31