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

Side by Side Diff: chrome/renderer/printing/print_web_view_helper_linux.cc

Issue 559263002: Replaced Metafile with PdfMetafileSkia in renderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Thu Sep 11 15:46:31 PDT 2014 Created 6 years, 3 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
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 "chrome/renderer/printing/print_web_view_helper.h" 5 #include "chrome/renderer/printing/print_web_view_helper.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "chrome/common/print_messages.h" 9 #include "chrome/common/print_messages.h"
10 #include "content/public/renderer/render_thread.h" 10 #include "content/public/renderer/render_thread.h"
11 #include "printing/metafile.h"
12 #include "printing/metafile_skia_wrapper.h" 11 #include "printing/metafile_skia_wrapper.h"
13 #include "printing/page_size_margins.h" 12 #include "printing/page_size_margins.h"
14 #include "printing/pdf_metafile_skia.h" 13 #include "printing/pdf_metafile_skia.h"
15 #include "skia/ext/platform_device.h" 14 #include "skia/ext/platform_device.h"
16 #include "skia/ext/vector_canvas.h" 15 #include "skia/ext/vector_canvas.h"
17 #include "third_party/WebKit/public/web/WebLocalFrame.h" 16 #include "third_party/WebKit/public/web/WebLocalFrame.h"
18 17
19 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) 18 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
20 #include "base/process/process_handle.h" 19 #include "base/process/process_handle.h"
21 #else 20 #else
22 #include "base/file_descriptor_posix.h" 21 #include "base/file_descriptor_posix.h"
23 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) 22 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
24 23
25 namespace printing { 24 namespace printing {
26 25
27 using blink::WebFrame; 26 using blink::WebFrame;
28 27
29 bool PrintWebViewHelper::RenderPreviewPage( 28 bool PrintWebViewHelper::RenderPreviewPage(
30 int page_number, 29 int page_number,
31 const PrintMsg_Print_Params& print_params) { 30 const PrintMsg_Print_Params& print_params) {
32 PrintMsg_PrintPage_Params page_params; 31 PrintMsg_PrintPage_Params page_params;
33 page_params.params = print_params; 32 page_params.params = print_params;
34 page_params.page_number = page_number; 33 page_params.page_number = page_number;
35 scoped_ptr<Metafile> draft_metafile; 34 scoped_ptr<PdfMetafileSkia> draft_metafile;
36 Metafile* initial_render_metafile = print_preview_context_.metafile(); 35 PdfMetafileSkia* initial_render_metafile = print_preview_context_.metafile();
37 if (print_preview_context_.IsModifiable() && is_print_ready_metafile_sent_) { 36 if (print_preview_context_.IsModifiable() && is_print_ready_metafile_sent_) {
38 draft_metafile.reset(new PdfMetafileSkia); 37 draft_metafile.reset(new PdfMetafileSkia);
39 initial_render_metafile = draft_metafile.get(); 38 initial_render_metafile = draft_metafile.get();
40 } 39 }
41 40
42 base::TimeTicks begin_time = base::TimeTicks::Now(); 41 base::TimeTicks begin_time = base::TimeTicks::Now();
43 PrintPageInternal(page_params, 42 PrintPageInternal(page_params,
44 print_preview_context_.GetPrintCanvasSize(), 43 print_preview_context_.GetPrintCanvasSize(),
45 print_preview_context_.prepared_frame(), 44 print_preview_context_.prepared_frame(),
46 initial_render_metafile); 45 initial_render_metafile);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 printed_page_params.metafile_data_handle.fd = -1; 144 printed_page_params.metafile_data_handle.fd = -1;
146 } 145 }
147 return true; 146 return true;
148 #endif // defined(OS_CHROMEOS) 147 #endif // defined(OS_CHROMEOS)
149 } 148 }
150 149
151 void PrintWebViewHelper::PrintPageInternal( 150 void PrintWebViewHelper::PrintPageInternal(
152 const PrintMsg_PrintPage_Params& params, 151 const PrintMsg_PrintPage_Params& params,
153 const gfx::Size& canvas_size, 152 const gfx::Size& canvas_size,
154 WebFrame* frame, 153 WebFrame* frame,
155 Metafile* metafile) { 154 PdfMetafileSkia* metafile) {
156 PageSizeMargins page_layout_in_points; 155 PageSizeMargins page_layout_in_points;
157 double scale_factor = 1.0f; 156 double scale_factor = 1.0f;
158 ComputePageLayoutInPointsForCss(frame, params.page_number, params.params, 157 ComputePageLayoutInPointsForCss(frame, params.page_number, params.params,
159 ignore_css_margins_, &scale_factor, 158 ignore_css_margins_, &scale_factor,
160 &page_layout_in_points); 159 &page_layout_in_points);
161 gfx::Size page_size; 160 gfx::Size page_size;
162 gfx::Rect content_area; 161 gfx::Rect content_area;
163 GetPageSizeAndContentAreaFromPageLayout(page_layout_in_points, &page_size, 162 GetPageSizeAndContentAreaFromPageLayout(page_layout_in_points, &page_size,
164 &content_area); 163 &content_area);
165 gfx::Rect canvas_area = 164 gfx::Rect canvas_area =
(...skipping 25 matching lines...) Expand all
191 } 190 }
192 RenderPageContent(frame, params.page_number, canvas_area, content_area, 191 RenderPageContent(frame, params.page_number, canvas_area, content_area,
193 scale_factor, canvas.get()); 192 scale_factor, canvas.get());
194 193
195 // Done printing. Close the device context to retrieve the compiled metafile. 194 // Done printing. Close the device context to retrieve the compiled metafile.
196 if (!metafile->FinishPage()) 195 if (!metafile->FinishPage())
197 NOTREACHED() << "metafile failed"; 196 NOTREACHED() << "metafile failed";
198 } 197 }
199 198
200 } // namespace printing 199 } // namespace printing
OLDNEW
« no previous file with comments | « chrome/renderer/printing/print_web_view_helper.cc ('k') | chrome/renderer/printing/print_web_view_helper_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698