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

Side by Side Diff: tests/Sk4xTest.cpp

Issue 1019773004: Port to real Sk2f. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 5 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 unified diff | Download patch
« no previous file with comments | « src/core/SkGeometry.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include "Test.h" 1 #include "Test.h"
2 #include "Sk4x.h" 2 #include "Sk4x.h"
3 3
4 #define ASSERT_EQ(a, b) REPORTER_ASSERT(r, a.equal(b).allTrue()) 4 #define ASSERT_EQ(a, b) REPORTER_ASSERT(r, a.equal(b).allTrue())
5 #define ASSERT_NE(a, b) REPORTER_ASSERT(r, a.notEqual(b).allTrue()) 5 #define ASSERT_NE(a, b) REPORTER_ASSERT(r, a.notEqual(b).allTrue())
6 6
7 DEF_TEST(Sk4x_Construction, r) { 7 DEF_TEST(Sk4x_Construction, r) {
8 Sk4f uninitialized; 8 Sk4f uninitialized;
9 Sk4f zero(0,0,0,0); 9 Sk4f zero(0,0,0,0);
10 Sk4f foo(1,2,3,4), 10 Sk4f foo(1,2,3,4),
(...skipping 24 matching lines...) Expand all
35 foo = Sk4f::Load(fs+1); 35 foo = Sk4f::Load(fs+1);
36 ASSERT_NE(foo, bar); 36 ASSERT_NE(foo, bar);
37 37
38 foo.storeAligned(fs); 38 foo.storeAligned(fs);
39 bar.store(fs+1); 39 bar.store(fs+1);
40 REPORTER_ASSERT(r, fs[0] == 6 && 40 REPORTER_ASSERT(r, fs[0] == 6 &&
41 fs[1] == 5 && 41 fs[1] == 5 &&
42 fs[2] == 6 && 42 fs[2] == 6 &&
43 fs[3] == 7 && 43 fs[3] == 7 &&
44 fs[4] == 8); 44 fs[4] == 8);
45
46 // Load2 and store2().
47 float two[2] = { 1.0f, 2.0f };
48 Sk4f twoIn4f = Sk4f::Load2(two);
49 twoIn4f = twoIn4f.multiply(Sk4f(2.0f));
50 twoIn4f.store2(two);
51
52 REPORTER_ASSERT(r, two[0] == 2.0f);
53 REPORTER_ASSERT(r, two[1] == 4.0f);
54 } 45 }
55 46
56 DEF_TEST(Sk4x_Conversions, r) { 47 DEF_TEST(Sk4x_Conversions, r) {
57 // Assuming IEEE floats. 48 // Assuming IEEE floats.
58 Sk4f zerof(0,0,0,0); 49 Sk4f zerof(0,0,0,0);
59 Sk4i zeroi(0,0,0,0); 50 Sk4i zeroi(0,0,0,0);
60 ASSERT_EQ(zeroi, zerof.cast<Sk4i>()); 51 ASSERT_EQ(zeroi, zerof.cast<Sk4i>());
61 ASSERT_EQ(zeroi, zerof.reinterpret<Sk4i>()); 52 ASSERT_EQ(zeroi, zerof.reinterpret<Sk4i>());
62 ASSERT_EQ(zerof, zeroi.cast<Sk4f>()); 53 ASSERT_EQ(zerof, zeroi.cast<Sk4f>());
63 ASSERT_EQ(zerof, zeroi.reinterpret<Sk4f>()); 54 ASSERT_EQ(zerof, zeroi.reinterpret<Sk4f>());
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 130 }
140 131
141 DEF_TEST(Sk4x_Swizzle, r) { 132 DEF_TEST(Sk4x_Swizzle, r) {
142 ASSERT_EQ(Sk4f(3,4,1,2), Sk4f(1,2,3,4).zwxy()); 133 ASSERT_EQ(Sk4f(3,4,1,2), Sk4f(1,2,3,4).zwxy());
143 ASSERT_EQ(Sk4f(1,2,5,6), Sk4f::XYAB(Sk4f(1,2,3,4), Sk4f(5,6,7,8))); 134 ASSERT_EQ(Sk4f(1,2,5,6), Sk4f::XYAB(Sk4f(1,2,3,4), Sk4f(5,6,7,8)));
144 ASSERT_EQ(Sk4f(3,4,7,8), Sk4f::ZWCD(Sk4f(1,2,3,4), Sk4f(5,6,7,8))); 135 ASSERT_EQ(Sk4f(3,4,7,8), Sk4f::ZWCD(Sk4f(1,2,3,4), Sk4f(5,6,7,8)));
145 ASSERT_EQ(Sk4i(3,4,1,2), Sk4i(1,2,3,4).zwxy()); 136 ASSERT_EQ(Sk4i(3,4,1,2), Sk4i(1,2,3,4).zwxy());
146 ASSERT_EQ(Sk4i(1,2,5,6), Sk4i::XYAB(Sk4i(1,2,3,4), Sk4i(5,6,7,8))); 137 ASSERT_EQ(Sk4i(1,2,5,6), Sk4i::XYAB(Sk4i(1,2,3,4), Sk4i(5,6,7,8)));
147 ASSERT_EQ(Sk4i(3,4,7,8), Sk4i::ZWCD(Sk4i(1,2,3,4), Sk4i(5,6,7,8))); 138 ASSERT_EQ(Sk4i(3,4,7,8), Sk4i::ZWCD(Sk4i(1,2,3,4), Sk4i(5,6,7,8)));
148 } 139 }
OLDNEW
« no previous file with comments | « src/core/SkGeometry.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698