| 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 SkPreMultiplyColor(0x00000000), | 201 SkPreMultiplyColor(0x00000000), |
| 202 }; | 202 }; |
| 203 auto packed = Sk4px::Load4(colors); | 203 auto packed = Sk4px::Load4(colors); |
| 204 | 204 |
| 205 auto wideLo = packed.widenLo(), | 205 auto wideLo = packed.widenLo(), |
| 206 wideHi = packed.widenHi(), | 206 wideHi = packed.widenHi(), |
| 207 wideLoHi = packed.widenLoHi(), | 207 wideLoHi = packed.widenLoHi(), |
| 208 wideLoHiAlt = wideLo + wideHi; | 208 wideLoHiAlt = wideLo + wideHi; |
| 209 REPORTER_ASSERT(r, 0 == memcmp(&wideLoHi, &wideLoHiAlt, sizeof(wideLoHi))); | 209 REPORTER_ASSERT(r, 0 == memcmp(&wideLoHi, &wideLoHiAlt, sizeof(wideLoHi))); |
| 210 } | 210 } |
| 211 |
| 212 DEF_TEST(Sk4f_toBytes, r) { |
| 213 uint8_t bytes[4]; |
| 214 |
| 215 // toBytes truncates, not rounds. |
| 216 Sk4f(0.7f).toBytes(bytes); |
| 217 REPORTER_ASSERT(r, bytes[0] == 0); |
| 218 |
| 219 // Clamping edge cases. |
| 220 Sk4f(-2.0f, -0.7f, 255.9f, 256.0f).toBytes(bytes); |
| 221 REPORTER_ASSERT(r, bytes[0] == 0); |
| 222 REPORTER_ASSERT(r, bytes[1] == 0); |
| 223 REPORTER_ASSERT(r, bytes[2] == 255); |
| 224 REPORTER_ASSERT(r, bytes[3] == 255); |
| 225 } |
| OLD | NEW |