Backed out 4 changesets (bug 952011)

CLOSED TREE

Backed out changeset da7b3853cbfd (bug 952011)
Backed out changeset 413375909458 (bug 952011)
Backed out changeset 577290ff145d (bug 952011)
Backed out changeset 89491b5d0af8 (bug 952011)
This commit is contained in:
Phil Ringnalda 2014-01-30 21:44:41 -08:00
Родитель f6f08af0a0
Коммит 03e1420fe8
7 изменённых файлов: 112 добавлений и 141 удалений

Просмотреть файл

@ -721,14 +721,6 @@ 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
{
@ -796,9 +788,10 @@ gfxRect gfx3DMatrix::ProjectRectBounds(const gfxRect& aRect) const
gfxPoint points[4];
points[0] = ProjectPoint(aRect.TopLeft());
points[1] = ProjectPoint(aRect.TopRight());
points[2] = ProjectPoint(aRect.BottomLeft());
points[3] = ProjectPoint(aRect.BottomRight());
points[1] = ProjectPoint(gfxPoint(aRect.X() + aRect.Width(), aRect.Y()));
points[2] = ProjectPoint(gfxPoint(aRect.X(), aRect.Y() + aRect.Height()));
points[3] = ProjectPoint(gfxPoint(aRect.X() + aRect.Width(),
aRect.Y() + aRect.Height()));
gfxFloat min_x, max_x;
gfxFloat min_y, max_y;
@ -816,34 +809,6 @@ gfxRect gfx3DMatrix::ProjectRectBounds(const gfxRect& aRect) const
return gfxRect(min_x, min_y, max_x - min_x, max_y - min_y);
}
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);
return Inverse().ProjectRectBounds(rect);
}
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)) {
return false;
}
*aOut = Inverse().ProjectPoint(aPoint);
return true;
}
gfxPoint3D gfx3DMatrix::GetNormalVector() const
{
// Define a plane in transformed space as the transformations

Просмотреть файл

@ -81,8 +81,6 @@ 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
@ -252,25 +250,6 @@ public:
gfxPoint ProjectPoint(const gfxPoint& aPoint) const;
gfxRect ProjectRectBounds(const gfxRect& aRect) const;
/**
* Transforms a point by the inverse of this matrix. In the case of projective transforms, some screen
* points have no equivalent in the untransformed plane (if they exist past the vanishing point). To
* avoid this, we need to specify the bounds of the untransformed plane to restrict the search area.
*
* @param aPoint Point to untransform.
* @param aChildBounds Bounds of the untransformed plane.
* @param aOut Untransformed point.
* @return Returns true if a point was found within a ChildBounds, false otherwise.
*/
bool UntransformPoint(const gfxPoint& aPoint, const gfxRect& aChildBounds, gfxPoint* aOut) const;
/**
* Same as UntransformPoint, but untransforms a rect and returns the bounding rect of the result.
* Returns an empty rect if the result doesn't intersect aChildBounds.
*/
gfxRect UntransformBounds(const gfxRect& aRect, const gfxRect& aChildBounds) const;
/**
* Inverts this matrix, if possible. Otherwise, the matrix is left

Просмотреть файл

@ -1561,10 +1561,7 @@ SetVisibleRegionForLayer(Layer* aLayer, const nsIntRegion& aLayerVisibleRegion,
// for the layer, so it doesn't really matter what we do here
gfxRect itemVisible(aRestrictToRect.x, aRestrictToRect.y,
aRestrictToRect.width, aRestrictToRect.height);
nsIntRect childBounds = aLayerVisibleRegion.GetBounds();
gfxRect childGfxBounds(childBounds.x, childBounds.y,
childBounds.width, childBounds.height);
gfxRect layerVisible = transform.UntransformBounds(itemVisible, childGfxBounds);
gfxRect layerVisible = transform.Inverse().ProjectRectBounds(itemVisible);
layerVisible.RoundOut();
nsIntRect visibleRect;

Просмотреть файл

@ -1400,7 +1400,7 @@ void nsDisplayList::HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
if (aRect.width != 1 || aRect.height != 1) {
point = aRect.Center();
}
temp.AppendElement(FramesWithDepth(transform->GetHitDepthAtPoint(aBuilder, point)));
temp.AppendElement(FramesWithDepth(transform->GetHitDepthAtPoint(point)));
writeFrames = &temp[temp.Length() - 1].mFrames;
}
} else {
@ -4459,8 +4459,13 @@ 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) ||
!UntransformVisibleRect(aBuilder, &untransformedVisibleRect))
!UntransformRectMatrix(mVisibleRect,
GetTransform(),
factor,
&untransformedVisibleRect))
{
untransformedVisibleRect = mFrame->GetVisualOverflowRectRelativeToSelf();
}
@ -4501,24 +4506,14 @@ void nsDisplayTransform::HitTest(nsDisplayListBuilder *aBuilder,
* Thus we have to invert the matrix, which normally does
* the reverse operation (e.g. regular->transformed)
*/
bool snap;
nsRect childBounds = mStoredList.GetBounds(aBuilder, &snap);
gfxRect childGfxBounds(NSAppUnitsToFloatPixels(childBounds.x, factor),
NSAppUnitsToFloatPixels(childBounds.y, factor),
NSAppUnitsToFloatPixels(childBounds.width, factor),
NSAppUnitsToFloatPixels(childBounds.height, factor));
/* Now, apply the transform and pass it down the channel. */
nsRect resultingRect;
if (aRect.width == 1 && aRect.height == 1) {
// Magic width/height indicating we're hit testing a point, not a rect
gfxPoint point;
if (!matrix.UntransformPoint(gfxPoint(NSAppUnitsToFloatPixels(aRect.x, factor),
NSAppUnitsToFloatPixels(aRect.y, factor)),
childGfxBounds,
&point)) {
return;
}
gfxPoint point = matrix.Inverse().ProjectPoint(
gfxPoint(NSAppUnitsToFloatPixels(aRect.x, factor),
NSAppUnitsToFloatPixels(aRect.y, factor)));
resultingRect = nsRect(NSFloatPixelsToAppUnits(float(point.x), factor),
NSFloatPixelsToAppUnits(float(point.y), factor),
@ -4530,7 +4525,7 @@ void nsDisplayTransform::HitTest(nsDisplayListBuilder *aBuilder,
NSAppUnitsToFloatPixels(aRect.width, factor),
NSAppUnitsToFloatPixels(aRect.height, factor));
gfxRect rect = matrix.UntransformBounds(originalRect, childGfxBounds);
gfxRect rect = matrix.Inverse().ProjectRectBounds(originalRect);;
resultingRect = nsRect(NSFloatPixelsToAppUnits(float(rect.X()), factor),
NSFloatPixelsToAppUnits(float(rect.Y()), factor),
@ -4538,10 +4533,6 @@ void nsDisplayTransform::HitTest(nsDisplayListBuilder *aBuilder,
NSFloatPixelsToAppUnits(float(rect.Height()), factor));
}
if (resultingRect.IsEmpty()) {
return;
}
#ifdef DEBUG_HIT
printf("Frame: %p\n", dynamic_cast<void *>(mFrame));
@ -4561,7 +4552,7 @@ void nsDisplayTransform::HitTest(nsDisplayListBuilder *aBuilder,
}
float
nsDisplayTransform::GetHitDepthAtPoint(nsDisplayListBuilder* aBuilder, const nsPoint& aPoint)
nsDisplayTransform::GetHitDepthAtPoint(const nsPoint& aPoint)
{
// GetTransform always operates in dev pixels.
float factor = mFrame->PresContext()->AppUnitsPerDevPixel();
@ -4569,19 +4560,9 @@ nsDisplayTransform::GetHitDepthAtPoint(nsDisplayListBuilder* aBuilder, const nsP
NS_ASSERTION(IsFrameVisible(mFrame, matrix), "We can't have hit a frame that isn't visible!");
bool snap;
nsRect childBounds = mStoredList.GetBounds(aBuilder, &snap);
gfxRect childGfxBounds(NSAppUnitsToFloatPixels(childBounds.x, factor),
NSAppUnitsToFloatPixels(childBounds.y, factor),
NSAppUnitsToFloatPixels(childBounds.width, factor),
NSAppUnitsToFloatPixels(childBounds.height, factor));
gfxPoint point;
DebugOnly<bool> result = matrix.UntransformPoint(gfxPoint(NSAppUnitsToFloatPixels(aPoint.x, factor),
NSAppUnitsToFloatPixels(aPoint.y, factor)),
childGfxBounds,
&point);
NS_ASSERTION(result, "Why are we trying to get the depth for a point we didn't hit?");
gfxPoint point =
matrix.Inverse().ProjectPoint(gfxPoint(NSAppUnitsToFloatPixels(aPoint.x, factor),
NSAppUnitsToFloatPixels(aPoint.y, factor)));
gfxPoint3D transformed = matrix.Transform3D(gfxPoint3D(point.x, point.y, 0));
return transformed.z;
@ -4625,6 +4606,8 @@ 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
@ -4632,7 +4615,7 @@ nsRegion nsDisplayTransform::GetOpaqueRegion(nsDisplayListBuilder *aBuilder,
// updated extremely cheaply, without invalidating any other
// content.
if (ShouldPrerenderTransformedContent(aBuilder, mFrame) ||
!UntransformVisibleRect(aBuilder, &untransformedVisible)) {
!UntransformRectMatrix(mVisibleRect, GetTransform(), factor, &untransformedVisible)) {
return nsRegion();
}
@ -4656,7 +4639,9 @@ nsRegion nsDisplayTransform::GetOpaqueRegion(nsDisplayListBuilder *aBuilder,
bool nsDisplayTransform::IsUniform(nsDisplayListBuilder *aBuilder, nscolor* aColor)
{
nsRect untransformedVisible;
if (!UntransformVisibleRect(aBuilder, &untransformedVisible)) {
// GetTransform always operates in dev pixels.
float factor = mFrame->PresContext()->AppUnitsPerDevPixel();
if (!UntransformRectMatrix(mVisibleRect, GetTransform(), factor, &untransformedVisible)) {
return false;
}
const gfx3DMatrix& matrix = GetTransform();
@ -4752,34 +4737,43 @@ nsRect nsDisplayTransform::TransformRectOut(const nsRect &aUntransformedBounds,
factor);
}
bool nsDisplayTransform::UntransformVisibleRect(nsDisplayListBuilder* aBuilder,
nsRect *aOutRect)
bool nsDisplayTransform::UntransformRectMatrix(const nsRect &aUntransformedBounds,
const gfx3DMatrix& aMatrix,
float aAppUnitsPerPixel,
nsRect *aOutRect)
{
const gfx3DMatrix& matrix = GetTransform();
if (matrix.IsSingular())
if (aMatrix.IsSingular())
return false;
// 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));
gfxRect result(NSAppUnitsToFloatPixels(aUntransformedBounds.x, aAppUnitsPerPixel),
NSAppUnitsToFloatPixels(aUntransformedBounds.y, aAppUnitsPerPixel),
NSAppUnitsToFloatPixels(aUntransformedBounds.width, aAppUnitsPerPixel),
NSAppUnitsToFloatPixels(aUntransformedBounds.height, aAppUnitsPerPixel));
bool snap;
nsRect childBounds = mStoredList.GetBounds(aBuilder, &snap);
gfxRect childGfxBounds(NSAppUnitsToFloatPixels(childBounds.x, factor),
NSAppUnitsToFloatPixels(childBounds.y, factor),
NSAppUnitsToFloatPixels(childBounds.width, factor),
NSAppUnitsToFloatPixels(childBounds.height, factor));
/* We want to untransform the matrix, so invert the transformation first! */
result = aMatrix.Inverse().ProjectRectBounds(result);
result = matrix.UntransformBounds(result, childGfxBounds);
*aOutRect = nsLayoutUtils::RoundGfxRectToAppRect(result, factor);
*aOutRect = nsLayoutUtils::RoundGfxRectToAppRect(result, aAppUnitsPerPixel);
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),

Просмотреть файл

@ -3051,7 +3051,7 @@ public:
const gfx3DMatrix& GetTransform();
float GetHitDepthAtPoint(nsDisplayListBuilder* aBuilder, const nsPoint& aPoint);
float GetHitDepthAtPoint(const nsPoint& aPoint);
/**
* TransformRect takes in as parameters a rectangle (in aFrame's coordinate
@ -3084,8 +3084,15 @@ public:
/* UntransformRect is like TransformRect, except that it inverts the
* transform.
*/
bool UntransformVisibleRect(nsDisplayListBuilder* aBuilder,
nsRect* aOutRect);
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);
static gfxPoint3D GetDeltaToTransformOrigin(const nsIFrame* aFrame,
float aAppUnitsPerPixel,

Просмотреть файл

@ -1833,21 +1833,22 @@ nsLayoutUtils::GetLayerTransformForFrame(nsIFrame* aFrame,
return true;
}
static bool
static gfxPoint
TransformGfxPointFromAncestor(nsIFrame *aFrame,
const gfxPoint &aPoint,
nsIFrame *aAncestor,
gfxPoint* aOut)
nsIFrame *aAncestor)
{
gfx3DMatrix ctm = nsLayoutUtils::GetTransformToAncestor(aFrame, aAncestor);
return ctm.Inverse().ProjectPoint(aPoint);
}
float factor = aFrame->PresContext()->AppUnitsPerDevPixel();
nsRect childBounds = aFrame->GetVisualOverflowRectRelativeToSelf();
gfxRect childGfxBounds(NSAppUnitsToFloatPixels(childBounds.x, factor),
NSAppUnitsToFloatPixels(childBounds.y, factor),
NSAppUnitsToFloatPixels(childBounds.width, factor),
NSAppUnitsToFloatPixels(childBounds.height, factor));
return ctm.UntransformPoint(aPoint, childGfxBounds, aOut);
static gfxRect
TransformGfxRectFromAncestor(nsIFrame *aFrame,
const gfxRect &aRect,
const nsIFrame *aAncestor)
{
gfx3DMatrix ctm = nsLayoutUtils::GetTransformToAncestor(aFrame, aAncestor);
return ctm.Inverse().ProjectRectBounds(aRect);
}
static gfxRect
@ -1889,20 +1890,43 @@ nsLayoutUtils::TransformAncestorPointToFrame(nsIFrame* aFrame,
NSAppUnitsToFloatPixels(aPoint.y, factor));
if (text) {
if (!TransformGfxPointFromAncestor(text, result, aAncestor, &result)) {
return nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
}
result = TransformGfxPointFromAncestor(text, result, aAncestor);
result = text->TransformFramePointToTextChild(result, aFrame);
} else {
if (!TransformGfxPointFromAncestor(aFrame, result, nullptr, &result)) {
return nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
}
result = TransformGfxPointFromAncestor(aFrame, result, nullptr);
}
return nsPoint(NSFloatPixelsToAppUnits(float(result.x), factor),
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,

Просмотреть файл

@ -653,6 +653,14 @@ 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.
@ -698,9 +706,6 @@ public:
/**
* Transform aPoint relative to aAncestor down to the coordinate system of
* aFrame.
*
* Returns nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE) if no equivalent
* point exists in the child frame (can happen with projective transforms).
*/
static nsPoint TransformAncestorPointToFrame(nsIFrame* aFrame,
const nsPoint& aPoint,