2de947e780
This test fell into disrepair when constant propagation was removed; it assumed that @if and @switch would work on all unchanging variables, not just those with the `const` modifier. Change-Id: Ie9c1816f9c0852fdea998e4e156047e4cca9ad5b Reviewed-on: https://skia-review.googlesource.com/c/skia/+/395000 Commit-Queue: John Stiles <johnstiles@google.com> Commit-Queue: Brian Osman <brianosman@google.com> Auto-Submit: John Stiles <johnstiles@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
64 lines
2.3 KiB
Plaintext
64 lines
2.3 KiB
Plaintext
// Declare a user enum.
|
|
enum class E {
|
|
kZero = 0,
|
|
kOne = 1,
|
|
kTwo = 2,
|
|
kThree = 3
|
|
};
|
|
|
|
void main() {
|
|
// Test that the user enum is subject to the same optimizations as a plain int.
|
|
const E e = E::kZero;
|
|
if (e == E::kZero) { sk_FragColor = half4(1); }
|
|
@if (e == E::kZero) { sk_FragColor = half4(2); }
|
|
@if (e != E::kZero) { sk_FragColor = half4(3); }
|
|
if (e == E::kOne) { sk_FragColor = half4(4); }
|
|
@if (e == E::kOne) { sk_FragColor = half4(5); }
|
|
@if (e != E::kOne) { sk_FragColor = half4(6); }
|
|
|
|
sk_FragColor = (e == E::kZero) ? half4(7) : half4(-7);
|
|
sk_FragColor = (e != E::kZero) ? half4(8) : half4(-8);
|
|
sk_FragColor = (e == E::kOne) ? half4(9) : half4(-9);
|
|
sk_FragColor = (e != E::kOne) ? half4(10) : half4(-10);
|
|
|
|
switch (e) {
|
|
case E::kZero: sk_FragColor = half4(11); break;
|
|
case E::kOne: sk_FragColor = half4(12); break;
|
|
}
|
|
@switch (E::kZero) {
|
|
case E::kZero: sk_FragColor = half4(13); break;
|
|
case E::kOne: sk_FragColor = half4(14); break;
|
|
}
|
|
|
|
// Test that built-in enums work equally well.
|
|
const SkBlendMode m = SkBlendMode::kClear;
|
|
if (m == SkBlendMode::kClear) { sk_FragColor = half4(15); }
|
|
@if (m == SkBlendMode::kClear) { sk_FragColor = half4(16); }
|
|
if (m == SkBlendMode::kSrc) { sk_FragColor = half4(17); }
|
|
@if (m != SkBlendMode::kDst) { sk_FragColor = half4(18); }
|
|
|
|
sk_FragColor = (m == SkBlendMode::kClear) ? half4(19) : half4(-19);
|
|
sk_FragColor = (m != SkBlendMode::kSrc) ? half4(20) : half4(-20);
|
|
|
|
@switch (SkBlendMode::kClear) {
|
|
case SkBlendMode::kClear: sk_FragColor = half4(21); break;
|
|
case SkBlendMode::kSrc: sk_FragColor = half4(22); break;
|
|
case SkBlendMode::kDst: sk_FragColor = half4(23); break;
|
|
}
|
|
|
|
// Test with a non-const enum.
|
|
E f = E::kOne;
|
|
if (f == E::kOne) { sk_FragColor = half4(1); }
|
|
if (f != E::kOne) { sk_FragColor = half4(4); }
|
|
|
|
sk_FragColor = (f == E::kZero) ? half4(7) : half4(-7);
|
|
sk_FragColor = (f != E::kZero) ? half4(8) : half4(-8);
|
|
sk_FragColor = (f == E::kOne) ? half4(9) : half4(-9);
|
|
sk_FragColor = (f != E::kOne) ? half4(10) : half4(-10);
|
|
|
|
switch (f) {
|
|
case E::kZero: sk_FragColor = half4(11); break;
|
|
case E::kOne: sk_FragColor = half4(12); break;
|
|
}
|
|
}
|