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

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

Issue 6673035: Move Start/EndPage() from NewPage/PageDone() to inside the metafile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Windows fix after rebasing 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | printing/printing_context_win.cc » ('j') | 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) 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/process_util.h" 8 #include "base/process_util.h"
9 #include "chrome/common/render_messages.h" 9 #include "chrome/common/render_messages.h"
10 #include "chrome/common/render_messages_params.h" 10 #include "chrome/common/render_messages_params.h"
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 GetPageSizeAndMarginsInPoints(frame, page_number, params, 202 GetPageSizeAndMarginsInPoints(frame, page_number, params,
203 &content_width_in_points, &content_height_in_points, NULL, NULL, NULL, 203 &content_width_in_points, &content_height_in_points, NULL, NULL, NULL,
204 NULL); 204 NULL);
205 205
206 // Since WebKit extends the page width depending on the magical scale factor 206 // Since WebKit extends the page width depending on the magical scale factor
207 // we make sure the canvas covers the worst case scenario (x2.0 currently). 207 // we make sure the canvas covers the worst case scenario (x2.0 currently).
208 // PrintContext will then set the correct clipping region. 208 // PrintContext will then set the correct clipping region.
209 int width = static_cast<int>(content_width_in_points * params.max_shrink); 209 int width = static_cast<int>(content_width_in_points * params.max_shrink);
210 int height = static_cast<int>(content_height_in_points * params.max_shrink); 210 int height = static_cast<int>(content_height_in_points * params.max_shrink);
211 211
212 bool result = (*metafile)->StartPage();
213 DCHECK(result);
214
212 #if 0 215 #if 0
213 // TODO(maruel): This code is kept for testing until the 100% GDI drawing 216 // TODO(maruel): This code is kept for testing until the 100% GDI drawing
214 // code is stable. maruels use this code's output as a reference when the 217 // code is stable. maruels use this code's output as a reference when the
215 // GDI drawing code fails. 218 // GDI drawing code fails.
216 219
217 // Mix of Skia and GDI based. 220 // Mix of Skia and GDI based.
218 skia::PlatformCanvas canvas(width, height, true); 221 skia::PlatformCanvas canvas(width, height, true);
219 canvas.drawARGB(255, 255, 255, 255, SkXfermode::kSrc_Mode); 222 canvas.drawARGB(255, 255, 255, 255, SkXfermode::kSrc_Mode);
220 float webkit_scale_factor = frame->printPage(page_number, &canvas); 223 float webkit_scale_factor = frame->printPage(page_number, &canvas);
221 if (*scale_factor <= 0 || webkit_scale_factor <= 0) { 224 if (*scale_factor <= 0 || webkit_scale_factor <= 0) {
(...skipping 26 matching lines...) Expand all
248 float webkit_scale_factor = frame->printPage(page_number, &canvas); 251 float webkit_scale_factor = frame->printPage(page_number, &canvas);
249 if (*scale_factor <= 0 || webkit_scale_factor <= 0) { 252 if (*scale_factor <= 0 || webkit_scale_factor <= 0) {
250 NOTREACHED() << "Printing page " << page_number << " failed."; 253 NOTREACHED() << "Printing page " << page_number << " failed.";
251 } else { 254 } else {
252 // Update the dpi adjustment with the "page |scale_factor|" calculated in 255 // Update the dpi adjustment with the "page |scale_factor|" calculated in
253 // webkit. 256 // webkit.
254 *scale_factor /= webkit_scale_factor; 257 *scale_factor /= webkit_scale_factor;
255 } 258 }
256 #endif 259 #endif
257 260
261 result = (*metafile)->FinishPage();
262 DCHECK(result);
263
258 skia::VectorPlatformDevice* platform_device = 264 skia::VectorPlatformDevice* platform_device =
259 static_cast<skia::VectorPlatformDevice*>(canvas.getDevice()); 265 static_cast<skia::VectorPlatformDevice*>(canvas.getDevice());
260 if (platform_device->alpha_blend_used() && !params.supports_alpha_blend) { 266 if (platform_device->alpha_blend_used() && !params.supports_alpha_blend) {
261 // Close the device context to retrieve the compiled metafile. 267 // Close the device context to retrieve the compiled metafile.
262 if (!(*metafile)->Close()) 268 if (!(*metafile)->Close())
263 NOTREACHED(); 269 NOTREACHED();
264 270
265 scoped_ptr<printing::NativeMetafile> metafile2( 271 scoped_ptr<printing::NativeMetafile> metafile2(
266 printing::NativeMetafileFactory::CreateMetafile()); 272 printing::NativeMetafileFactory::CreateMetafile());
267 // Page used alpha blend, but printer doesn't support it. Rewrite the 273 // Page used alpha blend, but printer doesn't support it. Rewrite the
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 // Copy the bits into shared memory. 332 // Copy the bits into shared memory.
327 if (!metafile->GetData(shared_buf.memory(), buf_size)) { 333 if (!metafile->GetData(shared_buf.memory(), buf_size)) {
328 NOTREACHED() << "GetData() failed"; 334 NOTREACHED() << "GetData() failed";
329 shared_buf.Unmap(); 335 shared_buf.Unmap();
330 return false; 336 return false;
331 } 337 }
332 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), shared_mem_handle); 338 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), shared_mem_handle);
333 shared_buf.Unmap(); 339 shared_buf.Unmap();
334 return true; 340 return true;
335 } 341 }
OLDNEW
« no previous file with comments | « no previous file | printing/printing_context_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698