aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/codec
diff options
context:
space:
mode:
authorGravatar Leon Scroggins III <scroggo@google.com>2017-04-12 10:49:52 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-12 15:22:43 +0000
commite132e7be5f9108692254c37db592ea7611abbc15 (patch)
tree44e7973680edc107da087f71d41619dd3aea178e /include/codec
parente5efa51b2acc86d1993132348d5b465855a653cc (diff)
Add SkCodec methods for individual frames
Add a version of getFrameInfo that returns information about a single frame, allowing a client to skip creating the entire vector. Add getFrameCount, for determining the number of frames in the image. Reimplement std::vector<FrameInfo> getFrameInfo with the new methods. Updates to the test: - getFrameInfo(size_t, FrameInfo*) fails before parsing - Test both versions of getFrameInfo - Recreate the codec between tests, to test parsing Change-Id: I77c19087f2f8dcf2c536d80167b18ad1ca96ae94 Reviewed-on: https://skia-review.googlesource.com/13190 Reviewed-by: Matt Sarett <msarett@google.com> Reviewed-by: Mike Reed <reed@google.com> Reviewed-by: Chris Blume <cblume@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
Diffstat (limited to 'include/codec')
-rw-r--r--include/codec/SkCodec.h35
1 files changed, 28 insertions, 7 deletions
diff --git a/include/codec/SkCodec.h b/include/codec/SkCodec.h
index 6d4352214c..aadcb059fe 100644
--- a/include/codec/SkCodec.h
+++ b/include/codec/SkCodec.h
@@ -593,6 +593,15 @@ public:
*/
int outputScanline(int inputScanline) const;
+ /**
+ * Return the number of frames in the image.
+ *
+ * May require reading through the stream.
+ */
+ size_t getFrameCount() {
+ return this->onGetFrameCount();
+ }
+
// The required frame for an independent frame is marked as
// kNone.
static constexpr size_t kNone = static_cast<size_t>(-1);
@@ -628,7 +637,18 @@ public:
};
/**
- * Return info about the frames in the image.
+ * Return info about a single frame.
+ *
+ * Only supported by multi-frame images. Does not read through the stream,
+ * so it should be called after getFrameCount() to parse any frames that
+ * have not already been parsed.
+ */
+ bool getFrameInfo(size_t index, FrameInfo* info) const {
+ return this->onGetFrameInfo(index, info);
+ }
+
+ /**
+ * Return info about all the frames in the image.
*
* May require reading through the stream to determine info about the
* frames (including the count).
@@ -637,9 +657,7 @@ public:
*
* For single-frame images, this will return an empty vector.
*/
- std::vector<FrameInfo> getFrameInfo() {
- return this->onGetFrameInfo();
- }
+ std::vector<FrameInfo> getFrameInfo();
static constexpr int kRepetitionCountInfinite = -1;
@@ -800,9 +818,12 @@ protected:
SkTransferFunctionBehavior premulBehavior);
SkColorSpaceXform* colorXform() const { return fColorXform.get(); }
- virtual std::vector<FrameInfo> onGetFrameInfo() {
- // empty vector - this is not animated.
- return std::vector<FrameInfo>{};
+ virtual size_t onGetFrameCount() {
+ return 1;
+ }
+
+ virtual bool onGetFrameInfo(size_t, FrameInfo*) const {
+ return false;
}
virtual int onGetRepetitionCount() {