diff --git a/gfx/2d/Matrix.h b/gfx/2d/Matrix.h index 8e2055c9f4a0..fc1060ac31ac 100644 --- a/gfx/2d/Matrix.h +++ b/gfx/2d/Matrix.h @@ -11,6 +11,7 @@ #include "Point.h" #include #include "mozilla/Attributes.h" +#include "mozilla/DebugOnly.h" namespace mozilla { namespace gfx { @@ -186,6 +187,14 @@ public: return true; } + Matrix Inverse() const + { + Matrix clone = *this; + DebugOnly inverted = clone.Invert(); + MOZ_ASSERT(inverted, "Attempted to get the inverse of a non-invertible matrix"); + return clone; + } + Float Determinant() const { return _11 * _22 - _12 * _21; @@ -671,6 +680,14 @@ public: bool Invert(); + Matrix4x4 Inverse() const + { + Matrix4x4 clone = *this; + DebugOnly inverted = clone.Invert(); + MOZ_ASSERT(inverted, "Attempted to get the inverse of a non-invertible matrix"); + return clone; + } + void Normalize() { for (int i = 0; i < 4; i++) {