Bug 1025553, part 6 - Remove gfxMatrix::Multiply(). r=Bas

This commit is contained in:
Jonathan Watt 2014-07-11 08:07:07 +01:00
parent 5d70a0f6cc
commit 19033b482e
11 changed files with 26 additions and 42 deletions

View File

@ -57,7 +57,7 @@ DeviceToImageTransform(gfxContext* aContext,
return gfxMatrix(0, 0, 0, 0, 0, 0); // singular
}
deviceToUser.Translate(-gfxPoint(-deviceX, -deviceY));
return gfxMatrix(deviceToUser).Multiply(aUserSpaceToImageSpace);
return deviceToUser * aUserSpaceToImageSpace;
}
static void
@ -159,7 +159,7 @@ gfxSurfaceDrawable::Draw(gfxContext* aContext,
PreparePatternForUntiledDrawing(pattern, deviceSpaceToImageSpace,
currentTarget, filter);
}
pattern->SetMatrix(gfxMatrix(aTransform).Multiply(mTransform));
pattern->SetMatrix(aTransform * mTransform);
aContext->NewPath();
aContext->SetPattern(pattern);
aContext->Rectangle(aFillRect);
@ -297,7 +297,7 @@ gfxPatternDrawable::Draw(gfxContext* aContext,
aContext->NewPath();
gfxMatrix oldMatrix = mPattern->GetMatrix();
mPattern->SetMatrix(gfxMatrix(aTransform).Multiply(oldMatrix));
mPattern->SetMatrix(aTransform * oldMatrix);
aContext->SetPattern(mPattern);
aContext->Rectangle(aFillRect);
aContext->Fill();

View File

@ -45,7 +45,7 @@ gfxMatrix::Rotate(gfxFloat radians)
}
const gfxMatrix&
gfxMatrix::Multiply(const gfxMatrix& m)
gfxMatrix::operator *= (const gfxMatrix& m)
{
cairo_matrix_multiply(CAIRO_MATRIX(this), CAIRO_MATRIX(this), CONST_CAIRO_MATRIX(&m));
return *this;

View File

@ -53,15 +53,13 @@ public:
/**
* Post-multiplies m onto the matrix.
*/
const gfxMatrix& operator *= (const gfxMatrix& m) {
return Multiply(m);
}
const gfxMatrix& operator *= (const gfxMatrix& m);
/**
* Multiplies *this with m and returns the result.
*/
gfxMatrix operator * (const gfxMatrix& m) const {
return gfxMatrix(*this).Multiply(m);
return gfxMatrix(*this) *= m;
}
/* Returns true if the other matrix is fuzzy-equal to this matrix.
@ -128,15 +126,6 @@ public:
*/
const gfxMatrix& Rotate(gfxFloat radians);
/**
* Multiplies the current matrix with m.
* This is a post-multiplication, i.e. the transformations of m are
* applied _after_ the existing transformations.
*
* XXX is that difference (compared to Rotate etc) a good thing?
*/
const gfxMatrix& Multiply(const gfxMatrix& m);
/**
* Multiplies the current matrix with m.
* This is a pre-multiplication, i.e. the transformations of m are

View File

@ -501,7 +501,7 @@ DeviceToImageTransform(gfxContext* aContext,
return gfxMatrix(0, 0, 0, 0, 0, 0); // singular
}
deviceToUser.Translate(-gfxPoint(-deviceX, -deviceY));
return gfxMatrix(deviceToUser).Multiply(aUserSpaceToImageSpace);
return deviceToUser * aUserSpaceToImageSpace;
}
/* These heuristics are based on Source/WebCore/platform/graphics/skia/ImageSkia.cpp:computeResamplingMode() */

View File

@ -388,19 +388,18 @@ ClippedImage::DrawSingleTile(gfxContext* aContext,
}
// Add a translation to the transform to reflect the clipping region.
gfxMatrix transform(aUserSpaceToImageSpace);
transform.Multiply(gfxMatrix().Translate(gfxPoint(mClip.x, mClip.y)));
gfxMatrix transform =
aUserSpaceToImageSpace * gfxMatrix::Translation(mClip.x, mClip.y);
// "Clamp the source rectangle" to the clipping region's width and height.
// Really, this means modifying the transform to get the results we want.
gfxRect sourceRect = transform.Transform(aFill);
if (sourceRect.width > mClip.width || sourceRect.height > mClip.height) {
gfxMatrix clampSource;
clampSource.Translate(gfxPoint(sourceRect.x, sourceRect.y));
gfxMatrix clampSource = gfxMatrix::Translation(sourceRect.TopLeft());
clampSource.Scale(ClampFactor(sourceRect.width, mClip.width),
ClampFactor(sourceRect.height, mClip.height));
clampSource.Translate(gfxPoint(-sourceRect.x, -sourceRect.y));
transform.Multiply(clampSource);
clampSource.Translate(-sourceRect.TopLeft());
transform *= clampSource;
}
return InnerImage()->Draw(aContext, aFilter, transform, aFill, aSubimage,

View File

@ -2623,8 +2623,7 @@ RasterImage::DrawWithPreDownscaleIfNeeded(imgFrame *aFrame,
needScaleReq = !surf;
if (surf) {
frame = mScaleResult.frame;
userSpaceToImageSpace.Multiply(gfxMatrix().Scale(scale.width,
scale.height));
userSpaceToImageSpace *= gfxMatrix::Scaling(scale.width, scale.height);
// Since we're switching to a scaled image, we need to transform the
// area of the subimage to draw accordingly, since imgFrame::Draw()

View File

@ -365,7 +365,7 @@ imgFrame::SurfaceForDrawing(bool aDoPadding,
aFill = imageSpaceToUserSpace.Transform(aSourceRect);
aSubimage = aSubimage.Intersect(available) - gfxPoint(aPadding.left, aPadding.top);
aUserSpaceToImageSpace.Multiply(gfxMatrix().Translate(-gfxPoint(aPadding.left, aPadding.top)));
aUserSpaceToImageSpace *= gfxMatrix::Translation(-aPadding.left, -aPadding.top);
aSourceRect = aSourceRect - gfxPoint(aPadding.left, aPadding.top);
aImageRect = gfxRect(0, 0, mSize.width, mSize.height);

View File

@ -975,7 +975,7 @@ TextRenderedRun::GetUserSpaceRect(nsPresContext* aContext,
}
gfxMatrix m = GetTransformFromRunUserSpaceToUserSpace(aContext);
if (aAdditionalTransform) {
m.Multiply(*aAdditionalTransform);
m *= *aAdditionalTransform;
}
return m.TransformBounds(r.ToThebesRect());
}
@ -3594,8 +3594,7 @@ SVGTextFrame::PaintSVG(nsRenderingContext* aContext,
return NS_ERROR_FAILURE;
}
gfxMatrix matrixForPaintServers(canvasTM);
matrixForPaintServers.Multiply(initialMatrix);
gfxMatrix matrixForPaintServers = canvasTM * initialMatrix;
// Check if we need to draw anything.
if (aDirtyRect) {
@ -3658,8 +3657,8 @@ SVGTextFrame::PaintSVG(nsRenderingContext* aContext,
// Set up the transform for painting the text frame for the substring
// indicated by the run.
gfxMatrix runTransform =
run.GetTransformFromUserSpaceForPainting(presContext, item);
runTransform.Multiply(currentMatrix);
run.GetTransformFromUserSpaceForPainting(presContext, item) *
currentMatrix;
gfx->SetMatrix(runTransform);
if (drawMode != DrawMode(0)) {
@ -3718,8 +3717,8 @@ SVGTextFrame::GetFrameForPoint(const nsPoint& aPoint)
continue;
}
gfxMatrix m = GetCanvasTM(FOR_HIT_TESTING);
m.PreMultiply(run.GetTransformFromRunUserSpaceToUserSpace(presContext));
gfxMatrix m = run.GetTransformFromRunUserSpaceToUserSpace(presContext) *
GetCanvasTM(FOR_HIT_TESTING);
if (!m.Invert()) {
return nullptr;
}
@ -5451,9 +5450,8 @@ SVGTextFrame::TransformFrameRectToTextChild(const gfxRect& aRect,
if (!userSpaceToRunUserSpace.Invert()) {
return result;
}
gfxMatrix m;
m.PreMultiply(userSpaceToRunUserSpace);
m.PreMultiply(run.GetTransformFromRunUserSpaceToFrameUserSpace(presContext));
gfxMatrix m = run.GetTransformFromRunUserSpaceToFrameUserSpace(presContext) *
userSpaceToRunUserSpace;
gfxRect incomingRectInFrameUserSpace =
m.TransformBounds(incomingRectInUserSpace);

View File

@ -268,7 +268,7 @@ nsSVGGradientFrame::GetPaintServerPattern(nsIFrame *aSource,
if (!nonScalingStrokeTM.Invert()) {
return nullptr;
}
patternMatrix.Multiply(nonScalingStrokeTM);
patternMatrix *= nonScalingStrokeTM;
}
if (!patternMatrix.Invert()) {

View File

@ -711,8 +711,8 @@ nsSVGIntegrationUtils::DrawableFromPaintServer(nsIFrame* aFrame,
// pattern size.
gfxFloat scaleX = overrideBounds.Width() / aRenderSize.width;
gfxFloat scaleY = overrideBounds.Height() / aRenderSize.height;
gfxMatrix scaleMatrix = gfxMatrix().Scale(scaleX, scaleY);
pattern->SetMatrix(scaleMatrix.Multiply(pattern->GetMatrix()));
gfxMatrix scaleMatrix = gfxMatrix::Scaling(scaleX, scaleY);
pattern->SetMatrix(scaleMatrix * pattern->GetMatrix());
nsRefPtr<gfxDrawable> drawable =
new gfxPatternDrawable(pattern, aRenderSize);
return drawable.forget();

View File

@ -1125,8 +1125,7 @@ PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents,
double style_expansion =
aStyleExpansionFactor * nsSVGUtils::GetStrokeWidth(aFrame);
gfxMatrix matrix = aMatrix;
matrix.Multiply(nsSVGUtils::GetStrokeTransform(aFrame));
gfxMatrix matrix = aMatrix * nsSVGUtils::GetStrokeTransform(aFrame);
double dx = style_expansion * (fabs(matrix._11) + fabs(matrix._21));
double dy = style_expansion * (fabs(matrix._22) + fabs(matrix._12));