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

Side by Side Diff: chrome/renderer/print_web_view_helper_win.cc

Issue 11275288: Merge 167271 - Moved AlphaBlend rasterization to renderer process like it was before 152681. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1271_60/src/
Patch Set: Created 8 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/printing/print_view_manager.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 "chrome/renderer/print_web_view_helper.h" 5 #include "chrome/renderer/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 "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/process_util.h" 10 #include "base/process_util.h"
(...skipping 20 matching lines...) Expand all
31 using printing::kPointsPerInch; 31 using printing::kPointsPerInch;
32 using printing::Metafile; 32 using printing::Metafile;
33 using WebKit::WebFrame; 33 using WebKit::WebFrame;
34 34
35 void PrintWebViewHelper::PrintPageInternal( 35 void PrintWebViewHelper::PrintPageInternal(
36 const PrintMsg_PrintPage_Params& params, 36 const PrintMsg_PrintPage_Params& params,
37 const gfx::Size& canvas_size, 37 const gfx::Size& canvas_size,
38 WebFrame* frame) { 38 WebFrame* frame) {
39 // Generate a memory-based metafile. It will use the current screen's DPI. 39 // Generate a memory-based metafile. It will use the current screen's DPI.
40 // Each metafile contains a single page. 40 // Each metafile contains a single page.
41 scoped_ptr<Metafile> metafile(new printing::NativeMetafile); 41 scoped_ptr<printing::NativeMetafile> metafile(new printing::NativeMetafile);
42 metafile->Init(); 42 metafile->Init();
43 DCHECK(metafile->context()); 43 DCHECK(metafile->context());
44 skia::InitializeDC(metafile->context()); 44 skia::InitializeDC(metafile->context());
45 45
46 int page_number = params.page_number; 46 int page_number = params.page_number;
47 47
48 // Calculate the dpi adjustment. 48 // Calculate the dpi adjustment.
49 // Browser will render context using desired_dpi, so we need to calculate 49 // Browser will render context using desired_dpi, so we need to calculate
50 // adjustment factor to play content on the printer DC later during the 50 // adjustment factor to play content on the printer DC later during the
51 // actual printing. 51 // actual printing.
52 double actual_shrink = static_cast<float>(params.params.desired_dpi / 52 double actual_shrink = static_cast<float>(params.params.desired_dpi /
53 params.params.dpi); 53 params.params.dpi);
54 gfx::Size page_size_in_dpi; 54 gfx::Size page_size_in_dpi;
55 gfx::Rect content_area_in_dpi; 55 gfx::Rect content_area_in_dpi;
56 56
57 // Render page for printing. 57 // Render page for printing.
58 RenderPage(params.params, page_number, frame, false, metafile.get(), 58 RenderPage(params.params, page_number, frame, false, metafile.get(),
59 &actual_shrink, &page_size_in_dpi, &content_area_in_dpi); 59 &actual_shrink, &page_size_in_dpi, &content_area_in_dpi);
60 60
61 // Close the device context to retrieve the compiled metafile. 61 // Close the device context to retrieve the compiled metafile.
62 if (!metafile->FinishDocument()) 62 if (!metafile->FinishDocument())
63 NOTREACHED(); 63 NOTREACHED();
64 64
65 if (!params.params.supports_alpha_blend && metafile->IsAlphaBlendUsed()) {
66 scoped_ptr<printing::NativeMetafile> raster_metafile(
67 metafile->RasterizeAlphaBlend());
68 if (raster_metafile.get())
69 metafile.swap(raster_metafile);
70 }
71
65 // Get the size of the compiled metafile. 72 // Get the size of the compiled metafile.
66 uint32 buf_size = metafile->GetDataSize(); 73 uint32 buf_size = metafile->GetDataSize();
67 DCHECK_GT(buf_size, 128u); 74 DCHECK_GT(buf_size, 128u);
68 75
69 PrintHostMsg_DidPrintPage_Params page_params; 76 PrintHostMsg_DidPrintPage_Params page_params;
70 page_params.data_size = buf_size; 77 page_params.data_size = buf_size;
71 page_params.metafile_data_handle = NULL; 78 page_params.metafile_data_handle = NULL;
72 page_params.page_number = page_number; 79 page_params.page_number = page_number;
73 page_params.document_cookie = params.params.document_cookie; 80 page_params.document_cookie = params.params.document_cookie;
74 page_params.actual_shrink = actual_shrink; 81 page_params.actual_shrink = actual_shrink;
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 shared_buf.Unmap(); 234 shared_buf.Unmap();
228 return false; 235 return false;
229 } 236 }
230 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), shared_mem_handle); 237 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), shared_mem_handle);
231 shared_buf.Unmap(); 238 shared_buf.Unmap();
232 239
233 Send(new PrintHostMsg_DuplicateSection(routing_id(), *shared_mem_handle, 240 Send(new PrintHostMsg_DuplicateSection(routing_id(), *shared_mem_handle,
234 shared_mem_handle)); 241 shared_mem_handle));
235 return true; 242 return true;
236 } 243 }
OLDNEW
« no previous file with comments | « chrome/browser/printing/print_view_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698