Bug 1111786 - Cherry-pick the skia 6f90475632b0ff8e9e83916ee6373d3c26cc9284 commit; r=upstream
authorEhsan Akhgari <ehsan@mozilla.com>
Mon, 15 Dec 2014 16:17:59 -0500
changeset 219801 0db8f08e7998dfeecb8014e1607c87370c17fe92
parent 219800 294cfcf466c87305abccd78d725dd2ea613d2813
child 219802 e8083c2c6649e07f3adad9b1320e6562bd7e5073
push id10419
push usercbook@mozilla.com
push dateTue, 16 Dec 2014 12:45:27 +0000
treeherderfx-team@ec87657146eb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersupstream
bugs1111786
milestone37.0a1
Bug 1111786 - Cherry-pick the skia 6f90475632b0ff8e9e83916ee6373d3c26cc9284 commit; r=upstream Rewrite NaN checks in terms of SkScalarIsNaN() We are trying to replace Skia's NaN checker with our own in Mozilla, so it would be nice to have to patch a single place by making sure these NaN checks used SkScalarIsNaN().
gfx/skia/trunk/include/core/SkPoint.h
gfx/skia/trunk/include/core/SkRect.h
gfx/skia/trunk/include/core/SkScalar.h
--- a/gfx/skia/trunk/include/core/SkPoint.h
+++ b/gfx/skia/trunk/include/core/SkPoint.h
@@ -343,21 +343,21 @@ struct SK_API SkPoint {
      *  Returns true if both X and Y are finite (not infinity or NaN)
      */
     bool isFinite() const {
         SkScalar accum = 0;
         accum *= fX;
         accum *= fY;
 
         // accum is either NaN or it is finite (zero).
-        SkASSERT(0 == accum || !(accum == accum));
+        SkASSERT(0 == accum || SkScalarIsNaN(accum));
 
         // value==value will be true iff value is not NaN
         // TODO: is it faster to say !accum or accum==accum?
-        return accum == accum;
+        return !SkScalarIsNaN(accum);
     }
 
     /**
      *  Returns true if the point's coordinates equal (x,y)
      */
     bool equals(SkScalar x, SkScalar y) const {
         return fX == x && fY == y;
     }
--- a/gfx/skia/trunk/include/core/SkRect.h
+++ b/gfx/skia/trunk/include/core/SkRect.h
@@ -452,21 +452,21 @@ struct SK_API SkRect {
     bool isFinite() const {
         float accum = 0;
         accum *= fLeft;
         accum *= fTop;
         accum *= fRight;
         accum *= fBottom;
 
         // accum is either NaN or it is finite (zero).
-        SkASSERT(0 == accum || !(accum == accum));
+        SkASSERT(0 == accum || SkScalarIsNaN(accum));
 
         // value==value will be true iff value is not NaN
         // TODO: is it faster to say !accum or accum==accum?
-        return accum == accum;
+        return !SkScalarIsNaN(accum);
     }
 
     SkScalar    x() const { return fLeft; }
     SkScalar    y() const { return fTop; }
     SkScalar    left() const { return fLeft; }
     SkScalar    top() const { return fTop; }
     SkScalar    right() const { return fRight; }
     SkScalar    bottom() const { return fBottom; }
--- a/gfx/skia/trunk/include/core/SkScalar.h
+++ b/gfx/skia/trunk/include/core/SkScalar.h
@@ -44,17 +44,17 @@ static inline bool SkScalarIsNaN(float x
 static inline bool SkScalarIsFinite(float x) {
     // We rely on the following behavior of infinities and nans
     // 0 * finite --> 0
     // 0 * infinity --> NaN
     // 0 * NaN --> NaN
     float prod = x * 0;
     // At this point, prod will either be NaN or 0
     // Therefore we can return (prod == prod) or (0 == prod).
-    return prod == prod;
+    return !SkScalarIsNaN(prod);
 }
 
 /** SkIntToScalar(n) returns its integer argument as an SkScalar
 */
 #define SkIntToScalar(n)        ((float)(n))
 /** SkFixedToScalar(n) returns its SkFixed argument as an SkScalar
 */
 #define SkFixedToScalar(x)      SkFixedToFloat(x)