diff options
author | Florin Malita <fmalita@chromium.org> | 2018-04-18 11:14:50 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-04-18 19:52:53 +0000 |
commit | 15a64e71f68f7d1fcd16247c3d30375d3e2f41e8 (patch) | |
tree | a4aec01af06e2f855ea339312cf68e1b175a4e4d /src/core/SkBlitMask_D32.cpp | |
parent | 63f69cdc326b2bbd4361aa4997f41a197a08d2f0 (diff) |
Convert A8 D32 mask blitters to Sk4px
Improves the newly added bench by ~25% (hsw):
-- before --
micros bench
2298.34 shadermaskfilter_picture_80 8888
2339.60 shadermaskfilter_picture_ff 8888
2287.11 shadermaskfilter_bitmap_80 8888
2223.14 shadermaskfilter_bitmap_ff 8888
-- after --
1693.36 shadermaskfilter_picture_80 8888
1637.45 shadermaskfilter_picture_ff 8888
1691.65 shadermaskfilter_bitmap_80 8888
1637.70 shadermaskfilter_bitmap_ff 8888
But: skia:7810
Change-Id: I7274b10f517551ee2c0646842f72e0372d55e509
Reviewed-on: https://skia-review.googlesource.com/121642
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Klein <mtklein@google.com>
Diffstat (limited to 'src/core/SkBlitMask_D32.cpp')
-rw-r--r-- | src/core/SkBlitMask_D32.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/core/SkBlitMask_D32.cpp b/src/core/SkBlitMask_D32.cpp index 1759ed6a33..4e88d330d9 100644 --- a/src/core/SkBlitMask_D32.cpp +++ b/src/core/SkBlitMask_D32.cpp @@ -5,6 +5,7 @@ * found in the LICENSE file. */ +#include "Sk4px.h" #include "SkBlitMask.h" #include "SkColor.h" #include "SkColorData.h" @@ -78,11 +79,20 @@ bool SkBlitMask::BlitColor(const SkPixmap& device, const SkMask& mask, static void A8_RowProc_Blend( SkPMColor* SK_RESTRICT dst, const void* maskIn, const SkPMColor* SK_RESTRICT src, int count) { const uint8_t* SK_RESTRICT mask = static_cast<const uint8_t*>(maskIn); + +#ifndef SK_SUPPORT_LEGACY_A8_MASKBLITTER + Sk4px::MapDstSrcAlpha(count, dst, src, mask, + [](const Sk4px& d, const Sk4px& s, const Sk4px& aa) { + const auto s_aa = s.approxMulDiv255(aa); + return s_aa + d.approxMulDiv255(s_aa.alphas().inv()); + }); +#else for (int i = 0; i < count; ++i) { if (mask[i]) { dst[i] = SkBlendARGB32(src[i], dst[i], mask[i]); } } +#endif } // expand the steps that SkAlphaMulQ performs, but this way we can @@ -97,6 +107,13 @@ static void A8_RowProc_Blend( static void A8_RowProc_Opaque( SkPMColor* SK_RESTRICT dst, const void* maskIn, const SkPMColor* SK_RESTRICT src, int count) { const uint8_t* SK_RESTRICT mask = static_cast<const uint8_t*>(maskIn); + +#ifndef SK_SUPPORT_LEGACY_A8_MASKBLITTER + Sk4px::MapDstSrcAlpha(count, dst, src, mask, + [](const Sk4px& d, const Sk4px& s, const Sk4px& aa) { + return (s * aa + d * aa.inv()).div255(); + }); +#else for (int i = 0; i < count; ++i) { int m = mask[i]; if (m) { @@ -117,6 +134,7 @@ static void A8_RowProc_Opaque( #endif } } +#endif // SK_SUPPORT_LEGACY_A8_MASKBLITTER } static int upscale31To255(int value) { |