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

Side by Side Diff: printing/pdf_metafile_skia.cc

Issue 6879098: Fix print preview clipping issues due to scaling. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Fix mac build. Created 9 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « printing/pdf_metafile_skia.h ('k') | skia/ext/vector_platform_device_skia.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "printing/pdf_metafile_skia.h" 5 #include "printing/pdf_metafile_skia.h"
6 6
7 #include "base/eintr_wrapper.h" 7 #include "base/eintr_wrapper.h"
8 #include "base/file_descriptor_posix.h" 8 #include "base/file_descriptor_posix.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "skia/ext/vector_platform_device_skia.h" 10 #include "skia/ext/vector_platform_device_skia.h"
(...skipping 19 matching lines...) Expand all
30 30
31 bool PdfMetafileSkia::Init() { 31 bool PdfMetafileSkia::Init() {
32 return true; 32 return true;
33 } 33 }
34 bool PdfMetafileSkia::InitFromData(const void* src_buffer, 34 bool PdfMetafileSkia::InitFromData(const void* src_buffer,
35 uint32 src_buffer_size) { 35 uint32 src_buffer_size) {
36 return data_->pdf_stream_.write(src_buffer, src_buffer_size); 36 return data_->pdf_stream_.write(src_buffer, src_buffer_size);
37 } 37 }
38 38
39 skia::PlatformDevice* PdfMetafileSkia::StartPageForVectorCanvas( 39 skia::PlatformDevice* PdfMetafileSkia::StartPageForVectorCanvas(
40 const gfx::Size& page_size, const gfx::Point& content_origin, 40 const gfx::Size& page_size, const gfx::Rect& content_area,
41 const float& scale_factor) { 41 const float& scale_factor) {
42 DCHECK(data_->current_page_.get() == NULL); 42 DCHECK(data_->current_page_.get() == NULL);
43 43
44 // Adjust for the margins and apply the scale factor. 44 // Adjust for the margins and apply the scale factor.
45 SkMatrix transform; 45 SkMatrix transform;
46 transform.setTranslate(SkIntToScalar(content_origin.x()), 46 transform.setTranslate(SkIntToScalar(content_area.x()),
47 SkIntToScalar(content_origin.y())); 47 SkIntToScalar(content_area.y()));
48 transform.preScale(SkFloatToScalar(scale_factor), 48 transform.preScale(SkFloatToScalar(scale_factor),
49 SkFloatToScalar(scale_factor)); 49 SkFloatToScalar(scale_factor));
50 50
51 // TODO(ctguil): Refactor: don't create the PDF device explicitly here.
52 SkISize pdf_page_size = SkISize::Make(page_size.width(), page_size.height());
53 SkISize pdf_content_size =
54 SkISize::Make(content_area.width(), content_area.height());
55 SkRefPtr<SkPDFDevice> pdf_device =
56 new SkPDFDevice(pdf_page_size, pdf_content_size, transform);
57 pdf_device->unref(); // SkRefPtr and new both took a reference.
51 skia::VectorPlatformDeviceSkia* device = 58 skia::VectorPlatformDeviceSkia* device =
52 new skia::VectorPlatformDeviceSkia(page_size.width(), page_size.height(), 59 new skia::VectorPlatformDeviceSkia(pdf_device.get());
53 transform);
54 data_->current_page_ = device->PdfDevice(); 60 data_->current_page_ = device->PdfDevice();
55 return device; 61 return device;
56 } 62 }
57 63
58 bool PdfMetafileSkia::StartPage(const gfx::Size& page_size, 64 bool PdfMetafileSkia::StartPage(const gfx::Size& page_size,
59 const gfx::Point& content_origin, 65 const gfx::Rect& content_area,
60 const float& scale_factor) { 66 const float& scale_factor) {
61 NOTREACHED(); 67 NOTREACHED();
62 return NULL; 68 return NULL;
63 } 69 }
64 70
65 bool PdfMetafileSkia::FinishPage() { 71 bool PdfMetafileSkia::FinishPage() {
66 DCHECK(data_->current_page_.get()); 72 DCHECK(data_->current_page_.get());
67 73
68 data_->pdf_doc_.appendPage(data_->current_page_); 74 data_->pdf_doc_.appendPage(data_->current_page_);
69 data_->current_page_ = NULL; 75 data_->current_page_ = NULL;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 result = false; 168 result = false;
163 } 169 }
164 } 170 }
165 return result; 171 return result;
166 } 172 }
167 #endif 173 #endif
168 174
169 PdfMetafileSkia::PdfMetafileSkia() : data_(new PdfMetafileSkiaData) {} 175 PdfMetafileSkia::PdfMetafileSkia() : data_(new PdfMetafileSkiaData) {}
170 176
171 } // namespace printing 177 } // namespace printing
OLDNEW
« no previous file with comments | « printing/pdf_metafile_skia.h ('k') | skia/ext/vector_platform_device_skia.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698