Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Unified Diff: tests/SwizzlerTest.cpp

Issue 1564233002: test+bench new swizzle SkOpts (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nah, that is dumb Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « bench/SwizzleBench.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/SwizzlerTest.cpp
diff --git a/tests/SwizzlerTest.cpp b/tests/SwizzlerTest.cpp
index 95aaf386392b87be3bfa677e337bed4778926e7c..f67cfeef7a028101781a58606aff3474ef22b931 100644
--- a/tests/SwizzlerTest.cpp
+++ b/tests/SwizzlerTest.cpp
@@ -7,6 +7,7 @@
#include "SkSwizzler.h"
#include "Test.h"
+#include "SkOpts.h"
// These are the values that we will look for to indicate that the fill was successful
static const uint8_t kFillIndex = 0x11;
@@ -124,3 +125,35 @@ DEF_TEST(SwizzlerFill, r) {
}
}
}
+
+DEF_TEST(SwizzleOpts, r) {
+ uint32_t dst, src;
+
+ // forall c, c*255 == c, c*0 == 0
+ for (int c = 0; c <= 255; c++) {
+ src = (255<<24) | c;
+ SkOpts::premul_xxxa(&dst, &src, 1);
+ REPORTER_ASSERT(r, dst == src);
+ SkOpts::premul_swaprb_xxxa(&dst, &src, 1);
+ REPORTER_ASSERT(r, dst == (uint32_t)((255<<24) | (c<<16)));
+
+ src = (0<<24) | c;
+ SkOpts::premul_xxxa(&dst, &src, 1);
+ REPORTER_ASSERT(r, dst == 0);
+ SkOpts::premul_swaprb_xxxa(&dst, &src, 1);
+ REPORTER_ASSERT(r, dst == 0);
+ }
+
+ // check a totally arbitrary color
+ src = 0xFACEB004;
+ SkOpts::premul_xxxa(&dst, &src, 1);
+ REPORTER_ASSERT(r, dst == 0xFACAAD04);
+
+ // swap red and blue
+ SkOpts::swaprb_xxxa(&dst, &src, 1);
+ REPORTER_ASSERT(r, dst == 0xFA04B0CE);
+
+ // all together now
+ SkOpts::premul_swaprb_xxxa(&dst, &src, 1);
+ REPORTER_ASSERT(r, dst == 0xFA04ADCA);
+}
« no previous file with comments | « bench/SwizzleBench.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698