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

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

Issue 7019013: Removal of dependencies on PlatformDevice classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Syncing merge conflicts. Created 9 years, 7 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 | Annotate | Revision Log
OLDNEW
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 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/process_util.h" 9 #include "base/process_util.h"
10 #include "base/scoped_ptr.h" 10 #include "base/scoped_ptr.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 void PrintWebViewHelper::PrintPageInternal( 75 void PrintWebViewHelper::PrintPageInternal(
76 const PrintMsg_PrintPage_Params& params, 76 const PrintMsg_PrintPage_Params& params,
77 const gfx::Size& canvas_size, 77 const gfx::Size& canvas_size,
78 WebFrame* frame) { 78 WebFrame* frame) {
79 // Generate a memory-based metafile. It will use the current screen's DPI. 79 // Generate a memory-based metafile. It will use the current screen's DPI.
80 // Each metafile contains a single page. 80 // Each metafile contains a single page.
81 scoped_ptr<Metafile> metafile(new printing::NativeMetafile); 81 scoped_ptr<Metafile> metafile(new printing::NativeMetafile);
82 metafile->Init(); 82 metafile->Init();
83 DCHECK(metafile->context()); 83 DCHECK(metafile->context());
84 skia::PlatformDevice::InitializeDC(metafile->context()); 84 skia::InitializeDC(metafile->context());
85 85
86 int page_number = params.page_number; 86 int page_number = params.page_number;
87 87
88 // Calculate the dpi adjustment. 88 // Calculate the dpi adjustment.
89 float scale_factor = static_cast<float>(params.params.desired_dpi / 89 float scale_factor = static_cast<float>(params.params.desired_dpi /
90 params.params.dpi); 90 params.params.dpi);
91 91
92 // Render page for printing. 92 // Render page for printing.
93 RenderPage(params.params, &scale_factor, page_number, false, frame, 93 RenderPage(params.params, &scale_factor, page_number, false, frame,
94 &metafile); 94 &metafile);
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 // PrintContext will then set the correct clipping region. 221 // PrintContext will then set the correct clipping region.
222 width = static_cast<int>(content_width_in_points * params.max_shrink); 222 width = static_cast<int>(content_width_in_points * params.max_shrink);
223 height = static_cast<int>(content_height_in_points * params.max_shrink); 223 height = static_cast<int>(content_height_in_points * params.max_shrink);
224 } 224 }
225 225
226 gfx::Size page_size(width, height); 226 gfx::Size page_size(width, height);
227 gfx::Rect content_area(static_cast<int>(margin_left_in_points), 227 gfx::Rect content_area(static_cast<int>(margin_left_in_points),
228 static_cast<int>(margin_top_in_points), 228 static_cast<int>(margin_top_in_points),
229 static_cast<int>(content_width_in_points), 229 static_cast<int>(content_width_in_points),
230 static_cast<int>(content_height_in_points)); 230 static_cast<int>(content_height_in_points));
231 skia::PlatformDevice* device = (*metafile)->StartPageForVectorCanvas( 231 SkDevice* device = (*metafile)->StartPageForVectorCanvas(
232 page_size, content_area, frame->getPrintPageShrink(page_number)); 232 page_size, content_area, frame->getPrintPageShrink(page_number));
233 DCHECK(device); 233 DCHECK(device);
234 // The printPage method may take a reference to the canvas we pass down, so it 234 // The printPage method may take a reference to the canvas we pass down, so it
235 // can't be a stack object. 235 // can't be a stack object.
236 SkRefPtr<skia::VectorCanvas> canvas = new skia::VectorCanvas(device); 236 SkRefPtr<skia::VectorCanvas> canvas = new skia::VectorCanvas(device);
237 canvas->unref(); // SkRefPtr and new both took a reference. 237 canvas->unref(); // SkRefPtr and new both took a reference.
238 if (is_preview) { 238 if (is_preview) {
239 printing::MetafileSkiaWrapper::SetMetafileOnCanvas(canvas.get(), 239 printing::MetafileSkiaWrapper::SetMetafileOnCanvas(canvas.get(),
240 metafile->get()); 240 metafile->get());
241 } 241 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 283
284 HGDIOBJ old_bitmap = SelectObject(bitmap_dc, hbitmap); 284 HGDIOBJ old_bitmap = SelectObject(bitmap_dc, hbitmap);
285 RECT rect = {0, 0, width, height }; 285 RECT rect = {0, 0, width, height };
286 HBRUSH whiteBrush = static_cast<HBRUSH>(GetStockObject(WHITE_BRUSH)); 286 HBRUSH whiteBrush = static_cast<HBRUSH>(GetStockObject(WHITE_BRUSH));
287 FillRect(bitmap_dc, &rect, whiteBrush); 287 FillRect(bitmap_dc, &rect, whiteBrush);
288 288
289 scoped_ptr<Metafile> metafile2(new printing::NativeMetafile); 289 scoped_ptr<Metafile> metafile2(new printing::NativeMetafile);
290 metafile2->Init(); 290 metafile2->Init();
291 HDC hdc = metafile2->context(); 291 HDC hdc = metafile2->context();
292 DCHECK(hdc); 292 DCHECK(hdc);
293 skia::PlatformDevice::InitializeDC(hdc); 293 skia::InitializeDC(hdc);
294 294
295 RECT metafile_bounds = (*metafile)->GetPageBounds(1).ToRECT(); 295 RECT metafile_bounds = (*metafile)->GetPageBounds(1).ToRECT();
296 // Process the old metafile, placing all non-AlphaBlend calls into the 296 // Process the old metafile, placing all non-AlphaBlend calls into the
297 // new metafile, and copying the results of all the AlphaBlend calls 297 // new metafile, and copying the results of all the AlphaBlend calls
298 // from the bitmap DC. 298 // from the bitmap DC.
299 EnumEnhMetaFile(hdc, 299 EnumEnhMetaFile(hdc,
300 (*metafile)->emf(), 300 (*metafile)->emf(),
301 EnhMetaFileProc, 301 EnhMetaFileProc,
302 &bitmap_dc, 302 &bitmap_dc,
303 &metafile_bounds); 303 &metafile_bounds);
(...skipping 26 matching lines...) Expand all
330 // Copy the bits into shared memory. 330 // Copy the bits into shared memory.
331 if (!metafile->GetData(shared_buf.memory(), buf_size)) { 331 if (!metafile->GetData(shared_buf.memory(), buf_size)) {
332 NOTREACHED() << "GetData() failed"; 332 NOTREACHED() << "GetData() failed";
333 shared_buf.Unmap(); 333 shared_buf.Unmap();
334 return false; 334 return false;
335 } 335 }
336 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), shared_mem_handle); 336 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), shared_mem_handle);
337 shared_buf.Unmap(); 337 shared_buf.Unmap();
338 return true; 338 return true;
339 } 339 }
OLDNEW
« no previous file with comments | « chrome/renderer/print_web_view_helper_linux.cc ('k') | chrome/renderer/safe_browsing/phishing_thumbnailer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698