aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--BUILD.gn6
-rw-r--r--bench/PDFBench.cpp52
-rw-r--r--tests/PDFDeflateWStreamTest.cpp7
-rw-r--r--tests/PDFGlyphsToUnicodeTest.cpp7
-rw-r--r--tests/PDFJpegEmbedTest.cpp6
-rw-r--r--tests/PDFPrimitivesTest.cpp6
6 files changed, 57 insertions, 27 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 24651c75bf..c4158c622e 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -28,6 +28,7 @@ declare_args() {
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("jpeg") {
}
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 @@ optional("pdf") {
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 573353fcab..e0d4934bce 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 @@ struct NullWStream : public SkWStream {
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 PDFShaderBench : public Benchmark {
}
};
-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 PDFCompressionBench;)
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 11d237059a..dcb7547495 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 @@ DEF_TEST(SkPDF_DeflateWStream, r) {
SkDeflateWStream emptyDeflateWStream(nullptr);
REPORTER_ASSERT(r, !emptyDeflateWStream.writeText("FOO"));
}
+
+#endif
diff --git a/tests/PDFGlyphsToUnicodeTest.cpp b/tests/PDFGlyphsToUnicodeTest.cpp
index 0d87cd7df2..332520bfb0 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 @@ endbfrange\n";
REPORTER_ASSERT(reporter, stream_equals(buffer2, 0, expectedResult2,
buffer2.bytesWritten()));
}
+
+#endif
diff --git a/tests/PDFJpegEmbedTest.cpp b/tests/PDFJpegEmbedTest.cpp
index 17dbac8cfa..100c9b3f11 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 @@ DEF_TEST(SkPDF_JpegEmbedTest, r) {
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 @@ DEF_TEST(SkPDF_JpegIdentification, r) {
REPORTER_ASSERT(r, !SkIsJFIF(data.get(), &info));
}
}
+#endif
diff --git a/tests/PDFPrimitivesTest.cpp b/tests/PDFPrimitivesTest.cpp
index 81b33ba3b7..de9af07d2f 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 @@ DEF_TEST(SkPDF_Primitives_Color, reporter) {
REPORTER_ASSERT(reporter, roundTrip == i);
}
}
+#endif