Remove implicit fuzzy operator== from BaseMatrix (bug 1435406, r=mattwoodrow)
authorRyan Hunt <rhunt@eqrion.net>
Fri, 02 Feb 2018 15:14:08 -0600
changeset 402501 f72d9fdf6e97fd7bde0098f9e4ca6c5ca952ef79
parent 402500 05b29220fc4de84e676cf4bfe7a673ae640dd929
child 402502 b11498239be623e9ccaa43d701dd2c7cd0e686fa
push id33390
push usernbeleuzu@mozilla.com
push dateTue, 06 Feb 2018 09:55:26 +0000
treeherdermozilla-central@f1a4b64f19b0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1435406
milestone60.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
Remove implicit fuzzy operator== from BaseMatrix (bug 1435406, r=mattwoodrow)
dom/svg/SVGTransformableElement.cpp
gfx/2d/DrawTargetCairo.cpp
gfx/2d/DrawTargetCapture.cpp
gfx/2d/Matrix.h
gfx/thebes/gfxPattern.cpp
--- a/dom/svg/SVGTransformableElement.cpp
+++ b/dom/svg/SVGTransformableElement.cpp
@@ -119,17 +119,17 @@ SVGTransformableElement::GetAnimateMotio
 {
   return mAnimateMotionTransform.get();
 }
 
 void
 SVGTransformableElement::SetAnimateMotionTransform(const gfx::Matrix* aMatrix)
 {
   if ((!aMatrix && !mAnimateMotionTransform) ||
-      (aMatrix && mAnimateMotionTransform && *aMatrix == *mAnimateMotionTransform)) {
+      (aMatrix && mAnimateMotionTransform && aMatrix->FuzzyEquals(*mAnimateMotionTransform))) {
     return;
   }
   bool transformSet = mTransforms && mTransforms->IsExplicitlySet();
   bool prevSet = mAnimateMotionTransform || transformSet;
   mAnimateMotionTransform = aMatrix ? new gfx::Matrix(*aMatrix) : nullptr;
   bool nowSet = mAnimateMotionTransform || transformSet;
   int32_t modType;
   if (prevSet && !nowSet) {
--- a/gfx/2d/DrawTargetCairo.cpp
+++ b/gfx/2d/DrawTargetCairo.cpp
@@ -63,25 +63,25 @@ namespace {
 class AutoPrepareForDrawing
 {
 public:
   AutoPrepareForDrawing(DrawTargetCairo* dt, cairo_t* ctx)
     : mCtx(ctx)
   {
     dt->PrepareForDrawing(ctx);
     cairo_save(mCtx);
-    MOZ_ASSERT(cairo_status(mCtx) || dt->GetTransform() == GetTransform());
+    MOZ_ASSERT(cairo_status(mCtx) || dt->GetTransform().FuzzyEquals(GetTransform()));
   }
 
   AutoPrepareForDrawing(DrawTargetCairo* dt, cairo_t* ctx, const Path* path)
     : mCtx(ctx)
   {
     dt->PrepareForDrawing(ctx, path);
     cairo_save(mCtx);
-    MOZ_ASSERT(cairo_status(mCtx) || dt->GetTransform() == GetTransform());
+    MOZ_ASSERT(cairo_status(mCtx) || dt->GetTransform().FuzzyEquals(GetTransform()));
   }
 
   ~AutoPrepareForDrawing()
   {
     cairo_restore(mCtx);
     cairo_status_t status = cairo_status(mCtx);
     if (status) {
       gfxWarning() << "DrawTargetCairo context in error state: " << cairo_status_to_string(status) << "(" << status << ")";
--- a/gfx/2d/DrawTargetCapture.cpp
+++ b/gfx/2d/DrawTargetCapture.cpp
@@ -360,17 +360,17 @@ DrawTargetCaptureImpl::ContainsOnlyColor
 
     if (command->GetType() != CommandType::FILLGLYPHS &&
         command->GetType() != CommandType::SETTRANSFORM) {
       return false;
     }
 
     if (command->GetType() == CommandType::SETTRANSFORM) {
       SetTransformCommand* transform = static_cast<SetTransformCommand*>(command);
-      if (transform->mTransform != Matrix()) {
+      if (!transform->mTransform.IsIdentity()) {
         return false;
       }
       continue;
     }
 
     FillGlyphsCommand* fillGlyphs = static_cast<FillGlyphsCommand*>(command);
     if (aScaledFont && fillGlyphs->mFont != aScaledFont) {
       return false;
--- a/gfx/2d/Matrix.h
+++ b/gfx/2d/Matrix.h
@@ -312,29 +312,30 @@ public:
    * Multiplies in the opposite order to operator=*.
    */
   BaseMatrix<T> &PreMultiply(const BaseMatrix<T> &aMatrix)
   {
     *this = aMatrix * *this;
     return *this;
   }
 
+  /**
+   * Please explicitly use either FuzzyEquals or ExactlyEquals.
+   */
+  bool operator==(const BaseMatrix<T>& other) const = delete;
+  bool operator!=(const BaseMatrix<T>& other) const = delete;
+
   /* Returns true if the other matrix is fuzzy-equal to this matrix.
    * Note that this isn't a cheap comparison!
    */
-  bool operator==(const BaseMatrix<T>& other) const
+  bool FuzzyEquals(const BaseMatrix<T>& o) const
   {
-    return FuzzyEqual(_11, other._11) && FuzzyEqual(_12, other._12) &&
-           FuzzyEqual(_21, other._21) && FuzzyEqual(_22, other._22) &&
-           FuzzyEqual(_31, other._31) && FuzzyEqual(_32, other._32);
-  }
-
-  bool operator!=(const BaseMatrix<T>& other) const
-  {
-    return !(*this == other);
+    return FuzzyEqual(_11, o._11) && FuzzyEqual(_12, o._12) &&
+           FuzzyEqual(_21, o._21) && FuzzyEqual(_22, o._22) &&
+           FuzzyEqual(_31, o._31) && FuzzyEqual(_32, o._32);
   }
 
   bool ExactlyEquals(const BaseMatrix<T>& o) const
   {
     return _11 == o._11 && _12 == o._12 &&
            _21 == o._21 && _22 == o._22 &&
            _31 == o._31 && _32 == o._32;
   }
--- a/gfx/thebes/gfxPattern.cpp
+++ b/gfx/thebes/gfxPattern.cpp
@@ -106,17 +106,17 @@ gfxPattern::GetInverseMatrix() const
 
 Pattern*
 gfxPattern::GetPattern(const DrawTarget *aTarget,
                        const Matrix *aOriginalUserToDevice)
 {
   Matrix patternToUser = mPatternToUserSpace;
 
   if (aOriginalUserToDevice &&
-      *aOriginalUserToDevice != aTarget->GetTransform()) {
+      !aOriginalUserToDevice->FuzzyEquals(aTarget->GetTransform())) {
     // mPatternToUserSpace maps from pattern space to the original user space,
     // but aTarget now has a transform to a different user space.  In order for
     // the Pattern* that we return to be usable in aTarget's new user space we
     // need the Pattern's mMatrix to be the transform from pattern space to
     // aTarget's -new- user space.  That transform is equivalent to the
     // transform from pattern space to original user space (patternToUser),
     // multiplied by the transform from original user space to device space,
     // multiplied by the transform from device space to current user space.