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

Side by Side Diff: webkit/plugins/ppapi/ppapi_plugin_instance.cc

Issue 10348002: ugrr... Fixing printing scaling again. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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
« no previous file with comments | « printing/printing.gyp ('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 "webkit/plugins/ppapi/ppapi_plugin_instance.h" 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/linked_ptr.h" 10 #include "base/memory/linked_ptr.h"
(...skipping 20 matching lines...) Expand all
31 #include "ppapi/shared_impl/ppb_input_event_shared.h" 31 #include "ppapi/shared_impl/ppb_input_event_shared.h"
32 #include "ppapi/shared_impl/ppb_url_util_shared.h" 32 #include "ppapi/shared_impl/ppb_url_util_shared.h"
33 #include "ppapi/shared_impl/ppb_view_shared.h" 33 #include "ppapi/shared_impl/ppb_view_shared.h"
34 #include "ppapi/shared_impl/ppp_instance_combined.h" 34 #include "ppapi/shared_impl/ppp_instance_combined.h"
35 #include "ppapi/shared_impl/resource.h" 35 #include "ppapi/shared_impl/resource.h"
36 #include "ppapi/shared_impl/scoped_pp_resource.h" 36 #include "ppapi/shared_impl/scoped_pp_resource.h"
37 #include "ppapi/shared_impl/time_conversion.h" 37 #include "ppapi/shared_impl/time_conversion.h"
38 #include "ppapi/shared_impl/var.h" 38 #include "ppapi/shared_impl/var.h"
39 #include "ppapi/thunk/enter.h" 39 #include "ppapi/thunk/enter.h"
40 #include "ppapi/thunk/ppb_buffer_api.h" 40 #include "ppapi/thunk/ppb_buffer_api.h"
41 #include "printing/custom_scaling.h"
41 #include "printing/units.h" 42 #include "printing/units.h"
42 #include "third_party/skia/include/core/SkCanvas.h" 43 #include "third_party/skia/include/core/SkCanvas.h"
43 #include "third_party/skia/include/core/SkRect.h" 44 #include "third_party/skia/include/core/SkRect.h"
44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" 45 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h"
45 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderli ne.h" 46 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderli ne.h"
46 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" 47 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h"
47 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 48 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
48 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" 49 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
49 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 50 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
50 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGamepads. h" 51 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGamepads. h"
(...skipping 1410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1461 gfx::Size size_in_pixels; 1462 gfx::Size size_in_pixels;
1462 size_in_pixels.set_width(printing::ConvertUnit( 1463 size_in_pixels.set_width(printing::ConvertUnit(
1463 current_print_settings_.printable_area.size.width, 1464 current_print_settings_.printable_area.size.width,
1464 static_cast<int>(printing::kPointsPerInch), 1465 static_cast<int>(printing::kPointsPerInch),
1465 current_print_settings_.dpi)); 1466 current_print_settings_.dpi));
1466 size_in_pixels.set_height(printing::ConvertUnit( 1467 size_in_pixels.set_height(printing::ConvertUnit(
1467 current_print_settings_.printable_area.size.height, 1468 current_print_settings_.printable_area.size.height,
1468 static_cast<int>(printing::kPointsPerInch), 1469 static_cast<int>(printing::kPointsPerInch),
1469 current_print_settings_.dpi)); 1470 current_print_settings_.dpi));
1470 // We need to scale down DC to fit an entire page into DC available area. 1471 // We need to scale down DC to fit an entire page into DC available area.
1472 // First, we'll try to use default scaling based on the 72dpi that is
1473 // used in webkit for printing.
1474 // If default scaling is not enough to fit the entire PDF without
1471 // Current metafile is based on screen DC and have current screen size. 1475 // Current metafile is based on screen DC and have current screen size.
1472 // Writing outside of those boundaries will result in the cut-off output. 1476 // Writing outside of those boundaries will result in the cut-off output.
1473 // On metafiles (this is the case here), scaling down will still record 1477 // On metafiles (this is the case here), scaling down will still record
1474 // original coordinates and we'll be able to print in full resolution. 1478 // original coordinates and we'll be able to print in full resolution.
1475 // Before playback we'll need to counter the scaling up that will happen 1479 // Before playback we'll need to counter the scaling up that will happen
1476 // in the browser (printed_document_win.cc). 1480 // in the browser (printed_document_win.cc).
1477 gfx::ScaleDC(dc, gfx::CalculatePageScale(dc, size_in_pixels.width(), 1481 double dynamic_scale = gfx::CalculatePageScale(dc, size_in_pixels.width(),
1478 size_in_pixels.height())); 1482 size_in_pixels.height());
1483 double page_scale = static_cast<double>(printing::kPointsPerInch) /
1484 static_cast<double>(current_print_settings_.dpi);
1485
1486 if (dynamic_scale < page_scale) {
1487 page_scale = dynamic_scale;
1488 printing::SetCustomPrintingPageScale(page_scale);
1489 }
1490
1491 gfx::ScaleDC(dc, page_scale);
1479 1492
1480 ret = render_proc(static_cast<unsigned char*>(mapper.data()), mapper.size(), 1493 ret = render_proc(static_cast<unsigned char*>(mapper.data()), mapper.size(),
1481 0, dc, current_print_settings_.dpi, 1494 0, dc, current_print_settings_.dpi,
1482 current_print_settings_.dpi, 0, 0, size_in_pixels.width(), 1495 current_print_settings_.dpi, 0, 0, size_in_pixels.width(),
1483 size_in_pixels.height(), true, false, true, true, true); 1496 size_in_pixels.height(), true, false, true, true, true);
1484 skia::EndPlatformPaint(canvas); 1497 skia::EndPlatformPaint(canvas);
1485 } 1498 }
1486 #endif // defined(OS_WIN) 1499 #endif // defined(OS_WIN)
1487 1500
1488 return ret; 1501 return ret;
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
2058 screen_size_for_fullscreen_ = gfx::Size(); 2071 screen_size_for_fullscreen_ = gfx::Size();
2059 WebElement element = container_->element(); 2072 WebElement element = container_->element();
2060 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); 2073 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_);
2061 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); 2074 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_);
2062 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); 2075 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_);
2063 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); 2076 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_);
2064 } 2077 }
2065 2078
2066 } // namespace ppapi 2079 } // namespace ppapi
2067 } // namespace webkit 2080 } // namespace webkit
OLDNEW
« no previous file with comments | « printing/printing.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698