Bug 1067191 - Part 1: Use an unsnapped destination rect when computing transforms for image drawing. r=roc, a=lmandel
authorSeth Fowler <seth@mozilla.com>
Thu, 25 Sep 2014 14:09:53 -0700
changeset 225436 27ac8a26be7d0be628de7fa95ad1d0b8b53038c5
parent 225435 88508b8c57ce608e51c677d904d763f8dc6b131b
child 225437 da372ef9b8efa1ca5d0edc17f1c43c7185e20da1
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, lmandel
bugs1067191
milestone34.0a2
Bug 1067191 - Part 1: Use an unsnapped destination rect when computing transforms for image drawing. r=roc, a=lmandel
layout/base/nsLayoutUtils.cpp
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -5043,23 +5043,25 @@ ComputeSnappedImageDrawingParameters(gfx
     }
   } else {
     didSnap = false;
     fill = devPixelFill;
   }
 
   gfxSize destScale = didSnap ? gfxSize(currentMatrix._11, currentMatrix._22)
                               : gfxSize(1.0, 1.0);
-  gfxSize snappedDest(NSAppUnitsToIntPixels(dest.width * destScale.width,
-                                            aAppUnitsPerDevPixel),
-                      NSAppUnitsToIntPixels(dest.height * destScale.height,
-                                            aAppUnitsPerDevPixel));
+  gfxSize appUnitScaledDest(dest.width * destScale.width,
+                            dest.height * destScale.height);
+  gfxSize scaledDest = appUnitScaledDest / aAppUnitsPerDevPixel;
+  gfxSize snappedScaledDest =
+    gfxSize(NSAppUnitsToIntPixels(appUnitScaledDest.width, aAppUnitsPerDevPixel),
+            NSAppUnitsToIntPixels(appUnitScaledDest.height, aAppUnitsPerDevPixel));
 
   nsIntSize intImageSize =
-    aImage->OptimalImageSizeForDest(snappedDest,
+    aImage->OptimalImageSizeForDest(snappedScaledDest,
                                     imgIContainer::FRAME_CURRENT,
                                     aGraphicsFilter, aImageFlags);
   gfxSize imageSize(intImageSize.width, intImageSize.height);
 
   // Compute the set of pixels that would be sampled by an ideal rendering
   gfxPoint subimageTopLeft =
     MapToFloatImagePixels(imageSize, devPixelDest, devPixelFill.TopLeft());
   gfxPoint subimageBottomRight =
@@ -5097,17 +5099,17 @@ ComputeSnappedImageDrawingParameters(gfx
     if (didSnap) {
       imageSpaceAnchorPoint.Round();
       anchorPoint = imageSpaceAnchorPoint;
       anchorPoint = MapToFloatUserPixels(imageSize, devPixelDest, anchorPoint);
       anchorPoint = currentMatrix.Transform(anchorPoint);
       anchorPoint.Round();
     }
 
-    gfxRect anchoredDestRect(anchorPoint, snappedDest);
+    gfxRect anchoredDestRect(anchorPoint, scaledDest);
     gfxRect anchoredImageRect(imageSpaceAnchorPoint, imageSize);
     transform = TransformBetweenRects(anchoredImageRect, anchoredDestRect);
     invTransform = TransformBetweenRects(anchoredDestRect, anchoredImageRect);
   }
 
   // If the transform is not a straight translation by integers, then
   // filtering will occur, and restricting the fill rect to the dirty rect
   // would change the values computed for edge pixels, which we can't allow.