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

Side by Side Diff: tests/SkNxTest.cpp

Issue 1526523003: Unify some SkNx code (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: typo Created 5 years 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/opts/SkXfermode_opts.h ('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 /* 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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 }; 200 };
201 auto packed = Sk4px::Load4(colors); 201 auto packed = Sk4px::Load4(colors);
202 202
203 auto wideLo = packed.widenLo(), 203 auto wideLo = packed.widenLo(),
204 wideHi = packed.widenHi(), 204 wideHi = packed.widenHi(),
205 wideLoHi = packed.widenLoHi(), 205 wideLoHi = packed.widenLoHi(),
206 wideLoHiAlt = wideLo + wideHi; 206 wideLoHiAlt = wideLo + wideHi;
207 REPORTER_ASSERT(r, 0 == memcmp(&wideLoHi, &wideLoHiAlt, sizeof(wideLoHi))); 207 REPORTER_ASSERT(r, 0 == memcmp(&wideLoHi, &wideLoHiAlt, sizeof(wideLoHi)));
208 } 208 }
209 209
210 DEF_TEST(Sk4f_toBytes, r) {
211 uint8_t bytes[4];
212
213 // toBytes truncates, not rounds.
214 Sk4f(0.7f).toBytes(bytes);
215 REPORTER_ASSERT(r, bytes[0] == 0);
216
217 // Clamping edge cases.
218 Sk4f(-2.0f, -0.7f, 255.9f, 256.0f).toBytes(bytes);
219 REPORTER_ASSERT(r, bytes[0] == 0);
220 REPORTER_ASSERT(r, bytes[1] == 0);
221 REPORTER_ASSERT(r, bytes[2] == 255);
222 REPORTER_ASSERT(r, bytes[3] == 255);
223 }
224
225 DEF_TEST(SkNx_cast, r) { 210 DEF_TEST(SkNx_cast, r) {
226 Sk4f fs(-1.7f, -1.4f, 0.5f, 1.9f); 211 Sk4f fs(-1.7f, -1.4f, 0.5f, 1.9f);
227 Sk4i is = SkNx_cast<int>(fs); 212 Sk4i is = SkNx_cast<int>(fs);
228 213
229 REPORTER_ASSERT(r, is.kth<0>() == -1); 214 REPORTER_ASSERT(r, is.kth<0>() == -1);
230 REPORTER_ASSERT(r, is.kth<1>() == -1); 215 REPORTER_ASSERT(r, is.kth<1>() == -1);
231 REPORTER_ASSERT(r, is.kth<2>() == 0); 216 REPORTER_ASSERT(r, is.kth<2>() == 0);
232 REPORTER_ASSERT(r, is.kth<3>() == 1); 217 REPORTER_ASSERT(r, is.kth<3>() == 1);
233 } 218 }
OLDNEW
« no previous file with comments | « src/opts/SkXfermode_opts.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698