diff options
Diffstat (limited to 'src/pdf')
-rw-r--r-- | src/pdf/SkPDFDevice.cpp | 24 | ||||
-rw-r--r-- | src/pdf/SkPDFFormXObject.cpp | 2 | ||||
-rw-r--r-- | src/pdf/SkPDFPage.cpp | 2 |
3 files changed, 16 insertions, 12 deletions
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp index 72b2e1bf6a..1c6477f9ba 100644 --- a/src/pdf/SkPDFDevice.cpp +++ b/src/pdf/SkPDFDevice.cpp @@ -120,8 +120,12 @@ void alignText(SkDrawCacheProc glyphCacheProc, const SkPaint& paint, SkDevice* SkPDFDeviceFactory::newDevice(SkCanvas*, SkBitmap::Config config, int width, int height, bool isOpaque, - bool /*isForLayer*/) { - return SkNEW_ARGS(SkPDFDevice, (width, height)); + bool isForLayer) { + SkPDFDevice::OriginTransform flip = SkPDFDevice::kFlip_OriginTransform; + if (isForLayer) { + flip = SkPDFDevice::kNoFlip_OriginTransform; + } + return SkNEW_ARGS(SkPDFDevice, (width, height, flip)); } static inline SkBitmap makeABitmap(int width, int height) { @@ -130,10 +134,11 @@ static inline SkBitmap makeABitmap(int width, int height) { return bitmap; } -SkPDFDevice::SkPDFDevice(int width, int height) +SkPDFDevice::SkPDFDevice(int width, int height, OriginTransform flipOrigin) : SkDevice(NULL, makeABitmap(width, height), false), fWidth(width), fHeight(height), + fFlipOrigin(flipOrigin), fGraphicStackIndex(0) { fGraphicStack[0].fColor = SK_ColorBLACK; fGraphicStack[0].fTextSize = SK_ScalarNaN; // This has no default value. @@ -143,6 +148,10 @@ SkPDFDevice::SkPDFDevice(int width, int height) fGraphicStack[0].fGraphicState = NULL; fGraphicStack[0].fClip.setRect(0,0, width, height); fGraphicStack[0].fTransform.reset(); + + if (flipOrigin == kFlip_OriginTransform) { + fContent.printf("1 0 0 -1 0 %d cm\n", fHeight); + } } SkPDFDevice::~SkPDFDevice() { @@ -549,13 +558,8 @@ SkRefPtr<SkPDFArray> SkPDFDevice::getMediaBox() const { return mediaBox; } -SkString SkPDFDevice::content(bool flipOrigin) const { - SkString result; - // Scale and translate to move the origin from the lower left to the - // upper left. - if (flipOrigin) - result.printf("1 0 0 -1 0 %d cm\n", fHeight); - result.append(fContent); +SkString SkPDFDevice::content() const { + SkString result = fContent; for (int i = 0; i < fGraphicStackIndex; i++) result.append("Q\n"); return result; diff --git a/src/pdf/SkPDFFormXObject.cpp b/src/pdf/SkPDFFormXObject.cpp index ef839a3b4e..40bfad74e3 100644 --- a/src/pdf/SkPDFFormXObject.cpp +++ b/src/pdf/SkPDFFormXObject.cpp @@ -28,7 +28,7 @@ SkPDFFormXObject::SkPDFFormXObject(SkPDFDevice* device) { // resources). device->getResources(&fResources); - SkString content = device->content(false); + SkString content = device->content(); SkMemoryStream* stream_data = new SkMemoryStream(content.c_str(), content.size()); SkAutoUnref stream_data_unref(stream_data); diff --git a/src/pdf/SkPDFPage.cpp b/src/pdf/SkPDFPage.cpp index 1c470c7d01..2bec90744e 100644 --- a/src/pdf/SkPDFPage.cpp +++ b/src/pdf/SkPDFPage.cpp @@ -32,7 +32,7 @@ void SkPDFPage::finalizePage(SkPDFCatalog* catalog, bool firstPage, insert("Resources", fDevice->getResourceDict().get()); insert("MediaBox", fDevice->getMediaBox().get()); - fContent = fDevice->content(true); + fContent = fDevice->content(); SkRefPtr<SkMemoryStream> contentStream = new SkMemoryStream( fContent.c_str(), fContent.size()); contentStream->unref(); // SkRefPtr and new both took a reference. |