rewrite new SkVx unit test
- be more explicit about casting
- general rewrite for clarity
Cq-Include-Trybots: skia.primary:Test-Win2016-MSVC-GCE-CPU-AVX2-x86_64-Debug-All-MSRTC
Change-Id: I924d6d247e6b9afcefb27c690715fdad84635a5d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/207721
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
diff --git a/tests/SkVxTest.cpp b/tests/SkVxTest.cpp
index 2e6ac61..cf453bc 100644
--- a/tests/SkVxTest.cpp
+++ b/tests/SkVxTest.cpp
@@ -146,21 +146,24 @@
for (int x = 0; x < 256; x++)
for (int y = 0; y < 256; y++) {
- int want = 255*(x/255.0 * y/255.0) + 0.5;
+ uint8_t want = (uint8_t)( 255*(x/255.0 * y/255.0) + 0.5 );
- auto xy = skvx::Vec<8,uint16_t>(x)
- * skvx::Vec<8,uint16_t>(y);
+ {
+ uint8_t got = skvx::div255(skvx::Vec<8, uint16_t>(x) *
+ skvx::Vec<8, uint16_t>(y) )[0];
+ REPORTER_ASSERT(r, got == want);
+ }
- REPORTER_ASSERT(r, all(skvx::div255(xy) == want));
+ {
+ uint8_t got = skvx::approx_scale(skvx::Vec<8,uint8_t>(x),
+ skvx::Vec<8,uint8_t>(y))[0];
- auto X = skvx::Vec<8,uint8_t>(x),
- Y = skvx::Vec<8,uint8_t>(y);
-
- REPORTER_ASSERT(r, all((skvx::approx_scale(X,Y) == want-1) |
- (skvx::approx_scale(X,Y) == want ) |
- (skvx::approx_scale(X,Y) == want+1) ));
- if (x == 0 || y == 0 || x == 255 || y == 255) {
- REPORTER_ASSERT(r, all(skvx::approx_scale(X,Y) == want));
+ REPORTER_ASSERT(r, got == want-1 ||
+ got == want ||
+ got == want+1);
+ if (x == 0 || y == 0 || x == 255 || y == 255) {
+ REPORTER_ASSERT(r, got == want);
+ }
}
}
}