Rename GIFImageReader to SkGifImageReader

The former could violate One Definition Rule in Google3, since other
projects that are based on Chrome/webkit also have GIFImageReader.
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2445653004

Review-Url: https://codereview.chromium.org/2445653004
diff --git a/BUILD.gn b/BUILD.gn
index 972f6a9..1967016 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -541,7 +541,7 @@
     "src/svg/SkSVGDevice.cpp",
     "src/utils/mac/SkStream_mac.cpp",
     "third_party/etc1/etc1.cpp",
-    "third_party/gif/GIFImageReader.cpp",
+    "third_party/gif/SkGifImageReader.cpp",
     "third_party/ktx/ktx.cpp",
   ]
 
diff --git a/gyp/codec.gyp b/gyp/codec.gyp
index e9780fe..51ee97f 100644
--- a/gyp/codec.gyp
+++ b/gyp/codec.gyp
@@ -55,7 +55,7 @@
         '../src/codec/SkCodecImageGenerator.cpp',
         '../src/ports/SkImageGenerator_skia.cpp',
 
-        '../third_party/gif/GIFImageReader.cpp',
+        '../third_party/gif/SkGifImageReader.cpp',
       ],
       'direct_dependent_settings': {
         'include_dirs': [
diff --git a/src/codec/SkGifCodec.cpp b/src/codec/SkGifCodec.cpp
index 3f37bc3..1c250fc 100644
--- a/src/codec/SkGifCodec.cpp
+++ b/src/codec/SkGifCodec.cpp
@@ -72,8 +72,8 @@
  * Reads enough of the stream to determine the image format
  */
 SkCodec* SkGifCodec::NewFromStream(SkStream* stream) {
-    std::unique_ptr<GIFImageReader> reader(new GIFImageReader(stream));
-    if (!reader->parse(GIFImageReader::GIFSizeQuery)) {
+    std::unique_ptr<SkGifImageReader> reader(new SkGifImageReader(stream));
+    if (!reader->parse(SkGifImageReader::GIFSizeQuery)) {
         // Not enough data to determine the size.
         return nullptr;
     }
@@ -110,7 +110,7 @@
 }
 
 SkGifCodec::SkGifCodec(const SkEncodedInfo& encodedInfo, const SkImageInfo& imageInfo,
-                       GIFImageReader* reader)
+                       SkGifImageReader* reader)
     : INHERITED(encodedInfo, imageInfo, nullptr)
     , fReader(reader)
     , fTmpBuffer(nullptr)
@@ -127,7 +127,7 @@
 }
 
 std::vector<SkCodec::FrameInfo> SkGifCodec::onGetFrameInfo() {
-    fReader->parse(GIFImageReader::GIFFrameCountQuery);
+    fReader->parse(SkGifImageReader::GIFFrameCountQuery);
     const size_t size = fReader->imagesCount();
     std::vector<FrameInfo> result(size);
     for (size_t i = 0; i < size; i++) {
@@ -184,7 +184,7 @@
                          kInvalidConversion);
     }
 
-    fReader->parse((GIFImageReader::GIFParseQuery) frameIndex);
+    fReader->parse((SkGifImageReader::GIFParseQuery) frameIndex);
 
     if (frameIndex >= fReader->imagesCount()) {
         return gif_error("frame index out of range!\n", kIncompleteInput);
@@ -269,7 +269,7 @@
     // It is possible the client has appended more data. Parse, if needed.
     const auto& options = this->options();
     const size_t frameIndex = options.fFrameIndex;
-    fReader->parse((GIFImageReader::GIFParseQuery) frameIndex);
+    fReader->parse((SkGifImageReader::GIFParseQuery) frameIndex);
 
     const bool firstCallToIncrementalDecode = fFirstCallToIncrementalDecode;
     fFirstCallToIncrementalDecode = false;
@@ -357,7 +357,7 @@
         }
     }
 
-    // Note: there is a difference between the following call to GIFImageReader::decode
+    // Note: there is a difference between the following call to SkGifImageReader::decode
     // returning false and leaving frameDecoded false:
     // - If the method returns false, there was an error in the stream. We still treat this as
     //   incomplete, since we have already decoded some rows.
diff --git a/src/codec/SkGifCodec.h b/src/codec/SkGifCodec.h
index 544ba13..b5f8f7c 100644
--- a/src/codec/SkGifCodec.h
+++ b/src/codec/SkGifCodec.h
@@ -12,7 +12,7 @@
 #include "SkImageInfo.h"
 #include "SkSwizzler.h"
 
-#include "GIFImageReader.h"
+#include "SkGifImageReader.h"
 
 /*
  *
@@ -30,7 +30,7 @@
      */
     static SkCodec* NewFromStream(SkStream*);
 
-    // Callback for GIFImageReader when a row is available.
+    // Callback for SkGifImageReader when a row is available.
     bool haveDecodedRow(size_t frameIndex, const unsigned char* rowBegin,
                         size_t rowNumber, unsigned repeatCount, bool writeTransparentPixels);
 protected:
@@ -127,31 +127,31 @@
     /*
      * Creates an instance of the decoder
      * Called only by NewFromStream
-     * Takes ownership of the GIFImageReader
+     * Takes ownership of the SkGifImageReader
      */
-    SkGifCodec(const SkEncodedInfo&, const SkImageInfo&, GIFImageReader*);
+    SkGifCodec(const SkEncodedInfo&, const SkImageInfo&, SkGifImageReader*);
 
-    std::unique_ptr<GIFImageReader>         fReader;
-    std::unique_ptr<uint8_t[]>              fTmpBuffer;
-    std::unique_ptr<SkSwizzler>             fSwizzler;
-    sk_sp<SkColorTable>                     fCurrColorTable;
+    std::unique_ptr<SkGifImageReader>   fReader;
+    std::unique_ptr<uint8_t[]>          fTmpBuffer;
+    std::unique_ptr<SkSwizzler>         fSwizzler;
+    sk_sp<SkColorTable>                 fCurrColorTable;
     // We may create a dummy table if there is not a Map in the input data. In
     // that case, we set this value to false, and we can skip a lot of decoding
     // work (which would not be meaningful anyway). We create a "fake"/"dummy"
     // one in that case, so the client and the swizzler have something to draw.
-    bool                                    fCurrColorTableIsReal;
+    bool                                fCurrColorTableIsReal;
     // Whether the background was filled.
-    bool                                    fFilledBackground;
+    bool                                fFilledBackground;
     // True on the first call to onIncrementalDecode. This value is passed to
     // decodeFrame.
-    bool                                    fFirstCallToIncrementalDecode;
+    bool                                fFirstCallToIncrementalDecode;
 
-    void*                                   fDst;
-    size_t                                  fDstRowBytes;
+    void*                               fDst;
+    size_t                              fDstRowBytes;
 
     // Updated inside haveDecodedRow when rows are decoded, unless we filled
     // the background, in which case it is set once and left alone.
-    int                                     fRowsDecoded;
+    int                                 fRowsDecoded;
 
     typedef SkCodec INHERITED;
 };
diff --git a/third_party/gif/GIFImageReader.cpp b/third_party/gif/SkGifImageReader.cpp
similarity index 98%
rename from third_party/gif/GIFImageReader.cpp
rename to third_party/gif/SkGifImageReader.cpp
index 859b45f..efc273d 100644
--- a/third_party/gif/GIFImageReader.cpp
+++ b/third_party/gif/SkGifImageReader.cpp
@@ -72,7 +72,7 @@
 mailing address.
 */
 
-#include "GIFImageReader.h"
+#include "SkGifImageReader.h"
 #include "SkColorPriv.h"
 #include "SkGifCodec.h"
 
@@ -85,7 +85,7 @@
 // Note, the hold will never need to be bigger than 256 bytes to gather up in the hold,
 // as each GIF block (except colormaps) can never be bigger than 256 bytes.
 // Colormaps are directly copied in the resp. global_colormap or dynamically allocated local_colormap.
-// So a fixed buffer in GIFImageReader is good enough.
+// So a fixed buffer in SkGifImageReader is good enough.
 // This buffer is only needed to copy left-over data from one GifWrite call to the next
 #define GETN(n, s) \
     do { \
@@ -198,7 +198,7 @@
 
 // Perform Lempel-Ziv-Welch decoding.
 // Returns true if decoding was successful. In this case the block will have been completely consumed and/or rowsRemaining will be 0.
-// Otherwise, decoding failed; returns false in this case, which will always cause the GIFImageReader to set the "decode failed" flag.
+// Otherwise, decoding failed; returns false in this case, which will always cause the SkGifImageReader to set the "decode failed" flag.
 bool GIFLZWContext::doLZW(const unsigned char* block, size_t bytesInBlock)
 {
     const size_t width = m_frameContext->width();
@@ -340,7 +340,7 @@
     return m_table;
 }
 
-sk_sp<SkColorTable> GIFImageReader::getColorTable(SkColorType colorType, size_t index) const {
+sk_sp<SkColorTable> SkGifImageReader::getColorTable(SkColorType colorType, size_t index) const {
     if (index >= m_frames.size()) {
         return nullptr;
     }
@@ -357,7 +357,7 @@
 }
 
 // Perform decoding for this frame. frameComplete will be true if the entire frame is decoded.
-// Returns false if a decoding error occurred. This is a fatal error and causes the GIFImageReader to set the "decode failed" flag.
+// Returns false if a decoding error occurred. This is a fatal error and causes the SkGifImageReader to set the "decode failed" flag.
 // Otherwise, either not enough data is available to decode further than before, or the new data has been decoded successfully; returns true in this case.
 bool GIFFrameContext::decode(SkGifCodec* client, bool* frameComplete)
 {
@@ -397,7 +397,7 @@
 // Decode a frame.
 // This method uses GIFFrameContext:decode() to decode the frame; decoding error is reported to client as a critical failure.
 // Return true if decoding has progressed. Return false if an error has occurred.
-bool GIFImageReader::decode(size_t frameIndex, bool* frameComplete)
+bool SkGifImageReader::decode(size_t frameIndex, bool* frameComplete)
 {
     GIFFrameContext* currentFrame = m_frames[frameIndex].get();
 
@@ -407,7 +407,7 @@
 // Parse incoming GIF data stream into internal data structures.
 // Return true if parsing has progressed or there is not enough data.
 // Return false if a fatal error is encountered.
-bool GIFImageReader::parse(GIFImageReader::GIFParseQuery query)
+bool SkGifImageReader::parse(SkGifImageReader::GIFParseQuery query)
 {
     if (m_parseCompleted) {
         return true;
@@ -849,7 +849,7 @@
     return true;
 }
 
-void GIFImageReader::addFrameIfNecessary()
+void SkGifImageReader::addFrameIfNecessary()
 {
     if (m_frames.empty() || m_frames.back()->isComplete()) {
         const size_t i = m_frames.size();
diff --git a/third_party/gif/GIFImageReader.h b/third_party/gif/SkGifImageReader.h
similarity index 98%
rename from third_party/gif/GIFImageReader.h
rename to third_party/gif/SkGifImageReader.h
index 307b8c4..5dc0e4f 100644
--- a/third_party/gif/GIFImageReader.h
+++ b/third_party/gif/SkGifImageReader.h
@@ -35,8 +35,8 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
-#ifndef GIFImageReader_h
-#define GIFImageReader_h
+#ifndef SkGifImageReader_h
+#define SkGifImageReader_h
 
 // Define ourselves as the clientPtr.  Mozilla just hacked their C++ callback class into this old C decoder,
 // so we will too.
@@ -275,10 +275,10 @@
     bool m_isDataSizeDefined;
 };
 
-class GIFImageReader final : public SkNoncopyable {
+class SkGifImageReader final : public SkNoncopyable {
 public:
     // This takes ownership of stream.
-    GIFImageReader(SkStream* stream)
+    SkGifImageReader(SkStream* stream)
         : m_client(nullptr)
         , m_state(GIFType)
         , m_bytesToConsume(6) // Number of bytes for GIF type, either "GIF87a" or "GIF89a".
@@ -293,7 +293,7 @@
     {
     }
 
-    ~GIFImageReader()
+    ~SkGifImageReader()
     {
     }