diff options
author | gene@chromium.org <gene@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-03 23:53:27 +0000 |
---|---|---|
committer | gene@chromium.org <gene@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-03 23:53:27 +0000 |
commit | 14d59480a248bc6181e1ed5044b59593b664278f (patch) | |
tree | 5ff319966d6df7127997b77eeb73c0f562492ef2 /webkit | |
parent | f5473494ad70a6e3bbae1a2676bf979948847d1d (diff) | |
download | chromium_src-14d59480a248bc6181e1ed5044b59593b664278f.zip chromium_src-14d59480a248bc6181e1ed5044b59593b664278f.tar.gz chromium_src-14d59480a248bc6181e1ed5044b59593b664278f.tar.bz2 |
ugrr... Fixing printing scaling again.
Not the nicest fix, but it should do the job. Now, we'll try to use default scaling (72dpi) whenever we can.
If sceen resolution droped below the point where metafile can't accomodate whole PDF page anymore, we'll use this
hack to pass custom scale in the TLS for the upper layer.
BUG=125499
TEST=Print PDF using print preview and system print dialog. Same for webpage. Make screen resolution 800x600 and repeat.
Review URL: http://codereview.chromium.org/10348002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135241 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/plugins/ppapi/ppapi_plugin_instance.cc | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc index 72135a9..140d7af 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc @@ -38,6 +38,7 @@ #include "ppapi/shared_impl/var.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/ppb_buffer_api.h" +#include "printing/custom_scaling.h" #include "printing/units.h" #include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkRect.h" @@ -1468,14 +1469,26 @@ bool PluginInstance::PrintPDFOutput(PP_Resource print_output, static_cast<int>(printing::kPointsPerInch), current_print_settings_.dpi)); // We need to scale down DC to fit an entire page into DC available area. + // First, we'll try to use default scaling based on the 72dpi that is + // used in webkit for printing. + // If default scaling is not enough to fit the entire PDF without // Current metafile is based on screen DC and have current screen size. // Writing outside of those boundaries will result in the cut-off output. // On metafiles (this is the case here), scaling down will still record // original coordinates and we'll be able to print in full resolution. // Before playback we'll need to counter the scaling up that will happen // in the browser (printed_document_win.cc). - gfx::ScaleDC(dc, gfx::CalculatePageScale(dc, size_in_pixels.width(), - size_in_pixels.height())); + double dynamic_scale = gfx::CalculatePageScale(dc, size_in_pixels.width(), + size_in_pixels.height()); + double page_scale = static_cast<double>(printing::kPointsPerInch) / + static_cast<double>(current_print_settings_.dpi); + + if (dynamic_scale < page_scale) { + page_scale = dynamic_scale; + printing::SetCustomPrintingPageScale(page_scale); + } + + gfx::ScaleDC(dc, page_scale); ret = render_proc(static_cast<unsigned char*>(mapper.data()), mapper.size(), 0, dc, current_print_settings_.dpi, |