Replace third_party/gif with new DEPS entry.

  - BUILD.gn `gif` optional source_set: use new skia_libgifcodec_path
    code, not third_party/gif code.

  - SkCodec.cpp: use third_party version of SkGifCodec.h.

  - rm src/codec/SkGifCodec.* third_party/gif/*

Original CL: https://review.skia.org/254582

Cq-Include-Trybots: luci.skia.skia.primary:Build-Debian9-Clang-x86-devrel-Android_SKQP
Bug: skia:9654
Change-Id: Ia0379af70a5ec5656a7d123b8b6816b9fa24eaee
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/255780
Reviewed-by: Hal Canary <halcanary@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index c60ec4e..c034f53 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -612,11 +612,22 @@
 
 optional("gif") {
   enabled = !skia_use_wuffs && skia_use_libgifcodec
-  public_defines = [ "SK_USE_LIBGIFCODEC" ]
-  sources = [
-    "src/codec/SkGifCodec.cpp",
-    "third_party/gif/SkGifImageReader.cpp",
-  ]
+  _libgifcodec_gni_path = "third_party/externals/libgifcodec/libgifcodec.gni"
+  if ("True" ==
+      exec_script("gn/checkpath.py",
+                  [ rebase_path(_libgifcodec_gni_path, root_build_dir) ],
+                  "trim string")) {
+    public_defines = [ "SK_USE_LIBGIFCODEC" ]
+    public_include_dirs = [
+      ".",
+      skia_libgifcodec_path,
+    ]
+    include_dirs = public_include_dirs
+    import(_libgifcodec_gni_path)
+    sources = rebase_path(libgifcodec_sources + libgifcodec_public,
+                          ".",
+                          skia_libgifcodec_path)
+  }
 }
 
 optional("heif") {