From 0815265fb2a3001d78adb2a1dbcc3d198a9a2093 Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Fri, 31 Jan 2014 16:58:26 +1300 Subject: [PATCH] Bug 952011 - Don't restrict Untransform points/rects to the child bounds if we're not a projective matrix. r=bjacob --- gfx/thebes/gfx3DMatrix.cpp | 15 +++++++++++++++ gfx/thebes/gfx3DMatrix.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/gfx/thebes/gfx3DMatrix.cpp b/gfx/thebes/gfx3DMatrix.cpp index e8e62f96c228..11bc0cd80052 100644 --- a/gfx/thebes/gfx3DMatrix.cpp +++ b/gfx/thebes/gfx3DMatrix.cpp @@ -721,6 +721,14 @@ gfx3DMatrix::Is2D(gfxMatrix* aMatrix) const return true; } +bool +gfx3DMatrix::IsProjective() const +{ + return _14 != 0.0f || _24 != 0.0f || + _34 != 0.0f || _44 != 1.0f; +} + + bool gfx3DMatrix::CanDraw2D(gfxMatrix* aMatrix) const { @@ -810,6 +818,9 @@ gfxRect gfx3DMatrix::ProjectRectBounds(const gfxRect& aRect) const gfxRect gfx3DMatrix::UntransformBounds(const gfxRect& aRect, const gfxRect& aChildBounds) const { + if (!IsProjective()) { + return Inverse().TransformBounds(aRect); + } gfxRect bounds = TransformBounds(aChildBounds); gfxRect rect = aRect.Intersect(bounds); @@ -819,6 +830,10 @@ gfxRect gfx3DMatrix::UntransformBounds(const gfxRect& aRect, const gfxRect& aChi bool gfx3DMatrix::UntransformPoint(const gfxPoint& aPoint, const gfxRect& aChildBounds, gfxPoint* aOut) const { + if (!IsProjective()) { + *aOut = Inverse().Transform(aPoint); + return true; + } gfxRect bounds = TransformBounds(aChildBounds); if (!bounds.Contains(aPoint)) { diff --git a/gfx/thebes/gfx3DMatrix.h b/gfx/thebes/gfx3DMatrix.h index 38a3ef96202c..d9d7b959464b 100644 --- a/gfx/thebes/gfx3DMatrix.h +++ b/gfx/thebes/gfx3DMatrix.h @@ -81,6 +81,8 @@ public: bool Is2D(gfxMatrix* aMatrix) const; bool Is2D() const; + bool IsProjective() const; + /** * Returns true if the matrix can be reduced to a 2D affine transformation * (i.e. as obtained by From2D). If it is, optionally returns the 2D