Bug 777194. Part 7: Add gfx3DMatrix::NudgeToIntegers. r=bas
 author Robert O'Callahan Sat, 25 Aug 2012 16:41:46 +1200 changeset 107468 d756d091d9c800e1e0f07256dad9e216b634a1fd parent 107467 2365bb8a416a62ec1a362fe6b6cf16b595723907 child 107469 22a46f5dca2be1fb16eca99bc251740c86ff781b push id 82 push user shu@rfrn.org push date Fri, 05 Oct 2012 13:20:22 +0000 reviewers bas bugs 777194 milestone 18.0a1
Bug 777194. Part 7: Add gfx3DMatrix::NudgeToIntegers. r=bas
 gfx/thebes/gfx3DMatrix.cpp file | annotate | diff | comparison | revisions gfx/thebes/gfx3DMatrix.h file | annotate | diff | comparison | revisions
```--- a/gfx/thebes/gfx3DMatrix.cpp
+++ b/gfx/thebes/gfx3DMatrix.cpp
@@ -805,8 +805,35 @@ bool gfx3DMatrix::IsBackfaceVisible() co
// Inverse()._33 < 0;
gfxFloat 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;
}

+static void NudgeToInteger(float *aVal)
+{
+  float r = NS_roundf(*aVal);
+  if (fabsf(*aVal - r) < 1e-4) {
+    *aVal = r;
+  }
+}
+
+void gfx3DMatrix::NudgeToIntegers(void)
+{
+  NudgeToInteger(&_11);
+  NudgeToInteger(&_12);
+  NudgeToInteger(&_13);
+  NudgeToInteger(&_14);
+  NudgeToInteger(&_21);
+  NudgeToInteger(&_22);
+  NudgeToInteger(&_23);
+  NudgeToInteger(&_24);
+  NudgeToInteger(&_31);
+  NudgeToInteger(&_32);
+  NudgeToInteger(&_33);
+  NudgeToInteger(&_34);
+  NudgeToInteger(&_41);
+  NudgeToInteger(&_42);
+  NudgeToInteger(&_43);
+  NudgeToInteger(&_44);
+}```
```--- a/gfx/thebes/gfx3DMatrix.h
+++ b/gfx/thebes/gfx3DMatrix.h
@@ -315,16 +315,18 @@ public:

/**
* Create a scale matrix.
*/
static gfx3DMatrix ScalingMatrix(float aX, float aY, float aZ);

gfxFloat Determinant() const;

+  void NudgeToIntegers(void);
+
private:

gfxFloat Determinant3x3() const;
gfx3DMatrix Inverse3x3() const;

gfx3DMatrix Multiply2D(const gfx3DMatrix &aMatrix) const;

public:```