aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pdf/SkPDFDevice.cpp
diff options
context:
space:
mode:
authorGravatar Hal Canary <halcanary@google.com>2018-05-09 14:20:12 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-05-11 17:36:57 +0000
commit825911444082ddd26e9f8bef349e44e048009f5d (patch)
tree321dda176993cef91a0bacae3cd7713fd619857c /src/pdf/SkPDFDevice.cpp
parent9bcfcb32de5fcf2f14daa7572455f798c9004025 (diff)
SkPDF: scale entire canvas for non-standard rasterDpi
TODO: add better testing around this. BUG: chromium:481429 Change-Id: I1296fae3fc9775febf17bba75722c30f48d67a95 Reviewed-on: https://skia-review.googlesource.com/127051 Commit-Queue: Hal Canary <halcanary@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'src/pdf/SkPDFDevice.cpp')
-rw-r--r--src/pdf/SkPDFDevice.cpp12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index c18219ab0d..ced94ce9a9 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -508,8 +508,9 @@ void SkPDFDevice::setFlip() {
// 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.setTranslate(0, SkIntToScalar(fPageSize.fHeight));
- fInitialTransform.preScale(SK_Scalar1, -SK_Scalar1);
+ SkScalar rasterScale = SkPDFUtils::kDpiForRasterScaleOne / fDocument->rasterDpi();
+ fInitialTransform.setConcat(SkMatrix::MakeScale(rasterScale, -rasterScale),
+ SkMatrix::MakeTrans(0, -fPageSize.fHeight));
}
SkPDFDevice::~SkPDFDevice() {
@@ -797,9 +798,6 @@ void SkPDFDevice::internalDrawPathWithFilter(const SkClipStack& clipStack,
: SkStrokeRec::kHairline_InitStyle;
path.transform(ctm, &path);
- // TODO(halcanary): respect fDocument->rasterDpi().
- // SkScalar rasterScale = (float)rasterDpi / SkPDFUtils::kDpiForRasterScaleOne;
- // Would it be easier to just change the device size (and pre-scale the canvas)?
SkIRect bounds = clipStack.bounds(this->bounds()).roundOut();
SkMask sourceMask;
if (!SkDraw::DrawToMask(path, &bounds, paint->getMaskFilter(), &SkMatrix::I(),
@@ -2157,7 +2155,6 @@ void SkPDFDevice::internalDrawImageRect(SkKeyedImage imageSubset,
// Rasterize the bitmap using perspective in a new bitmap.
if (transform.hasPerspective()) {
- SkASSERT(fDocument->rasterDpi() > 0);
// Transform the bitmap in the new space, without taking into
// account the initial transform.
SkPath perspectiveOutline;
@@ -2173,9 +2170,6 @@ void SkPDFDevice::internalDrawImageRect(SkKeyedImage imageSubset,
// account the initial transform.
SkMatrix total = transform;
total.postConcat(fInitialTransform);
- SkScalar dpiScale = SkIntToScalar(fDocument->rasterDpi()) /
- SkIntToScalar(SkPDFUtils::kDpiForRasterScaleOne);
- total.postScale(dpiScale, dpiScale);
SkPath physicalPerspectiveOutline;
physicalPerspectiveOutline.addRect(imageBounds);