Bug 1065764, part 2 - Make Moz2D's Matrix::NudgeToIntegers() return a reference. r=Bas
authorJonathan Watt <jwatt@jwatt.org>
Thu, 11 Sep 2014 01:46:21 +0100
changeset 204755 924061fef059
parent 204754 940e62389b4d
child 204756 3e8befc46687
push id27465
push usercbook@mozilla.com
push dateThu, 11 Sep 2014 13:27:15 +0000
treeherdermozilla-central@ef81f73048dc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas
bugs1065764
milestone35.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 1065764, part 2 - Make Moz2D's Matrix::NudgeToIntegers() return a reference. r=Bas
gfx/2d/Matrix.cpp
gfx/2d/Matrix.h
--- a/gfx/2d/Matrix.cpp
+++ b/gfx/2d/Matrix.cpp
@@ -57,25 +57,26 @@ Matrix::TransformBounds(const Rect &aRec
       min_y = quad[i].y;
     if (quad[i].y > max_y)
       max_y = quad[i].y;
   }
 
   return Rect(min_x, min_y, max_x - min_x, max_y - min_y);
 }
 
-void
+Matrix&
 Matrix::NudgeToIntegers()
 {
   NudgeToInteger(&_11);
   NudgeToInteger(&_12);
   NudgeToInteger(&_21);
   NudgeToInteger(&_22);
   NudgeToInteger(&_31);
   NudgeToInteger(&_32);
+  return *this;
 }
 
 Rect
 Matrix4x4::TransformBounds(const Rect& aRect) const
 {
   Point quad[4];
   Float min_x, max_x;
   Float min_y, max_y;
--- a/gfx/2d/Matrix.h
+++ b/gfx/2d/Matrix.h
@@ -295,17 +295,17 @@ public:
 
   /* Returns true if the matrix is singular.
    */
   bool IsSingular() const
   {
     return Determinant() == 0;
   }
 
-  GFX2D_API void NudgeToIntegers();
+  GFX2D_API Matrix &NudgeToIntegers();
 
   bool IsTranslation() const
   {
     return FuzzyEqual(_11, 1.0f) && FuzzyEqual(_12, 0.0f) &&
            FuzzyEqual(_21, 0.0f) && FuzzyEqual(_22, 1.0f);
   }
 
   bool IsIntegerTranslation() const
@@ -733,17 +733,17 @@ public:
     // Inverse()._33 < 0;
     Float det = Determinant();
     Float __33 = _12*_24*_41 - _14*_22*_41 +
                 _14*_21*_42 - _11*_24*_42 -
                 _12*_21*_44 + _11*_22*_44;
     return (__33 * det) < 0;
   }
 
-  void NudgeToIntegersFixedEpsilon()
+  Matrix4x4 &NudgeToIntegersFixedEpsilon()
   {
     static const float error = 1e-5f;
     NudgeToInteger(&_11, error);
     NudgeToInteger(&_12, error);
     NudgeToInteger(&_13, error);
     NudgeToInteger(&_14, error);
     NudgeToInteger(&_21, error);
     NudgeToInteger(&_22, error);
@@ -752,16 +752,17 @@ public:
     NudgeToInteger(&_31, error);
     NudgeToInteger(&_32, error);
     NudgeToInteger(&_33, error);
     NudgeToInteger(&_34, error);
     NudgeToInteger(&_41, error);
     NudgeToInteger(&_42, error);
     NudgeToInteger(&_43, error);
     NudgeToInteger(&_44, error);
+    return *this;
   }
 
   Point4D TransposedVector(int aIndex) const
   {
       MOZ_ASSERT(aIndex >= 0 && aIndex <= 3, "Invalid matrix array index");
       return Point4D(*((&_11)+aIndex), *((&_21)+aIndex), *((&_31)+aIndex), *((&_41)+aIndex));
   }