xref: /aosp_15_r20/external/skia/resources/sksl/shared/SwitchWithFallthrough.sksl (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1/*#pragma settings RewriteSwitchStatements*/
2
3uniform half4 colorGreen, colorRed;
4
5bool switch_fallthrough(int value) {
6    bool ok = false;
7    switch (value) {
8        case 2:  break;
9        case 1:
10        case 0:  ok = true; break;
11        default: break;
12    }
13    return ok;
14}
15
16bool switch_fallthrough_twice(int value) {
17    bool ok = false;
18    switch (value) {
19        case 0:  break;
20        case 1:
21        case 2:
22        case 3:  ok = true; break;
23        default: break;
24    }
25    return ok;
26}
27
28half4 main(float2 coords) {
29    int x = int(colorGreen.g);
30    return (switch_fallthrough(x) && switch_fallthrough_twice(x)) ? colorGreen : colorRed;
31}
32