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 <brianosman@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
This commit is contained in:
Leon Scroggins III 2018-10-03 16:19:10 -04:00 committed by Skia Commit-Bot
parent 314d3772a4
commit fc38ba73e0

View File

@ -372,10 +372,14 @@ SkCodec::Result SkCodec::getPixels(const SkImageInfo& dstInfo, void* pixels, siz
return result; 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) { size_t rowBytes, const SkCodec::Options* options) {
fStartedIncrementalDecode = false; fStartedIncrementalDecode = false;
SkImageInfo info = dstInfo;
if (!info.colorSpace()) {
info = info.makeColorSpace(SkColorSpace::MakeSRGB());
}
if (kUnknown_SkColorType == info.colorType()) { if (kUnknown_SkColorType == info.colorType()) {
return kInvalidConversion; 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) { const SkCodec::Options* options) {
// Reset fCurrScanline in case of failure. // Reset fCurrScanline in case of failure.
fCurrScanline = -1; fCurrScanline = -1;
SkImageInfo info = dstInfo;
if (!info.colorSpace()) {
info = info.makeColorSpace(SkColorSpace::MakeSRGB());
}
if (!this->rewindIfNeeded()) { if (!this->rewindIfNeeded()) {
return kCouldNotRewind; return kCouldNotRewind;
} }