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 /printing | |
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 'printing')
-rw-r--r-- | printing/custom_scaling.cc | 37 | ||||
-rw-r--r-- | printing/custom_scaling.h | 33 | ||||
-rw-r--r-- | printing/printing.gyp | 4 |
3 files changed, 73 insertions, 1 deletions
diff --git a/printing/custom_scaling.cc b/printing/custom_scaling.cc new file mode 100644 index 0000000..dead79c --- /dev/null +++ b/printing/custom_scaling.cc @@ -0,0 +1,37 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "printing/custom_scaling.h" + +#include "base/threading/thread_local.h" + +namespace printing { + +static base::ThreadLocalPointer<double> gPrintingPageScale; + +bool GetCustomPrintingPageScale(double* scale) { + double* ptr = gPrintingPageScale.Get(); + if (ptr != NULL) { + *scale = *ptr; + } + return ptr != NULL; +} + +void SetCustomPrintingPageScale(double scale) { + ClearCustomPrintingPageScale(); + double* ptr = new double; + *ptr = scale; + gPrintingPageScale.Set(ptr); +} + +void ClearCustomPrintingPageScale() { + double* ptr = gPrintingPageScale.Get(); + if (ptr != NULL) { + delete ptr; + } + gPrintingPageScale.Set(NULL); +} + +} // namespace printing + diff --git a/printing/custom_scaling.h b/printing/custom_scaling.h new file mode 100644 index 0000000..3f46d2e --- /dev/null +++ b/printing/custom_scaling.h @@ -0,0 +1,33 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PRINTING_CUSTOM_SCALING_H_ +#define PRINTING_CUSTOM_SCALING_H_ + +#include "printing/printing_export.h" + +namespace printing { + +// This set of function allows plugin to set custom printing scale in the +// thread local storage. It is a hack to pass scale through this, but +// alternative is to do major refactoring to pass this scale factor all the +// from plugin through webkit to the upper level. +// We should definitely revisit this approach in favor of better implementation +// later. In the mean time, this looks like a simplest way fixing printing +// issues now. + +// Gets custom printing scale from the TLS. Return false if it has not been +// set. +PRINTING_EXPORT bool GetCustomPrintingPageScale(double* scale); + +// Sets custom printing scale in TLS. +PRINTING_EXPORT void SetCustomPrintingPageScale(double scale); + +// Clears custom printing scale in TLS. +PRINTING_EXPORT void ClearCustomPrintingPageScale(); + +} // namespace printing + +#endif // PRINTING_CUSTOM_SCALING_H_ + diff --git a/printing/printing.gyp b/printing/printing.gyp index 41d7793..c9c9790 100644 --- a/printing/printing.gyp +++ b/printing/printing.gyp @@ -1,4 +1,4 @@ -# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -32,6 +32,8 @@ 'backend/print_backend_consts.cc', 'backend/print_backend_consts.h', 'backend/print_backend_dummy.cc', + 'custom_scaling.cc', + 'custom_scaling.h', 'emf_win.cc', 'emf_win.h', 'image.cc', |