OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "Sk4px.h" | 8 #include "Sk4px.h" |
9 #include "SkNx.h" | 9 #include "SkNx.h" |
10 #include "SkRandom.h" | 10 #include "SkRandom.h" |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 } | 208 } |
209 | 209 |
210 DEF_TEST(SkNx_abs, r) { | 210 DEF_TEST(SkNx_abs, r) { |
211 auto fs = Sk4f(0.0f, -0.0f, 2.0f, -4.0f).abs(); | 211 auto fs = Sk4f(0.0f, -0.0f, 2.0f, -4.0f).abs(); |
212 REPORTER_ASSERT(r, fs.kth<0>() == 0.0f); | 212 REPORTER_ASSERT(r, fs.kth<0>() == 0.0f); |
213 REPORTER_ASSERT(r, fs.kth<1>() == 0.0f); | 213 REPORTER_ASSERT(r, fs.kth<1>() == 0.0f); |
214 REPORTER_ASSERT(r, fs.kth<2>() == 2.0f); | 214 REPORTER_ASSERT(r, fs.kth<2>() == 2.0f); |
215 REPORTER_ASSERT(r, fs.kth<3>() == 4.0f); | 215 REPORTER_ASSERT(r, fs.kth<3>() == 4.0f); |
216 } | 216 } |
217 | 217 |
218 DEF_TEST(SkNx_floor, r) { | |
219 auto fs = Sk4f(0.4f, -0.4f, 0.6f, -0.6f).floor(); | |
220 REPORTER_ASSERT(r, fs.kth<0>() == 0.0f); | |
221 REPORTER_ASSERT(r, fs.kth<1>() == -1.0f); | |
222 REPORTER_ASSERT(r, fs.kth<2>() == 0.0f); | |
223 REPORTER_ASSERT(r, fs.kth<3>() == -1.0f); | |
224 } | |
225 | |
226 DEF_TEST(SkNx_shuffle, r) { | 218 DEF_TEST(SkNx_shuffle, r) { |
227 Sk4f f4(0,10,20,30); | 219 Sk4f f4(0,10,20,30); |
228 | 220 |
229 Sk2f f2 = SkNx_shuffle<2,1>(f4); | 221 Sk2f f2 = SkNx_shuffle<2,1>(f4); |
230 REPORTER_ASSERT(r, f2[0] == 20); | 222 REPORTER_ASSERT(r, f2[0] == 20); |
231 REPORTER_ASSERT(r, f2[1] == 10); | 223 REPORTER_ASSERT(r, f2[1] == 10); |
232 | 224 |
233 f4 = SkNx_shuffle<0,1,1,0>(f2); | 225 f4 = SkNx_shuffle<0,1,1,0>(f2); |
234 REPORTER_ASSERT(r, f4[0] == 20); | 226 REPORTER_ASSERT(r, f4[0] == 20); |
235 REPORTER_ASSERT(r, f4[1] == 10); | 227 REPORTER_ASSERT(r, f4[1] == 10); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 (uint16_t)rand.nextU16(), (uint16_t)rand.nextU16(), | 260 (uint16_t)rand.nextU16(), (uint16_t)rand.nextU16(), |
269 }; | 261 }; |
270 auto u4_0 = Sk4h::Load(s16); | 262 auto u4_0 = Sk4h::Load(s16); |
271 auto f4 = SkNx_cast<float>(u4_0); | 263 auto f4 = SkNx_cast<float>(u4_0); |
272 auto u4_1 = SkNx_cast<uint16_t>(f4); | 264 auto u4_1 = SkNx_cast<uint16_t>(f4); |
273 uint16_t d16[4]; | 265 uint16_t d16[4]; |
274 u4_1.store(d16); | 266 u4_1.store(d16); |
275 REPORTER_ASSERT(r, !memcmp(s16, d16, sizeof(s16))); | 267 REPORTER_ASSERT(r, !memcmp(s16, d16, sizeof(s16))); |
276 } | 268 } |
277 } | 269 } |
OLD | NEW |