Bug 834896 - Replace uses of gfx_min/gfx_max with std::min/std::max. r=joe
authorMats Palmgren <matspal@gmail.com>
Wed, 30 Jan 2013 17:02:27 +0100
changeset 120381 a9ba0d91735831824c50b58eaa905ce6badc5b9a
parent 120380 c8cf23a719b70acd6a58a002c0918ab1f12ca68f
child 120382 134c19beec11a45b85ab971a708adc240187e4ea
push id24251
push userryanvm@gmail.com
push dateThu, 31 Jan 2013 20:56:22 +0000
treeherdermozilla-central@683b08dc1afd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjoe
bugs834896
milestone21.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 834896 - Replace uses of gfx_min/gfx_max with std::min/std::max. r=joe
gfx/2d/BaseRect.h
gfx/thebes/RoundedRect.h
--- a/gfx/2d/BaseRect.h
+++ b/gfx/2d/BaseRect.h
@@ -79,33 +79,33 @@ struct BaseRect {
   // Always returns false if aRect is empty or 'this' is empty.
   bool Intersects(const Sub& aRect) const
   {
     return x < aRect.XMost() && aRect.x < XMost() &&
            y < aRect.YMost() && aRect.y < YMost();
   }
   // Returns the rectangle containing the intersection of the points
   // (including edges) of *this and aRect. If there are no points in that
-  // intersection, returns an empty rectangle with x/y set to the gfx_max of the x/y
+  // intersection, returns an empty rectangle with x/y set to the std::max of the x/y
   // of *this and aRect.
   Sub Intersect(const Sub& aRect) const
   {
     Sub result;
-    result.x = gfx_max(x, aRect.x);
-    result.y = gfx_max(y, aRect.y);
-    result.width = gfx_min(XMost(), aRect.XMost()) - result.x;
-    result.height = gfx_min(YMost(), aRect.YMost()) - result.y;
+    result.x = std::max(x, aRect.x);
+    result.y = std::max(y, aRect.y);
+    result.width = std::min(XMost(), aRect.XMost()) - result.x;
+    result.height = std::min(YMost(), aRect.YMost()) - result.y;
     if (result.width < 0 || result.height < 0) {
       result.SizeTo(0, 0);
     }
     return result;
   }
   // Sets *this to be the rectangle containing the intersection of the points
   // (including edges) of *this and aRect. If there are no points in that
-  // intersection, sets *this to be an empty rectangle with x/y set to the gfx_max
+  // intersection, sets *this to be an empty rectangle with x/y set to the std::max
   // of the x/y of *this and aRect.
   //
   // 'this' can be the same object as either aRect1 or aRect2
   bool IntersectRect(const Sub& aRect1, const Sub& aRect2)
   {
     *static_cast<Sub*>(this) = aRect1.Intersect(aRect2);
     return !IsEmpty();
   }
@@ -125,20 +125,20 @@ struct BaseRect {
     }
   }
   // Returns the smallest rectangle that contains both the points (including
   // edges) of both aRect1 and aRect2.
   // Thus, empty input rectangles are allowed to affect the result.
   Sub UnionEdges(const Sub& aRect) const
   {
     Sub result;
-    result.x = gfx_min(x, aRect.x);
-    result.y = gfx_min(y, aRect.y);
-    result.width = gfx_max(XMost(), aRect.XMost()) - result.x;
-    result.height = gfx_max(YMost(), aRect.YMost()) - result.y;
+    result.x = std::min(x, aRect.x);
+    result.y = std::min(y, aRect.y);
+    result.width = std::max(XMost(), aRect.XMost()) - result.x;
+    result.height = std::max(YMost(), aRect.YMost()) - result.y;
     return result;
   }
   // Computes the smallest rectangle that contains both the area of both
   // aRect1 and aRect2, and fills 'this' with the result.
   // Thus, empty input rectangles are ignored.
   // If both rectangles are empty, sets 'this' to aRect2.
   //
   // 'this' can be the same object as either aRect1 or aRect2
@@ -189,25 +189,25 @@ struct BaseRect {
   }
   void Inflate(const SizeT& aSize) { Inflate(aSize.width, aSize.height); }
 
   void Deflate(T aD) { Deflate(aD, aD); }
   void Deflate(T aDx, T aDy)
   {
     x += aDx;
     y += aDy;
-    width = gfx_max(T(0), width - 2 * aDx);
-    height = gfx_max(T(0), height - 2 * aDy);
+    width = std::max(T(0), width - 2 * aDx);
+    height = std::max(T(0), height - 2 * aDy);
   }
   void Deflate(const Margin& aMargin)
   {
     x += aMargin.left;
     y += aMargin.top;
-    width = gfx_max(T(0), width - aMargin.LeftRight());
-    height = gfx_max(T(0), height - aMargin.TopBottom());
+    width = std::max(T(0), width - aMargin.LeftRight());
+    height = std::max(T(0), height - aMargin.TopBottom());
   }
   void Deflate(const SizeT& aSize) { Deflate(aSize.width, aSize.height); }
 
   // Return true if the rectangles contain the same set of points, including
   // points on the edges.
   // Use when we care about the exact x/y/width/height values being
   // equal (i.e. we care about differences in empty rectangles).
   bool IsEqualEdges(const Sub& aRect) const
@@ -365,18 +365,18 @@ struct BaseRect {
   // that the result is the largest integer-coordinate rectangle contained by the
   // unrounded result.
   void ScaleRoundIn(double aXScale, double aYScale)
   {
     T right = static_cast<T>(floor(double(XMost()) * aXScale));
     T bottom = static_cast<T>(floor(double(YMost()) * aYScale));
     x = static_cast<T>(ceil(double(x) * aXScale));
     y = static_cast<T>(ceil(double(y) * aYScale));
-    width = gfx_max<T>(0, right - x);
-    height = gfx_max<T>(0, bottom - y);
+    width = std::max<T>(0, right - x);
+    height = std::max<T>(0, bottom - y);
   }
   // Scale 'this' by 1/aScale, converting coordinates to integers so that the result is
   // the smallest integer-coordinate rectangle containing the unrounded result.
   // Note: this can turn an empty rectangle into a non-empty rectangle
   void ScaleInverseRoundOut(double aScale) { ScaleInverseRoundOut(aScale, aScale); }
   // Scale 'this' by 1/aXScale and 1/aYScale, converting coordinates to integers so
   // that the result is the smallest integer-coordinate rectangle containing the
   // unrounded result.
@@ -397,18 +397,18 @@ struct BaseRect {
   // that the result is the largest integer-coordinate rectangle contained by the
   // unrounded result.
   void ScaleInverseRoundIn(double aXScale, double aYScale)
   {
     T right = static_cast<T>(floor(double(XMost()) / aXScale));
     T bottom = static_cast<T>(floor(double(YMost()) / aYScale));
     x = static_cast<T>(ceil(double(x) / aXScale));
     y = static_cast<T>(ceil(double(y) / aYScale));
-    width = gfx_max<T>(0, right - x);
-    height = gfx_max<T>(0, bottom - y);
+    width = std::max<T>(0, right - x);
+    height = std::max<T>(0, bottom - y);
   }
 
   /**
    * Clamp aPoint to this rectangle. It is allowed to end up on any
    * edge of the rectangle.
    */
   Point ClampPoint(const Point& aPoint) const
   {
--- a/gfx/thebes/RoundedRect.h
+++ b/gfx/thebes/RoundedRect.h
@@ -13,28 +13,28 @@ namespace mozilla {
  * Note: CoreGraphics and Direct2D only support rounded rectangle with the same
  * radii on all corners. However, supporting CSS's border-radius requires the extra flexibility. */
 struct RoundedRect {
     RoundedRect(gfxRect &aRect, gfxCornerSizes &aCorners) : rect(aRect), corners(aCorners) { }
     void Deflate(gfxFloat aTopWidth, gfxFloat aBottomWidth, gfxFloat aLeftWidth, gfxFloat aRightWidth) {
         // deflate the internal rect
         rect.x += aLeftWidth;
         rect.y += aTopWidth;
-        rect.width = gfx::gfx_max(0., rect.width - aLeftWidth - aRightWidth);
-        rect.height = gfx::gfx_max(0., rect.height - aTopWidth - aBottomWidth);
+        rect.width = std::max(0., rect.width - aLeftWidth - aRightWidth);
+        rect.height = std::max(0., rect.height - aTopWidth - aBottomWidth);
 
-        corners.sizes[NS_CORNER_TOP_LEFT].width  = gfx::gfx_max(0., corners.sizes[NS_CORNER_TOP_LEFT].width - aLeftWidth);
-        corners.sizes[NS_CORNER_TOP_LEFT].height = gfx::gfx_max(0., corners.sizes[NS_CORNER_TOP_LEFT].height - aTopWidth);
+        corners.sizes[NS_CORNER_TOP_LEFT].width  = std::max(0., corners.sizes[NS_CORNER_TOP_LEFT].width - aLeftWidth);
+        corners.sizes[NS_CORNER_TOP_LEFT].height = std::max(0., corners.sizes[NS_CORNER_TOP_LEFT].height - aTopWidth);
 
-        corners.sizes[NS_CORNER_TOP_RIGHT].width  = gfx::gfx_max(0., corners.sizes[NS_CORNER_TOP_RIGHT].width - aRightWidth);
-        corners.sizes[NS_CORNER_TOP_RIGHT].height = gfx::gfx_max(0., corners.sizes[NS_CORNER_TOP_RIGHT].height - aTopWidth);
+        corners.sizes[NS_CORNER_TOP_RIGHT].width  = std::max(0., corners.sizes[NS_CORNER_TOP_RIGHT].width - aRightWidth);
+        corners.sizes[NS_CORNER_TOP_RIGHT].height = std::max(0., corners.sizes[NS_CORNER_TOP_RIGHT].height - aTopWidth);
 
-        corners.sizes[NS_CORNER_BOTTOM_LEFT].width  = gfx::gfx_max(0., corners.sizes[NS_CORNER_BOTTOM_LEFT].width - aLeftWidth);
-        corners.sizes[NS_CORNER_BOTTOM_LEFT].height = gfx::gfx_max(0., corners.sizes[NS_CORNER_BOTTOM_LEFT].height - aBottomWidth);
+        corners.sizes[NS_CORNER_BOTTOM_LEFT].width  = std::max(0., corners.sizes[NS_CORNER_BOTTOM_LEFT].width - aLeftWidth);
+        corners.sizes[NS_CORNER_BOTTOM_LEFT].height = std::max(0., corners.sizes[NS_CORNER_BOTTOM_LEFT].height - aBottomWidth);
 
-        corners.sizes[NS_CORNER_BOTTOM_RIGHT].width  = gfx::gfx_max(0., corners.sizes[NS_CORNER_BOTTOM_RIGHT].width - aRightWidth);
-        corners.sizes[NS_CORNER_BOTTOM_RIGHT].height = gfx::gfx_max(0., corners.sizes[NS_CORNER_BOTTOM_RIGHT].height - aBottomWidth);
+        corners.sizes[NS_CORNER_BOTTOM_RIGHT].width  = std::max(0., corners.sizes[NS_CORNER_BOTTOM_RIGHT].width - aRightWidth);
+        corners.sizes[NS_CORNER_BOTTOM_RIGHT].height = std::max(0., corners.sizes[NS_CORNER_BOTTOM_RIGHT].height - aBottomWidth);
     }
     gfxRect rect;
     gfxCornerSizes corners;
 };
 
 } // namespace mozilla