aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar scroggo <scroggo@chromium.org>2016-11-01 08:28:28 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-11-01 08:28:28 -0700
commite71b1a1496738ebce4a8cac4ffa5ee1413996542 (patch)
tree725838575056d43c89536794e9e4f0c8c063f749 /include
parentc25c5d73e9f4d840dc758c399496d5690709ad58 (diff)
Report repetition count in SkCodec
Add a new accessor to retrieve the repetition count. Remove constants (and corresponding copyright) in SkCodecAnimation. These may make sense for the calling code, but are not needed here. kRepetitionCountInfinite corresponds to Blink's kAnimationLoopInfinite. Move cLoopCountNotSeen to private. It is used to determine whether we still need to parse. Add a new enum to the parse query - only parse enough to determine the repetition count. Unlike Chromium, SkGifCodec does not account for deleting the reader (which SkGifCodec does not do) or failed decodes. Add a test. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2447863002 Review-Url: https://codereview.chromium.org/2447863002
Diffstat (limited to 'include')
-rw-r--r--include/codec/SkCodec.h23
1 files changed, 21 insertions, 2 deletions
diff --git a/include/codec/SkCodec.h b/include/codec/SkCodec.h
index c2519cb840..f2a717c716 100644
--- a/include/codec/SkCodec.h
+++ b/include/codec/SkCodec.h
@@ -607,8 +607,8 @@ public:
/**
* Return info about the frames in the image.
*
- * May require reading through the stream to determine the number of
- * frames.
+ * May require reading through the stream to determine info about the
+ * frames (including the count).
*
* As such, future decoding calls may require a rewind.
*
@@ -618,6 +618,21 @@ public:
return this->onGetFrameInfo();
}
+ static constexpr int kRepetitionCountInfinite = -1;
+
+ /**
+ * Return the number of times to repeat, if this image is animated.
+ *
+ * May require reading the stream to find the repetition count.
+ *
+ * As such, future decoding calls may require a rewind.
+ *
+ * For single-frame images, this will return 0.
+ */
+ int getRepetitionCount() {
+ return this->onGetRepetitionCount();
+ }
+
protected:
/**
* Takes ownership of SkStream*
@@ -766,6 +781,10 @@ protected:
return {};
}
+ virtual int onGetRepetitionCount() {
+ return 0;
+ }
+
/**
* Used for testing with qcms.
* FIXME: Remove this when we are done comparing with qcms.