diff --git a/experimental/tools/pdf-comparison.py b/experimental/tools/pdf-comparison.py index d70469566450..00f24f5cde73 100755 --- a/experimental/tools/pdf-comparison.py +++ b/experimental/tools/pdf-comparison.py @@ -211,9 +211,7 @@ def checkout_worktree(checkoutable): return directory def build_skia(directory, executable): - args = ('--args=is_debug=false' - ' extra_cflags=["-DSK_PDF_LESS_COMPRESSION",' - ' "-DSK_PDF_BASE85_BINARY"] ') + args = ('--args=is_debug=false') if test_exe('ccache'): args += ' cc_wrapper="ccache"' args += EXTRA_GN_ARGS diff --git a/src/pdf/SkPDFBitmap.cpp b/src/pdf/SkPDFBitmap.cpp index b2874d930c69..25e38b4059e6 100644 --- a/src/pdf/SkPDFBitmap.cpp +++ b/src/pdf/SkPDFBitmap.cpp @@ -114,22 +114,11 @@ void emit_image_stream(SkPDFDocument* doc, pdfDict.insertRef("SMask", sMask); } pdfDict.insertInt("BitsPerComponent", 8); - #ifdef SK_PDF_BASE85_BINARY - auto filters = SkPDFMakeArray(); - filters->appendName("ASCII85Decode"); - switch (format) { - case SkPDFStreamFormat::DCT: filters->appendName("DCTDecode"); break; - case SkPDFStreamFormat::Flate: filters->appendName("FlateDecode"); break; - case SkPDFStreamFormat::Uncompressed: break; - } - pdfDict.insertObject("Filter", std::move(filters)); - #else switch (format) { case SkPDFStreamFormat::DCT: pdfDict.insertName("Filter", "DCTDecode"); break; case SkPDFStreamFormat::Flate: pdfDict.insertName("Filter", "FlateDecode"); break; case SkPDFStreamFormat::Uncompressed: break; } - #endif if (format == SkPDFStreamFormat::DCT) { pdfDict.insertInt("ColorTransform", 0); } @@ -175,9 +164,6 @@ void do_deflated_alpha(const SkPixmap& pm, SkPDFDocument* doc, SkPDFIndirectRefe deflateWStream->finalize(); } - #ifdef SK_PDF_BASE85_BINARY - SkPDFUtils::Base85Encode(buffer.detachAsStream(), &buffer); - #endif int length = SkToInt(buffer.bytesWritten()); emit_image_stream(doc, ref, [&buffer](SkWStream* stream) { buffer.writeToAndReset(stream); }, pm.info().dimensions(), SkPDFUnion::Name("DeviceGray"), @@ -288,9 +274,6 @@ void do_deflated_image(const SkPixmap& pm, } } - #ifdef SK_PDF_BASE85_BINARY - SkPDFUtils::Base85Encode(buffer.detachAsStream(), &buffer); - #endif int length = SkToInt(buffer.bytesWritten()); emit_image_stream(doc, ref, [&buffer](SkWStream* stream) { buffer.writeToAndReset(stream); }, pm.info().dimensions(), std::move(colorSpace), sMask, length, format); @@ -321,11 +304,6 @@ bool do_jpeg(sk_sp data, SkColorSpace* imageColorSpace, SkPDFDocument* d || kTopLeft_SkEncodedOrigin != exifOrientation) { return false; } - #ifdef SK_PDF_BASE85_BINARY - SkDynamicMemoryWStream buffer; - SkPDFUtils::Base85Encode(SkMemoryStream::MakeDirect(data->data(), data->size()), &buffer); - data = buffer.detachAsData(); - #endif int channels = yuv ? 3 : 1; SkPDFUnion colorSpace = yuv ? SkPDFUnion::Name("DeviceRGB") : SkPDFUnion::Name("DeviceGray"); diff --git a/src/pdf/SkPDFTypes.cpp b/src/pdf/SkPDFTypes.cpp index c43955b047d3..2dda3879e5cc 100644 --- a/src/pdf/SkPDFTypes.cpp +++ b/src/pdf/SkPDFTypes.cpp @@ -561,17 +561,6 @@ static void serialize_stream(SkPDFDict* origDict, SkDeflateWStream deflateWStream(&compressedData,SkToInt(doc->metadata().fCompressionLevel)); SkStreamCopy(&deflateWStream, stream); deflateWStream.finalize(); - #ifdef SK_PDF_BASE85_BINARY - { - SkPDFUtils::Base85Encode(compressedData.detachAsStream(), &compressedData); - tmp = compressedData.detachAsStream(); - stream = tmp.get(); - auto filters = SkPDFMakeArray(); - filters->appendName("ASCII85Decode"); - filters->appendName("FlateDecode"); - dict.insertObject("Filter", std::move(filters)); - } - #else if (stream->getLength() > compressedData.bytesWritten() + kMinimumSavings) { tmp = compressedData.detachAsStream(); stream = tmp.get(); @@ -579,7 +568,6 @@ static void serialize_stream(SkPDFDict* origDict, } else { SkAssertResult(stream->rewind()); } - #endif } dict.insertInt("Length", stream->getLength()); diff --git a/src/pdf/SkPDFTypes.h b/src/pdf/SkPDFTypes.h index a0a3c80590dc..78fa68fc623c 100644 --- a/src/pdf/SkPDFTypes.h +++ b/src/pdf/SkPDFTypes.h @@ -189,12 +189,6 @@ static inline std::unique_ptr SkPDFMakeDict(const char* type = nullpt enum class SkPDFSteamCompressionEnabled : bool { No = false, Yes = true, - Default = -#ifdef SK_PDF_LESS_COMPRESSION - No, -#else - Yes, -#endif }; // Exposed for unit testing. @@ -205,5 +199,5 @@ SkPDFIndirectReference SkPDFStreamOut( std::unique_ptr dict, std::unique_ptr stream, SkPDFDocument* doc, - SkPDFSteamCompressionEnabled compress = SkPDFSteamCompressionEnabled::Default); + SkPDFSteamCompressionEnabled compress = SkPDFSteamCompressionEnabled::Yes); #endif diff --git a/src/pdf/SkPDFUtils.cpp b/src/pdf/SkPDFUtils.cpp index 9d99885bc949..0447074f706a 100644 --- a/src/pdf/SkPDFUtils.cpp +++ b/src/pdf/SkPDFUtils.cpp @@ -359,43 +359,6 @@ bool SkPDFUtils::ToBitmap(const SkImage* img, SkBitmap* dst) { return false; } -#ifdef SK_PDF_BASE85_BINARY -void SkPDFUtils::Base85Encode(std::unique_ptr stream, SkDynamicMemoryWStream* dst) { - SkASSERT(dst); - SkASSERT(stream); - dst->writeText("\n"); - int column = 0; - while (true) { - uint8_t src[4] = {0, 0, 0, 0}; - size_t count = stream->read(src, 4); - SkASSERT(count < 5); - if (0 == count) { - dst->writeText("~>\n"); - return; - } - uint32_t v = ((uint32_t)src[0] << 24) | ((uint32_t)src[1] << 16) | - ((uint32_t)src[2] << 8) | src[3]; - if (v == 0 && count == 4) { - dst->writeText("z"); - column += 1; - } else { - char buffer[5]; - for (int n = 4; n > 0; --n) { - buffer[n] = (v % 85) + '!'; - v /= 85; - } - buffer[0] = v + '!'; - dst->write(buffer, count + 1); - column += count + 1; - } - if (column > 74) { - dst->writeText("\n"); - column = 0; - } - } -} -#endif // SK_PDF_BASE85_BINARY - void SkPDFUtils::AppendTransform(const SkMatrix& matrix, SkWStream* content) { SkScalar values[6]; if (!matrix.asAffine(values)) { diff --git a/src/pdf/SkPDFUtils.h b/src/pdf/SkPDFUtils.h index 58cc18fa9a25..1d7bef4dce2f 100644 --- a/src/pdf/SkPDFUtils.h +++ b/src/pdf/SkPDFUtils.h @@ -141,10 +141,6 @@ void PopulateTilingPatternDict(SkPDFDict* pattern, bool ToBitmap(const SkImage* img, SkBitmap* dst); -#ifdef SK_PDF_BASE85_BINARY -void Base85Encode(std::unique_ptr src, SkDynamicMemoryWStream* dst); -#endif // SK_PDF_BASE85_BINARY - void AppendTransform(const SkMatrix&, SkWStream*); // Takes SkTime::GetNSecs() [now] and puts it into the provided struct. diff --git a/tests/PDFJpegEmbedTest.cpp b/tests/PDFJpegEmbedTest.cpp index d2593f12ebf5..ceb5c3d8a653 100644 --- a/tests/PDFJpegEmbedTest.cpp +++ b/tests/PDFJpegEmbedTest.cpp @@ -96,10 +96,6 @@ DEF_TEST(SkPDF_JpegEmbedTest, r) { sk_sp pdfData = pdf.detachAsData(); SkASSERT(pdfData); - #ifndef SK_PDF_BASE85_BINARY - REPORTER_ASSERT(r, is_subset_of(mandrillData.get(), pdfData.get())); - #endif - // This JPEG uses a nonstandard colorspace - it can not be // embedded into the PDF directly. REPORTER_ASSERT(r, !is_subset_of(cmykData.get(), pdfData.get()));