diff options
author | ctguil@chromium.org <ctguil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-30 02:24:44 +0000 |
---|---|---|
committer | ctguil@chromium.org <ctguil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-30 02:24:44 +0000 |
commit | 39892b93d23fa18a0571f9098eebe5bcaeea91f0 (patch) | |
tree | 7f1d519e2350d26d8d0e82be2a069ade51925778 /printing/pdf_metafile_skia.cc | |
parent | f1e6bdc4cd64a95528400c3614610760ff13bc1f (diff) | |
download | chromium_src-39892b93d23fa18a0571f9098eebe5bcaeea91f0.zip chromium_src-39892b93d23fa18a0571f9098eebe5bcaeea91f0.tar.gz chromium_src-39892b93d23fa18a0571f9098eebe5bcaeea91f0.tar.bz2 |
Fix print preview clipping issues due to scaling.
BUG=79941
TEST=none
Review URL: http://codereview.chromium.org/6879098
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83657 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing/pdf_metafile_skia.cc')
-rw-r--r-- | printing/pdf_metafile_skia.cc | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/printing/pdf_metafile_skia.cc b/printing/pdf_metafile_skia.cc index 1d2b0798..80d4931 100644 --- a/printing/pdf_metafile_skia.cc +++ b/printing/pdf_metafile_skia.cc @@ -37,26 +37,32 @@ bool PdfMetafileSkia::InitFromData(const void* src_buffer, } skia::PlatformDevice* PdfMetafileSkia::StartPageForVectorCanvas( - const gfx::Size& page_size, const gfx::Point& content_origin, + const gfx::Size& page_size, const gfx::Rect& content_area, const float& scale_factor) { DCHECK(data_->current_page_.get() == NULL); // Adjust for the margins and apply the scale factor. SkMatrix transform; - transform.setTranslate(SkIntToScalar(content_origin.x()), - SkIntToScalar(content_origin.y())); + transform.setTranslate(SkIntToScalar(content_area.x()), + SkIntToScalar(content_area.y())); transform.preScale(SkFloatToScalar(scale_factor), SkFloatToScalar(scale_factor)); + // TODO(ctguil): Refactor: don't create the PDF device explicitly here. + SkISize pdf_page_size = SkISize::Make(page_size.width(), page_size.height()); + SkISize pdf_content_size = + SkISize::Make(content_area.width(), content_area.height()); + SkRefPtr<SkPDFDevice> pdf_device = + new SkPDFDevice(pdf_page_size, pdf_content_size, transform); + pdf_device->unref(); // SkRefPtr and new both took a reference. skia::VectorPlatformDeviceSkia* device = - new skia::VectorPlatformDeviceSkia(page_size.width(), page_size.height(), - transform); + new skia::VectorPlatformDeviceSkia(pdf_device.get()); data_->current_page_ = device->PdfDevice(); return device; } bool PdfMetafileSkia::StartPage(const gfx::Size& page_size, - const gfx::Point& content_origin, + const gfx::Rect& content_area, const float& scale_factor) { NOTREACHED(); return NULL; |