diff options
author | Brian Osman <brianosman@google.com> | 2018-09-07 15:24:44 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-09-07 19:46:47 +0000 |
commit | b3f383041ad8cc7bc9b464e394cff4704f17348e (patch) | |
tree | 96494683a885325db6f482b5b49beb2d5bc65a8c /src/codec/SkJpegCodec.cpp | |
parent | 094b3eaf479ca121ecc6d7d94d459a3e8303b4b7 (diff) | |
download | platform_external_skqp-b3f383041ad8cc7bc9b464e394cff4704f17348e.tar.gz platform_external_skqp-b3f383041ad8cc7bc9b464e394cff4704f17348e.tar.bz2 platform_external_skqp-b3f383041ad8cc7bc9b464e394cff4704f17348e.zip |
Add support for gray + colorspace to SkCodec
Bug: skia:
Change-Id: Ib0996ac5aff5eeb4bd67e9938ad0d9246703a0e7
Reviewed-on: https://skia-review.googlesource.com/151661
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'src/codec/SkJpegCodec.cpp')
-rw-r--r-- | src/codec/SkJpegCodec.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/codec/SkJpegCodec.cpp b/src/codec/SkJpegCodec.cpp index 7888b8a9fc..21570fddfe 100644 --- a/src/codec/SkJpegCodec.cpp +++ b/src/codec/SkJpegCodec.cpp @@ -302,8 +302,7 @@ std::unique_ptr<SkCodec> SkJpegCodec::MakeFromStream(std::unique_ptr<SkStream> s SkJpegCodec::SkJpegCodec(SkEncodedInfo&& info, std::unique_ptr<SkStream> stream, JpegDecoderMgr* decoderMgr, SkEncodedOrigin origin) - : INHERITED(std::move(info), skcms_PixelFormat_RGBA_8888, std::move(stream), - origin) + : INHERITED(std::move(info), skcms_PixelFormat_RGBA_8888, std::move(stream), origin) , fDecoderMgr(decoderMgr) , fReadyState(decoderMgr->dinfo()->global_state) , fSwizzleSrcRow(nullptr) @@ -426,12 +425,15 @@ bool SkJpegCodec::conversionSupported(const SkImageInfo& dstInfo, SkColorType sr } break; case kGray_8_SkColorType: - SkASSERT(!needsColorXform); if (JCS_GRAYSCALE != encodedColorType) { return false; } - fDecoderMgr->dinfo()->out_color_space = JCS_GRAYSCALE; + if (needsColorXform) { + fDecoderMgr->dinfo()->out_color_space = JCS_EXT_RGBA; + } else { + fDecoderMgr->dinfo()->out_color_space = JCS_GRAYSCALE; + } break; case kRGBA_F16_SkColorType: SkASSERT(needsColorXform); @@ -505,7 +507,8 @@ int SkJpegCodec::readRows(const SkImageInfo& dstInfo, void* dst, size_t rowBytes // We can never swizzle "in place" because the swizzler may perform sampling and/or // subsetting. // When fColorXformSrcRow is non-null, it means that we need to color xform and that - // we cannot color xform "in place" (many times we can, but not when the dst is F16). + // we cannot color xform "in place" (many times we can, but not when the src and dst + // are different sizes). // In this case, we will color xform from fColorXformSrcRow into the dst. JSAMPLE* decodeDst = (JSAMPLE*) dst; uint32_t* swizzleDst = (uint32_t*) dst; @@ -624,8 +627,8 @@ void SkJpegCodec::allocateStorage(const SkImageInfo& dstInfo) { } size_t xformBytes = 0; - if (this->colorXform() && (kRGBA_F16_SkColorType == dstInfo.colorType() || - kRGB_565_SkColorType == dstInfo.colorType())) { + + if (this->colorXform() && sizeof(uint32_t) != dstInfo.bytesPerPixel()) { xformBytes = dstWidth * sizeof(uint32_t); } |