diff options
author | Mike Reed <reed@google.com> | 2017-12-15 05:23:54 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-12-15 05:24:09 +0000 |
commit | 800f5541bb0f4ea0f6923592355bdb64f156d8b3 (patch) | |
tree | fcad288bcdd54f3a59349aed7fbc5c326ae3cb31 /src | |
parent | 7f846f273ceaa5a3a8880e9af260f94bd1e614b6 (diff) |
Revert "remove SK_SUPPORT_LEGACY_PDF_PIXELSERIALIZER dead code"
This reverts commit 7f846f273ceaa5a3a8880e9af260f94bd1e614b6.
Reason for revert: missed callsite in google3
Original change's description:
> remove SK_SUPPORT_LEGACY_PDF_PIXELSERIALIZER dead code
>
> Bug: skia:
> Change-Id: Ia88f3e2fdf6d5c6e5128eaefda0d68c7042ae7a2
> Reviewed-on: https://skia-review.googlesource.com/85500
> Commit-Queue: Mike Reed <reed@google.com>
> Reviewed-by: Hal Canary <halcanary@google.com>
TBR=halcanary@google.com,reed@google.com
Change-Id: I232dc24831bd8d52e9cbbc7ee58177af0617574a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/85600
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/pdf/SkDocument_PDF_None.cpp | 15 | ||||
-rw-r--r-- | src/pdf/SkPDFBitmap.cpp | 21 | ||||
-rw-r--r-- | src/pdf/SkPDFBitmap.h | 11 | ||||
-rw-r--r-- | src/pdf/SkPDFCanon.h | 6 | ||||
-rw-r--r-- | src/pdf/SkPDFDevice.cpp | 3 | ||||
-rw-r--r-- | src/pdf/SkPDFDocument.cpp | 52 | ||||
-rw-r--r-- | src/pdf/SkPDFDocument.h | 15 |
7 files changed, 114 insertions, 9 deletions
diff --git a/src/pdf/SkDocument_PDF_None.cpp b/src/pdf/SkDocument_PDF_None.cpp index 50ed0b6d3b..4971c81d45 100644 --- a/src/pdf/SkDocument_PDF_None.cpp +++ b/src/pdf/SkDocument_PDF_None.cpp @@ -15,3 +15,18 @@ sk_sp<SkDocument> SkDocument::MakePDF(SkWStream* stream) { return nullptr; } +#ifdef SK_SUPPORT_LEGACY_PDF_PIXELSERIALIZER +sk_sp<SkDocument> SkDocument::MakePDF(SkWStream* stream, + SkScalar dpi, + const PDFMetadata& metadata, + sk_sp<SkPixelSerializer> jpegEncoder, + bool pdfa) { + return nullptr; +} +sk_sp<SkDocument> SkDocument::MakePDF(SkWStream* stream, SkScalar dpi) { + return nullptr; +} +sk_sp<SkDocument> SkDocument::MakePDF(const char path[], SkScalar dpi) { + return nullptr; +} +#endif diff --git a/src/pdf/SkPDFBitmap.cpp b/src/pdf/SkPDFBitmap.cpp index faae47ef63..b9b73a9e28 100644 --- a/src/pdf/SkPDFBitmap.cpp +++ b/src/pdf/SkPDFBitmap.cpp @@ -407,7 +407,11 @@ void PDFJpegBitmap::emitObject(SkWStream* stream, //////////////////////////////////////////////////////////////////////////////// -sk_sp<SkPDFObject> SkPDFCreateBitmapObject(sk_sp<SkImage> image, int encodingQuality) { +sk_sp<SkPDFObject> SkPDFCreateBitmapObject(sk_sp<SkImage> image, +#ifdef SK_SUPPORT_LEGACY_PDF_PIXELSERIALIZER + SkPixelSerializer* pixelSerializer, +#endif + int encodingQuality) { SkASSERT(image); SkASSERT(encodingQuality >= 0); sk_sp<SkData> data = image->refEncodedData(); @@ -423,6 +427,21 @@ sk_sp<SkPDFObject> SkPDFCreateBitmapObject(sk_sp<SkImage> image, int encodingQua } } +#ifdef SK_SUPPORT_LEGACY_PDF_PIXELSERIALIZER + if (pixelSerializer) { + SkBitmap bm; + if (SkPDFUtils::ToBitmap(image.get(), &bm)) { + data = pixelSerializer->encodeToData(bm.pixmap()); + if (data && SkIsJFIF(data.get(), &info)) { + bool yuv = info.fType == SkJFIFInfo::kYCbCr; + if (info.fSize == image->dimensions()) { // Sanity check. + return sk_make_sp<PDFJpegBitmap>(info.fSize, data.get(), yuv); + } + } + } + } +#endif + const bool isOpaque = image_compute_is_opaque(image.get()); if (encodingQuality <= 100 && isOpaque) { diff --git a/src/pdf/SkPDFBitmap.h b/src/pdf/SkPDFBitmap.h index 52ac59fea8..a4e8ec5ccb 100644 --- a/src/pdf/SkPDFBitmap.h +++ b/src/pdf/SkPDFBitmap.h @@ -10,15 +10,20 @@ #include "SkRefCnt.h" class SkImage; +#ifdef SK_SUPPORT_LEGACY_PDF_PIXELSERIALIZER +class SkPixelSerializer; +#endif class SkPDFObject; /** * SkPDFBitmap wraps a SkImage and serializes it as an image Xobject. * It is designed to use a minimal amout of memory, aside from refing * the image, and its emitObject() does not cache any data. - * - * quality > 100 means lossless */ -sk_sp<SkPDFObject> SkPDFCreateBitmapObject(sk_sp<SkImage>, int encodingQuality = 101); +sk_sp<SkPDFObject> SkPDFCreateBitmapObject(sk_sp<SkImage>, +#ifdef SK_SUPPORT_LEGACY_PDF_PIXELSERIALIZER + SkPixelSerializer*, +#endif + int encodingQuality); #endif // SkPDFBitmap_DEFINED diff --git a/src/pdf/SkPDFCanon.h b/src/pdf/SkPDFCanon.h index b9a6c68322..d68e471289 100644 --- a/src/pdf/SkPDFCanon.h +++ b/src/pdf/SkPDFCanon.h @@ -11,6 +11,9 @@ #include "SkPDFGradientShader.h" #include "SkPDFGraphicState.h" #include "SkPDFShader.h" +#ifdef SK_SUPPORT_LEGACY_PDF_PIXELSERIALIZER +#include "SkPixelSerializer.h" +#endif #include "SkTDArray.h" #include "SkTHash.h" #include "SkTypeface.h" @@ -42,6 +45,9 @@ public: SkTHashMap<SkPDFStrokeGraphicState, sk_sp<SkPDFDict>> fStrokeGSMap; SkTHashMap<SkPDFFillGraphicState, sk_sp<SkPDFDict>> fFillGSMap; +#ifdef SK_SUPPORT_LEGACY_PDF_PIXELSERIALIZER + sk_sp<SkPixelSerializer> fPixelSerializer; +#endif sk_sp<SkPDFStream> fInvertFunction; sk_sp<SkPDFDict> fNoSmaskGraphicState; sk_sp<SkPDFArray> fRangeObject; diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp index 0628b8f905..582a44a963 100644 --- a/src/pdf/SkPDFDevice.cpp +++ b/src/pdf/SkPDFDevice.cpp @@ -2512,6 +2512,9 @@ void SkPDFDevice::internalDrawImageRect(SkKeyedImage imageSubset, if (!pdfimage) { SkASSERT(imageSubset); pdfimage = SkPDFCreateBitmapObject(imageSubset.release(), +#ifdef SK_SUPPORT_LEGACY_PDF_PIXELSERIALIZER + fDocument->canon()->fPixelSerializer.get(), +#endif fDocument->metadata().fEncodingQuality); if (!pdfimage) { return; diff --git a/src/pdf/SkPDFDocument.cpp b/src/pdf/SkPDFDocument.cpp index 939e9ed991..f7c35ca2ac 100644 --- a/src/pdf/SkPDFDocument.cpp +++ b/src/pdf/SkPDFDocument.cpp @@ -12,6 +12,9 @@ #include "SkPDFCanon.h" #include "SkPDFDevice.h" #include "SkPDFUtils.h" +#ifdef SK_SUPPORT_LEGACY_PDF_PIXELSERIALIZER +#include "SkPixelSerializer.h" +#endif #include "SkStream.h" SkPDFObjectSerializer::SkPDFObjectSerializer() : fBaseOffset(0), fNextToBeSerialized(0) {} @@ -173,9 +176,16 @@ static sk_sp<SkPDFDict> generate_page_tree(SkTArray<sk_sp<SkPDFDict>>* pages) { SkPDFDocument::SkPDFDocument(SkWStream* stream, void (*doneProc)(SkWStream*, bool), - const SkDocument::PDFMetadata& metadata) + const SkDocument::PDFMetadata& metadata +#ifdef SK_SUPPORT_LEGACY_PDF_PIXELSERIALIZER + , sk_sp<SkPixelSerializer> jpegEncoder +#endif + ) : SkDocument(stream, doneProc) , fMetadata(metadata) { +#ifdef SK_SUPPORT_LEGACY_PDF_PIXELSERIALIZER + fCanon.fPixelSerializer = std::move(jpegEncoder); +#endif } SkPDFDocument::~SkPDFDocument() { @@ -426,7 +436,11 @@ void SkPDFDocument::onClose(SkWStream* stream) { sk_sp<SkDocument> SkPDFMakeDocument(SkWStream* stream, void (*proc)(SkWStream*, bool), - const SkDocument::PDFMetadata& metadata) { + const SkDocument::PDFMetadata& metadata +#ifdef SK_SUPPORT_LEGACY_PDF_PIXELSERIALIZER + , sk_sp<SkPixelSerializer> jpeg +#endif + ) { SkDocument::PDFMetadata meta = metadata; if (meta.fRasterDPI <= 0) { meta.fRasterDPI = 72.0f; @@ -434,7 +448,12 @@ sk_sp<SkDocument> SkPDFMakeDocument(SkWStream* stream, if (meta.fEncodingQuality < 0) { meta.fEncodingQuality = 0; } - return stream ? sk_make_sp<SkPDFDocument>(stream, proc, meta) : nullptr; + return stream ? sk_make_sp<SkPDFDocument>(stream, proc, meta +#ifdef SK_SUPPORT_LEGACY_PDF_PIXELSERIALIZER + , std::move(jpeg) +#endif + ) + : nullptr; } sk_sp<SkDocument> SkDocument::MakePDF(SkWStream* stream, const PDFMetadata& metadata) { @@ -445,3 +464,30 @@ sk_sp<SkDocument> SkDocument::MakePDF(SkWStream* stream) { return SkPDFMakeDocument(stream, nullptr, PDFMetadata()); } +#ifdef SK_SUPPORT_LEGACY_PDF_PIXELSERIALIZER +sk_sp<SkDocument> SkDocument::MakePDF(SkWStream* stream, + SkScalar dpi, + const PDFMetadata& metadata, + sk_sp<SkPixelSerializer> jpegEncoder, + bool pdfa) { + PDFMetadata meta = metadata; + meta.fRasterDPI = dpi; + meta.fPDFA = pdfa; + return SkPDFMakeDocument(stream, nullptr, meta, jpegEncoder); +} +sk_sp<SkDocument> SkDocument::MakePDF(SkWStream* stream, SkScalar dpi) { + PDFMetadata meta; + meta.fRasterDPI = dpi; + return SkPDFMakeDocument(stream, nullptr, meta, nullptr); +} +sk_sp<SkDocument> SkDocument::MakePDF(const char path[], SkScalar dpi) { + auto delete_wstream = [](SkWStream* stream, bool) { delete stream; }; + auto stream = skstd::make_unique<SkFILEWStream>(path); + if (!stream->isValid()) { + return nullptr; + } + PDFMetadata meta; + meta.fRasterDPI = dpi; + return SkPDFMakeDocument(stream.release(), delete_wstream, meta, nullptr); +} +#endif diff --git a/src/pdf/SkPDFDocument.h b/src/pdf/SkPDFDocument.h index a13670a080..7cfd0bd1c3 100644 --- a/src/pdf/SkPDFDocument.h +++ b/src/pdf/SkPDFDocument.h @@ -10,6 +10,9 @@ #include "SkDocument.h" #include "SkPDFCanon.h" #include "SkPDFMetadata.h" +#ifdef SK_SUPPORT_LEGACY_PDF_PIXELSERIALIZER +#include "SkPixelSerializer.h" +#endif #include "SkPDFFont.h" class SkPDFDevice; @@ -26,7 +29,11 @@ class SkPDFDevice; */ sk_sp<SkDocument> SkPDFMakeDocument(SkWStream* stream, void (*doneProc)(SkWStream*, bool), - const SkDocument::PDFMetadata&); + const SkDocument::PDFMetadata& +#ifdef SK_SUPPORT_LEGACY_PDF_PIXELSERIALIZER + , sk_sp<SkPixelSerializer> = nullptr +#endif + ); // Logically part of SkPDFDocument (like SkPDFCanon), but separate to // keep similar functionality together. @@ -53,7 +60,11 @@ class SkPDFDocument : public SkDocument { public: SkPDFDocument(SkWStream*, void (*)(SkWStream*, bool), - const SkDocument::PDFMetadata&); + const SkDocument::PDFMetadata& +#ifdef SK_SUPPORT_LEGACY_PDF_PIXELSERIALIZER + , sk_sp<SkPixelSerializer> = nullptr +#endif + ); ~SkPDFDocument() override; SkCanvas* onBeginPage(SkScalar, SkScalar) override; void onEndPage() override; |