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, |