diff options
author | Mike Reed <reed@google.com> | 2017-12-14 13:25:04 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-12-14 21:20:27 +0000 |
commit | a4daf193196c6da63b1c16e3490cad3c5ca6bf8b (patch) | |
tree | da83a9b8ffeb0b07ffb5fdc87705d25c242c5b1c /include | |
parent | dbd43481f1da3c9c87f5d913660f216ec531870a (diff) |
Moving extra options/parameters into PDFMetadata
Bug: skia:
Change-Id: I29aa69e5765a7f8ba05b0361912d1f5276d77de3
Reviewed-on: https://skia-review.googlesource.com/84501
Reviewed-by: Hal Canary <halcanary@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkDocument.h | 70 |
1 files changed, 48 insertions, 22 deletions
diff --git a/include/core/SkDocument.h b/include/core/SkDocument.h index a868f1e699..df7cd73c3a 100644 --- a/include/core/SkDocument.h +++ b/include/core/SkDocument.h @@ -10,7 +10,9 @@ #include "SkBitmap.h" #include "SkPicture.h" +#ifdef SK_SUPPORT_LEGACY_PDF_PIXELSERIALIZER #include "SkPixelSerializer.h" +#endif #include "SkRect.h" #include "SkRefCnt.h" #include "SkString.h" @@ -86,8 +88,34 @@ public: * The date and time the document was most recently modified. */ OptionalTimestamp fModified; + + /** The DPI (pixels-per-inch) at which features without + * native PDF support will be rasterized (e.g. draw image + * with perspective, draw text with perspective, ...) A + * larger DPI would create a PDF that reflects the + * original intent with better fidelity, but it can make + * for larger PDF files too, which would use more memory + * while rendering, and it would be slower to be processed + * or sent online or to printer. + */ + SkScalar fRasterDPI = SK_ScalarDefaultRasterDPI; + + /** If true, include XMP metadata, a document UUID, and sRGB output intent information. + * This adds length to the document and makes it non-reproducable, but are necessary + * features for PDF/A-2b conformance + */ + bool fPDFA = false; + + /** + * Encoding quality controls the trade-off between size and quality. By default this is + * set to 101 percent, which corresponds to lossless encoding. If this value is set to + * a value <= 100, and the image is opaque, it will be encoded (using JPEG) with that + * quality setting. + */ + int fEncodingQuality = 101; }; +#ifdef SK_SUPPORT_LEGACY_PDF_PIXELSERIALIZER /** * Create a PDF-backed document, writing the results into a * SkWStream. @@ -109,16 +137,6 @@ public: * or sent online or to printer. * @param metadata a PDFmetadata object. Any fields may be left * empty. - * @param jpegEncoder For PDF documents, if a jpegEncoder is set, - * use it to encode SkImages and SkBitmaps as [JFIF]JPEGs. - * This feature is deprecated and is only supplied for - * backwards compatability. - * The prefered method to create PDFs with JPEG images is - * to use SkImage::NewFromEncoded() and not jpegEncoder. - * Chromium uses NewFromEncoded. - * If the encoder is unset, or if jpegEncoder->onEncode() - * returns NULL, fall back on encoding images losslessly - * with Deflate. * @param pdfa Iff true, include XMP metadata, a document UUID, * and sRGB output intent information. This adds length * to the document and makes it non-reproducable, but are @@ -129,23 +147,32 @@ public: */ static sk_sp<SkDocument> MakePDF(SkWStream* stream, SkScalar dpi, - const SkDocument::PDFMetadata& metadata, + const PDFMetadata& metadata, sk_sp<SkPixelSerializer> jpegEncoder, bool pdfa); - - static sk_sp<SkDocument> MakePDF(SkWStream* stream, - SkScalar dpi = SK_ScalarDefaultRasterDPI) { - return SkDocument::MakePDF(stream, dpi, SkDocument::PDFMetadata(), - nullptr, false); - } - - static sk_sp<SkDocument> MakePDF(SkWStream* stream, const PDFMetadata& metadata); - /** * Create a PDF-backed document, writing the results into a file. */ static sk_sp<SkDocument> MakePDF(const char outputFilePath[], SkScalar dpi = SK_ScalarDefaultRasterDPI); + static sk_sp<SkDocument> MakePDF(SkWStream* stream, SkScalar dpi); +#endif + + /** + * Create a PDF-backed document, writing the results into a + * SkWStream. + * + * PDF pages are sized in point units. 1 pt == 1/72 inch == 127/360 mm. + * + * @param stream A PDF document will be written to this stream. The document may write + * to the stream at anytime during its lifetime, until either close() is + * called or the document is deleted. + * @param metadata a PDFmetadata object. Any fields may be left empty. + * + * @returns NULL if there is an error, otherwise a newly created PDF-backed SkDocument. + */ + static sk_sp<SkDocument> MakePDF(SkWStream* stream, const PDFMetadata& metadata); + static sk_sp<SkDocument> MakePDF(SkWStream* stream); #ifdef SK_BUILD_FOR_WIN /** @@ -179,8 +206,7 @@ public: * into the page. The document owns this canvas, and it will go out of * scope when endPage() or close() is called, or the document is deleted. */ - SkCanvas* beginPage(SkScalar width, SkScalar height, - const SkRect* content = nullptr); + SkCanvas* beginPage(SkScalar width, SkScalar height, const SkRect* content = nullptr); /** * Call endPage() when the content for the current page has been drawn |