skia2/resources/sksl/shared/SwitchWithFallthrough.sksl

30 lines
615 B
Plaintext
Raw Normal View History

uniform half4 colorGreen, colorRed;
bool switch_fallthrough(int value) {
bool ok = false;
switch (value) {
case 2: break;
case 1:
case 0: ok = true; break;
default: break;
}
return ok;
}
bool switch_fallthrough_twice(int value) {
bool ok = false;
switch (value) {
case 0: break;
case 1:
case 2:
case 3: ok = true; break;
default: break;
}
return ok;
}
half4 main(float2 coords) {
int x = int(colorGreen.g);
return (switch_fallthrough(x) && switch_fallthrough_twice(x)) ? colorGreen : colorRed;
}