Bug 952977: More gfx::Matrix cleanup in nsDisplayTransform r=nical

This commit is contained in:
David Zbarsky 2014-08-01 08:31:48 -04:00
Родитель 604ca01f70
Коммит 1c4b5d248a
5 изменённых файлов: 26 добавлений и 23 удалений

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

@ -63,6 +63,8 @@ using namespace mozilla;
using namespace mozilla::layers;
using namespace mozilla::dom;
using namespace mozilla::layout;
using namespace mozilla::gfx;
typedef FrameMetrics::ViewID ViewID;
#ifdef DEBUG
@ -4596,7 +4598,7 @@ nsDisplayTransform::GetResultingTransformMatrixInternal(const FrameTransformProp
gfx3DMatrix result;
// Call IsSVGTransformed() regardless of the value of
// disp->mSpecifiedTransform, since we still need any transformFromSVGParent.
mozilla::gfx::Matrix svgTransform, transformFromSVGParent;
Matrix svgTransform, transformFromSVGParent;
bool hasSVGTransforms =
frame && frame->IsSVGTransformed(&svgTransform, &transformFromSVGParent);
/* Transformed frames always have a transform, or are preserving 3d (and might still have perspective!) */
@ -4771,7 +4773,7 @@ static bool IsFrameVisible(nsIFrame* aFrame, const gfx3DMatrix& aMatrix)
return true;
}
const gfx3DMatrix&
const Matrix4x4&
nsDisplayTransform::GetTransform()
{
if (mTransform.IsIdentity()) {
@ -4782,7 +4784,7 @@ nsDisplayTransform::GetTransform()
0.0f);
if (mTransformGetter) {
mTransform = mTransformGetter(mFrame, scale);
mTransform.ChangeBasis(newOrigin);
mTransform.ChangeBasis(newOrigin.x, newOrigin.y, newOrigin.z);
} else {
/**
* Passing true as the final argument means that we want to shift the
@ -4792,9 +4794,9 @@ nsDisplayTransform::GetTransform()
* to be an ancestor of the preserve-3d chain, so we only need to do
* this once.
*/
mTransform =
mTransform = ToMatrix4x4(
GetResultingTransformMatrix(mFrame, ToReferenceFrame(), scale,
nullptr, nullptr, true);
nullptr, nullptr, true));
}
}
return mTransform;
@ -4810,7 +4812,7 @@ already_AddRefed<Layer> nsDisplayTransform::BuildLayer(nsDisplayListBuilder *aBu
LayerManager *aManager,
const ContainerLayerParameters& aContainerParameters)
{
const gfx3DMatrix& newTransformMatrix = GetTransform();
const gfx3DMatrix& newTransformMatrix = To3DMatrix(GetTransform());
if (mFrame->StyleDisplay()->mBackfaceVisibility == NS_STYLE_BACKFACE_VISIBILITY_HIDDEN &&
newTransformMatrix.IsBackfaceVisible()) {
@ -4923,7 +4925,7 @@ void nsDisplayTransform::HitTest(nsDisplayListBuilder *aBuilder,
*/
// GetTransform always operates in dev pixels.
float factor = mFrame->PresContext()->AppUnitsPerDevPixel();
gfx3DMatrix matrix = GetTransform();
gfx3DMatrix matrix = To3DMatrix(GetTransform());
if (!IsFrameVisible(mFrame, matrix)) {
return;
@ -4999,7 +5001,7 @@ nsDisplayTransform::GetHitDepthAtPoint(nsDisplayListBuilder* aBuilder, const nsP
{
// GetTransform always operates in dev pixels.
float factor = mFrame->PresContext()->AppUnitsPerDevPixel();
gfx3DMatrix matrix = GetTransform();
gfx3DMatrix matrix = To3DMatrix(GetTransform());
NS_ASSERTION(IsFrameVisible(mFrame, matrix), "We can't have hit a frame that isn't visible!");
@ -5025,7 +5027,7 @@ nsRect nsDisplayTransform::GetBounds(nsDisplayListBuilder *aBuilder, bool* aSnap
// GetTransform always operates in dev pixels.
float factor = mFrame->PresContext()->AppUnitsPerDevPixel();
return nsLayoutUtils::MatrixTransformRect(untransformedBounds,
GetTransform(),
To3DMatrix(GetTransform()),
factor);
}
@ -5061,10 +5063,10 @@ nsRegion nsDisplayTransform::GetOpaqueRegion(nsDisplayListBuilder *aBuilder,
return nsRegion();
}
const gfx3DMatrix& matrix = GetTransform();
const Matrix4x4& matrix = GetTransform();
nsRegion result;
gfxMatrix matrix2d;
Matrix matrix2d;
bool tmpSnap;
if (matrix.Is2D(&matrix2d) &&
matrix2d.PreservesAxisAlignedRectangles() &&
@ -5084,9 +5086,9 @@ bool nsDisplayTransform::IsUniform(nsDisplayListBuilder *aBuilder, nscolor* aCol
if (!UntransformVisibleRect(aBuilder, &untransformedVisible)) {
return false;
}
const gfx3DMatrix& matrix = GetTransform();
const Matrix4x4& matrix = GetTransform();
gfxMatrix matrix2d;
Matrix matrix2d;
return matrix.Is2D(&matrix2d) &&
matrix2d.PreservesAxisAlignedRectangles() &&
mStoredList.GetVisibleRect().Contains(untransformedVisible) &&
@ -5211,7 +5213,7 @@ bool nsDisplayTransform::UntransformRect(const nsRect &aTransformedBounds,
bool nsDisplayTransform::UntransformVisibleRect(nsDisplayListBuilder* aBuilder,
nsRect *aOutRect)
{
const gfx3DMatrix& matrix = GetTransform();
const gfx3DMatrix& matrix = To3DMatrix(GetTransform());
if (matrix.IsSingular())
return false;
@ -5243,7 +5245,7 @@ void
nsDisplayTransform::WriteDebugInfo(nsACString& aTo)
{
std::stringstream ss;
AppendToString(ss, gfx::ToMatrix4x4(GetTransform()));
AppendToString(ss, GetTransform());
aTo += ss.str().c_str();
}
#endif

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

@ -3157,6 +3157,7 @@ private:
*/
class nsDisplayTransform: public nsDisplayItem
{
typedef mozilla::gfx::Matrix4x4 Matrix4x4;
public:
/**
* Returns a matrix (in pixels) for the current frame. The matrix should be relative to
@ -3165,7 +3166,7 @@ public:
* @param aFrame The frame to compute the transform for.
* @param aAppUnitsPerPixel The number of app units per graphics unit.
*/
typedef gfx3DMatrix (* ComputeTransformFunction)(nsIFrame* aFrame, float aAppUnitsPerPixel);
typedef Matrix4x4 (* ComputeTransformFunction)(nsIFrame* aFrame, float aAppUnitsPerPixel);
/* Constructor accepts a display list, empties it, and wraps it up. It also
* ferries the underlying frame to the nsDisplayItem constructor.
@ -3244,7 +3245,7 @@ public:
INDEX_MAX = UINT32_MAX >> nsDisplayItem::TYPE_BITS
};
const gfx3DMatrix& GetTransform();
const Matrix4x4& GetTransform();
float GetHitDepthAtPoint(nsDisplayListBuilder* aBuilder, const nsPoint& aPoint);
@ -3387,7 +3388,7 @@ private:
bool aOffsetByOrigin);
nsDisplayWrapList mStoredList;
gfx3DMatrix mTransform;
Matrix4x4 mTransform;
ComputeTransformFunction mTransformGetter;
nsRect mChildrenVisibleRect;
uint32_t mIndex;

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

@ -2416,7 +2416,7 @@ nsLayoutUtils::GetLayerTransformForFrame(nsIFrame* aFrame,
new (&builder) nsDisplayTransform(&builder, aFrame, &list, nsRect());
*aTransform =
item->GetTransform();
To3DMatrix(item->GetTransform());
item->~nsDisplayTransform();
return true;

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

@ -462,10 +462,10 @@ static void PaintHeaderFooter(nsIFrame* aFrame, nsRenderingContext* aCtx,
static_cast<nsPageFrame*>(aFrame)->PaintHeaderFooter(*aCtx, aPt);
}
static gfx3DMatrix ComputePageTransform(nsIFrame* aFrame, float aAppUnitsPerPixel)
static gfx::Matrix4x4 ComputePageTransform(nsIFrame* aFrame, float aAppUnitsPerPixel)
{
float scale = aFrame->PresContext()->GetPageScale();
return gfx3DMatrix::ScalingMatrix(scale, scale, 1);
return gfx::Matrix4x4().Scale(scale, scale, 1);
}
//------------------------------------------------------------------------------

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

@ -766,11 +766,11 @@ nsSimplePageSequenceFrame::DoPageEnd()
return rv;
}
static gfx3DMatrix
static gfx::Matrix4x4
ComputePageSequenceTransform(nsIFrame* aFrame, float aAppUnitsPerPixel)
{
float scale = aFrame->PresContext()->GetPrintPreviewScale();
return gfx3DMatrix::ScalingMatrix(scale, scale, 1);
return gfx::Matrix4x4().Scale(scale, scale, 1);
}
void