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

Side by Side Diff: printing/pdf_metafile_cg_mac.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_cg_mac.h ('k') | printing/pdf_metafile_cg_mac_unittest.cc » ('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_cg_mac.h" 5 #include "printing/pdf_metafile_cg_mac.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/mac/scoped_cftyperef.h" 9 #include "base/mac/scoped_cftyperef.h"
10 #include "base/sys_string_conversions.h" 10 #include "base/sys_string_conversions.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 } 57 }
58 58
59 pdf_data_.reset(CFDataCreateMutable(kCFAllocatorDefault, src_buffer_size)); 59 pdf_data_.reset(CFDataCreateMutable(kCFAllocatorDefault, src_buffer_size));
60 CFDataAppendBytes(pdf_data_, static_cast<const UInt8*>(src_buffer), 60 CFDataAppendBytes(pdf_data_, static_cast<const UInt8*>(src_buffer),
61 src_buffer_size); 61 src_buffer_size);
62 62
63 return true; 63 return true;
64 } 64 }
65 65
66 skia::PlatformDevice* PdfMetafileCg::StartPageForVectorCanvas( 66 skia::PlatformDevice* PdfMetafileCg::StartPageForVectorCanvas(
67 const gfx::Size& page_size, const gfx::Point& content_origin, 67 const gfx::Size& page_size, const gfx::Rect& content_area,
68 const float& scale_factor) { 68 const float& scale_factor) {
69 NOTIMPLEMENTED(); 69 NOTIMPLEMENTED();
70 return NULL; 70 return NULL;
71 } 71 }
72 72
73 bool PdfMetafileCg::StartPage(const gfx::Size& page_size, 73 bool PdfMetafileCg::StartPage(const gfx::Size& page_size,
74 const gfx::Point& content_origin, 74 const gfx::Rect& content_area,
75 const float& scale_factor) { 75 const float& scale_factor) {
76 DCHECK(context_.get()); 76 DCHECK(context_.get());
77 DCHECK(!page_is_open_); 77 DCHECK(!page_is_open_);
78 78
79 double height = page_size.height(); 79 double height = page_size.height();
80 double width = page_size.width(); 80 double width = page_size.width();
81 81
82 CGRect bounds = CGRectMake(0, 0, width, height); 82 CGRect bounds = CGRectMake(0, 0, width, height);
83 CGContextBeginPage(context_, &bounds); 83 CGContextBeginPage(context_, &bounds);
84 page_is_open_ = true; 84 page_is_open_ = true;
85 CGContextSaveGState(context_); 85 CGContextSaveGState(context_);
86 86
87 // Flip the context. 87 // Flip the context.
88 CGContextTranslateCTM(context_, 0, height); 88 CGContextTranslateCTM(context_, 0, height);
89 CGContextScaleCTM(context_, scale_factor, -scale_factor); 89 CGContextScaleCTM(context_, scale_factor, -scale_factor);
90 90
91 // Move the context to origin. 91 // Move to the context origin.
92 CGContextTranslateCTM(context_, content_origin.x(), content_origin.y()); 92 CGContextTranslateCTM(context_, content_area.x(), content_area.y());
93 93
94 return context_.get() != NULL; 94 return context_.get() != NULL;
95 } 95 }
96 96
97 bool PdfMetafileCg::FinishPage() { 97 bool PdfMetafileCg::FinishPage() {
98 DCHECK(context_.get()); 98 DCHECK(context_.get());
99 DCHECK(page_is_open_); 99 DCHECK(page_is_open_);
100 100
101 CGContextRestoreGState(context_); 101 CGContextRestoreGState(context_);
102 CGContextEndPage(context_); 102 CGContextEndPage(context_);
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 248
249 if (!pdf_doc_.get()) { 249 if (!pdf_doc_.get()) {
250 ScopedCFTypeRef<CGDataProviderRef> pdf_data_provider( 250 ScopedCFTypeRef<CGDataProviderRef> pdf_data_provider(
251 CGDataProviderCreateWithCFData(pdf_data_)); 251 CGDataProviderCreateWithCFData(pdf_data_));
252 pdf_doc_.reset(CGPDFDocumentCreateWithProvider(pdf_data_provider)); 252 pdf_doc_.reset(CGPDFDocumentCreateWithProvider(pdf_data_provider));
253 } 253 }
254 return pdf_doc_.get(); 254 return pdf_doc_.get();
255 } 255 }
256 256
257 } // namespace printing 257 } // namespace printing
OLDNEW
« no previous file with comments | « printing/pdf_metafile_cg_mac.h ('k') | printing/pdf_metafile_cg_mac_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698