Bug 1404536 - Use float division not accidentally int division. - r=daoshengmu draft
authorJeff Gilbert <jgilbert@mozilla.com>
Thu, 26 Oct 2017 17:02:04 -0700
changeset 687233 3e09dac63ef568d29262f39acaac66f502d8b02a
parent 687232 20f893eea7c01dae451e6c5f1a348b54fc754799
child 737603 a4e46de41a5908a6f7fd27f9732fa5f9662cf4b7
push id86443
push userbmo:jgilbert@mozilla.com
push dateThu, 26 Oct 2017 23:52:47 +0000
reviewersdaoshengmu
bugs1404536
milestone58.0a1
Bug 1404536 - Use float division not accidentally int division. - r=daoshengmu MozReview-Commit-ID: KUIE0dl6hlE
gfx/gl/GLBlitHelper.cpp
--- a/gfx/gl/GLBlitHelper.cpp
+++ b/gfx/gl/GLBlitHelper.cpp
@@ -168,37 +168,36 @@ SubRectMat3(const float x, const float y
     ret.at(2,1) = y;
     ret.at(2,2) = 1.0f;
     return ret;
 }
 
 Mat3
 SubRectMat3(const gfx::IntRect& subrect, const gfx::IntSize& size)
 {
-    return SubRectMat3(subrect.x / size.width,
-                       subrect.y / size.height,
-                       subrect.width / size.width,
-                       subrect.height / size.height);
+    return SubRectMat3(float(subrect.x) / size.width,
+                       float(subrect.y) / size.height,
+                       float(subrect.width) / size.width,
+                       float(subrect.height) / size.height);
 }
 
 Mat3
 SubRectMat3(const gfx::IntRect& bigSubrect, const gfx::IntSize& smallSize,
             const gfx::IntSize& divisors)
 {
     const float x = float(bigSubrect.x) / divisors.width;
     const float y = float(bigSubrect.y) / divisors.height;
     const float w = float(bigSubrect.width) / divisors.width;
     const float h = float(bigSubrect.height) / divisors.height;
     return SubRectMat3(x / smallSize.width,
                        y / smallSize.height,
                        w / smallSize.width,
                        h / smallSize.height);
 }
 
-
 // --
 
 ScopedSaveMultiTex::ScopedSaveMultiTex(GLContext* const gl, const uint8_t texCount,
                                        const GLenum texTarget)
     : mGL(*gl)
     , mTexCount(texCount)
     , mTexTarget(texTarget)
     , mOldTexUnit(mGL.GetIntAs<GLenum>(LOCAL_GL_ACTIVE_TEXTURE))