diff options
Diffstat (limited to 'gfx/thebes/gfxUtils.cpp')
-rw-r--r-- | gfx/thebes/gfxUtils.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/gfx/thebes/gfxUtils.cpp b/gfx/thebes/gfxUtils.cpp index 1ec73fbde0..3fc1f64639 100644 --- a/gfx/thebes/gfxUtils.cpp +++ b/gfx/thebes/gfxUtils.cpp @@ -692,7 +692,7 @@ gfxUtils::ClipToRegion(DrawTarget* aTarget, const nsIntRegion& aRegion) } /*static*/ gfxFloat -gfxUtils::ClampToScaleFactor(gfxFloat aVal) +gfxUtils::ClampToScaleFactor(gfxFloat aVal, bool aRoundDown) { // Arbitary scale factor limitation. We can increase this // for better scaling performance at the cost of worse @@ -713,14 +713,17 @@ gfxUtils::ClampToScaleFactor(gfxFloat aVal) gfxFloat power = log(aVal)/log(kScaleResolution); - // If power is within 1e-5 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-5) { + // If power is within 1e-5 of an integer, round to nearest to + // prevent floating point errors. power = NS_round(power); - } else if (inverse) { + } else if (inverse != aRoundDown) { + // Use floor when we are either inverted or rounding down, but + // not both. power = floor(power); } else { + // Otherwise, ceil when we are not inverted and not rounding + // down, or we are inverted and rounding down. power = ceil(power); } |