BUILD.gn: skia_enable_pdf
BUG=skia:
Change-Id: Icf616bec73e81aad97815b519566ff5b9db611e3
Reviewed-on: https://skia-review.googlesource.com/6495
Commit-Queue: Hal Canary <halcanary@google.com>
Reviewed-by: Mike Klein <mtklein@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index 24651c7..c4158c6 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -28,6 +28,7 @@
skia_enable_android_framework_defines = false
skia_enable_discrete_gpu = true
skia_enable_gpu = true
+ skia_enable_pdf = true
skia_enable_tools = is_skia_standalone
skia_enable_vulkan_debug_layers = is_skia_standalone && is_debug
skia_vulkan_sdk = getenv("VULKAN_SDK")
@@ -429,7 +430,8 @@
}
optional("pdf") {
- enabled = skia_use_zlib
+ enabled = skia_use_zlib && skia_enable_pdf
+ public_defines = [ "SK_SUPPORT_PDF" ]
deps = [
"//third_party/zlib",
@@ -439,7 +441,7 @@
if (skia_use_sfntly) {
deps += [ "//third_party/sfntly" ]
- public_defines = [ "SK_PDF_USE_SFNTLY" ]
+ public_defines += [ "SK_PDF_USE_SFNTLY" ]
}
}
diff --git a/bench/PDFBench.cpp b/bench/PDFBench.cpp
index 573353f..e0d4934 100644
--- a/bench/PDFBench.cpp
+++ b/bench/PDFBench.cpp
@@ -6,15 +6,12 @@
*/
#include "Benchmark.h"
+
#include "Resources.h"
#include "SkAutoPixmapStorage.h"
#include "SkData.h"
#include "SkGradientShader.h"
#include "SkImage.h"
-#include "SkPDFBitmap.h"
-#include "SkPDFDocument.h"
-#include "SkPDFShader.h"
-#include "SkPDFUtils.h"
#include "SkPixmap.h"
#include "SkRandom.h"
#include "SkStream.h"
@@ -27,6 +24,33 @@
size_t fN;
};
+struct WStreamWriteTextBenchmark : public Benchmark {
+ std::unique_ptr<SkWStream> fWStream;
+ WStreamWriteTextBenchmark() : fWStream(new NullWStream) {}
+ const char* onGetName() override { return "WStreamWriteText"; }
+ bool isSuitableFor(Backend backend) override {
+ return backend == kNonRendering_Backend;
+ }
+ void onDraw(int loops, SkCanvas*) override {
+ while (loops-- > 0) {
+ for (int i = 1000; i-- > 0;) {
+ fWStream->writeText("HELLO SKIA!\n");
+ }
+ }
+ }
+};
+} // namespace
+
+DEF_BENCH(return new WStreamWriteTextBenchmark;)
+
+#ifdef SK_SUPPORT_PDF
+
+#include "SkPDFBitmap.h"
+#include "SkPDFDocument.h"
+#include "SkPDFShader.h"
+#include "SkPDFUtils.h"
+
+namespace {
static void test_pdf_object_serialization(const sk_sp<SkPDFObject> object) {
// SkDebugWStream wStream;
NullWStream wStream;
@@ -207,22 +231,6 @@
}
};
-struct WStreamWriteTextBenchmark : public Benchmark {
- std::unique_ptr<SkWStream> fWStream;
- WStreamWriteTextBenchmark() : fWStream(new NullWStream) {}
- const char* onGetName() override { return "WStreamWriteText"; }
- bool isSuitableFor(Backend backend) override {
- return backend == kNonRendering_Backend;
- }
- void onDraw(int loops, SkCanvas*) override {
- while (loops-- > 0) {
- for (int i = 1000; i-- > 0;) {
- fWStream->writeText("HELLO SKIA!\n");
- }
- }
- }
-};
-
struct WritePDFTextBenchmark : public Benchmark {
std::unique_ptr<SkWStream> fWStream;
WritePDFTextBenchmark() : fWStream(new NullWStream) {}
@@ -249,5 +257,7 @@
DEF_BENCH(return new PDFScalarBench;)
DEF_BENCH(return new PDFColorComponentBench;)
DEF_BENCH(return new PDFShaderBench;)
-DEF_BENCH(return new WStreamWriteTextBenchmark;)
DEF_BENCH(return new WritePDFTextBenchmark;)
+
+#endif
+
diff --git a/tests/PDFDeflateWStreamTest.cpp b/tests/PDFDeflateWStreamTest.cpp
index 11d2370..dcb7547 100644
--- a/tests/PDFDeflateWStreamTest.cpp
+++ b/tests/PDFDeflateWStreamTest.cpp
@@ -5,9 +5,12 @@
* found in the LICENSE file.
*/
+#include "Test.h"
+
+#ifdef SK_SUPPORT_PDF
+
#include "SkDeflate.h"
#include "SkRandom.h"
-#include "Test.h"
namespace {
@@ -162,3 +165,5 @@
SkDeflateWStream emptyDeflateWStream(nullptr);
REPORTER_ASSERT(r, !emptyDeflateWStream.writeText("FOO"));
}
+
+#endif
diff --git a/tests/PDFGlyphsToUnicodeTest.cpp b/tests/PDFGlyphsToUnicodeTest.cpp
index 0d87cd7d..332520b 100644
--- a/tests/PDFGlyphsToUnicodeTest.cpp
+++ b/tests/PDFGlyphsToUnicodeTest.cpp
@@ -5,11 +5,14 @@
* found in the LICENSE file.
*/
+#include "Test.h"
+
+#ifdef SK_SUPPORT_PDF
+
#include "SkBitSet.h"
#include "SkData.h"
#include "SkPDFMakeToUnicodeCmap.h"
#include "SkStream.h"
-#include "Test.h"
static const int kMaximumGlyphCount = SK_MaxU16 + 1;
@@ -178,3 +181,5 @@
REPORTER_ASSERT(reporter, stream_equals(buffer2, 0, expectedResult2,
buffer2.bytesWritten()));
}
+
+#endif
diff --git a/tests/PDFJpegEmbedTest.cpp b/tests/PDFJpegEmbedTest.cpp
index 17dbac8..100c9b3 100644
--- a/tests/PDFJpegEmbedTest.cpp
+++ b/tests/PDFJpegEmbedTest.cpp
@@ -9,7 +9,6 @@
#include "SkData.h"
#include "SkDocument.h"
#include "SkImageGenerator.h"
-#include "SkJpegInfo.h"
#include "SkStream.h"
#include "Resources.h"
@@ -80,6 +79,10 @@
REPORTER_ASSERT(r, !is_subset_of(cmykData.get(), pdfData.get()));
}
+#ifdef SK_SUPPORT_PDF
+
+#include "SkJpegInfo.h"
+
DEF_TEST(SkPDF_JpegIdentification, r) {
static struct {
const char* path;
@@ -208,3 +211,4 @@
REPORTER_ASSERT(r, !SkIsJFIF(data.get(), &info));
}
}
+#endif
diff --git a/tests/PDFPrimitivesTest.cpp b/tests/PDFPrimitivesTest.cpp
index 81b33ba..de9af07 100644
--- a/tests/PDFPrimitivesTest.cpp
+++ b/tests/PDFPrimitivesTest.cpp
@@ -5,6 +5,10 @@
* found in the LICENSE file.
*/
+#include "Test.h"
+
+#ifdef SK_SUPPORT_PDF
+
#include "Resources.h"
#include "SkBitmap.h"
#include "SkCanvas.h"
@@ -24,7 +28,6 @@
#include "SkSpecialImage.h"
#include "SkStream.h"
#include "SkTypes.h"
-#include "Test.h"
#include "sk_tool_utils.h"
#include <cstdlib>
@@ -486,3 +489,4 @@
REPORTER_ASSERT(reporter, roundTrip == i);
}
}
+#endif