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 #ifndef Sk4pxXfermode_DEFINED | 8 #ifndef Sk4pxXfermode_DEFINED |
9 #define Sk4pxXfermode_DEFINED | 9 #define Sk4pxXfermode_DEFINED |
10 | 10 |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 for (int i = 0; i < n; i++) { | 258 for (int i = 0; i < n; i++) { |
259 SkPMColor dst32 = SkPixel16ToPixel32(dst[i]); | 259 SkPMColor dst32 = SkPixel16ToPixel32(dst[i]); |
260 dst32 = aa ? this->xfer32(dst32, src[i], aa[i]) | 260 dst32 = aa ? this->xfer32(dst32, src[i], aa[i]) |
261 : this->xfer32(dst32, src[i]); | 261 : this->xfer32(dst32, src[i]); |
262 dst[i] = SkPixel32ToPixel16(dst32); | 262 dst[i] = SkPixel32ToPixel16(dst32); |
263 } | 263 } |
264 } | 264 } |
265 | 265 |
266 private: | 266 private: |
267 static Sk4f Load(SkPMColor c) { | 267 static Sk4f Load(SkPMColor c) { |
268 return Sk4f::FromBytes((uint8_t*)&c) * Sk4f(1.0f/255); | 268 return SkNx_cast<float>(Sk4b::Load((uint8_t*)&c)) * Sk4f(1.0f/255); |
269 } | 269 } |
270 static SkPMColor Round(const Sk4f& f) { | 270 static SkPMColor Round(const Sk4f& f) { |
271 SkPMColor c; | 271 SkPMColor c; |
272 (f * Sk4f(255) + Sk4f(0.5f)).toBytes((uint8_t*)&c); | 272 SkNx_cast<uint8_t>(f * Sk4f(255) + Sk4f(0.5f)).store((uint8_t*)&c); |
273 return c; | 273 return c; |
274 } | 274 } |
275 inline SkPMColor xfer32(SkPMColor dst, SkPMColor src) const { | 275 inline SkPMColor xfer32(SkPMColor dst, SkPMColor src) const { |
276 return Round(fProcF(Load(dst), Load(src))); | 276 return Round(fProcF(Load(dst), Load(src))); |
277 } | 277 } |
278 | 278 |
279 inline SkPMColor xfer32(SkPMColor dst, SkPMColor src, SkAlpha aa) const { | 279 inline SkPMColor xfer32(SkPMColor dst, SkPMColor src, SkAlpha aa) const { |
280 Sk4f s(Load(src)), | 280 Sk4f s(Load(src)), |
281 d(Load(dst)), | 281 d(Load(dst)), |
282 b(fProcF(d,s)); | 282 b(fProcF(d,s)); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 #undef CASE | 330 #undef CASE |
331 | 331 |
332 default: break; | 332 default: break; |
333 } | 333 } |
334 return nullptr; | 334 return nullptr; |
335 } | 335 } |
336 | 336 |
337 } // namespace SK_OPTS_NS | 337 } // namespace SK_OPTS_NS |
338 | 338 |
339 #endif//Sk4pxXfermode_DEFINED | 339 #endif//Sk4pxXfermode_DEFINED |
OLD | NEW |