| OLD | NEW |
| 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 #import <ApplicationServices/ApplicationServices.h> | 7 #import <ApplicationServices/ApplicationServices.h> |
| 8 #import <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/printed_page.h" | 12 #include "printing/printed_page.h" |
| 13 | 13 |
| 14 namespace printing { | 14 namespace printing { |
| 15 | 15 |
| 16 void PrintedDocument::RenderPrintedPage( | 16 void PrintedDocument::RenderPrintedPage( |
| 17 const PrintedPage& page, gfx::NativeDrawingContext context) const { | 17 const PrintedPage& page, |
| 18 skia::NativeDrawingContext context) const { |
| 18 #ifndef NDEBUG | 19 #ifndef NDEBUG |
| 19 { | 20 { |
| 20 // Make sure the page is from our list. | 21 // Make sure the page is from our list. |
| 21 base::AutoLock lock(lock_); | 22 base::AutoLock lock(lock_); |
| 22 DCHECK(&page == mutable_.pages_.find(page.page_number() - 1)->second.get()); | 23 DCHECK(&page == mutable_.pages_.find(page.page_number() - 1)->second.get()); |
| 23 } | 24 } |
| 24 #endif | 25 #endif |
| 25 | 26 |
| 26 DCHECK(context); | 27 DCHECK(context); |
| 27 | 28 |
| 28 const PageSetup& page_setup(immutable_.settings_.page_setup_device_units()); | 29 const PageSetup& page_setup(immutable_.settings_.page_setup_device_units()); |
| 29 gfx::Rect content_area; | 30 gfx::Rect content_area; |
| 30 page.GetCenteredPageContentRect(page_setup.physical_size(), &content_area); | 31 page.GetCenteredPageContentRect(page_setup.physical_size(), &content_area); |
| 31 | 32 |
| 32 const MetafilePlayer* metafile = page.metafile(); | 33 const MetafilePlayer* metafile = page.metafile(); |
| 33 // 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. |
| 34 const int page_number = 1; | 35 const int page_number = 1; |
| 35 struct Metafile::MacRenderPageParams params; | 36 struct Metafile::MacRenderPageParams params; |
| 36 params.autorotate = true; | 37 params.autorotate = true; |
| 37 metafile->RenderPage(page_number, context, content_area.ToCGRect(), params); | 38 metafile->RenderPage(page_number, context, content_area.ToCGRect(), params); |
| 38 } | 39 } |
| 39 | 40 |
| 40 } // namespace printing | 41 } // namespace printing |
| OLD | NEW |