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
diff --git a/src/codec/SkCodecAnimation.h b/src/codec/SkCodecAnimation.h
index d3fc553..b0495b8 100644
--- a/src/codec/SkCodecAnimation.h
+++ b/src/codec/SkCodecAnimation.h
@@ -5,31 +5,6 @@
  * found in the LICENSE file.
  */
 
-/*
- * Copyright (C) 2015 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
 #ifndef SkCodecAnimation_DEFINED
 #define SkCodecAnimation_DEFINED
 
@@ -38,25 +13,6 @@
 
 class SkCodecAnimation {
 public:
-
-    // GIF and WebP support animation. The explanation below is in terms of GIF,
-    // but the same constants are used for WebP, too.
-    // GIFs have an optional 16-bit unsigned loop count that describes how an
-    // animated GIF should be cycled.  If the loop count is absent, the animation
-    // cycles once; if it is 0, the animation cycles infinitely; otherwise the
-    // animation plays n + 1 cycles (where n is the specified loop count).  If the
-    // GIF decoder defaults to kAnimationLoopOnce in the absence of any loop count
-    // and translates an explicit "0" loop count to kAnimationLoopInfinite, then we
-    // get a couple of nice side effects:
-    //   * By making kAnimationLoopOnce be 0, we allow the animation cycling code to
-    //     avoid special-casing it, and simply treat all non-negative loop counts
-    //     identically.
-    //   * By making the other two constants negative, we avoid conflicts with any
-    //     real loop count values.
-    static const int kAnimationLoopOnce = 0;
-    static const int kAnimationLoopInfinite = -1;
-    static const int kAnimationNone = -2;
-
     /**
      *  This specifies how the next frame is based on this frame.
      *
diff --git a/src/codec/SkGifCodec.cpp b/src/codec/SkGifCodec.cpp
index 1322396..277da03 100644
--- a/src/codec/SkGifCodec.cpp
+++ b/src/codec/SkGifCodec.cpp
@@ -139,6 +139,11 @@
     return result;
 }
 
+int SkGifCodec::onGetRepetitionCount() {
+    fReader->parse(SkGifImageReader::SkGIFLoopCountQuery);
+    return fReader->loopCount();
+}
+
 void SkGifCodec::initializeColorTable(const SkImageInfo& dstInfo, size_t frameIndex) {
     fCurrColorTable = fReader->getColorTable(dstInfo.colorType(), frameIndex);
     fCurrColorTableIsReal = fCurrColorTable;
diff --git a/src/codec/SkGifCodec.h b/src/codec/SkGifCodec.h
index 9d8e0e4..5793766 100644
--- a/src/codec/SkGifCodec.h
+++ b/src/codec/SkGifCodec.h
@@ -49,6 +49,7 @@
     uint64_t onGetFillValue(const SkImageInfo&) const override;
 
     std::vector<FrameInfo> onGetFrameInfo() override;
+    int onGetRepetitionCount() override;
 
     Result onStartIncrementalDecode(const SkImageInfo& /*dstInfo*/, void*, size_t,
             const SkCodec::Options&, SkPMColor*, int*) override;