diff options
author | 2013-10-21 17:14:37 +0000 | |
---|---|---|
committer | 2013-10-21 17:14:37 +0000 | |
commit | 8c294900f31d8d032b62182f011019276d27d5d0 (patch) | |
tree | 92507dad54441936a44e3fab985600d74d027fb8 /src | |
parent | 9f51d16b54f0256f3f9ea00c85324d70535e374d (diff) |
Add DPI stettings to SkDocument::CreatePDF(). Tests will be added in a future cl, once DPI will be used in SkPDFDevice
R=reed@google.com, bungeman@google.com, vandebo@chromium.org
Author: edisonn@google.com
Review URL: https://codereview.chromium.org/32233003
git-svn-id: http://skia.googlecode.com/svn/trunk@11886 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/doc/SkDocument_PDF.cpp | 21 | ||||
-rw-r--r-- | src/pdf/SkPDFDevice.cpp | 7 |
2 files changed, 20 insertions, 8 deletions
diff --git a/src/doc/SkDocument_PDF.cpp b/src/doc/SkDocument_PDF.cpp index 695929f32f..362493d538 100644 --- a/src/doc/SkDocument_PDF.cpp +++ b/src/doc/SkDocument_PDF.cpp @@ -12,9 +12,11 @@ class SkDocument_PDF : public SkDocument { public: SkDocument_PDF(SkWStream* stream, void (*doneProc)(SkWStream*), - SkPicture::EncodeBitmap encoder) + SkPicture::EncodeBitmap encoder, + SkScalar rasterDpi) : SkDocument(stream, doneProc) - , fEncoder(encoder) { + , fEncoder(encoder) + , fRasterDpi(rasterDpi) { fDoc = SkNEW(SkPDFDocument); fCanvas = NULL; fDevice = NULL; @@ -38,6 +40,9 @@ protected: if (fEncoder) { fDevice->setDCTEncoder(fEncoder); } + if (fRasterDpi != 0) { + fDevice->setRasterDpi(fRasterDpi); + } fCanvas = SkNEW_ARGS(SkCanvas, (fDevice)); return fCanvas; } @@ -76,24 +81,28 @@ private: SkPDFDeviceFlattener* fDevice; SkCanvas* fCanvas; SkPicture::EncodeBitmap fEncoder; + SkScalar fRasterDpi; }; /////////////////////////////////////////////////////////////////////////////// SkDocument* SkDocument::CreatePDF(SkWStream* stream, void (*done)(SkWStream*), - SkPicture::EncodeBitmap enc) { - return stream ? SkNEW_ARGS(SkDocument_PDF, (stream, done, enc)) : NULL; + SkPicture::EncodeBitmap enc, + SkScalar dpi) { + return stream ? SkNEW_ARGS(SkDocument_PDF, (stream, done, enc, dpi)) : NULL; } static void delete_wstream(SkWStream* stream) { SkDELETE(stream); } -SkDocument* SkDocument::CreatePDF(const char path[], SkPicture::EncodeBitmap enc) { +SkDocument* SkDocument::CreatePDF(const char path[], + SkPicture::EncodeBitmap enc, + SkScalar dpi) { SkFILEWStream* stream = SkNEW_ARGS(SkFILEWStream, (path)); if (!stream->isValid()) { SkDELETE(stream); return NULL; } - return SkNEW_ARGS(SkDocument_PDF, (stream, delete_wstream, enc)); + return SkNEW_ARGS(SkDocument_PDF, (stream, delete_wstream, enc, dpi)); } diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp index e90edb1408..1aed85632a 100644 --- a/src/pdf/SkPDFDevice.cpp +++ b/src/pdf/SkPDFDevice.cpp @@ -704,7 +704,8 @@ SkPDFDevice::SkPDFDevice(const SkISize& pageSize, const SkISize& contentSize, fLastContentEntry(NULL), fLastMarginContentEntry(NULL), fClipStack(NULL), - fEncoder(NULL) { + fEncoder(NULL), + fRasterDpi(SkFloatToScalar(72.0f)) { // just report that PDF does not supports perspective // TODO(edisonn): update the shape when possible // or dump in an image otherwise @@ -734,7 +735,9 @@ SkPDFDevice::SkPDFDevice(const SkISize& layerSize, fExistingClipRegion(existingClipRegion), fLastContentEntry(NULL), fLastMarginContentEntry(NULL), - fClipStack(NULL) { + fClipStack(NULL), + fEncoder(NULL), + fRasterDpi(SkFloatToScalar(72.0f)) { fInitialTransform.reset(); this->init(); } |