xref: /aosp_15_r20/external/skia/resources/sksl/folding/TernaryFolding.rts (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1uniform half4 colorRed, colorGreen;
2
3bool do_side_effect(out bool x) {
4    x = true;
5    return false;
6}
7
8const bool TRUE = true;
9const bool FALSE = false;
10
11half4 main(float2 coords) {
12    bool ok;
13
14    ok = (colorRed == colorGreen) ? true : true;
15
16    ok = ok && (colorGreen.g == 1 ? true : true);
17    ok = ok && (colorGreen.g == 0 ? TRUE : true);
18    ok = ok || (colorGreen.g == 1 ? false : false);
19    ok = ok || (colorGreen.g == 0 ? false : FALSE);
20
21    half4 green = coords.x == coords.y ? colorGreen : colorGreen;
22    half4 red   = coords.x != coords.y ? colorRed   : colorRed;
23
24    // Make sure side effects are honored.
25    bool param = false;
26    bool call = do_side_effect(param) ? true : true;
27
28    return (ok && param && call) ? green : red;
29}
30