Index: src/codec/SkCodec.cpp |
diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp |
index d12de21f515e45c861f6793cdd0b73b4bcc8055f..009db033cbbc32d1a38318636b9839d0d27be4f2 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() {} |
@@ -137,11 +138,26 @@ SkCodec::Result SkCodec::getPixels(const SkImageInfo& info, void* pixels, size_t |
if (nullptr == options) { |
options = &optsStorage; |
} |
- const Result result = this->onGetPixels(info, pixels, rowBytes, *options, ctable, ctableCount); |
+ |
+ // On an incomplete decode, the subclass can specify the number of scanlines that it failed |
+ // to decode. |
+ int incompleteScanlines = 0; |
+ const Result result = this->onGetPixels(info, pixels, rowBytes, *options, ctable, ctableCount, |
+ &incompleteScanlines); |
if ((kIncompleteInput == result || kSuccess == result) && ctableCount) { |
SkASSERT(*ctableCount >= 0 && *ctableCount <= 256); |
} |
+ |
+ // A return value of kIncompleteInput indicates a truncated image stream. |
+ // In this case, we will fill any uninitialized memory with a default value. |
+ if (kIncompleteInput == result && 0 != incompleteScanlines) { |
+ void* fillDst = this->getFillDst(pixels, rowBytes, info.height() - incompleteScanlines); |
scroggo
2015/09/25 15:55:05
My mistake, you end up doing another subtract. If
msarett
2015/10/01 12:44:52
Acknowledged.
|
+ const SkImageInfo fillInfo = info.makeWH(info.width(), incompleteScanlines); |
+ const uint32_t fillValue = this->getFillValue(fillInfo); |
+ SkSwizzler::Fill(fillDst, fillInfo, rowBytes, fillValue, options->fZeroInitialized); |
+ } |
+ |
return result; |
} |