aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party/gif/SkGifImageReader.h
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 /third_party/gif/SkGifImageReader.h
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 'third_party/gif/SkGifImageReader.h')
-rw-r--r--third_party/gif/SkGifImageReader.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/third_party/gif/SkGifImageReader.h b/third_party/gif/SkGifImageReader.h
index 5936350681..2b1b2d9423 100644
--- a/third_party/gif/SkGifImageReader.h
+++ b/third_party/gif/SkGifImageReader.h
@@ -298,8 +298,6 @@ public:
{
}
- static constexpr int cLoopCountNotSeen = -2;
-
~SkGifImageReader()
{
}
@@ -317,6 +315,8 @@ public:
SkGIFSizeQuery = -1,
// Parse to the end, so we know about all frames.
SkGIFFrameCountQuery = -2,
+ // Parse until we see the loop count.
+ SkGIFLoopCountQuery = -3,
};
// Parse incoming GIF data stream into internal data structures.
@@ -340,7 +340,12 @@ public:
// FIXME: This extra complexity is not necessary and we should just report m_frames.size().
return m_frames.back()->isHeaderDefined() ? m_frames.size() : m_frames.size() - 1;
}
- int loopCount() const { return m_loopCount; }
+ int loopCount() const {
+ if (cLoopCountNotSeen == m_loopCount) {
+ return 0;
+ }
+ return m_loopCount;
+ }
const SkGIFColorMap& globalColorMap() const
{
@@ -389,6 +394,8 @@ private:
unsigned m_screenWidth; // Logical screen width & height.
unsigned m_screenHeight;
SkGIFColorMap m_globalColorMap;
+
+ static constexpr int cLoopCountNotSeen = -2;
int m_loopCount; // Netscape specific extension block to control the number of animation loops a GIF renders.
std::vector<std::unique_ptr<SkGIFFrameContext>> m_frames;