xref: /aosp_15_r20/external/skia/resources/sksl/shared/LogicalAndShortCircuit.sksl (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1uniform half4 colorGreen, colorRed;
2
3bool TrueTrue() {
4    int x = 1, y = 1;
5    if ((x == 1) && ((y += 1) == 2)) { // LHS true, RHS is executed and is true
6        return (x == 1 && y == 2);
7    } else {
8        return false;
9    }
10}
11
12bool TrueFalse() {
13    int x = 1, y = 1;
14    if ((x == 1) && ((y += 1) == 3)) { // LHS true, RHS is executed and is false
15        return false;
16    } else {
17        return (x == 1 && y == 2);
18    }
19}
20
21bool FalseTrue() {
22    int x = 1, y = 1;
23    if ((x == 2) && ((y += 1) == 2)) { // LHS false, RHS not executed but would be true
24        return false;
25    } else {
26        return (x == 1 && y == 1);
27    }
28}
29
30bool FalseFalse() {
31    int x = 1, y = 1;
32    if ((x == 2) && ((y += 1) == 3)) { // LHS false, RHS not executed but would be false
33        return false;
34    } else {
35        return (x == 1 && y == 1);
36    }
37}
38
39half4 main(float2) {
40    return TrueTrue() && TrueFalse() && FalseTrue() && FalseFalse() ? colorGreen : colorRed;
41}
42