aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/codec
diff options
context:
space:
mode:
authorGravatar Leon Scroggins III <scroggo@google.com>2017-06-12 16:41:09 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-06-12 20:55:59 +0000
commit1f6af6baadabd4d92a7bf582f6f9d70cb081758c (patch)
tree4ea997de77d51db13894f6aa1aa0e10084a4bd55 /include/codec
parent13b6afd148c6c4f4801969f4bc0cd265a8e74a36 (diff)
Consolidate decoding frames into SkCodec
Add a new private method to SkCodec that handles Options.fFrameIndex: - Check to ensure the index is valid - Call onGetFrameCount to force parsing the stream - Recursively call getPixels (it should be complete, so no need for incremental decoding) to decode the prior frame if necessary - Zero fill a RestoreBGColor frame Call the method in getPixels and startIncrementalDecode, and remove duplicate code from GIF and WEBP. Remove support for scaling frames beyond the first, which is currently unused. Preserve the feature of SkGifCodec that it will only parse to the end of the first frame if the first frame is asked for. (Also note that when we continue a partial frame, we won't force parsing the full stream.) If the client only wants the first frame, parsing the rest would be unnecessary. But if the client wants the second, we assume they will want any remaining frames, so we parse the remainder of the stream. This simplifies the code (so SkCodec does not have to ask its subclass to parse up to a particular frame). Update tests that relied on the old behavior: - Codec_partialAnim now hardcodes the bytes needed. Previously it relied on the old behavior that GIF only parsed up to the frame being decoded. - Codec_skipFullParse now only tests the first frame, since that is the case where it is important to skip a full parse. TBR=reed@google.com No changes to the public API. Change-Id: Ic2f075452dfeedb4e3e60e6cf4df33ee7bd38495 Reviewed-on: https://skia-review.googlesource.com/19276 Reviewed-by: Leon Scroggins <scroggo@google.com> Reviewed-by: Matt Sarett <msarett@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
Diffstat (limited to 'include/codec')
-rw-r--r--include/codec/SkCodec.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/include/codec/SkCodec.h b/include/codec/SkCodec.h
index 4773d20a0c..6b3aa5e020 100644
--- a/include/codec/SkCodec.h
+++ b/include/codec/SkCodec.h
@@ -23,8 +23,8 @@
#include <vector>
class SkColorSpace;
-class SkColorSpaceXform;
class SkData;
+class SkFrameHolder;
class SkPngChunkReader;
class SkSampler;
@@ -880,6 +880,18 @@ private:
return dim == fSrcInfo.dimensions() || this->onDimensionsSupported(dim);
}
+ /**
+ * For multi-framed images, return the object with information about the frames.
+ */
+ virtual const SkFrameHolder* getFrameHolder() const {
+ return nullptr;
+ }
+
+ /**
+ * Check for a valid Options.fFrameIndex, and decode prior frames if necessary.
+ */
+ Result handleFrameIndex(const SkImageInfo&, void* pixels, size_t rowBytes, const Options&);
+
// Methods for scanline decoding.
virtual Result onStartScanlineDecode(const SkImageInfo& /*dstInfo*/,
const Options& /*options*/, SkPMColor* /*ctable*/, int* /*ctableCount*/) {