diff options
author | Matt Sarett <msarett@google.com> | 2016-12-13 13:29:54 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-12-13 19:06:02 +0000 |
commit | 9bf39c245e678e9b008ad2d97b98aecc05c6dc2b (patch) | |
tree | d29985b925ff19cee2787a44b53b2459cb4ec342 | |
parent | 293d696fcfb9f1c83019c4b15c4864cd6649ed78 (diff) |
Fix double CMYK->RGBA conversion on swizzled jpeg decodes
BUG=skia:
Change-Id: I4e8c4128f974cc491fcef0bbc1137b5d62b6f967
Reviewed-on: https://skia-review.googlesource.com/5933
Commit-Queue: Matt Sarett <msarett@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
-rw-r--r-- | src/codec/SkJpegCodec.cpp | 14 | ||||
-rw-r--r-- | src/codec/SkSwizzler.cpp | 6 | ||||
-rw-r--r-- | src/codec/SkSwizzler.h | 8 |
3 files changed, 15 insertions, 13 deletions
diff --git a/src/codec/SkJpegCodec.cpp b/src/codec/SkJpegCodec.cpp index ad5ce5834d..8c2f5dc4e3 100644 --- a/src/codec/SkJpegCodec.cpp +++ b/src/codec/SkJpegCodec.cpp @@ -626,12 +626,14 @@ void SkJpegCodec::allocateStorage(const SkImageInfo& dstInfo) { } void SkJpegCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Options& options) { - // libjpeg-turbo may have already performed color conversion. We must indicate the - // appropriate format to the swizzler. + // libjpeg-turbo will handle format conversion from YUV to RGBA, BGRA, or 565. fColorXform + // will handle format conversion from CMYK. We only need the swizzler to perform format + // conversion when we have a CMYK image without a fColorXform. + bool skipFormatConversion = this->colorXform() || + (JCS_CMYK != fDecoderMgr->dinfo()->out_color_space); + SkEncodedInfo swizzlerInfo = this->getEncodedInfo(); - bool preSwizzled = true; - if (JCS_CMYK == fDecoderMgr->dinfo()->out_color_space) { - preSwizzled = false; + if (!skipFormatConversion) { swizzlerInfo = SkEncodedInfo::Make(SkEncodedInfo::kInvertedCMYK_Color, swizzlerInfo.alpha(), swizzlerInfo.bitsPerComponent()); @@ -647,7 +649,7 @@ void SkJpegCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Options& swizzlerOptions.fSubset = &fSwizzlerSubset; } fSwizzler.reset(SkSwizzler::CreateSwizzler(swizzlerInfo, nullptr, dstInfo, swizzlerOptions, - nullptr, preSwizzled)); + nullptr, skipFormatConversion)); SkASSERT(fSwizzler); } diff --git a/src/codec/SkSwizzler.cpp b/src/codec/SkSwizzler.cpp index 0bbe824dc2..9cada7b39d 100644 --- a/src/codec/SkSwizzler.cpp +++ b/src/codec/SkSwizzler.cpp @@ -682,14 +682,14 @@ SkSwizzler* SkSwizzler::CreateSwizzler(const SkEncodedInfo& encodedInfo, const SkImageInfo& dstInfo, const SkCodec::Options& options, const SkIRect* frame, - bool preSwizzled) { + bool skipFormatConversion) { if (SkEncodedInfo::kPalette_Color == encodedInfo.color() && nullptr == ctable) { return nullptr; } RowProc fastProc = nullptr; RowProc proc = nullptr; - if (preSwizzled) { + if (skipFormatConversion) { switch (dstInfo.colorType()) { case kGray_8_SkColorType: proc = &sample1; @@ -1003,7 +1003,7 @@ SkSwizzler* SkSwizzler::CreateSwizzler(const SkEncodedInfo& encodedInfo, int srcBPP; const int dstBPP = SkColorTypeBytesPerPixel(dstInfo.colorType()); - if (preSwizzled) { + if (skipFormatConversion) { srcBPP = dstBPP; } else { // Store bpp in bytes if it is an even multiple, otherwise use bits diff --git a/src/codec/SkSwizzler.h b/src/codec/SkSwizzler.h index 139ca4fd10..ebaed7ea33 100644 --- a/src/codec/SkSwizzler.h +++ b/src/codec/SkSwizzler.h @@ -27,9 +27,8 @@ public: * Contains partial scanline information. * @param frame Is non-NULL if the source pixels are part of an image * frame that is a subset of the full image. - * @param preSwizzled Indicates that the codec has already swizzled to the - * destination format. The swizzler only needs to sample - * and/or subset. + * @param skipFormatConversion Indicates that we should skip format conversion. + * The swizzler only needs to sample and/or subset. * * Note that a deeper discussion of partial scanline subsets and image frame * subsets is below. Currently, we do not support both simultaneously. If @@ -39,7 +38,8 @@ public: */ static SkSwizzler* CreateSwizzler(const SkEncodedInfo& encodedInfo, const SkPMColor* ctable, const SkImageInfo& dstInfo, const SkCodec::Options&, - const SkIRect* frame = nullptr, bool preSwizzled = false); + const SkIRect* frame = nullptr, + bool skipFormatConversion = false); /** * Swizzle a line. Generally this will be called height times, once |