Bug 1065031, part 2 - Changes to Moz2D consuming code to update callers of Moz2D Matrix's Translate, Scale and Rotate methods to use these methods' new names. r=Bas

This commit is contained in:
Jonathan Watt 2014-09-10 18:29:35 +01:00
parent fa99069d2a
commit 423fda249a
26 changed files with 75 additions and 83 deletions

View File

@ -437,7 +437,7 @@ DOMMatrix::TranslateSelf(double aTx,
Ensure3DMatrix();
mMatrix3D->Translate(aTx, aTy, aTz);
} else {
mMatrix2D->Translate(aTx, aTy);
mMatrix2D->PreTranslate(aTx, aTy);
}
return this;
@ -517,7 +517,7 @@ DOMMatrix::RotateSelf(double aAngle, double aOriginX, double aOriginY)
if (mMatrix3D) {
RotateAxisAngleSelf(0, 0, 1, aAngle);
} else {
*mMatrix2D = mMatrix2D->Rotate(aAngle * radPerDegree);
*mMatrix2D = mMatrix2D->PreRotate(aAngle * radPerDegree);
}
TranslateSelf(-aOriginX, -aOriginY);

View File

@ -465,8 +465,8 @@ SVGMotionSMILType::CreateMatrix(const nsSMILValue& aSMILVal)
arr[i].mRotateType,
rotateAngle, point);
}
matrix.Translate(point.x, point.y);
matrix = gfx::Matrix::Rotation(rotateAngle) * matrix;
matrix.PreTranslate(point.x, point.y);
matrix.PreRotate(rotateAngle);
}
return matrix;
}

View File

@ -1277,7 +1277,7 @@ CanvasRenderingContext2D::Scale(double x, double y, ErrorResult& error)
}
Matrix newMatrix = mTarget->GetTransform();
mTarget->SetTransform(newMatrix.Scale(x, y));
mTarget->SetTransform(newMatrix.PreScale(x, y));
}
void
@ -1302,8 +1302,7 @@ CanvasRenderingContext2D::Translate(double x, double y, ErrorResult& error)
return;
}
Matrix newMatrix = mTarget->GetTransform();
mTarget->SetTransform(newMatrix.Translate(x, y));
mTarget->SetTransform(Matrix(mTarget->GetTransform()).PreTranslate(x, y));
}
void
@ -3023,9 +3022,9 @@ CanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
// Translate so that the anchor point is at 0,0, then scale and then
// translate back.
newTransform.Translate(aX, 0);
newTransform.Scale(aMaxWidth.Value() / totalWidth, 1);
newTransform.Translate(-aX, 0);
newTransform.PreTranslate(aX, 0);
newTransform.PreScale(aMaxWidth.Value() / totalWidth, 1);
newTransform.PreTranslate(-aX, 0);
/* we do this to avoid an ICE in the android compiler */
Matrix androidCompilerBug = newTransform;
mTarget->SetTransform(androidCompilerBug);

View File

@ -1727,10 +1727,7 @@ WebGLContext::GetSurfaceSnapshot(bool* aPremultAlpha)
return nullptr;
}
Matrix m;
m.Translate(0.0, mHeight);
m.Scale(1.0, -1.0);
dt->SetTransform(m);
dt->SetTransform(Matrix::Translation(0.0, mHeight).PreScale(1.0, -1.0));
dt->DrawSurface(surf,
Rect(0, 0, mWidth, mHeight),

View File

@ -295,9 +295,9 @@ RotatedContentBuffer::BorrowDrawTargetForQuadrantUpdate(const nsIntRect& aBounds
NS_ASSERTION(quadrantRect.Contains(bounds), "Messed up quadrants");
mLoanedTransform = mLoanedDrawTarget->GetTransform();
mLoanedTransform.Translate(-quadrantRect.x, -quadrantRect.y);
mLoanedDrawTarget->SetTransform(mLoanedTransform);
mLoanedTransform.Translate(quadrantRect.x, quadrantRect.y);
mLoanedDrawTarget->SetTransform(Matrix(mLoanedTransform).
PreTranslate(-quadrantRect.x,
-quadrantRect.y));
return mLoanedDrawTarget;
}

View File

@ -36,13 +36,12 @@ BasicCanvasLayer::Paint(DrawTarget* aDT,
return;
}
Matrix m;
Matrix oldTM;
if (mNeedsYFlip) {
m = aDT->GetTransform();
Matrix newTransform = m;
newTransform.Translate(0.0f, mBounds.height);
newTransform.Scale(1.0f, -1.0f);
aDT->SetTransform(newTransform);
oldTM = aDT->GetTransform();
aDT->SetTransform(Matrix(oldTM).
PreTranslate(0.0f, mBounds.height).
PreScale(1.0f, -1.0f));
}
FillRectWithMask(aDT, aDeviceOffset,
@ -52,7 +51,7 @@ BasicCanvasLayer::Paint(DrawTarget* aDT,
aMaskLayer);
if (mNeedsYFlip) {
aDT->SetTransform(m);
aDT->SetTransform(oldTM);
}
}

View File

@ -290,7 +290,7 @@ BasicCompositor::DrawQuad(const gfx::Rect& aRect,
MOZ_ASSERT(effectMask->mMaskTransform.Is2D(), "How did we end up with a 3D transform here?!");
MOZ_ASSERT(!effectMask->mIs3D);
maskTransform = effectMask->mMaskTransform.As2D();
maskTransform.Translate(-offset.x, -offset.y);
maskTransform.PreTranslate(-offset.x, -offset.y);
}
switch (aEffectChain.mPrimaryEffect->mType) {

View File

@ -31,7 +31,7 @@ GetMaskData(Layer* aMaskLayer,
Matrix4x4 effectiveTransform = aMaskLayer->GetEffectiveTransform();
DebugOnly<bool> maskIs2D = effectiveTransform.CanDraw2D(&transform);
NS_ASSERTION(maskIs2D, "How did we end up with a 3D transform here?!");
transform.Translate(-aDeviceOffset.x, -aDeviceOffset.y);
transform.PreTranslate(-aDeviceOffset.x, -aDeviceOffset.y);
aMaskData->Construct(transform, surface);
return true;
}

View File

@ -934,9 +934,8 @@ ContentClientIncremental::BorrowDrawTargetForPainting(PaintState& aPaintState,
result = mLoanedDrawTarget;
mLoanedTransform = mLoanedDrawTarget->GetTransform();
mLoanedTransform.Translate(-drawBounds.x, -drawBounds.y);
result->SetTransform(mLoanedTransform);
mLoanedTransform.Translate(drawBounds.x, drawBounds.y);
result->SetTransform(Matrix(mLoanedTransform).
PreTranslate(-drawBounds.x, -drawBounds.y));
if (mContentType == gfxContentType::COLOR_ALPHA) {
gfxUtils::ClipToRegion(result, aPaintState.mRegionToDraw);

View File

@ -830,8 +830,8 @@ CompositorD3D11::PrepareViewport(const gfx::IntSize& aSize,
mContext->RSSetViewports(1, &viewport);
Matrix viewMatrix = Matrix::Translation(-1.0, 1.0);
viewMatrix.Scale(2.0f / float(aSize.width), 2.0f / float(aSize.height));
viewMatrix.Scale(1.0f, -1.0f);
viewMatrix.PreScale(2.0f / float(aSize.width), 2.0f / float(aSize.height));
viewMatrix.PreScale(1.0f, -1.0f);
viewMatrix = aWorldTransform * viewMatrix;

View File

@ -588,16 +588,16 @@ CompositorOGL::PrepareViewport(const gfx::IntSize& aSize,
Matrix viewMatrix;
if (mGLContext->IsOffscreen()) {
// In case of rendering via GL Offscreen context, disable Y-Flipping
viewMatrix.Translate(-1.0, -1.0);
viewMatrix.Scale(2.0f / float(aSize.width), 2.0f / float(aSize.height));
viewMatrix.PreTranslate(-1.0, -1.0);
viewMatrix.PreScale(2.0f / float(aSize.width), 2.0f / float(aSize.height));
} else {
viewMatrix.Translate(-1.0, 1.0);
viewMatrix.Scale(2.0f / float(aSize.width), 2.0f / float(aSize.height));
viewMatrix.Scale(1.0f, -1.0f);
viewMatrix.PreTranslate(-1.0, 1.0);
viewMatrix.PreScale(2.0f / float(aSize.width), 2.0f / float(aSize.height));
viewMatrix.PreScale(1.0f, -1.0f);
}
if (!mTarget) {
viewMatrix.Translate(mRenderOffset.x, mRenderOffset.y);
viewMatrix.PreTranslate(mRenderOffset.x, mRenderOffset.y);
}
viewMatrix = aWorldTransform * viewMatrix;
@ -1212,8 +1212,8 @@ CompositorOGL::DrawQuad(const Rect& aRect,
// Drawing is always flipped, but when copying between surfaces we want to avoid
// this, so apply a flip here to cancel the other one out.
Matrix transform;
transform.Translate(0.0, 1.0);
transform.Scale(1.0f, -1.0f);
transform.PreTranslate(0.0, 1.0);
transform.PreScale(1.0f, -1.0f);
program->SetTextureTransform(Matrix4x4::From2D(transform));
program->SetTextureUnit(0);
@ -1496,8 +1496,8 @@ CompositorOGL::CopyToTarget(DrawTarget* aTarget, const nsIntPoint& aTopLeft, con
// Map from GL space to Cairo space and reverse the world transform.
Matrix glToCairoTransform = aTransform;
glToCairoTransform.Invert();
glToCairoTransform.Scale(1.0, -1.0);
glToCairoTransform.Translate(0.0, -height);
glToCairoTransform.PreScale(1.0, -1.0);
glToCairoTransform.PreTranslate(0.0, -height);
glToCairoTransform.PostTranslate(-aTopLeft.x, -aTopLeft.y);

View File

@ -93,7 +93,7 @@ DrawBlur(gfxContext* aDestinationCtx,
Matrix oldTransform = dest->GetTransform();
Matrix newTransform = oldTransform;
newTransform.Translate(aTopLeft.x, aTopLeft.y);
newTransform.PreTranslate(aTopLeft.x, aTopLeft.y);
// Avoid a semi-expensive clip operation if we can, otherwise
// clip to the dirty rect

View File

@ -434,14 +434,14 @@ void
gfxContext::Translate(const gfxPoint& pt)
{
Matrix newMatrix = mTransform;
ChangeTransform(newMatrix.Translate(Float(pt.x), Float(pt.y)));
ChangeTransform(newMatrix.PreTranslate(Float(pt.x), Float(pt.y)));
}
void
gfxContext::Scale(gfxFloat x, gfxFloat y)
{
Matrix newMatrix = mTransform;
ChangeTransform(newMatrix.Scale(Float(x), Float(y)));
ChangeTransform(newMatrix.PreScale(Float(x), Float(y)));
}
void
@ -1163,11 +1163,9 @@ gfxContext::PopGroup()
Matrix mat = mTransform;
mat.Invert();
mat.PreTranslate(deviceOffset.x, deviceOffset.y); // device offset translation
Matrix deviceOffsetTranslation;
deviceOffsetTranslation.Translate(deviceOffset.x, deviceOffset.y);
nsRefPtr<gfxPattern> pat = new gfxPattern(src, deviceOffsetTranslation * mat);
nsRefPtr<gfxPattern> pat = new gfxPattern(src, mat);
return pat.forget();
}
@ -1186,10 +1184,9 @@ gfxContext::PopGroupToSource()
Matrix mat = mTransform;
mat.Invert();
mat.PreTranslate(deviceOffset.x, deviceOffset.y); // device offset translation
Matrix deviceOffsetTranslation;
deviceOffsetTranslation.Translate(deviceOffset.x, deviceOffset.y);
CurrentState().surfTransform = deviceOffsetTranslation * mat;
CurrentState().surfTransform = mat;
}
bool

View File

@ -224,7 +224,7 @@ gfxPattern::GetPattern(DrawTarget *aTarget, Matrix *aPatternTransform)
double x, y;
cairo_surface_get_device_offset(surf, &x, &y);
newMat.Translate(-x, -y);
newMat.PreTranslate(-x, -y);
mGfxPattern = new (mSurfacePattern.addr())
SurfacePattern(mSourceSurface, ToExtendMode(extend), newMat, ToFilter(filter));
return mGfxPattern;

View File

@ -4620,10 +4620,10 @@ ContainerState::SetupMaskLayer(Layer *aLayer,
Matrix::Scaling(surfaceSize.width / boundingRect.Width(),
surfaceSize.height / boundingRect.Height());
gfx::Point p = boundingRect.TopLeft();
maskTransform.Translate(-p.x, -p.y);
maskTransform.PreTranslate(-p.x, -p.y);
// imageTransform is only used when the clip is painted to the mask
gfx::Matrix imageTransform = maskTransform;
imageTransform.Scale(mParameters.mXScale, mParameters.mYScale);
imageTransform.PreScale(mParameters.mXScale, mParameters.mYScale);
nsAutoPtr<MaskLayerImageCache::MaskLayerImageKey> newKey(
new MaskLayerImageCache::MaskLayerImageKey());

View File

@ -2180,8 +2180,8 @@ nsDisplayBackgroundImage::ConfigureLayer(ImageLayer* aLayer, const nsIntPoint& a
gfxPoint p = mDestRect.TopLeft() + aOffset;
Matrix transform = Matrix::Translation(p.x, p.y);
transform.Scale(mDestRect.width/imageSize.width,
mDestRect.height/imageSize.height);
transform.PreScale(mDestRect.width / imageSize.width,
mDestRect.height / imageSize.height);
aLayer->SetBaseTransform(gfx::Matrix4x4::From2D(transform));
}

View File

@ -283,7 +283,8 @@ nsHTMLCanvasFrame::BuildLayer(nsDisplayListBuilder* aBuilder,
// Transform the canvas into the right place
gfxPoint p = r.TopLeft() + aContainerParameters.mOffset;
Matrix transform = Matrix::Translation(p.x, p.y);
transform.Scale(r.Width()/canvasSize.width, r.Height()/canvasSize.height);
transform.PreScale(r.Width() / canvasSize.width,
r.Height() / canvasSize.height);
layer->SetBaseTransform(gfx::Matrix4x4::From2D(transform));
layer->SetFilter(nsLayoutUtils::GetGraphicsFilterForFrame(this));

View File

@ -1445,8 +1445,8 @@ nsDisplayImage::ConfigureLayer(ImageLayer *aLayer, const nsIntPoint& aOffset)
gfxPoint p = destRect.TopLeft() + aOffset;
Matrix transform = Matrix::Translation(p.x, p.y);
transform.Scale(destRect.Width()/imageWidth,
destRect.Height()/imageHeight);
transform.PreScale(destRect.Width() / imageWidth,
destRect.Height() / imageHeight);
aLayer->SetBaseTransform(gfx::Matrix4x4::From2D(transform));
}

View File

@ -224,7 +224,8 @@ nsVideoFrame::BuildLayer(nsDisplayListBuilder* aBuilder,
// Set a transform on the layer to draw the video in the right place
gfxPoint p = r.TopLeft() + aContainerParameters.mOffset;
Matrix transform = Matrix::Translation(p.x, p.y);
transform.Scale(r.Width()/frameSize.width, r.Height()/frameSize.height);
transform.PreScale(r.Width() / frameSize.width,
r.Height() / frameSize.height);
layer->SetBaseTransform(gfx::Matrix4x4::From2D(transform));
nsRefPtr<Layer> result = layer.forget();
return result.forget();

View File

@ -9,6 +9,7 @@
// Keep others in (case-insensitive) order:
#include "gfxPlatform.h"
#include "gfxUtils.h"
#include "mozilla/gfx/Helpers.h"
#include "nsISVGChildFrame.h"
#include "nsRenderingContext.h"
#include "nsCSSFilterInstance.h"
@ -407,12 +408,11 @@ nsFilterInstance::Render(gfxContext* aContext)
return NS_OK;
}
Matrix oldDTMatrix;
RefPtr<DrawTarget> dt = aContext->GetDrawTarget();
oldDTMatrix = dt->GetTransform();
Matrix matrix = ToMatrix(ctm);
matrix.Translate(filterRect.x, filterRect.y);
dt->SetTransform(matrix * oldDTMatrix);
AutoSaveTransform autoSR(dt);
Matrix newTM = ToMatrix(ctm).PreTranslate(filterRect.x, filterRect.y) * dt->GetTransform();
dt->SetTransform(newTM);
ComputeNeededBoxes();
@ -430,8 +430,6 @@ nsFilterInstance::Render(gfxContext* aContext)
mStrokePaint.mSourceSurface, mStrokePaint.mSurfaceRect,
mInputImages);
dt->SetTransform(oldDTMatrix);
return NS_OK;
}

View File

@ -277,7 +277,7 @@ nsSVGImageFrame::TransformContextForPainting(gfxContext* aGfxContext,
nscoord appUnitsPerDevPx = PresContext()->AppUnitsPerDevPixel();
gfxFloat pageZoomFactor =
nsPresContext::AppUnitsToFloatCSSPixels(appUnitsPerDevPx);
imageTransform.Scale(pageZoomFactor, pageZoomFactor);
imageTransform.PreScale(pageZoomFactor, pageZoomFactor);
}
if (imageTransform.IsSingular()) {

View File

@ -368,7 +368,7 @@ nsSVGPathGeometryFrame::ReflowSVG()
fabs(scaleFactors.height) >= 1e-6;
gfx::Matrix scaling;
if (applyScaling) {
scaling.Scale(scaleFactors.width, scaleFactors.height);
scaling.PreScale(scaleFactors.width, scaleFactors.height);
}
gfxRect extent = GetBBoxContribution(scaling, flags).ToThebesRect();
if (applyScaling) {

View File

@ -197,8 +197,8 @@ GetPatternMatrix(uint16_t aPatternUnits,
float scale = 1.0f / MaxExpansion(callerCTM);
Matrix patternMatrix = patternTransform;
patternMatrix.Scale(scale, scale);
patternMatrix.Translate(minx, miny);
patternMatrix.PreScale(scale, scale);
patternMatrix.PreTranslate(minx, miny);
return patternMatrix;
}
@ -368,8 +368,8 @@ nsSVGPatternFrame::PaintPattern(Matrix* patternMatrix,
patternFrame->mCTM->PreMultiply(tempTM);
// and rescale pattern to compensate
patternMatrix->Scale(patternWidth / surfaceSize.width,
patternHeight / surfaceSize.height);
patternMatrix->PreScale(patternWidth / surfaceSize.width,
patternHeight / surfaceSize.height);
}
RefPtr<DrawTarget> dt =

View File

@ -404,8 +404,8 @@ nsDisplayXULImage::ConfigureLayer(ImageLayer* aLayer, const nsIntPoint& aOffset)
gfxPoint p = destRect.TopLeft() + aOffset;
Matrix transform = Matrix::Translation(p.x, p.y);
transform.Scale(destRect.Width()/imageWidth,
destRect.Height()/imageHeight);
transform.PreScale(destRect.Width() / imageWidth,
destRect.Height() / imageHeight);
aLayer->SetBaseTransform(gfx::Matrix4x4::From2D(transform));
}

View File

@ -3014,8 +3014,9 @@ GLPresenter::BeginFrame(nsIntSize aRenderSize)
// Matrix to transform (0, 0, width, height) to viewport space (-1.0, 1.0,
// 2, 2) and flip the contents.
gfx::Matrix viewMatrix = gfx::Matrix::Translation(-1.0, 1.0);
viewMatrix.Scale(2.0f / float(aRenderSize.width), 2.0f / float(aRenderSize.height));
viewMatrix.Scale(1.0f, -1.0f);
viewMatrix.PreScale(2.0f / float(aRenderSize.width),
2.0f / float(aRenderSize.height));
viewMatrix.PreScale(1.0f, -1.0f);
gfx::Matrix4x4 matrix3d = gfx::Matrix4x4::From2D(viewMatrix);
matrix3d._33 = 0.0f;

View File

@ -20,16 +20,16 @@ ComputeTransformForRotation(const nsIntRect& aBounds,
case ROTATION_0:
break;
case ROTATION_90:
transform.Translate(aBounds.width, 0);
transform = gfx::Matrix::Rotation(floatPi / 2) * transform;
transform.PreTranslate(aBounds.width, 0);
transform.PreRotate(floatPi / 2);
break;
case ROTATION_180:
transform.Translate(aBounds.width, aBounds.height);
transform = gfx::Matrix::Rotation(floatPi) * transform;
transform.PreTranslate(aBounds.width, aBounds.height);
transform.PreRotate(floatPi);
break;
case ROTATION_270:
transform.Translate(0, aBounds.height);
transform = gfx::Matrix::Rotation(floatPi * 3 / 2) * transform;
transform.PreTranslate(0, aBounds.height);
transform.PreRotate(floatPi * 3 / 2);
break;
default:
MOZ_CRASH("Unknown rotation");