summaryrefslogtreecommitdiffstats
path: root/pdf
diff options
context:
space:
mode:
authorraymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-16 08:35:44 +0000
committerraymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-16 08:35:44 +0000
commitcdd5491a7f80ac170189792d19a6f0e385ef5250 (patch)
treeab750320a5ef4811a2ca2a0f510386357fb7cf01 /pdf
parent1a7d89c67344fb6b8342a45fa98662bb64e8b128 (diff)
downloadchromium_src-cdd5491a7f80ac170189792d19a6f0e385ef5250.zip
chromium_src-cdd5491a7f80ac170189792d19a6f0e385ef5250.tar.gz
chromium_src-cdd5491a7f80ac170189792d19a6f0e385ef5250.tar.bz2
Fix min threshhold calculation for resizing the PDF graphics context
This fixes the calculation for the threshhold we use to calculate whether the graphics context needs to be resized. There isn't a correctness issue here, as the context will always be large enough but it results in resizing more than necessary. This example demonstrates the issue: -If the plugin size was 100 x 100, we would set the context size to 100+kBufferSize x 100+kBufferSize. -If the plugin was then resized to 90x90 we would check to see if the plugin size is smaller than (100+kBufferSize)-kBufferSize x (100+kBufferSize)-kBufferSize which is equal to 100 x 100. -But we really intend to check whether it is smaller than 100-kBufferSize x 100-kBufferSize Thus we should check whether the plugin is smaller than the (current context size) - 2*kBufferSize which is kBufferSize less than the plugin size when the context size was last computed. BUG=303491 Review URL: https://codereview.chromium.org/337443002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277387 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'pdf')
-rw-r--r--pdf/paint_manager.cc16
1 files changed, 11 insertions, 5 deletions
diff --git a/pdf/paint_manager.cc b/pdf/paint_manager.cc
index 093e0cd..f452b37 100644
--- a/pdf/paint_manager.cc
+++ b/pdf/paint_manager.cc
@@ -41,15 +41,21 @@ PaintManager::~PaintManager() {
// static
pp::Size PaintManager::GetNewContextSize(const pp::Size& current_context_size,
const pp::Size& plugin_size) {
- // The number of additional space in pixels to allocate to the right/bottom
- // of the context.
- const int kBufferSize = 100;
+ // The amount of additional space in pixels to allocate to the right/bottom of
+ // the context.
+ const int kBufferSize = 50;
// Default to returning the same size.
pp::Size result = current_context_size;
- pp::Size min_size(std::max(current_context_size.width() - kBufferSize, 0),
- std::max(current_context_size.height() - kBufferSize, 0));
+ // The minimum size of the plugin before resizing the context to ensure we
+ // aren't wasting too much memory. We deduct twice the kBufferSize from the
+ // current context size which gives a threshhold that is kBufferSize below
+ // the plugin size when the context size was last computed.
+ pp::Size min_size(
+ std::max(current_context_size.width() - 2 * kBufferSize, 0),
+ std::max(current_context_size.height() - 2 * kBufferSize, 0));
+
// If the plugin size is bigger than the current context size, we need to
// resize the context. If the plugin size is smaller than the current
// context size by a given threshhold then resize the context so that we