Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1069)

Unified Diff: src/pdf/SkPDFDevice.cpp

Issue 24811002: Update the SkDocument interface to allow for 1) abort won't emit pdf, 2) close can report success/f… (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/pdf/SkPDFDevice.cpp
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index d13d30cbfb46efbbbe29f6bc3f22522190af75de..933bc32038a9d5aec62b6f52b12dd8ae6ed6bb25 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -707,6 +707,34 @@ SkPDFDevice::SkPDFDevice(const SkISize& pageSize, const SkISize& contentSize,
this->init();
}
+SkISize SkSizeToISize(const SkSize& size) {
+ return SkISize::Make(SkScalarRoundToInt(size.width()), SkScalarRoundToInt(size.height()));
+}
+
+SkPDFDevice::SkPDFDevice(const SkSize& trimBox, const SkRect& content)
+ : SkBitmapDevice(makeContentBitmap(SkSizeToISize(SkSize::Make(content.width(), content.height())),
+ NULL)),
+ fPageSize(SkSizeToISize(SkSize::Make(content.width(), content.height()))),
+ fContentSize(SkSizeToISize(trimBox)),
+ fLastContentEntry(NULL),
+ fLastMarginContentEntry(NULL),
+ fClipStack(NULL),
+ fEncoder(NULL) {
+ // Skia generally uses the top left as the origin but PDF natively has the
+ // origin at the bottom left. This matrix corrects for that. But that only
+ // needs to be done once, we don't do it when layering.
+ fInitialTransform.reset();
+ fInitialTransform.setTranslate(0, SkIntToScalar(fPageSize.fHeight));
+ fInitialTransform.preScale(SK_Scalar1, -SK_Scalar1);
+ fInitialTransform.preTranslate(-content.left(), -content.top());
+
+ SkIRect existingClip = SkIRect::MakeWH(this->width(), this->height());
+ fExistingClipRegion.setRect(existingClip);
+
+ this->init();
+}
+
+
// TODO(vandebo) change layerSize to SkSize.
SkPDFDevice::SkPDFDevice(const SkISize& layerSize,
const SkClipStack& existingClipStack,

Powered by Google App Engine
This is Rietveld 408576698