aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/codec/SkCodec.cpp8
-rw-r--r--src/codec/SkCodecImageGenerator.cpp2
-rw-r--r--src/codec/SkGifCodec.cpp15
-rw-r--r--src/codec/SkSampledCodec.cpp4
4 files changed, 14 insertions, 15 deletions
diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp
index 60d25210c8..26b31ae11f 100644
--- a/src/codec/SkCodec.cpp
+++ b/src/codec/SkCodec.cpp
@@ -317,8 +317,10 @@ SkCodec::Result SkCodec::getPixels(const SkImageInfo& info, void* pixels, size_t
const Result result = this->onGetPixels(info, pixels, rowBytes, *options, ctable, ctableCount,
&rowsDecoded);
- if ((kIncompleteInput == result || kSuccess == result) && ctableCount) {
- SkASSERT(*ctableCount >= 0 && *ctableCount <= 256);
+ if (ctableCount) {
+ if (kIncompleteInput == result || kSuccess == result || kErrorInInput == result) {
+ SkASSERT(*ctableCount >= 0 && *ctableCount <= 256);
+ }
}
// A return value of kIncompleteInput indicates a truncated image stream.
@@ -326,7 +328,7 @@ SkCodec::Result SkCodec::getPixels(const SkImageInfo& info, void* pixels, size_t
// Some subclasses will take care of filling any uninitialized memory on
// their own. They indicate that all of the memory has been filled by
// setting rowsDecoded equal to the height.
- if (kIncompleteInput == result && rowsDecoded != info.height()) {
+ if ((kIncompleteInput == result || kErrorInInput == result) && rowsDecoded != info.height()) {
// FIXME: (skbug.com/5772) fillIncompleteImage will fill using the swizzler's width, unless
// there is a subset. In that case, it will use the width of the subset. From here, the
// subset will only be non-null in the case of SkWebpCodec, but it treats the subset
diff --git a/src/codec/SkCodecImageGenerator.cpp b/src/codec/SkCodecImageGenerator.cpp
index bf794d60d3..20d547ad36 100644
--- a/src/codec/SkCodecImageGenerator.cpp
+++ b/src/codec/SkCodecImageGenerator.cpp
@@ -49,6 +49,7 @@ bool SkCodecImageGenerator::onGetPixels(const SkImageInfo& info, void* pixels, s
switch (result) {
case SkCodec::kSuccess:
case SkCodec::kIncompleteInput:
+ case SkCodec::kErrorInInput:
return true;
default:
return false;
@@ -66,6 +67,7 @@ bool SkCodecImageGenerator::onGetYUV8Planes(const SkYUVSizeInfo& sizeInfo, void*
switch (result) {
case SkCodec::kSuccess:
case SkCodec::kIncompleteInput:
+ case SkCodec::kErrorInInput:
return true;
default:
return false;
diff --git a/src/codec/SkGifCodec.cpp b/src/codec/SkGifCodec.cpp
index eefe8986b7..89889d2555 100644
--- a/src/codec/SkGifCodec.cpp
+++ b/src/codec/SkGifCodec.cpp
@@ -407,20 +407,15 @@ SkCodec::Result SkGifCodec::decodeFrame(bool firstAttempt, const Options& opts,
return kSuccess;
}
- // Note: there is a difference between the following call to SkGifImageReader::decode
- // returning false and leaving frameDecoded false:
- // - If the method returns false, there was an error in the stream. We still treat this as
- // incomplete, since we have already decoded some rows.
- // - If frameDecoded is false, that just means that we do not have enough data. If more data
- // is supplied, we may be able to continue decoding this frame. We also treat this as
- // incomplete.
- // FIXME: Ensure that we do not attempt to continue decoding if the method returns false and
- // more data is supplied.
bool frameDecoded = false;
- if (!fReader->decode(frameIndex, &frameDecoded) || !frameDecoded) {
+ const bool fatalError = !fReader->decode(frameIndex, &frameDecoded);
+ if (fatalError || !frameDecoded) {
if (rowsDecoded) {
*rowsDecoded = fRowsDecoded;
}
+ if (fatalError) {
+ return kErrorInInput;
+ }
return kIncompleteInput;
}
diff --git a/src/codec/SkSampledCodec.cpp b/src/codec/SkSampledCodec.cpp
index 2b6483b058..045f184f29 100644
--- a/src/codec/SkSampledCodec.cpp
+++ b/src/codec/SkSampledCodec.cpp
@@ -251,12 +251,12 @@ SkCodec::Result SkSampledCodec::sampledDecode(const SkImageInfo& info, void* pix
if (incResult == SkCodec::kSuccess) {
return SkCodec::kSuccess;
}
- SkASSERT(incResult == SkCodec::kIncompleteInput);
+ SkASSERT(incResult == SkCodec::kIncompleteInput || incResult == SkCodec::kErrorInInput);
SkASSERT(rowsDecoded <= info.height());
this->codec()->fillIncompleteImage(info, pixels, rowBytes, options.fZeroInitialized,
info.height(), rowsDecoded);
- return SkCodec::kIncompleteInput;
+ return incResult;
} else if (startResult != SkCodec::kUnimplemented) {
return startResult;
} // kUnimplemented means use the old method.