Bug 1057642 - Revert [Int]::PointTyped::[x|y] to be of primitive type. r=kats
authorBotond Ballo <botond@mozilla.com>
Thu, 28 Aug 2014 12:45:48 -0400
changeset 223914 b54f8eca9cb99eeecffa8b53efa438c7a335bf66
parent 223913 6fac9e4a3738f357b09af562d3e77f58601b316f
child 223915 15109655e5f03e13c76b7e30f08f483a98a82409
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)
reviewerskats
bugs1057642
milestone34.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 1057642 - Revert [Int]::PointTyped::[x|y] to be of primitive type. r=kats
content/base/public/Element.h
dom/canvas/CanvasRenderingContext2D.cpp
dom/events/EventStateManager.cpp
gfx/2d/BasePoint.h
gfx/2d/DrawTargetD2D.cpp
gfx/2d/DrawTargetTiled.cpp
gfx/2d/HelpersD2D.h
gfx/2d/Path.cpp
gfx/2d/Point.h
gfx/2d/SVGTurbulenceRenderer-inl.h
gfx/layers/apz/src/AsyncPanZoomController.cpp
gfx/layers/apz/src/Axis.cpp
gfx/layers/apz/src/Axis.h
gfx/layers/opengl/CompositorOGL.cpp
widget/xpwidgets/nsBaseWidget.cpp
--- a/content/base/public/Element.h
+++ b/content/base/public/Element.h
@@ -721,30 +721,30 @@ public:
   already_AddRefed<ShadowRoot> CreateShadowRoot(ErrorResult& aError);
   already_AddRefed<DestinationInsertionPointList> GetDestinationInsertionPoints();
 
   void ScrollIntoView();
   void ScrollIntoView(bool aTop, const ScrollOptions &aOptions);
   int32_t ScrollTop()
   {
     nsIScrollableFrame* sf = GetScrollFrame();
-    return sf ? sf->GetScrollPositionCSSPixels().y.value : 0;
+    return sf ? sf->GetScrollPositionCSSPixels().y : 0;
   }
   void SetScrollTop(int32_t aScrollTop)
   {
     nsIScrollableFrame* sf = GetScrollFrame();
     if (sf) {
       sf->ScrollToCSSPixels(CSSIntPoint(sf->GetScrollPositionCSSPixels().x,
                                         aScrollTop));
     }
   }
   int32_t ScrollLeft()
   {
     nsIScrollableFrame* sf = GetScrollFrame();
-    return sf ? sf->GetScrollPositionCSSPixels().x.value : 0;
+    return sf ? sf->GetScrollPositionCSSPixels().x : 0;
   }
   void SetScrollLeft(int32_t aScrollLeft)
   {
     nsIScrollableFrame* sf = GetScrollFrame();
     if (sf) {
       sf->ScrollToCSSPixels(CSSIntPoint(aScrollLeft,
                                         sf->GetScrollPositionCSSPixels().y));
     }
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -1984,17 +1984,17 @@ CanvasRenderingContext2D::ArcTo(double x
   bool anticlockwise;
 
   if (p0 == p1 || p1 == p2 || radius == 0) {
     LineTo(p1.x, p1.y);
     return;
   }
 
   // Check for colinearity
-  dir = (p2.x - p1.x).value * (p0.y - p1.y).value + (p2.y - p1.y).value * (p1.x - p0.x).value;
+  dir = (p2.x - p1.x) * (p0.y - p1.y) + (p2.y - p1.y) * (p1.x - p0.x);
   if (dir == 0) {
     LineTo(p1.x, p1.y);
     return;
   }
 
 
   // XXX - Math for this code was already available from the non-azure code
   // and would be well tested. Perhaps converting to bezier directly might
@@ -4509,17 +4509,17 @@ CanvasPath::ArcTo(double x1, double y1, 
   bool anticlockwise;
 
   if (p0 == p1 || p1 == p2 || radius == 0) {
     LineTo(p1.x, p1.y);
     return;
   }
 
   // Check for colinearity
-  dir = (p2.x - p1.x).value * (p0.y - p1.y).value + (p2.y - p1.y).value * (p1.x - p0.x).value;
+  dir = (p2.x - p1.x) * (p0.y - p1.y) + (p2.y - p1.y) * (p1.x - p0.x);
   if (dir == 0) {
     LineTo(p1.x, p1.y);
     return;
   }
 
 
   // XXX - Math for this code was already available from the non-azure code
   // and would be well tested. Perhaps converting to bezier directly might
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -1591,18 +1591,18 @@ EventStateManager::GenerateDragGesture(n
       if (!pixelThresholdY)
         pixelThresholdY = 5;
     }
 
     // fire drag gesture if mouse has moved enough
     LayoutDeviceIntPoint pt = aEvent->refPoint +
       LayoutDeviceIntPoint::FromUntyped(aEvent->widget->WidgetToScreenOffset());
     LayoutDeviceIntPoint distance = pt - mGestureDownPoint;
-    if (Abs(distance.x.value) > AssertedCast<uint32_t>(pixelThresholdX) ||
-        Abs(distance.y.value) > AssertedCast<uint32_t>(pixelThresholdY)) {
+    if (Abs(distance.x) > AssertedCast<uint32_t>(pixelThresholdX) ||
+        Abs(distance.y) > AssertedCast<uint32_t>(pixelThresholdY)) {
       if (Prefs::ClickHoldContextMenu()) {
         // stop the click-hold before we fire off the drag gesture, in case
         // it takes a long time
         KillClickHoldTimer();
       }
 
       nsCOMPtr<nsISupports> container = aPresContext->GetContainerWeak();
       nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(container);
--- a/gfx/2d/BasePoint.h
+++ b/gfx/2d/BasePoint.h
@@ -15,17 +15,17 @@ namespace gfx {
 
 /**
  * Do not use this class directly. Subclass it, pass that subclass as the
  * Sub parameter, and only use that subclass. This allows methods to safely
  * cast 'this' to 'Sub*'.
  */
 template <class T, class Sub, class Coord = T>
 struct BasePoint {
-  Coord x, y;
+  T x, y;
 
   // Constructors
   MOZ_CONSTEXPR BasePoint() : x(0), y(0) {}
   MOZ_CONSTEXPR BasePoint(Coord aX, Coord aY) : x(aX), y(aY) {}
 
   void MoveTo(T aX, T aY) { x = aX; y = aY; }
   void MoveBy(T aDx, T aDy) { x += aDx; y += aDy; }
 
@@ -63,17 +63,17 @@ struct BasePoint {
     return Sub(x / aScale, y / aScale);
   }
 
   Sub operator-() const {
     return Sub(-x, -y);
   }
 
   T Length() const {
-    return hypot(x.value, y.value);
+    return hypot(x, y);
   }
 
   // Round() is *not* rounding to nearest integer if the values are negative.
   // They are always rounding as floor(n + 0.5).
   // See https://bugzilla.mozilla.org/show_bug.cgi?id=410748#c14
   Sub& Round() {
     x = Coord(floor(T(x) + T(0.5)));
     y = Coord(floor(T(y) + T(0.5)));
--- a/gfx/2d/DrawTargetD2D.cpp
+++ b/gfx/2d/DrawTargetD2D.cpp
@@ -2594,17 +2594,17 @@ DrawTargetD2D::SetupEffectForRadialGradi
   float matrix[] = { invTransform._11, invTransform._12, 0, 0,
                       invTransform._21, invTransform._22, 0, 0,
                       invTransform._31, invTransform._32, 1.0f, 0,
                       0, 0, 0, 1.0f };
 
   mPrivateData->mEffect->GetVariableByName("DeviceSpaceToUserSpace")->
     AsMatrix()->SetMatrix(matrix);
 
-  float A = dc.x.value * dc.x.value + dc.y.value * dc.y.value - dr * dr;
+  float A = dc.x * dc.x + dc.y * dc.y - dr * dr;
 
   uint32_t offset = 0;
   switch (stops->mStopCollection->GetExtendMode()) {
   case D2D1_EXTEND_MODE_WRAP:
     offset = 1;
     break;
   case D2D1_EXTEND_MODE_MIRROR:
     offset = 2;
--- a/gfx/2d/DrawTargetTiled.cpp
+++ b/gfx/2d/DrawTargetTiled.cpp
@@ -31,18 +31,18 @@ DrawTargetTiled::Init(const TileSet& aTi
     if (mTiles[0].mDrawTarget->GetFormat() != mTiles.back().mDrawTarget->GetFormat() ||
         mTiles[0].mDrawTarget->GetBackendType() != mTiles.back().mDrawTarget->GetBackendType()) {
       return false;
     }
     uint32_t newXMost = max(mRect.XMost(),
                             mTiles[i].mTileOrigin.x + mTiles[i].mDrawTarget->GetSize().width);
     uint32_t newYMost = max(mRect.YMost(),
                             mTiles[i].mTileOrigin.y + mTiles[i].mDrawTarget->GetSize().height);
-    mRect.x = min(mRect.x, mTiles[i].mTileOrigin.x.value);
-    mRect.y = min(mRect.y, mTiles[i].mTileOrigin.y.value);
+    mRect.x = min(mRect.x, mTiles[i].mTileOrigin.x);
+    mRect.y = min(mRect.y, mTiles[i].mTileOrigin.y);
     mRect.width = newXMost - mRect.x;
     mRect.height = newYMost - mRect.y;
   }
   return true;
 }
 
 class SnapshotTiled : public SourceSurface
 {
--- a/gfx/2d/HelpersD2D.h
+++ b/gfx/2d/HelpersD2D.h
@@ -234,17 +234,17 @@ static inline bool IsPatternSupportedByD
     static_cast<const RadialGradientPattern*>(&aPattern);
   
   if (pat->mRadius1 != 0) {
     return false;
   }
 
   Point diff = pat->mCenter2 - pat->mCenter1;
 
-  if (sqrt(diff.x.value * diff.x.value + diff.y.value * diff.y.value) >= pat->mRadius2) {
+  if (sqrt(diff.x * diff.x + diff.y * diff.y) >= pat->mRadius2) {
     // Inner point lies outside the circle.
     return false;
   }
 
   return true;
 }
 
 /**
--- a/gfx/2d/Path.cpp
+++ b/gfx/2d/Path.cpp
@@ -245,17 +245,17 @@ FlattenBezierCurveSegment(const BezierCo
    */
   BezierControlPoints currentCP = aControlPoints;
 
   Float t = 0;
   while (t < 1.0f) {
     Point cp21 = currentCP.mCP2 - currentCP.mCP3;
     Point cp31 = currentCP.mCP3 - currentCP.mCP1;
 
-    Float s3 = (cp31.x.value * cp21.y.value - cp31.y.value * cp21.x.value) / hypotf(cp21.x, cp21.y);
+    Float s3 = (cp31.x * cp21.y - cp31.y * cp21.x) / hypotf(cp21.x, cp21.y);
 
     t = 2 * Float(sqrt(aTolerance / (3. * abs(s3))));
 
     if (t >= 1.0f) {
       aSink->LineTo(aControlPoints.mCP4);
       break;
     }
 
@@ -281,17 +281,17 @@ FindInflectionApproximationRange(BezierC
 
       // Use the absolute value so that Min and Max will correspond with the
       // minimum and maximum of the range.
       *aMin = aT - CubicRoot(abs(aTolerance / (cp41.x - cp41.y)));
       *aMax = aT + CubicRoot(abs(aTolerance / (cp41.x - cp41.y)));
       return;
     }
 
-    Float s3 = (cp41.x.value * cp21.y.value - cp41.y.value * cp21.x.value) / hypotf(cp21.x, cp21.y);
+    Float s3 = (cp41.x * cp21.y - cp41.y * cp21.x) / hypotf(cp21.x, cp21.y);
 
     if (s3 == 0) {
       // This means within the precision we have it can be approximated
       // infinitely by a linear segment. Deal with this by specifying the
       // approximation range as extending beyond the entire curve.
       *aMin = -1.0f;
       *aMax = 2.0f;
       return;
--- a/gfx/2d/Point.h
+++ b/gfx/2d/Point.h
@@ -93,24 +93,24 @@ struct PointTyped :
   PointTyped<UnknownUnits> ToUnknownPoint() const {
     return PointTyped<UnknownUnits>(this->x, this->y);
   }
 };
 typedef PointTyped<UnknownUnits> Point;
 
 template<class units>
 IntPointTyped<units> RoundedToInt(const PointTyped<units>& aPoint) {
-  return IntPointTyped<units>(aPoint.x.Rounded(),
-                              aPoint.y.Rounded());
+  return IntPointTyped<units>(int32_t(floorf(aPoint.x + 0.5f)),
+                              int32_t(floorf(aPoint.y + 0.5f)));
 }
 
 template<class units>
 IntPointTyped<units> TruncatedToInt(const PointTyped<units>& aPoint) {
-  return IntPointTyped<units>(aPoint.x.Truncated(),
-                              aPoint.y.Truncated());
+  return IntPointTyped<units>(int32_t(aPoint.x),
+                              int32_t(aPoint.y));
 }
 
 template<class units>
 struct Point3DTyped :
   public BasePoint3D< Float, Point3DTyped<units> > {
   static_assert(IsPixel<units>::value,
                 "'units' must be a coordinate system tag");
 
--- a/gfx/2d/SVGTurbulenceRenderer-inl.h
+++ b/gfx/2d/SVGTurbulenceRenderer-inl.h
@@ -235,20 +235,20 @@ SVGTurbulenceRenderer<Type,Stitch,f32x4_
   Point r = aVec - topLeftLatticePoint; // fractional offset
 
   IntPoint b0 = AdjustForStitch(topLeftLatticePoint, aStitchInfo);
   IntPoint b1 = AdjustForStitch(b0 + IntPoint(1, 1), aStitchInfo);
 
   uint8_t i = mLatticeSelector[b0.x & sBM];
   uint8_t j = mLatticeSelector[b1.x & sBM];
 
-  const f32x4_t* qua = mGradient[(i + b0.y.value) & sBM];
-  const f32x4_t* qub = mGradient[(i + b1.y.value) & sBM];
-  const f32x4_t* qva = mGradient[(j + b0.y.value) & sBM];
-  const f32x4_t* qvb = mGradient[(j + b1.y.value) & sBM];
+  const f32x4_t* qua = mGradient[(i + b0.y) & sBM];
+  const f32x4_t* qub = mGradient[(i + b1.y) & sBM];
+  const f32x4_t* qva = mGradient[(j + b0.y) & sBM];
+  const f32x4_t* qvb = mGradient[(j + b1.y) & sBM];
 
   return BiMix(simd::WSumF32(qua[0], qua[1], r.x, r.y),
                simd::WSumF32(qva[0], qva[1], r.x - 1.f, r.y),
                simd::WSumF32(qub[0], qub[1], r.x, r.y - 1.f),
                simd::WSumF32(qvb[0], qvb[1], r.x - 1.f, r.y - 1.f),
                SCurve(r));
 }
 
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -374,18 +374,18 @@ static bool IsCloseToHorizontal(float aA
 static bool IsCloseToVertical(float aAngle, float aThreshold)
 {
   return (fabs(aAngle - (M_PI / 2)) < aThreshold);
 }
 
 template <typename Units>
 static bool IsZero(const gfx::PointTyped<Units>& aPoint)
 {
-  return FuzzyEqualsMultiplicative(aPoint.x.value, 0.0f)
-      && FuzzyEqualsMultiplicative(aPoint.y.value, 0.0f);
+  return FuzzyEqualsMultiplicative(aPoint.x, 0.0f)
+      && FuzzyEqualsMultiplicative(aPoint.y, 0.0f);
 }
 
 static inline void LogRendertraceRect(const ScrollableLayerGuid& aGuid, const char* aDesc, const char* aColor, const CSSRect& aRect)
 {
 #ifdef APZC_ENABLE_RENDERTRACE
   static const TimeStamp sRenderStart = TimeStamp::Now();
   TimeDuration delta = TimeStamp::Now() - sRenderStart;
   printf_stderr("(%llu,%lu,%llu)%s RENDERTRACE %f rect %s %f %f %f %f\n",
@@ -533,19 +533,19 @@ public:
 
       } else {
         // Otherwise, hand off the fling to the next APZC in the overscroll
         // handoff chain.
 
         // We may have reached the end of the scroll range along one axis but
         // not the other. In such a case we only want to hand off the relevant
         // component of the fling.
-        if (FuzzyEqualsAdditive(overscroll.x.value, 0.0f, COORDINATE_EPSILON)) {
+        if (FuzzyEqualsAdditive(overscroll.x, 0.0f, COORDINATE_EPSILON)) {
           velocity.x = 0;
-        } else if (FuzzyEqualsAdditive(overscroll.y.value, 0.0f, COORDINATE_EPSILON)) {
+        } else if (FuzzyEqualsAdditive(overscroll.y, 0.0f, COORDINATE_EPSILON)) {
           velocity.y = 0;
         }
 
         // To hand off the fling, we attempt to find a target APZC and start a new
         // fling with the same velocity on that APZC. For simplicity, the actual
         // overscroll of the current sample is discarded rather than being handed
         // off. The compositor should sample animations sufficiently frequently
         // that this is not noticeable. The target APZC is chosen by seeing if
--- a/gfx/layers/apz/src/Axis.cpp
+++ b/gfx/layers/apz/src/Axis.cpp
@@ -65,18 +65,18 @@ void Axis::UpdateWithTouchAtDevicePoint(
 void Axis::StartTouch(ScreenCoord aPos, uint32_t aTimestampMs) {
   mStartPos = aPos;
   mPos = aPos;
   mPosTimeMs = aTimestampMs;
   mAxisLocked = false;
 }
 
 bool Axis::AdjustDisplacement(CSSCoord aDisplacement,
-                              CSSCoord& aDisplacementOut,
-                              CSSCoord& aOverscrollAmountOut)
+                              /* CSSCoord */ float& aDisplacementOut,
+                              /* CSSCoord */ float& aOverscrollAmountOut)
 {
   if (mAxisLocked) {
     aOverscrollAmountOut = 0;
     aDisplacementOut = 0;
     return false;
   }
 
   CSSCoord displacement = aDisplacement;
--- a/gfx/layers/apz/src/Axis.h
+++ b/gfx/layers/apz/src/Axis.h
@@ -83,18 +83,18 @@ public:
    * to prevent the viewport from overscrolling the page rect), and axis locking
    * (which might prevent any displacement from happening). If overscroll
    * ocurred, its amount is written to |aOverscrollAmountOut|.
    * The |aDisplacementOut| parameter is set to the adjusted
    * displacement, and the function returns true iff internal overscroll amounts
    * were changed.
    */
   bool AdjustDisplacement(CSSCoord aDisplacement,
-                          CSSCoord& aDisplacementOut,
-                          CSSCoord& aOverscrollAmountOut);
+                          /* CSSCoord */ float& aDisplacementOut,
+                          /* CSSCoord */ float& aOverscrollAmountOut);
 
   /**
    * Overscrolls this axis by the requested amount in the requested direction.
    * The axis must be at the end of its scroll range in this direction.
    */
   void OverscrollBy(CSSCoord aOverscroll);
 
   /**
--- a/gfx/layers/opengl/CompositorOGL.cpp
+++ b/gfx/layers/opengl/CompositorOGL.cpp
@@ -469,18 +469,18 @@ DecomposeIntoNoRepeatRects(const Rect& a
              aRect.x, aRect.y, aRect.XMost(), aRect.YMost(),
              tl.x, tl.y, br.x, br.y,
              flipped);
     return 1;
   }
 
   // If we are dealing with wrapping br.x and br.y are greater than 1.0 so
   // wrap them here as well.
-  br = Point(xwrap ? WrapTexCoord(br.x) : br.x.value,
-             ywrap ? WrapTexCoord(br.y) : br.y.value);
+  br = Point(xwrap ? WrapTexCoord(br.x) : br.x,
+             ywrap ? WrapTexCoord(br.y) : br.y);
 
   // If we wrap around along the x axis, we will draw first from
   // tl.x .. 1.0 and then from 0.0 .. br.x (which we just wrapped above).
   // The same applies for the Y axis. The midpoints we calculate here are
   // only valid if we actually wrap around.
   GLfloat xmid = aRect.x + (1.0f - tl.x) / texCoordRect.width * aRect.width;
   GLfloat ymid = aRect.y + (1.0f - tl.y) / texCoordRect.height * aRect.height;
 
--- a/widget/xpwidgets/nsBaseWidget.cpp
+++ b/widget/xpwidgets/nsBaseWidget.cpp
@@ -1800,18 +1800,18 @@ nsBaseWidget::debug_DumpEvent(FILE *    
 
   fprintf(aFileOut,
           "%4d %-26s widget=%-8p name=%-12s id=0x%-6x refpt=%d,%d\n",
           _GetPrintCount(),
           tempString.get(),
           (void *) aWidget,
           aWidgetName.get(),
           aWindowID,
-          aGuiEvent->refPoint.x.value,
-          aGuiEvent->refPoint.y.value);
+          aGuiEvent->refPoint.x,
+          aGuiEvent->refPoint.y);
 }
 //////////////////////////////////////////////////////////////
 /* static */ void
 nsBaseWidget::debug_DumpPaintEvent(FILE *                aFileOut,
                                    nsIWidget *           aWidget,
                                    const nsIntRegion &   aRegion,
                                    const nsAutoCString & aWidgetName,
                                    int32_t               aWindowID)