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

Unified Diff: chrome/renderer/print_web_view_helper_win.cc

Issue 6665046: Unfork VectorPlatformCanvas. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 9 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/print_web_view_helper_linux.cc ('k') | printing/emf_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/print_web_view_helper_win.cc
diff --git a/chrome/renderer/print_web_view_helper_win.cc b/chrome/renderer/print_web_view_helper_win.cc
index 33ff59be7cbb7c17eaacb1602e7b17e525ba2a31..9ddb7eb31c5ac441a110d9fe4ecc46b27df4ffb2 100644
--- a/chrome/renderer/print_web_view_helper_win.cc
+++ b/chrome/renderer/print_web_view_helper_win.cc
@@ -197,8 +197,7 @@ void PrintWebViewHelper::CreatePreviewDocument(
void PrintWebViewHelper::RenderPage(
const ViewMsg_Print_Params& params, float* scale_factor, int page_number,
WebFrame* frame, scoped_ptr<printing::NativeMetafile>* metafile) {
- HDC hdc = (*metafile)->context();
- DCHECK(hdc);
+ DCHECK(metafile->get()->context());
double content_width_in_points;
double content_height_in_points;
@@ -216,49 +215,14 @@ void PrintWebViewHelper::RenderPage(
int width = static_cast<int>(content_width_in_points * params.max_shrink);
int height = static_cast<int>(content_height_in_points * params.max_shrink);
- bool result = (*metafile)->StartPage(
- gfx::Size(width, height),
- gfx::Point(static_cast<int>(margin_top_in_points),
- static_cast<int>(margin_left_in_points)),
- *scale_factor);
- DCHECK(result);
-
-#if 0
- // TODO(maruel): This code is kept for testing until the 100% GDI drawing
- // code is stable. maruels use this code's output as a reference when the
- // GDI drawing code fails.
-
- // Mix of Skia and GDI based.
- skia::PlatformCanvas canvas(width, height, true);
- canvas.drawARGB(255, 255, 255, 255, SkXfermode::kSrc_Mode);
- float webkit_scale_factor = frame->printPage(page_number, &canvas);
- if (*scale_factor <= 0 || webkit_scale_factor <= 0) {
- NOTREACHED() << "Printing page " << page_number << " failed.";
- } else {
- // Update the dpi adjustment with the "page |scale_factor|" calculated in
- // webkit.
- *scale_factor /= webkit_scale_factor;
- }
+ gfx::Size page_size(width, height);
+ gfx::Point(static_cast<int>(margin_left_in_points),
+ static_cast<int>(margin_top_in_points));
+ skia::PlatformDevice* device = (*metafile)->StartPageForVectorCanvas(
+ page_size, content_origin, 1.0f);
+ DCHECK(device);
+ skia::VectorCanvas canvas(device);
- // Create a BMP v4 header that we can serialize.
- BITMAPV4HEADER bitmap_header;
- gfx::CreateBitmapV4Header(width, height, &bitmap_header);
- const SkBitmap& src_bmp = canvas.getDevice()->accessBitmap(true);
- SkAutoLockPixels src_lock(src_bmp);
- int retval = StretchDIBits(hdc,
- 0,
- 0,
- width, height,
- 0, 0,
- width, height,
- src_bmp.getPixels(),
- reinterpret_cast<BITMAPINFO*>(&bitmap_header),
- DIB_RGB_COLORS,
- SRCCOPY);
- DCHECK(retval != GDI_ERROR);
-#else
- // 100% GDI based.
- skia::VectorCanvas canvas(hdc, width, height);
float webkit_scale_factor = frame->printPage(page_number, &canvas);
if (*scale_factor <= 0 || webkit_scale_factor <= 0) {
NOTREACHED() << "Printing page " << page_number << " failed.";
@@ -267,13 +231,12 @@ void PrintWebViewHelper::RenderPage(
// webkit.
*scale_factor /= webkit_scale_factor;
}
-#endif
- result = (*metafile)->FinishPage();
+ bool result = (*metafile)->FinishPage();
DCHECK(result);
skia::VectorPlatformDevice* platform_device =
- static_cast<skia::VectorPlatformDevice*>(canvas.getDevice());
+ static_cast<skia::VectorPlatformDevice*>(device);
if (platform_device->alpha_blend_used() && !params.supports_alpha_blend) {
// Close the device context to retrieve the compiled metafile.
if (!(*metafile)->Close())
« no previous file with comments | « chrome/renderer/print_web_view_helper_linux.cc ('k') | printing/emf_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698