From fc38ba73e05a40ed37eb18a9930ade8db7282322 Mon Sep 17 00:00:00 2001 From: Leon Scroggins III Date: Wed, 3 Oct 2018 16:19:10 -0400 Subject: [PATCH] Fix-up colorSpace-less decodes Follow-up to https://skia-review.googlesource.com/c/skia/+/156627 When attempting to decode into an SkImageInfo without an SkColorSpace, assume it is SRGB. This updates scanline and incremental decodes to do so just like getPixels does. Bug: skia:8382 Change-Id: Ife3c44088be4065c065d7682fe1cb0dc1dd6376f Reviewed-on: https://skia-review.googlesource.com/c/159325 Reviewed-by: Brian Osman Commit-Queue: Leon Scroggins --- src/codec/SkCodec.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp index 73a6a2925a..f9c34dd245 100644 --- a/src/codec/SkCodec.cpp +++ b/src/codec/SkCodec.cpp @@ -372,10 +372,14 @@ SkCodec::Result SkCodec::getPixels(const SkImageInfo& dstInfo, void* pixels, siz return result; } -SkCodec::Result SkCodec::startIncrementalDecode(const SkImageInfo& info, void* pixels, +SkCodec::Result SkCodec::startIncrementalDecode(const SkImageInfo& dstInfo, void* pixels, size_t rowBytes, const SkCodec::Options* options) { fStartedIncrementalDecode = false; + SkImageInfo info = dstInfo; + if (!info.colorSpace()) { + info = info.makeColorSpace(SkColorSpace::MakeSRGB()); + } if (kUnknown_SkColorType == info.colorType()) { return kInvalidConversion; } @@ -441,11 +445,16 @@ SkCodec::Result SkCodec::startIncrementalDecode(const SkImageInfo& info, void* p } -SkCodec::Result SkCodec::startScanlineDecode(const SkImageInfo& info, +SkCodec::Result SkCodec::startScanlineDecode(const SkImageInfo& dstInfo, const SkCodec::Options* options) { // Reset fCurrScanline in case of failure. fCurrScanline = -1; + SkImageInfo info = dstInfo; + if (!info.colorSpace()) { + info = info.makeColorSpace(SkColorSpace::MakeSRGB()); + } + if (!this->rewindIfNeeded()) { return kCouldNotRewind; }