summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Weintraub <asweintraub@google.com>2017-11-29 23:27:10 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-11-29 23:27:10 +0000
commit98b56332e9b5c04cde680301a8b0685590c3b922 (patch)
tree97b1f6f67b60678f37844322ccb0a657f9b3266c
parent02f46ae70560c4bd70950faa1496e0c6b244ff8d (diff)
downloadpdfium-98b56332e9b5c04cde680301a8b0685590c3b922.tar.xz
Allow building pdfium against the system version of libpng.
Bug: Change-Id: I0c930ca30637f58af3b60ed8f1383bd9234a1723 Reviewed-on: https://pdfium-review.googlesource.com/19850 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
-rw-r--r--BUILD.gn4
-rw-r--r--core/fxcodec/codec/ccodec_pngmodule.cpp7
-rw-r--r--pdfium.gni3
-rw-r--r--testing/image_diff/image_diff_png.cpp7
-rw-r--r--third_party/BUILD.gn15
5 files changed, 30 insertions, 6 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 228271d534..4a9daca59a 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -273,7 +273,7 @@ static_library("image_diff") {
configs += [ ":pdfium_core_config" ]
deps = []
if (!pdf_enable_xfa) {
- deps += [ "third_party:fx_lpng" ]
+ deps += [ "third_party:png" ]
}
}
@@ -781,8 +781,8 @@ static_library("fxcodec") {
"core/fxcodec/lbmp/fx_bmp.h",
]
deps += [
- "third_party:fx_lpng",
"third_party:fx_tiff",
+ "third_party:png",
]
}
if (is_posix) {
diff --git a/core/fxcodec/codec/ccodec_pngmodule.cpp b/core/fxcodec/codec/ccodec_pngmodule.cpp
index 40bdfba7ce..37e83f7248 100644
--- a/core/fxcodec/codec/ccodec_pngmodule.cpp
+++ b/core/fxcodec/codec/ccodec_pngmodule.cpp
@@ -14,10 +14,11 @@
#include "core/fxge/fx_dib.h"
#include "third_party/base/ptr_util.h"
-extern "C" {
-#undef FAR
+#ifdef USE_SYSTEM_LIBPNG
+#include <png.h>
+#else
#include "third_party/libpng16/png.h"
-} // extern "C"
+#endif
#define PNG_ERROR_SIZE 256
diff --git a/pdfium.gni b/pdfium.gni
index 530301a5d9..f05623af77 100644
--- a/pdfium.gni
+++ b/pdfium.gni
@@ -61,6 +61,9 @@ declare_args() {
# Don't build against bundled lcms2.
use_system_lcms2 = false
+
+ # Don't build against bundled libpng.
+ use_system_libpng = false
}
if (pdf_use_skia && pdf_use_skia_paths) {
diff --git a/testing/image_diff/image_diff_png.cpp b/testing/image_diff/image_diff_png.cpp
index 56be539057..48b5ae17b4 100644
--- a/testing/image_diff/image_diff_png.cpp
+++ b/testing/image_diff/image_diff_png.cpp
@@ -17,9 +17,14 @@
#include <string>
#include "third_party/base/logging.h"
-#include "third_party/libpng16/png.h"
#include "third_party/zlib/zlib.h"
+#ifdef USE_SYSTEM_LIBPNG
+#include <png.h>
+#else
+#include "third_party/libpng16/png.h"
+#endif
+
namespace image_diff_png {
namespace {
diff --git a/third_party/BUILD.gn b/third_party/BUILD.gn
index a188f56194..3861f6aed7 100644
--- a/third_party/BUILD.gn
+++ b/third_party/BUILD.gn
@@ -398,6 +398,21 @@ static_library("fx_libopenjpeg") {
]
}
+config("system_libpng_config") {
+ libs = [ "png" ]
+ defines = [ "USE_SYSTEM_LIBPNG" ]
+}
+
+group("png") {
+ if (use_system_libpng) {
+ public_configs = [ ":system_libpng_config" ]
+ } else {
+ public_deps = [
+ ":fx_lpng",
+ ]
+ }
+}
+
static_library("fx_lpng") {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [