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

Side by Side Diff: printing/printed_document_mac.cc

Issue 2839323002: Revert of printing::Metafile: Simplify OS_MACOSX-specific code path (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_skia.cc ('k') | no next file » | 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/printed_document.h" 5 #include "printing/printed_document.h"
6 6
7 #include <ApplicationServices/ApplicationServices.h> 7 #import <ApplicationServices/ApplicationServices.h>
8 #include <CoreFoundation/CoreFoundation.h> 8 #import <CoreFoundation/CoreFoundation.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "printing/page_number.h" 11 #include "printing/page_number.h"
12 #include "printing/pdf_metafile_cg_mac.h"
13 #include "printing/printed_page.h" 12 #include "printing/printed_page.h"
14 13
15 namespace printing { 14 namespace printing {
16 15
17 void PrintedDocument::RenderPrintedPage( 16 void PrintedDocument::RenderPrintedPage(
18 const PrintedPage& page, 17 const PrintedPage& page,
19 skia::NativeDrawingContext context) const { 18 skia::NativeDrawingContext context) const {
20 #ifndef NDEBUG 19 #ifndef NDEBUG
21 { 20 {
22 // Make sure the page is from our list. 21 // Make sure the page is from our list.
23 base::AutoLock lock(lock_); 22 base::AutoLock lock(lock_);
24 DCHECK(&page == mutable_.pages_.find(page.page_number() - 1)->second.get()); 23 DCHECK(&page == mutable_.pages_.find(page.page_number() - 1)->second.get());
25 } 24 }
26 #endif 25 #endif
27 26
28 DCHECK(context); 27 DCHECK(context);
29 28
30 const PageSetup& page_setup(immutable_.settings_.page_setup_device_units()); 29 const PageSetup& page_setup(immutable_.settings_.page_setup_device_units());
31 gfx::Rect content_area; 30 gfx::Rect content_area;
32 page.GetCenteredPageContentRect(page_setup.physical_size(), &content_area); 31 page.GetCenteredPageContentRect(page_setup.physical_size(), &content_area);
33 32
34 const MetafilePlayer* metafile = page.metafile(); 33 const MetafilePlayer* metafile = page.metafile();
35
36 // Each Metafile is a one-page PDF, and pages use 1-based indexing. 34 // Each Metafile is a one-page PDF, and pages use 1-based indexing.
37 const int page_number = 1; 35 const int page_number = 1;
38 PdfMetafileCg::RenderPageParams params; 36 struct Metafile::MacRenderPageParams params;
39 params.autorotate = true; 37 params.autorotate = true;
40 std::vector<char> buffer; 38 metafile->RenderPage(page_number, context, content_area.ToCGRect(), params);
41 if (metafile->GetDataAsVector(&buffer)) {
42 PdfMetafileCg::RenderPage(buffer, page_number, context,
43 content_area.ToCGRect(), params);
44 }
45 } 39 }
46 40
47 } // namespace printing 41 } // namespace printing
OLDNEW
« no previous file with comments | « printing/pdf_metafile_skia.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698