Bug 1283330 - take floating point inaccuracy into account for assertions in DecomposeIntoNoRepeatRects. r=nical
authorLee Salzman <lsalzman@mozilla.com>
Wed, 27 Jul 2016 12:23:34 -0400
changeset 331981 c3c3bc22ff728c3988d137de63c5c048ded4a3eb
parent 331980 e7e10e7ea1b22d3dba378640b2ebe263be6550bf
child 331982 bc0e9c0e8f36d9a35cedcaccc0b0f06d7c61ed70
push id9858
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 14:37:10 +0000
treeherdermozilla-aurora@203106ef6cb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1283330
milestone50.0a1
Bug 1283330 - take floating point inaccuracy into account for assertions in DecomposeIntoNoRepeatRects. r=nical
gfx/layers/Compositor.cpp
--- a/gfx/layers/Compositor.cpp
+++ b/gfx/layers/Compositor.cpp
@@ -375,25 +375,28 @@ DecomposeIntoNoRepeatRects(const gfx::Re
 
   // 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;
 
+  // Due to floating-point inaccuracy, we have to use XMost()-x and YMost()-y
+  // to calculate width and height, respectively, to ensure that size will
+  // remain consistent going from absolute to relative and back again.
   NS_ASSERTION(!xwrap ||
-               (xmid > aRect.x &&
-                xmid < aRect.XMost() &&
-                FuzzyEqual((xmid - aRect.x) + (aRect.XMost() - xmid), aRect.width)),
+               (xmid >= aRect.x &&
+                xmid <= aRect.XMost() &&
+                FuzzyEqual((xmid - aRect.x) + (aRect.XMost() - xmid), aRect.XMost() - aRect.x)),
                "xmid should be within [x,XMost()] and the wrapped rect should have the same width");
   NS_ASSERTION(!ywrap ||
-               (ymid > aRect.y &&
-                ymid < aRect.YMost() &&
-                FuzzyEqual((ymid - aRect.y) + (aRect.YMost() - ymid), aRect.height)),
+               (ymid >= aRect.y &&
+                ymid <= aRect.YMost() &&
+                FuzzyEqual((ymid - aRect.y) + (aRect.YMost() - ymid), aRect.YMost() - aRect.y)),
                "ymid should be within [y,YMost()] and the wrapped rect should have the same height");
 
   if (!xwrap && ywrap) {
     SetRects(0, aLayerRects, aTextureRects,
              aRect.x, aRect.y, aRect.XMost(), ymid,
              tl.x, tl.y, br.x, 1.0f,
              flipped);
     SetRects(1, aLayerRects, aTextureRects,