Chromium Code Reviews| Index: src/codec/SkCodec.cpp |
| diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp |
| index d12de21f515e45c861f6793cdd0b73b4bcc8055f..1e347f7186917cf8a9457e01b3d39f17ae41910a 100644 |
| --- a/src/codec/SkCodec.cpp |
| +++ b/src/codec/SkCodec.cpp |
| @@ -79,6 +79,7 @@ SkCodec::SkCodec(const SkImageInfo& info, SkStream* stream) |
| : fInfo(info) |
| , fStream(stream) |
| , fNeedsRewind(false) |
| + , fIncompleteScanlines(0) |
| {} |
| SkCodec::~SkCodec() {} |
| @@ -142,6 +143,17 @@ SkCodec::Result SkCodec::getPixels(const SkImageInfo& info, void* pixels, size_t |
| if ((kIncompleteInput == result || kSuccess == result) && ctableCount) { |
| SkASSERT(*ctableCount >= 0 && *ctableCount <= 256); |
| } |
| + |
| + // A return value of kIncompleteInput generally indicates a truncated image stream. |
|
scroggo
2015/09/22 18:02:48
generally? Is there an exception?
msarett
2015/09/23 13:22:40
Nope. Removing that word.
|
| + // In this case, we will fill the provided memory with a default value. |
| + if (kIncompleteInput == result && 0 != fIncompleteScanlines) { |
| + void* fillDst = this->getFillDst(pixels, rowBytes, info.height() - fIncompleteScanlines); |
| + const SkImageInfo fillInfo = info.makeWH(info.width(), fIncompleteScanlines); |
| + const uint32_t fillValue = this->getFillValue(fillInfo); |
| + SkSwizzler::Fill(fillDst, fillInfo, rowBytes, fillValue, options->fZeroInitialized); |
| + fIncompleteScanlines = 0; |
| + } |
| + |
| return result; |
| } |