OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2015 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #ifndef SkBlitMask_opts_DEFINED |
| 9 #define SkBlitMask_opts_DEFINED |
| 10 |
| 11 #include "Sk4px.h" |
| 12 |
| 13 namespace SK_OPTS_NS { |
| 14 |
| 15 static void blit_mask_d32_a8(SkPMColor* dst, size_t dstRB, |
| 16 const SkAlpha* mask, size_t maskRB, |
| 17 SkColor color, int w, int h) { |
| 18 auto s = Sk4px::DupPMColor(SkPreMultiplyColor(color)); |
| 19 |
| 20 auto fn = [&](const Sk4px& d, const Sk4px& aa) { |
| 21 // = (s + d(1-sa))aa + d(1-aa) |
| 22 // = s*aa + d(1-sa*aa) |
| 23 auto left = s.approxMulDiv255(aa), |
| 24 right = d.approxMulDiv255(left.alphas().inv()); |
| 25 return left + right; // This does not overflow (exhaustively checked). |
| 26 }; |
| 27 |
| 28 while (h --> 0) { |
| 29 Sk4px::MapDstAlpha(w, dst, mask, fn); |
| 30 dst += dstRB / sizeof(*dst); |
| 31 mask += maskRB / sizeof(*mask); |
| 32 } |
| 33 } |
| 34 |
| 35 } // SK_OPTS_NS |
| 36 |
| 37 #endif//SkBlitMask_opts_DEFINED |
OLD | NEW |