From ef6f9c65527412ec4057ea0551f2e051beb94d32 Mon Sep 17 00:00:00 2001 From: Matt Sarett Date: Thu, 25 May 2017 18:53:02 -0400 Subject: [PATCH] [m59] dither when converting to 4444 NOTREECHECKS=true NOTRY=true NOPRESUBMIT=true Bug: 720105 Change-Id: I2a3b8a56795403077151ccebed978a94f2350def Change-Id: I2a3b8a56795403077151ccebed978a94f2350def Reviewed-on: https://skia-review.googlesource.com/18021 Reviewed-by: Mike Klein Commit-Queue: Mike Klein --- src/core/SkConvertPixels.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/core/SkConvertPixels.cpp b/src/core/SkConvertPixels.cpp index b919f5d..6106626 100644 --- a/src/core/SkConvertPixels.cpp +++ b/src/core/SkConvertPixels.cpp @@ -9,6 +9,7 @@ #include "SkColorSpaceXformPriv.h" #include "SkColorTable.h" #include "SkConvertPixels.h" +#include "SkDither.h" #include "SkHalf.h" #include "SkImageInfoPriv.h" #include "SkOpts.h" @@ -416,6 +417,25 @@ void SkConvertPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB, return; } + // Chrome M59 Bug Fix: Convert to 4444 with dithering. + // This code is unnecessary in Skia for M60, since the raster pipeline implementation + // will dither. + if (kARGB_4444_SkColorType == dstInfo.colorType() && kN32_SkColorType == srcInfo.colorType() && + kUnpremul_SkAlphaType != srcInfo.alphaType()) { + for (int y = 0; y < srcInfo.height(); y++) { + DITHER_4444_SCAN(y); + SkPMColor16* SK_RESTRICT dstRow = (SkPMColor16*)dstPixels; + const SkPMColor* SK_RESTRICT srcRow = (const SkPMColor*)srcPixels; + for (int x = 0; x < srcInfo.width(); ++x) { + dstRow[x] = SkDitherARGB32To4444(srcRow[x], DITHER_VALUE(x)); + } + dstPixels = (char*)dstPixels + dstRB; + srcPixels = (const char*)srcPixels + srcRB; + } + + return; + } + // Default: Use the pipeline. convert_with_pipeline(dstInfo, dstPixels, dstRB, srcInfo, srcPixels, srcRB, isColorAware, behavior); -- 2.7.4