aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec/SkCodec.cpp
diff options
context:
space:
mode:
authorGravatar Leon Scroggins III <scroggo@google.com>2017-07-06 12:26:09 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-06 16:49:36 +0000
commit674a1848ae62277ea9a2d022b60aa1f17d306f17 (patch)
tree0f1b7396e4a7c3d2c561fd96969063e51062faaa /src/codec/SkCodec.cpp
parent005a970eb9d70e729cdebf0f79551577b112aa7b (diff)
Add SkCodec::Result indicating error in the data
Previously, SkGifCodec treated an error in the LZW data as incomplete, since we can still draw the partially decoded image. But a client doing incremental decodes needs to distinguish this from truly incomplete data. In the case of an error, the client should not attempt to provide more data and decode again. Add kErrorInInput, and return it when SkGifCodec sees a fatal error. Treat it the same as kIncompleteInput when it comes to filling and DM. Bug: skia:6825 Change-Id: Ic6ce3a62c0b065ed34dcd8006309e43272a3db9f Reviewed-on: https://skia-review.googlesource.com/21530 Commit-Queue: Leon Scroggins <scroggo@google.com> Reviewed-by: Mike Reed <reed@google.com> Reviewed-by: Chris Blume <cblume@chromium.org>
Diffstat (limited to 'src/codec/SkCodec.cpp')
-rw-r--r--src/codec/SkCodec.cpp8
1 files changed, 5 insertions, 3 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