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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 185 |
186 // We're a bit more flexible on this method: correct for 0 or 255, other
wise off by <=1. | 186 // We're a bit more flexible on this method: correct for 0 or 255, other
wise off by <=1. |
187 int fast = av.approxMulDiv255(bv).kth<0>(); | 187 int fast = av.approxMulDiv255(bv).kth<0>(); |
188 REPORTER_ASSERT(r, fast-exact >= -1 && fast-exact <= 1); | 188 REPORTER_ASSERT(r, fast-exact >= -1 && fast-exact <= 1); |
189 if (a == 0 || a == 255 || b == 0 || b == 255) { | 189 if (a == 0 || a == 255 || b == 0 || b == 255) { |
190 REPORTER_ASSERT(r, fast == exact); | 190 REPORTER_ASSERT(r, fast == exact); |
191 } | 191 } |
192 } | 192 } |
193 } | 193 } |
194 } | 194 } |
| 195 |
| 196 DEF_TEST(Sk4px_widening, r) { |
| 197 SkPMColor colors[] = { |
| 198 SkPreMultiplyColor(0xff00ff00), |
| 199 SkPreMultiplyColor(0x40008000), |
| 200 SkPreMultiplyColor(0x7f020406), |
| 201 SkPreMultiplyColor(0x00000000), |
| 202 }; |
| 203 auto packed = Sk4px::Load4(colors); |
| 204 |
| 205 auto wideLo = packed.widenLo(), |
| 206 wideHi = packed.widenHi(), |
| 207 wideLoHi = packed.widenLoHi(), |
| 208 wideLoHiAlt = wideLo + wideHi; |
| 209 REPORTER_ASSERT(r, 0 == memcmp(&wideLoHi, &wideLoHiAlt, sizeof(wideLoHi))); |
| 210 } |
OLD | NEW |