diff options
author | 2017-02-09 16:22:39 -0500 | |
---|---|---|
committer | 2017-02-09 22:11:13 +0000 | |
commit | c7b29089475772a51541323a93a15baad2a5feaa (patch) | |
tree | 308b5bf2b4d4b0d7bf7bd021e147028e7b7878b2 /src/images | |
parent | 5881e82060e59abe477ba34d33ada661c53d81f0 (diff) |
Refactor pixel conversion: premul and unpremul
Just going for simpler and more code sharing.
BUG=skia:
Change-Id: I84c20cd4dbb6950f7b4d0bc659c4b3b5a2af201c
Reviewed-on: https://skia-review.googlesource.com/8287
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Matt Sarett <msarett@google.com>
Diffstat (limited to 'src/images')
-rw-r--r-- | src/images/transform_scanline.h | 39 |
1 files changed, 3 insertions, 36 deletions
diff --git a/src/images/transform_scanline.h b/src/images/transform_scanline.h index 6bf347419f..d855964989 100644 --- a/src/images/transform_scanline.h +++ b/src/images/transform_scanline.h @@ -15,6 +15,7 @@ #include "SkPreConfig.h" #include "SkRasterPipeline.h" #include "SkUnPreMultiply.h" +#include "SkUnPreMultiplyPriv.h" /** * Function template for transforming scanlines. @@ -128,46 +129,12 @@ static inline void transform_scanline_444(char* SK_RESTRICT dst, const char* SK_ } } -template <bool kIsRGBA> -static inline void transform_scanline_unpremultiply(char* SK_RESTRICT dst, - const char* SK_RESTRICT src, int width) { - const uint32_t* srcP = (const SkPMColor*)src; - const SkUnPreMultiply::Scale* table = SkUnPreMultiply::GetScaleTable(); - - for (int i = 0; i < width; i++) { - uint32_t c = *srcP++; - unsigned r, g, b, a; - if (kIsRGBA) { - r = (c >> 0) & 0xFF; - g = (c >> 8) & 0xFF; - b = (c >> 16) & 0xFF; - a = (c >> 24) & 0xFF; - } else { - r = (c >> 16) & 0xFF; - g = (c >> 8) & 0xFF; - b = (c >> 0) & 0xFF; - a = (c >> 24) & 0xFF; - } - - if (0 != a && 255 != a) { - SkUnPreMultiply::Scale scale = table[a]; - r = SkUnPreMultiply::ApplyScale(scale, r); - g = SkUnPreMultiply::ApplyScale(scale, g); - b = SkUnPreMultiply::ApplyScale(scale, b); - } - *dst++ = r; - *dst++ = g; - *dst++ = b; - *dst++ = a; - } -} - /** * Transform from legacy kPremul, kRGBA_8888_SkColorType to 4-bytes-per-pixel unpremultiplied RGBA. */ static inline void transform_scanline_rgbA(char* SK_RESTRICT dst, const char* SK_RESTRICT src, int width, int, const SkPMColor*) { - transform_scanline_unpremultiply<true>(dst, src, width); + SkUnpremultiplyRow<false>((uint32_t*) dst, (const uint32_t*) src, width); } /** @@ -175,7 +142,7 @@ static inline void transform_scanline_rgbA(char* SK_RESTRICT dst, const char* SK */ static inline void transform_scanline_bgrA(char* SK_RESTRICT dst, const char* SK_RESTRICT src, int width, int, const SkPMColor*) { - transform_scanline_unpremultiply<false>(dst, src, width); + SkUnpremultiplyRow<true>((uint32_t*) dst, (const uint32_t*) src, width); } template <bool kIsRGBA> |