Bug 1082530, part 5 - remove the variant of Moz2D's UserToDevicePixelSnapped that takes a Matrix argument instead of a DrawTarget argument. r=mattwoodrow
authorJonathan Watt <jwatt@jwatt.org>
Sun, 19 Oct 2014 10:22:47 +0100
changeset 211144 1abfecf86c502bf7ca33be585d44f235f7592112
parent 211143 5f6dc495c8b612631fd91b67f7303e24178f3f15
child 211145 2dbb3fbd7385ae8a8e0e29d9d1dc00829eaee2d9
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersmattwoodrow
bugs1082530
milestone36.0a1
Bug 1082530, part 5 - remove the variant of Moz2D's UserToDevicePixelSnapped that takes a Matrix argument instead of a DrawTarget argument. r=mattwoodrow
gfx/2d/PathHelpers.h
--- a/gfx/2d/PathHelpers.h
+++ b/gfx/2d/PathHelpers.h
@@ -192,20 +192,24 @@ extern UserDataKey sDisablePixelSnapping
  *
  * Note that the snapping is such that filling the rect using a DrawTarget
  * which has the identity matrix as its transform will result in crisp edges.
  * (That is, aRect will have integer values, aligning its edges between pixel
  * boundaries.)  If on the other hand you stroking the rect with an odd valued
  * stroke width then the edges of the stroke will be antialiased (assuming an
  * AntialiasMode that does antialiasing).
  */
-inline bool UserToDevicePixelSnapped(Rect& aRect, const Matrix& aTransform,
+inline bool UserToDevicePixelSnapped(Rect& aRect, const DrawTarget& aDrawTarget,
                                      bool aAllowScaleOr90DegreeRotate = false)
 {
-  Matrix mat = aTransform;
+  if (aDrawTarget.GetUserData(&sDisablePixelSnapping)) {
+    return false;
+  }
+
+  Matrix mat = aDrawTarget.GetTransform();
 
   const Float epsilon = 0.0000001f;
 #define WITHIN_E(a,b) (fabs((a)-(b)) < epsilon)
   if (!aAllowScaleOr90DegreeRotate &&
       (!WITHIN_E(mat._11, 1.f) || !WITHIN_E(mat._22, 1.f) ||
        !WITHIN_E(mat._12, 0.f) || !WITHIN_E(mat._21, 0.f))) {
     // We have non-translation, but only translation is allowed.
     return false;
@@ -230,25 +234,16 @@ inline bool UserToDevicePixelSnapped(Rec
       aRect.SizeTo(Size(std::max(p1.x, p3.x) - aRect.X(),
                         std::max(p1.y, p3.y) - aRect.Y()));
       return true;
   }
 
   return false;
 }
 
-inline bool UserToDevicePixelSnapped(Rect& aRect, const DrawTarget& aDrawTarget,
-                                     bool aIgnoreScale = false)
-{
-  if (aDrawTarget.GetUserData(&sDisablePixelSnapping)) {
-    return false;
-  }
-  return UserToDevicePixelSnapped(aRect, aDrawTarget.GetTransform());
-}
-
 /**
  * This function has the same behavior as UserToDevicePixelSnapped except that
  * aRect is not transformed to device space.
  */
 inline void MaybeSnapToDevicePixels(Rect& aRect, const DrawTarget& aDrawTarget,
                                     bool aIgnoreScale = false)
 {
   if (UserToDevicePixelSnapped(aRect, aDrawTarget, aIgnoreScale)) {