[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 <mtklein@chromium.org>
Commit-Queue: Mike Klein <mtklein@chromium.org>
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 @@
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);