From 971ac55d18ea84a39109ac73057c59e5906d4b89 Mon Sep 17 00:00:00 2001 From: Jeff Muizelaar Date: Fri, 21 Jun 2013 14:55:24 -0400 Subject: [PATCH] Bug 885621. Fix gfxPattern::GetMatrix() with azure and add GetInverseMatrix(). r=bas Currently SetMatrix will take the Inverse of the passed in matrix but GetMatrix doesn't not invert it on the way out. This fixes that and adds a GetInverseMatrix() so that we don't double invert it when we need the inverse. --HG-- extra : rebase_source : 6bb2049ccee22c62b1825687ecd09ddd1aad8b2e --- gfx/thebes/gfxContext.cpp | 3 +-- gfx/thebes/gfxPattern.cpp | 17 +++++++++++++++++ gfx/thebes/gfxPattern.h | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/gfx/thebes/gfxContext.cpp b/gfx/thebes/gfxContext.cpp index 3913637dd93..600cd2982fe 100644 --- a/gfx/thebes/gfxContext.cpp +++ b/gfx/thebes/gfxContext.cpp @@ -1431,8 +1431,7 @@ gfxContext::Mask(gfxPattern *pattern) } if (needsClip) { - Matrix mat = ToMatrix(pattern->GetMatrix()); - mat.Invert(); + Matrix mat = ToMatrix(pattern->GetInverseMatrix()); mat = mat * GetDTTransform(); mDT->SetTransform(mat); diff --git a/gfx/thebes/gfxPattern.cpp b/gfx/thebes/gfxPattern.cpp index dbf52310a74..3362c1dd30e 100644 --- a/gfx/thebes/gfxPattern.cpp +++ b/gfx/thebes/gfxPattern.cpp @@ -122,6 +122,23 @@ gfxPattern::GetMatrix() const cairo_matrix_t mat; cairo_pattern_get_matrix(mPattern, &mat); return gfxMatrix(*reinterpret_cast(&mat)); + } else { + // invert at the higher precision of gfxMatrix + // cause we need to convert at some point anyways + gfxMatrix mat = ThebesMatrix(mTransform); + mat.Invert(); + return mat; + } +} + +gfxMatrix +gfxPattern::GetInverseMatrix() const +{ + if (mPattern) { + cairo_matrix_t mat; + cairo_pattern_get_matrix(mPattern, &mat); + cairo_matrix_invert(&mat); + return gfxMatrix(*reinterpret_cast(&mat)); } else { return ThebesMatrix(mTransform); } diff --git a/gfx/thebes/gfxPattern.h b/gfx/thebes/gfxPattern.h index f0648a170cf..37e62a43d7a 100644 --- a/gfx/thebes/gfxPattern.h +++ b/gfx/thebes/gfxPattern.h @@ -41,6 +41,7 @@ public: void SetMatrix(const gfxMatrix& matrix); gfxMatrix GetMatrix() const; + gfxMatrix GetInverseMatrix() const; /* Get an Azure Pattern for the current Cairo pattern. aPattern transform * specifies the transform that was set on the DrawTarget when the pattern