Bug 1223486 - Ensure WrapTexCoord returns 0.0 instead of 1.0 when given a negative whole number. r=Bas
 author Kartikaya Gupta Thu, 19 Nov 2015 10:49:31 -0500 changeset 297431 1fdb5e461f106c706c18029afd547450a6f2c397 parent 297425 5dcdd3c728fac543a832c9081d7221ee912ba762 child 297436 e5d9e71f97386a838f0f5e589f84282735b77d15 push id unknown push user unknown push date unknown reviewers Bas bugs 1223486 milestone 45.0a1
Bug 1223486 - Ensure WrapTexCoord returns 0.0 instead of 1.0 when given a negative whole number. r=Bas
 gfx/gl/DecomposeIntoNoRepeatTriangles.cpp file | annotate | diff | comparison | revisions gfx/layers/Compositor.cpp file | annotate | diff | comparison | revisions
```--- a/gfx/gl/DecomposeIntoNoRepeatTriangles.cpp
+++ b/gfx/gl/DecomposeIntoNoRepeatTriangles.cpp
@@ -35,25 +35,18 @@ RectTriangles::addRect(GLfloat x0, GLflo
}
AppendRectToCoordArray(mVertexCoords, x0, y0, x1, y1);
AppendRectToCoordArray(mTexCoords, tx0, ty0, tx1, ty1);
}

static GLfloat
WrapTexCoord(GLfloat v)
{
-    // fmodf gives negative results for negative numbers;
-    // that is, fmodf(0.75, 1.0) == 0.75, but
-    // fmodf(-0.75, 1.0) == -0.75.  For the negative case,
-    // the result we need is 0.25, so we add 1.0f.
-    if (v < 0.0f) {
-        return 1.0f + fmodf(v, 1.0f);
-    }
-
-    return fmodf(v, 1.0f);
+    // This should return values in range [0, 1.0)
+    return v - floorf(v);
}

void
DecomposeIntoNoRepeatTriangles(const gfx::IntRect& aTexCoordRect,
const gfx::IntSize& aTexSize,
RectTriangles& aRects,
bool aFlipY /* = false */)
{```
```--- a/gfx/layers/Compositor.cpp
+++ b/gfx/layers/Compositor.cpp
@@ -195,25 +195,18 @@ Compositor::FillRect(const gfx::Rect& aR
aClipRect, effects, opacity,
aTransform);
}

static float
WrapTexCoord(float v)
{
-    // fmodf gives negative results for negative numbers;
-    // that is, fmodf(0.75, 1.0) == 0.75, but
-    // fmodf(-0.75, 1.0) == -0.75.  For the negative case,
-    // the result we need is 0.25, so we add 1.0f.
-    if (v < 0.0f) {
-        return 1.0f + fmodf(v, 1.0f);
-    }
-
-    return fmodf(v, 1.0f);
+    // This should return values in range [0, 1.0)
+    return v - floorf(v);
}

static void
SetRects(size_t n,
decomposedRectArrayT* aLayerRects,
decomposedRectArrayT* aTextureRects,
float x0, float y0, float x1, float y1,
float tx0, float ty0, float tx1, float ty1,```