aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec/SkCodec.cpp
diff options
context:
space:
mode:
authorGravatar Leon Scroggins III <scroggo@google.com>2017-01-27 13:16:28 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-27 18:50:37 +0000
commit428865794bd76937f4ad03d791ca07cda131f83e (patch)
tree7f0829825b14bd8228082b5842db4010f12dd6f6 /src/codec/SkCodec.cpp
parentc121a8849cf6d1d535e69fc3836c5720e0372a28 (diff)
Set fOptions in SkCodec::getPixels
Subclasses sometimes try to read fOptions, but it used to not get set for full decodes. As a result, they might be reading the Options from a previous scanline/incremental decode. In addition to being wrong, this is bad in the case of an fSubset pointing to a rectangle that no longer exists. So set fOptions in getPixels, prior to any attempts to read it by sub- classes. Use a different workaround for the webp/incomplete bug. Set fSubset to null prior to calling fillIncompleteImage. It can only be non-null for webp, and in that case we do not want the fill call to be using the subset width. Modify the Codec_jpeg_rewind test to use an incomplete image, so that it will also test fillIncompleteImage. DM tests of inc0.webp and inc1.webp will verify that the incomplete bug has not resurfaced. BUG=skia:5772 Change-Id: If5e1e3c9a7f337183783299c0a9e58dcbbc84119 Reviewed-on: https://skia-review.googlesource.com/7682 Commit-Queue: Matt Sarett <msarett@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com> Reviewed-by: Matt Sarett <msarett@google.com>
Diffstat (limited to 'src/codec/SkCodec.cpp')
-rw-r--r--src/codec/SkCodec.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp
index 739c9cd673..e9eeb4529a 100644
--- a/src/codec/SkCodec.cpp
+++ b/src/codec/SkCodec.cpp
@@ -215,9 +215,7 @@ SkCodec::Result SkCodec::getPixels(const SkImageInfo& info, void* pixels, size_t
}
fDstInfo = info;
- // FIXME: fOptions should be updated to options here, since fillIncompleteImage (called below
- // in this method) accesses it. Without updating, it uses the old value.
- //fOptions = *options;
+ fOptions = *options;
// On an incomplete decode, the subclass will specify the number of scanlines that it decoded
// successfully.
@@ -235,6 +233,12 @@ SkCodec::Result SkCodec::getPixels(const SkImageInfo& info, void* pixels, size_t
// 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()) {
+ // 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
+ // differenty from the other codecs, and it needs to use the width specified by the info.
+ // Set the subset to null so SkWebpCodec uses the correct width.
+ fOptions.fSubset = nullptr;
this->fillIncompleteImage(info, pixels, rowBytes, options->fZeroInitialized, info.height(),
rowsDecoded);
}