| 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 REPORTER_ASSERT(r, f2[0] == 20); | 230 REPORTER_ASSERT(r, f2[0] == 20); |
| 231 REPORTER_ASSERT(r, f2[1] == 10); | 231 REPORTER_ASSERT(r, f2[1] == 10); |
| 232 | 232 |
| 233 f4 = SkNx_shuffle<0,1,1,0>(f2); | 233 f4 = SkNx_shuffle<0,1,1,0>(f2); |
| 234 REPORTER_ASSERT(r, f4[0] == 20); | 234 REPORTER_ASSERT(r, f4[0] == 20); |
| 235 REPORTER_ASSERT(r, f4[1] == 10); | 235 REPORTER_ASSERT(r, f4[1] == 10); |
| 236 REPORTER_ASSERT(r, f4[2] == 10); | 236 REPORTER_ASSERT(r, f4[2] == 10); |
| 237 REPORTER_ASSERT(r, f4[3] == 20); | 237 REPORTER_ASSERT(r, f4[3] == 20); |
| 238 } | 238 } |
| 239 | 239 |
| 240 DEF_TEST(SkNx_int_float, r) { |
| 241 Sk4f f(-2.3f, 1.0f, 0.45f, 0.6f); |
| 242 |
| 243 Sk4i i = SkNx_cast<int>(f); |
| 244 REPORTER_ASSERT(r, i[0] == -2); |
| 245 REPORTER_ASSERT(r, i[1] == 1); |
| 246 REPORTER_ASSERT(r, i[2] == 0); |
| 247 REPORTER_ASSERT(r, i[3] == 0); |
| 248 |
| 249 f = SkNx_cast<float>(i); |
| 250 REPORTER_ASSERT(r, f[0] == -2.0f); |
| 251 REPORTER_ASSERT(r, f[1] == 1.0f); |
| 252 REPORTER_ASSERT(r, f[2] == 0.0f); |
| 253 REPORTER_ASSERT(r, f[3] == 0.0f); |
| 254 } |
| 255 |
| 240 #include "SkRandom.h" | 256 #include "SkRandom.h" |
| 241 | 257 |
| 242 DEF_TEST(SkNx_u16_float, r) { | 258 DEF_TEST(SkNx_u16_float, r) { |
| 243 { | 259 { |
| 244 // u16 --> float | 260 // u16 --> float |
| 245 auto h4 = Sk4h(15, 17, 257, 65535); | 261 auto h4 = Sk4h(15, 17, 257, 65535); |
| 246 auto f4 = SkNx_cast<float>(h4); | 262 auto f4 = SkNx_cast<float>(h4); |
| 247 REPORTER_ASSERT(r, f4.kth<0>() == 15.0f); | 263 REPORTER_ASSERT(r, f4.kth<0>() == 15.0f); |
| 248 REPORTER_ASSERT(r, f4.kth<1>() == 17.0f); | 264 REPORTER_ASSERT(r, f4.kth<1>() == 17.0f); |
| 249 REPORTER_ASSERT(r, f4.kth<2>() == 257.0f); | 265 REPORTER_ASSERT(r, f4.kth<2>() == 257.0f); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 268 (uint16_t)rand.nextU16(), (uint16_t)rand.nextU16(), | 284 (uint16_t)rand.nextU16(), (uint16_t)rand.nextU16(), |
| 269 }; | 285 }; |
| 270 auto u4_0 = Sk4h::Load(s16); | 286 auto u4_0 = Sk4h::Load(s16); |
| 271 auto f4 = SkNx_cast<float>(u4_0); | 287 auto f4 = SkNx_cast<float>(u4_0); |
| 272 auto u4_1 = SkNx_cast<uint16_t>(f4); | 288 auto u4_1 = SkNx_cast<uint16_t>(f4); |
| 273 uint16_t d16[4]; | 289 uint16_t d16[4]; |
| 274 u4_1.store(d16); | 290 u4_1.store(d16); |
| 275 REPORTER_ASSERT(r, !memcmp(s16, d16, sizeof(s16))); | 291 REPORTER_ASSERT(r, !memcmp(s16, d16, sizeof(s16))); |
| 276 } | 292 } |
| 277 } | 293 } |
| OLD | NEW |