OLD | NEW |
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 "chrome/renderer/print_web_view_helper.h" | 5 #include "chrome/renderer/print_web_view_helper.h" |
6 | 6 |
7 #import <AppKit/AppKit.h> | 7 #import <AppKit/AppKit.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/mac/scoped_nsautorelease_pool.h" | 10 #include "base/mac/scoped_nsautorelease_pool.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 base::TimeTicks begin_time = base::TimeTicks::Now(); | 83 base::TimeTicks begin_time = base::TimeTicks::Now(); |
84 RenderPage(printParams.page_size, content_area, scale_factor, page_number, | 84 RenderPage(printParams.page_size, content_area, scale_factor, page_number, |
85 print_preview_context_.frame(), initial_render_metafile); | 85 print_preview_context_.frame(), initial_render_metafile); |
86 print_preview_context_.RenderedPreviewPage( | 86 print_preview_context_.RenderedPreviewPage( |
87 base::TimeTicks::Now() - begin_time); | 87 base::TimeTicks::Now() - begin_time); |
88 | 88 |
89 if (print_preview_context_.IsModifiable()) { | 89 if (print_preview_context_.IsModifiable()) { |
90 #if defined(USE_SKIA) | 90 #if defined(USE_SKIA) |
91 DCHECK(!draft_metafile.get()); | 91 DCHECK(!draft_metafile.get()); |
92 draft_metafile.reset(reinterpret_cast<printing::PreviewMetafile*>( | 92 draft_metafile.reset( |
93 print_preview_context_.metafile())->GetMetafileForCurrentPage()); | 93 print_preview_context_.metafile()->GetMetafileForCurrentPage()); |
94 #else | 94 #else |
95 draft_metafile->FinishDocument(); | 95 draft_metafile->FinishDocument(); |
96 | 96 |
97 // With CG, we rendered into a new metafile so we could get it as a draft | 97 // With CG, we rendered into a new metafile so we could get it as a draft |
98 // document. Now we need to add it to complete document. But the document | 98 // document. Now we need to add it to complete document. But the document |
99 // has already been scaled and adjusted for margins, so do a 1:1 drawing. | 99 // has already been scaled and adjusted for margins, so do a 1:1 drawing. |
100 printing::Metafile* complete_metafile = print_preview_context_.metafile(); | 100 printing::Metafile* complete_metafile = print_preview_context_.metafile(); |
101 bool success = complete_metafile->StartPage( | 101 bool success = complete_metafile->StartPage( |
102 printParams.page_size, gfx::Rect(printParams.page_size), 1.0); | 102 printParams.page_size, gfx::Rect(printParams.page_size), 1.0); |
103 DCHECK(success); | 103 DCHECK(success); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 base::mac::ScopedNSAutoreleasePool pool; | 146 base::mac::ScopedNSAutoreleasePool pool; |
147 CGContextRef cgContext = metafile->context(); | 147 CGContextRef cgContext = metafile->context(); |
148 CGContextRef canvasPtr = cgContext; | 148 CGContextRef canvasPtr = cgContext; |
149 #endif | 149 #endif |
150 frame->printPage(page_number, canvasPtr); | 150 frame->printPage(page_number, canvasPtr); |
151 } | 151 } |
152 | 152 |
153 // Done printing. Close the device context to retrieve the compiled metafile. | 153 // Done printing. Close the device context to retrieve the compiled metafile. |
154 metafile->FinishPage(); | 154 metafile->FinishPage(); |
155 } | 155 } |
OLD | NEW |