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

Unified Diff: tests/Sk4x4fTest.cpp

Issue 1825663002: Sk4x4f (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: port srcover_n_srgb_bw Created 4 years, 9 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 | « src/core/SkXfermode4f.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/Sk4x4fTest.cpp
diff --git a/tests/Sk4x4fTest.cpp b/tests/Sk4x4fTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..100e13973ff876fd0804f743600bb26f31ef4fc1
--- /dev/null
+++ b/tests/Sk4x4fTest.cpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "Sk4x4f.h"
+#include "Test.h"
+
+DEF_TEST(Sk4x4f, r) {
+ Sk4x4f f;
+
+ Sk4f x{ 0, 1, 2, 3},
+ y{ 4, 5, 6, 7},
+ z{ 8, 9,10,11},
+ w{12,13,14,15};
+ f = Sk4x4f::Transpose(x,y,z,w);
+ REPORTER_ASSERT(r, f.r[0] == 0 && f.r[1] == 4 && f.r[2] == 8 && f.r[3] == 12);
+ REPORTER_ASSERT(r, f.g[0] == 1 && f.g[1] == 5 && f.g[2] == 9 && f.g[3] == 13);
+ REPORTER_ASSERT(r, f.b[0] == 2 && f.b[1] == 6 && f.b[2] == 10 && f.b[3] == 14);
+ REPORTER_ASSERT(r, f.a[0] == 3 && f.a[1] == 7 && f.a[2] == 11 && f.a[3] == 15);
+
+ Sk4f s,t,u,v;
+ f.transpose(&s,&t,&u,&v);
+ REPORTER_ASSERT(r, (x == s).allTrue()
+ && (y == t).allTrue()
+ && (z == u).allTrue()
+ && (w == v).allTrue());
+
+
+ float fs[16] = {0,1,2,3, 4,5,6,7, 8,9,10,11, 12,13,14,15};
+ f = Sk4x4f::Transpose(fs);
+ REPORTER_ASSERT(r, f.r[0] == 0 && f.r[1] == 4 && f.r[2] == 8 && f.r[3] == 12);
+ REPORTER_ASSERT(r, f.g[0] == 1 && f.g[1] == 5 && f.g[2] == 9 && f.g[3] == 13);
+ REPORTER_ASSERT(r, f.b[0] == 2 && f.b[1] == 6 && f.b[2] == 10 && f.b[3] == 14);
+ REPORTER_ASSERT(r, f.a[0] == 3 && f.a[1] == 7 && f.a[2] == 11 && f.a[3] == 15);
+
+ float fs_back[16];
+ f.transpose(fs_back);
+ REPORTER_ASSERT(r, 0 == memcmp(fs, fs_back, sizeof(fs)));
+
+
+ uint8_t bs[16] = {0,1,2,3, 4,5,6,7, 8,9,10,11, 12,13,14,15};
+ f = Sk4x4f::Transpose(bs);
+ REPORTER_ASSERT(r, f.r[0] == 0 && f.r[1] == 4 && f.r[2] == 8 && f.r[3] == 12);
+ REPORTER_ASSERT(r, f.g[0] == 1 && f.g[1] == 5 && f.g[2] == 9 && f.g[3] == 13);
+ REPORTER_ASSERT(r, f.b[0] == 2 && f.b[1] == 6 && f.b[2] == 10 && f.b[3] == 14);
+ REPORTER_ASSERT(r, f.a[0] == 3 && f.a[1] == 7 && f.a[2] == 11 && f.a[3] == 15);
+
+ uint8_t bs_back[16];
+ f.transpose(bs_back);
+ REPORTER_ASSERT(r, 0 == memcmp(bs, bs_back, sizeof(bs)));
+}
« no previous file with comments | « src/core/SkXfermode4f.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698