xref: /aosp_15_r20/external/skia/resources/sksl/folding/BoolFolding.rts (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1*c8dee2aaSAndroid Build Coastguard Workeruniform half4 colorRed, colorGreen;
2*c8dee2aaSAndroid Build Coastguard Worker
3*c8dee2aaSAndroid Build Coastguard Workerbool test() {
4*c8dee2aaSAndroid Build Coastguard Worker    bool a = 1 == 1 || 2 == 8;
5*c8dee2aaSAndroid Build Coastguard Worker    bool b = 1 > 1  || 2 == 8;
6*c8dee2aaSAndroid Build Coastguard Worker    bool c = 1 == 1 && 2 <= 8;
7*c8dee2aaSAndroid Build Coastguard Worker    bool d = 1 == 2 && 2 == 8;
8*c8dee2aaSAndroid Build Coastguard Worker    bool e = 1 == 1 ^^ 1 != 1;
9*c8dee2aaSAndroid Build Coastguard Worker    bool f = 1 == 1 ^^ 1 == 1;
10*c8dee2aaSAndroid Build Coastguard Worker    bool g = true == true;
11*c8dee2aaSAndroid Build Coastguard Worker    bool h = false == true;
12*c8dee2aaSAndroid Build Coastguard Worker    bool i = true == !false;
13*c8dee2aaSAndroid Build Coastguard Worker    bool j = false == !false;
14*c8dee2aaSAndroid Build Coastguard Worker
15*c8dee2aaSAndroid Build Coastguard Worker    const bool TRUE = true;
16*c8dee2aaSAndroid Build Coastguard Worker    const bool FALSE = false;
17*c8dee2aaSAndroid Build Coastguard Worker    bool k = all(bool4(1 == 1, !false, 123 > 12, TRUE));       // all are true
18*c8dee2aaSAndroid Build Coastguard Worker    bool l = all(bool3(TRUE, 1 == 2, true));                   // three out of four are true
19*c8dee2aaSAndroid Build Coastguard Worker    bool m = any(bool4(true, 1 == 2, true, TRUE));             // three out of four are true
20*c8dee2aaSAndroid Build Coastguard Worker    bool n = any(bool2(0 == 1, FALSE));                        // none are true
21*c8dee2aaSAndroid Build Coastguard Worker    bool o = any(not(bool2(0 == 1, FALSE)));                   // all true
22*c8dee2aaSAndroid Build Coastguard Worker    bool p = all(not(bool4(1 == 1, !false, 123 > 12, TRUE)));  // none are true
23*c8dee2aaSAndroid Build Coastguard Worker
24*c8dee2aaSAndroid Build Coastguard Worker    bool q = bool4(true) == bool4(true, true, true, true);
25*c8dee2aaSAndroid Build Coastguard Worker    bool r = bool4(true) == bool4(true, false, true, true);
26*c8dee2aaSAndroid Build Coastguard Worker    bool s = bool4(true, true, true, true) == bool4(true);
27*c8dee2aaSAndroid Build Coastguard Worker    bool t = bool4(true, true, true, false) == bool4(true);
28*c8dee2aaSAndroid Build Coastguard Worker
29*c8dee2aaSAndroid Build Coastguard Worker    bool u = (!a == !a);
30*c8dee2aaSAndroid Build Coastguard Worker    bool v = (!a != !a);
31*c8dee2aaSAndroid Build Coastguard Worker
32*c8dee2aaSAndroid Build Coastguard Worker    return a && !b && c && !d && e && !f && g && !h && i && !j && k && !l && m && !n && o && !p
33*c8dee2aaSAndroid Build Coastguard Worker             && q && !r && s && !t && u && !v;
34*c8dee2aaSAndroid Build Coastguard Worker}
35*c8dee2aaSAndroid Build Coastguard Worker
36*c8dee2aaSAndroid Build Coastguard Workerhalf4 main(float2 coords) {
37*c8dee2aaSAndroid Build Coastguard Worker    return test() ? colorGreen : colorRed;
38*c8dee2aaSAndroid Build Coastguard Worker}
39*c8dee2aaSAndroid Build Coastguard Worker
40