Bug 952011 - Don't restrict Untransform points/rects to the child bounds if we're not a projective matrix. r=bjacob

This commit is contained in:
Matt Woodrow 2014-01-31 16:58:26 +13:00
parent 1339dec76d
commit 075dc50551
2 changed files with 17 additions and 0 deletions

View File

@ -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)) {

View File

@ -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