Bug 952011 - Remove some nsLayoutUtils transform functions that are no longer needed. r=roc

This commit is contained in:
Matt Woodrow 2014-02-04 12:25:22 +13:00
parent 2258859236
commit d9d558f8f0
4 changed files with 15 additions and 92 deletions

View File

@ -4459,13 +4459,8 @@ bool nsDisplayTransform::ComputeVisibility(nsDisplayListBuilder *aBuilder,
* think that it's painting in its original rectangular coordinate space.
* If we can't untransform, take the entire overflow rect */
nsRect untransformedVisibleRect;
// GetTransform always operates in dev pixels.
float factor = mFrame->PresContext()->AppUnitsPerDevPixel();
if (ShouldPrerenderTransformedContent(aBuilder, mFrame) ||
!UntransformRectMatrix(mVisibleRect,
GetTransform(),
factor,
&untransformedVisibleRect))
!UntransformVisibleRect(&untransformedVisibleRect))
{
untransformedVisibleRect = mFrame->GetVisualOverflowRectRelativeToSelf();
}
@ -4606,8 +4601,6 @@ nsRegion nsDisplayTransform::GetOpaqueRegion(nsDisplayListBuilder *aBuilder,
{
*aSnap = false;
nsRect untransformedVisible;
// GetTransform always operates in dev pixels.
float factor = mFrame->PresContext()->AppUnitsPerDevPixel();
// If we're going to prerender all our content, pretend like we
// don't have opqaue content so that everything under us is rendered
// as well. That will increase graphics memory usage if our frame
@ -4615,7 +4608,7 @@ nsRegion nsDisplayTransform::GetOpaqueRegion(nsDisplayListBuilder *aBuilder,
// updated extremely cheaply, without invalidating any other
// content.
if (ShouldPrerenderTransformedContent(aBuilder, mFrame) ||
!UntransformRectMatrix(mVisibleRect, GetTransform(), factor, &untransformedVisible)) {
!UntransformVisibleRect(&untransformedVisible)) {
return nsRegion();
}
@ -4639,9 +4632,7 @@ nsRegion nsDisplayTransform::GetOpaqueRegion(nsDisplayListBuilder *aBuilder,
bool nsDisplayTransform::IsUniform(nsDisplayListBuilder *aBuilder, nscolor* aColor)
{
nsRect untransformedVisible;
// GetTransform always operates in dev pixels.
float factor = mFrame->PresContext()->AppUnitsPerDevPixel();
if (!UntransformRectMatrix(mVisibleRect, GetTransform(), factor, &untransformedVisible)) {
if (!UntransformVisibleRect(&untransformedVisible)) {
return false;
}
const gfx3DMatrix& matrix = GetTransform();
@ -4737,43 +4728,27 @@ nsRect nsDisplayTransform::TransformRectOut(const nsRect &aUntransformedBounds,
factor);
}
bool nsDisplayTransform::UntransformRectMatrix(const nsRect &aUntransformedBounds,
const gfx3DMatrix& aMatrix,
float aAppUnitsPerPixel,
nsRect *aOutRect)
bool nsDisplayTransform::UntransformVisibleRect(nsRect *aOutRect)
{
if (aMatrix.IsSingular())
const gfx3DMatrix& matrix = GetTransform();
if (matrix.IsSingular())
return false;
gfxRect result(NSAppUnitsToFloatPixels(aUntransformedBounds.x, aAppUnitsPerPixel),
NSAppUnitsToFloatPixels(aUntransformedBounds.y, aAppUnitsPerPixel),
NSAppUnitsToFloatPixels(aUntransformedBounds.width, aAppUnitsPerPixel),
NSAppUnitsToFloatPixels(aUntransformedBounds.height, aAppUnitsPerPixel));
// GetTransform always operates in dev pixels.
float factor = mFrame->PresContext()->AppUnitsPerDevPixel();
gfxRect result(NSAppUnitsToFloatPixels(mVisibleRect.x, factor),
NSAppUnitsToFloatPixels(mVisibleRect.y, factor),
NSAppUnitsToFloatPixels(mVisibleRect.width, factor),
NSAppUnitsToFloatPixels(mVisibleRect.height, factor));
/* We want to untransform the matrix, so invert the transformation first! */
result = aMatrix.Inverse().ProjectRectBounds(result);
result = matrix.Inverse().ProjectRectBounds(result);
*aOutRect = nsLayoutUtils::RoundGfxRectToAppRect(result, aAppUnitsPerPixel);
*aOutRect = nsLayoutUtils::RoundGfxRectToAppRect(result, factor);
return true;
}
bool nsDisplayTransform::UntransformRect(const nsRect &aUntransformedBounds,
const nsIFrame* aFrame,
const nsPoint &aOrigin,
nsRect* aOutRect)
{
NS_PRECONDITION(aFrame, "Can't take the transform based on a null frame!");
/* Grab the matrix. If the transform is degenerate, just hand back the
* empty rect.
*/
float factor = aFrame->PresContext()->AppUnitsPerDevPixel();
gfx3DMatrix matrix = GetResultingTransformMatrix(aFrame, aOrigin, factor);
return UntransformRectMatrix(aUntransformedBounds, matrix, factor, aOutRect);
}
nsDisplaySVGEffects::nsDisplaySVGEffects(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame, nsDisplayList* aList)
: nsDisplayWrapList(aBuilder, aFrame, aList),

View File

@ -3084,15 +3084,7 @@ public:
/* UntransformRect is like TransformRect, except that it inverts the
* transform.
*/
static bool UntransformRect(const nsRect &aUntransformedBounds,
const nsIFrame* aFrame,
const nsPoint &aOrigin,
nsRect* aOutRect);
static bool UntransformRectMatrix(const nsRect &aUntransformedBounds,
const gfx3DMatrix& aMatrix,
float aAppUnitsPerPixel,
nsRect* aOutRect);
bool UntransformVisibleRect(nsRect* aOutRect);
static gfxPoint3D GetDeltaToTransformOrigin(const nsIFrame* aFrame,
float aAppUnitsPerPixel,

View File

@ -1847,15 +1847,6 @@ TransformGfxPointFromAncestor(nsIFrame *aFrame,
return ctm.Inverse().ProjectPoint(aPoint);
}
static gfxRect
TransformGfxRectFromAncestor(nsIFrame *aFrame,
const gfxRect &aRect,
const nsIFrame *aAncestor)
{
gfx3DMatrix ctm = nsLayoutUtils::GetTransformToAncestor(aFrame, aAncestor);
return ctm.Inverse().ProjectRectBounds(aRect);
}
static gfxRect
TransformGfxRectToAncestor(nsIFrame *aFrame,
const gfxRect &aRect,
@ -1905,33 +1896,6 @@ nsLayoutUtils::TransformAncestorPointToFrame(nsIFrame* aFrame,
NSFloatPixelsToAppUnits(float(result.y), factor));
}
nsRect
nsLayoutUtils::TransformAncestorRectToFrame(nsIFrame* aFrame,
const nsRect &aRect,
const nsIFrame* aAncestor)
{
SVGTextFrame* text = GetContainingSVGTextFrame(aFrame);
float srcAppUnitsPerDevPixel = aAncestor->PresContext()->AppUnitsPerDevPixel();
gfxRect result(NSAppUnitsToFloatPixels(aRect.x, srcAppUnitsPerDevPixel),
NSAppUnitsToFloatPixels(aRect.y, srcAppUnitsPerDevPixel),
NSAppUnitsToFloatPixels(aRect.width, srcAppUnitsPerDevPixel),
NSAppUnitsToFloatPixels(aRect.height, srcAppUnitsPerDevPixel));
if (text) {
result = TransformGfxRectFromAncestor(text, result, aAncestor);
result = text->TransformFrameRectToTextChild(result, aFrame);
} else {
result = TransformGfxRectFromAncestor(aFrame, result, aAncestor);
}
float destAppUnitsPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel();
return nsRect(NSFloatPixelsToAppUnits(float(result.x), destAppUnitsPerDevPixel),
NSFloatPixelsToAppUnits(float(result.y), destAppUnitsPerDevPixel),
NSFloatPixelsToAppUnits(float(result.width), destAppUnitsPerDevPixel),
NSFloatPixelsToAppUnits(float(result.height), destAppUnitsPerDevPixel));
}
nsRect
nsLayoutUtils::TransformFrameRectToAncestor(nsIFrame* aFrame,
const nsRect& aRect,

View File

@ -653,14 +653,6 @@ public:
nsTArray<nsIFrame*> &aOutFrames,
uint32_t aFlags = 0);
/**
* Transform aRect relative to aAncestor down to the coordinate system of
* aFrame. Computes the bounding-box of the true quadrilateral.
*/
static nsRect TransformAncestorRectToFrame(nsIFrame* aFrame,
const nsRect& aRect,
const nsIFrame* aAncestor);
/**
* Transform aRect relative to aFrame up to the coordinate system of
* aAncestor. Computes the bounding-box of the true quadrilateral.