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

Unified Diff: experimental/PdfViewer/SkPdfRenderer.cpp

Issue 19000004: add ability to specify the DPI at which to render the page (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 5 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: experimental/PdfViewer/SkPdfRenderer.cpp
===================================================================
--- experimental/PdfViewer/SkPdfRenderer.cpp (revision 10006)
+++ experimental/PdfViewer/SkPdfRenderer.cpp (working copy)
@@ -1923,7 +1923,7 @@
PdfContext* gPdfContext = NULL;
-bool SkPdfRenderer::renderPage(int page, SkCanvas* canvas) const {
+bool SkPdfRenderer::renderPage(int page, SkCanvas* canvas, const SkRect& dst) const {
if (!fPdfDoc) {
return false;
}
@@ -1941,13 +1941,14 @@
gPdfContext = &pdfContext;
// TODO(edisonn): get matrix stuff right.
- // TODO(edisonn): add DPI/scale/zoom.
SkScalar z = SkIntToScalar(0);
- SkRect rect = fPdfDoc->MediaBox(page);
- SkScalar w = rect.width();
- SkScalar h = rect.height();
+ SkScalar w = dst.width();
+ SkScalar h = dst.height();
- SkPoint pdfSpace[4] = {SkPoint::Make(z, z), SkPoint::Make(w, z), SkPoint::Make(w, h), SkPoint::Make(z, h)};
+ SkScalar wp = fPdfDoc->MediaBox(page).width();
+ SkScalar hp = fPdfDoc->MediaBox(page).height();
+
+ SkPoint pdfSpace[4] = {SkPoint::Make(z, z), SkPoint::Make(wp, z), SkPoint::Make(wp, hp), SkPoint::Make(z, hp)};
// SkPoint skiaSpace[4] = {SkPoint::Make(z, h), SkPoint::Make(w, h), SkPoint::Make(w, z), SkPoint::Make(z, z)};
// TODO(edisonn): add flag for this app to create sourunding buffer zone
@@ -1977,12 +1978,12 @@
pdfContext.fGraphicsState.fMatrixTm = pdfContext.fGraphicsState.fMatrix;
pdfContext.fGraphicsState.fMatrixTlm = pdfContext.fGraphicsState.fMatrix;
- canvas->setMatrix(pdfContext.fOriginalMatrix);
-
#ifndef PDF_DEBUG_NO_PAGE_CLIPING
- canvas->clipRect(SkRect::MakeXYWH(z, z, w, h), SkRegion::kIntersect_Op, true);
+ canvas->clipRect(dst, SkRegion::kIntersect_Op, true);
#endif
+ canvas->setMatrix(pdfContext.fOriginalMatrix);
+
// erase with red before?
// SkPaint paint;
// paint.setColor(SK_ColorRED);

Powered by Google App Engine
This is Rietveld 408576698