Bug 820061 - Clamp layer scale factors to inverse powers of 2 as well. r=roc
authorMatt Woodrow <mwoodrow@mozilla.com>
Mon, 17 Dec 2012 17:30:51 +1300
changeset 125344 8d66bb18b4a309ead5506630fa8c44c9553065a9
parent 125343 aba8a2ef62253e0fe8d6807d591300ab8af2e46c
child 125345 9d6e95e7785580d4b3756ecbfa4c18725e9791cb
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs820061
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 820061 - Clamp layer scale factors to inverse powers of 2 as well. r=roc
gfx/thebes/gfxUtils.cpp
--- a/gfx/thebes/gfxUtils.cpp
+++ b/gfx/thebes/gfxUtils.cpp
@@ -550,30 +550,42 @@ gfxUtils::ClampToScaleFactor(gfxFloat aV
   static const gfxFloat kScaleResolution = 2;
 
   // Negative scaling is just a flip and irrelevant to
   // our resolution calculation.
   if (aVal < 0.0) {
     aVal = -aVal;
   }
 
+  bool inverse = false;
+  if (aVal < 1.0) {
+    inverse = true;
+    aVal = 1 / aVal;
+  }
+
   gfxFloat power = log(aVal)/log(kScaleResolution);
 
   // If power is within 1e-6 of an integer, round to nearest to
   // prevent floating point errors, otherwise round up to the
   // next integer value.
   if (fabs(power - NS_round(power)) < 1e-6) {
     power = NS_round(power);
+  } else if (inverse) {
+    power = floor(power);
   } else {
     power = ceil(power);
   }
 
   gfxFloat scale = pow(kScaleResolution, power);
 
-  return NS_MAX(scale, 1.0);
+  if (inverse) {
+    scale = 1 / scale;
+  }
+
+  return scale;
 }
 
 
 /*static*/ void
 gfxUtils::PathFromRegion(gfxContext* aContext, const nsIntRegion& aRegion)
 {
   PathFromRegionInternal(aContext, aRegion, false);
 }