Use shared //third_party/libpng dependency

Uses //third_party/libpng for the libpng dependency, instead of PDFium's
private copy in //third_party/libpng16.

Bug: chromium:1130821
Change-Id: I749843df3f94363e20c14755e8b711c74b57acd5
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/101311
Commit-Queue: K. Moon <kmoon@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index 7339b2a..86520a5 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -26,10 +26,7 @@
   cflags_cc = []
   ldflags = []
   include_dirs = [ "." ]
-  defines = [
-    "PNG_PREFIX",
-    "PNG_USE_READ_MACROS",
-  ]
+  defines = []
 
   if (!use_system_libopenjpeg2) {
     defines += [ "OPJ_STATIC" ]
diff --git a/core/fxcodec/png/DEPS b/core/fxcodec/png/DEPS
index cc73855..9caa4d8 100644
--- a/core/fxcodec/png/DEPS
+++ b/core/fxcodec/png/DEPS
@@ -1,3 +1,3 @@
 include_rules = [
-  '+third_party/libpng16/png.h',
+  '+third_party/libpng/png.h',
 ]
diff --git a/core/fxcodec/png/png_decoder.cpp b/core/fxcodec/png/png_decoder.cpp
index 484658c..3cf4221 100644
--- a/core/fxcodec/png/png_decoder.cpp
+++ b/core/fxcodec/png/png_decoder.cpp
@@ -17,7 +17,7 @@
 #ifdef USE_SYSTEM_LIBPNG
 #include <png.h>
 #else
-#include "third_party/libpng16/png.h"
+#include "third_party/libpng/png.h"
 #endif
 
 #define PNG_ERROR_SIZE 256
diff --git a/docs/getting-started.md b/docs/getting-started.md
index 6470f8a..dbba9a1 100644
--- a/docs/getting-started.md
+++ b/docs/getting-started.md
@@ -75,7 +75,7 @@
 
 ```
 PDF_LIBS="-lpdfium -lfpdfapi -lfxge -lfpdfdoc -lfxcrt -lfx_agg \
--lfxcodec -lfx_lpng -lfx_libopenjpeg -lfx_lcms2 -lfx_freetype -ljpeg \
+-lfxcodec -lpng -lfx_libopenjpeg -lfx_lcms2 -lfx_freetype -ljpeg \
 -lfdrm -lpwl -lbigint -lformfiller -ljavascript -lfxedit"
 PDF_DIR=<path/to/pdfium>
 
diff --git a/samples/BUILD.gn b/samples/BUILD.gn
index ef32562..4a59acf 100644
--- a/samples/BUILD.gn
+++ b/samples/BUILD.gn
@@ -13,10 +13,7 @@
 config("pdfium_samples_config") {
   cflags = []
   ldflags = []
-  defines = [
-    "PNG_PREFIX",
-    "PNG_USE_READ_MACROS",
-  ]
+  defines = []
   include_dirs = [ ".." ]
   if (pdf_use_skia) {
     defines += [ "PDF_ENABLE_SKIA" ]
diff --git a/testing/fuzzers/BUILD.gn b/testing/fuzzers/BUILD.gn
index 46401b4..9667ba1 100644
--- a/testing/fuzzers/BUILD.gn
+++ b/testing/fuzzers/BUILD.gn
@@ -9,10 +9,7 @@
     "../..:pdfium_strict_config",
     "../..:pdfium_noshorten_config",
   ]
-  defines = [
-    "PNG_PREFIX",
-    "PNG_USE_READ_MACROS",
-  ]
+  defines = []
   include_dirs = [ "../.." ]
 }
 
diff --git a/testing/image_diff/DEPS b/testing/image_diff/DEPS
index 4bd2335..fcac201 100644
--- a/testing/image_diff/DEPS
+++ b/testing/image_diff/DEPS
@@ -1,5 +1,5 @@
 include_rules = [
-  '+third_party/libpng16',
+  '+third_party/libpng',
   '+third_party/zlib',
 ]
 
diff --git a/testing/image_diff/image_diff_png.cpp b/testing/image_diff/image_diff_png.cpp
index ddf4091..c2e8b03 100644
--- a/testing/image_diff/image_diff_png.cpp
+++ b/testing/image_diff/image_diff_png.cpp
@@ -27,7 +27,7 @@
 #ifdef USE_SYSTEM_LIBPNG
 #include <png.h>
 #else
-#include "third_party/libpng16/png.h"
+#include "third_party/libpng/png.h"
 #endif
 
 namespace image_diff_png {
diff --git a/third_party/BUILD.gn b/third_party/BUILD.gn
index 9fc2dd5..b30538a 100644
--- a/third_party/BUILD.gn
+++ b/third_party/BUILD.gn
@@ -443,7 +443,7 @@
   if (use_system_libpng) {
     public_configs = [ ":system_libpng_config" ]
   } else {
-    public_deps = [ ":fx_lpng" ]
+    public_deps = [ "//third_party/libpng" ]
   }
 }