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

Side by Side Diff: printing/pdf_metafile_cg_mac.cc

Issue 2835193007: Revert of clean up printing::Image and printing::Metafile (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « printing/pdf_metafile_cg_mac.h ('k') | printing/pdf_metafile_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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 bool PdfMetafileCg::RenderPage(const std::vector<char>& src_buffer, 167 bool PdfMetafileCg::RenderPage(const std::vector<char>& src_buffer,
168 unsigned int page_number, 168 unsigned int page_number,
169 CGContextRef context, 169 CGContextRef context,
170 const CGRect rect, 170 const CGRect rect,
171 const PdfMetafileCg::RenderPageParams& params) { 171 const PdfMetafileCg::RenderPageParams& params) {
172 PdfMetafileCg metafile; 172 PdfMetafileCg metafile;
173 if (!metafile.InitFromData(src_buffer.data(), src_buffer.size())) { 173 if (!metafile.InitFromData(src_buffer.data(), src_buffer.size())) {
174 LOG(ERROR) << "Unable to initialize PDF document from data"; 174 LOG(ERROR) << "Unable to initialize PDF document from data";
175 return false; 175 return false;
176 } 176 }
177 return metafile.OnRenderPage(page_number, context, rect, params); 177 CGPDFDocumentRef pdf_doc = metafile.GetPDFDocument();
178 }
179
180 bool PdfMetafileCg::OnRenderPage(
181 unsigned int page_number,
182 CGContextRef context,
183 const CGRect rect,
184 const PdfMetafileCg::RenderPageParams& params) {
185 CGPDFDocumentRef pdf_doc = GetPDFDocument();
186 if (!pdf_doc) { 178 if (!pdf_doc) {
187 LOG(ERROR) << "Unable to create PDF document from data"; 179 LOG(ERROR) << "Unable to create PDF document from data";
188 return false; 180 return false;
189 } 181 }
190 CGPDFPageRef pdf_page = CGPDFDocumentGetPage(pdf_doc, page_number); 182 CGPDFPageRef pdf_page = CGPDFDocumentGetPage(pdf_doc, page_number);
191 CGRect source_rect = CGPDFPageGetBoxRect(pdf_page, kCGPDFCropBox); 183 CGRect source_rect = CGPDFPageGetBoxRect(pdf_page, kCGPDFCropBox);
192 int pdf_src_rotation = CGPDFPageGetRotationAngle(pdf_page); 184 int pdf_src_rotation = CGPDFPageGetRotationAngle(pdf_page);
193 float scaling_factor = 1.0; 185 float scaling_factor = 1.0;
194 const bool source_is_landscape = 186 const bool source_is_landscape =
195 (source_rect.size.width > source_rect.size.height); 187 (source_rect.size.width > source_rect.size.height);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 305
314 if (!pdf_doc_.get()) { 306 if (!pdf_doc_.get()) {
315 ScopedCFTypeRef<CGDataProviderRef> pdf_data_provider( 307 ScopedCFTypeRef<CGDataProviderRef> pdf_data_provider(
316 CGDataProviderCreateWithCFData(pdf_data_)); 308 CGDataProviderCreateWithCFData(pdf_data_));
317 pdf_doc_.reset(CGPDFDocumentCreateWithProvider(pdf_data_provider)); 309 pdf_doc_.reset(CGPDFDocumentCreateWithProvider(pdf_data_provider));
318 } 310 }
319 return pdf_doc_.get(); 311 return pdf_doc_.get();
320 } 312 }
321 313
322 } // namespace printing 314 } // namespace printing
OLDNEW
« no previous file with comments | « printing/pdf_metafile_cg_mac.h ('k') | printing/pdf_metafile_skia.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698