diff --git a/content/svg/content/src/SVGContentUtils.cpp b/content/svg/content/src/SVGContentUtils.cpp index f414d99420c7..65fe81c094a4 100644 --- a/content/svg/content/src/SVGContentUtils.cpp +++ b/content/svg/content/src/SVGContentUtils.cpp @@ -425,7 +425,7 @@ GetCTMInternal(nsSVGElement *aElement, bool aScreenCTM, bool aHaveRecursed) } } } - return gfx::ToMatrix(matrix) * gfx::Matrix().Translate(x, y); + return ToMatrix(matrix).PostTranslate(x, y); } gfx::Matrix diff --git a/content/svg/content/src/SVGFEImageElement.cpp b/content/svg/content/src/SVGFEImageElement.cpp index c8ff33c7c516..e28f5a1ebf16 100644 --- a/content/svg/content/src/SVGFEImageElement.cpp +++ b/content/svg/content/src/SVGFEImageElement.cpp @@ -231,8 +231,8 @@ SVGFEImageElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance, SVGContentUtils::GetViewBoxTransform(aFilterSubregion.width, aFilterSubregion.height, 0, 0, nativeSize.width, nativeSize.height, mPreserveAspectRatio); - Matrix xyTM = Matrix().Translate(aFilterSubregion.x, aFilterSubregion.y); - Matrix TM = viewBoxTM * xyTM; + Matrix TM = viewBoxTM; + TM.PostTranslate(aFilterSubregion.x, aFilterSubregion.y); Filter filter = ToFilter(nsLayoutUtils::GetGraphicsFilterForFrame(frame)); diff --git a/content/svg/content/src/SVGForeignObjectElement.cpp b/content/svg/content/src/SVGForeignObjectElement.cpp index 26037162f5c6..3cb03fb80fdf 100644 --- a/content/svg/content/src/SVGForeignObjectElement.cpp +++ b/content/svg/content/src/SVGForeignObjectElement.cpp @@ -85,7 +85,7 @@ SVGForeignObjectElement::PrependLocalTransformsTo(const gfxMatrix &aMatrix, float x, y; const_cast(this)-> GetAnimatedLengthValues(&x, &y, nullptr); - gfxMatrix toUserSpace = gfxMatrix().Translate(gfxPoint(x, y)); + gfxMatrix toUserSpace = gfxMatrix::Translation(x, y); if (aWhich == eChildToUserSpace) { return toUserSpace * aMatrix; } diff --git a/content/svg/content/src/SVGIFrameElement.cpp b/content/svg/content/src/SVGIFrameElement.cpp index baf437b9841a..7b413fcf7129 100644 --- a/content/svg/content/src/SVGIFrameElement.cpp +++ b/content/svg/content/src/SVGIFrameElement.cpp @@ -74,7 +74,7 @@ SVGIFrameElement::PrependLocalTransformsTo(const gfxMatrix &aMatrix, float x, y; const_cast(this)-> GetAnimatedLengthValues(&x, &y, nullptr); - gfxMatrix toUserSpace = gfxMatrix().Translate(gfxPoint(x, y)); + gfxMatrix toUserSpace = gfxMatrix::Translation(x, y); if (aWhich == eChildToUserSpace) { return toUserSpace; } diff --git a/content/svg/content/src/SVGMarkerElement.cpp b/content/svg/content/src/SVGMarkerElement.cpp index 483fa263147c..620af71f288e 100644 --- a/content/svg/content/src/SVGMarkerElement.cpp +++ b/content/svg/content/src/SVGMarkerElement.cpp @@ -16,6 +16,8 @@ #include "mozilla/gfx/Matrix.h" #include "SVGContentUtils.h" +using namespace mozilla::gfx; + NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Marker) namespace mozilla { @@ -359,7 +361,8 @@ SVGMarkerElement::GetViewBoxTransform() gfx::Point ref = viewBoxTM * gfx::Point(refX, refY); - gfx::Matrix TM = viewBoxTM * gfx::Matrix().Translate(-ref.x, -ref.y); + Matrix TM = viewBoxTM; + TM.PostTranslate(-ref.x, -ref.y); mViewBoxToViewportTransform = new gfx::Matrix(TM); } diff --git a/content/svg/content/src/SVGSVGElement.cpp b/content/svg/content/src/SVGSVGElement.cpp index f34669be8dfa..60ea7fc58cc4 100644 --- a/content/svg/content/src/SVGSVGElement.cpp +++ b/content/svg/content/src/SVGSVGElement.cpp @@ -968,10 +968,10 @@ SVGSVGElement::PrependLocalTransformsTo(const gfxMatrix &aMatrix, const_cast(this)->GetAnimatedLengthValues(&x, &y, nullptr); if (aWhich == eAllTransforms) { // the common case - return ThebesMatrix(GetViewBoxTransform()) * gfxMatrix().Translate(gfxPoint(x, y)) * fromUserSpace; + return ThebesMatrix(GetViewBoxTransform()) * gfxMatrix::Translation(x, y) * fromUserSpace; } NS_ABORT_IF_FALSE(aWhich == eChildToUserSpace, "Unknown TransformTypes"); - return ThebesMatrix(GetViewBoxTransform()) * gfxMatrix().Translate(gfxPoint(x, y)) * aMatrix; + return ThebesMatrix(GetViewBoxTransform()) * gfxMatrix::Translation(x, y) * aMatrix; } if (IsRoot()) { diff --git a/content/svg/content/src/SVGUseElement.cpp b/content/svg/content/src/SVGUseElement.cpp index 965dcbefc643..58c320800d2e 100644 --- a/content/svg/content/src/SVGUseElement.cpp +++ b/content/svg/content/src/SVGUseElement.cpp @@ -434,7 +434,7 @@ SVGUseElement::PrependLocalTransformsTo(const gfxMatrix &aMatrix, // our 'x' and 'y' attributes: float x, y; const_cast(this)->GetAnimatedLengthValues(&x, &y, nullptr); - gfxMatrix toUserSpace = gfxMatrix().Translate(gfxPoint(x, y)); + gfxMatrix toUserSpace = gfxMatrix::Translation(x, y); if (aWhich == eChildToUserSpace) { return toUserSpace * aMatrix; } diff --git a/gfx/2d/DrawTargetD2D1.cpp b/gfx/2d/DrawTargetD2D1.cpp index 8515f37269c5..3c1c91b06ad0 100644 --- a/gfx/2d/DrawTargetD2D1.cpp +++ b/gfx/2d/DrawTargetD2D1.cpp @@ -95,8 +95,8 @@ DrawTargetD2D1::DrawSurface(SourceSurface *aSurface, // Here we scale the source pattern up to the size and position where we want // it to be. Matrix transform; - transform.Translate(aDest.x, aDest.y); - transform.Scale(xScale, yScale); + transform.PreTranslate(aDest.x, aDest.y); + transform.PreScale(xScale, yScale); mDC->CreateImageBrush(image, D2D1::ImageBrushProperties(samplingBounds), D2D1::BrushProperties(aOptions.mAlpha, D2DMatrix(transform)), diff --git a/gfx/layers/RotatedBuffer.cpp b/gfx/layers/RotatedBuffer.cpp index 4c950d319835..04eddd0ab678 100644 --- a/gfx/layers/RotatedBuffer.cpp +++ b/gfx/layers/RotatedBuffer.cpp @@ -122,8 +122,8 @@ RotatedBuffer::DrawBufferQuadrant(gfx::DrawTarget* aTarget, Matrix oldTransform = aTarget->GetTransform(); // Transform from user -> buffer space. - Matrix transform; - transform.Translate(quadrantTranslation.x, quadrantTranslation.y); + Matrix transform = + Matrix::Translation(quadrantTranslation.x, quadrantTranslation.y); Matrix inverseMask = *aMaskTransform; inverseMask.Invert(); @@ -661,8 +661,7 @@ RotatedContentBuffer::BeginPaint(ThebesLayer* aLayer, if (!isClear && (mode != SurfaceMode::SURFACE_COMPONENT_ALPHA || HaveBufferOnWhite())) { // Copy the bits nsIntPoint offset = -destBufferRect.TopLeft(); - Matrix mat; - mat.Translate(offset.x, offset.y); + Matrix mat = Matrix::Translation(offset.x, offset.y); destDTBuffer->SetTransform(mat); if (!EnsureBuffer()) { return result; diff --git a/gfx/layers/basic/BasicCompositor.cpp b/gfx/layers/basic/BasicCompositor.cpp index 684655e40bbd..c85d3f5ec745 100644 --- a/gfx/layers/basic/BasicCompositor.cpp +++ b/gfx/layers/basic/BasicCompositor.cpp @@ -261,9 +261,7 @@ BasicCompositor::DrawQuad(const gfx::Rect& aRect, return; } - Matrix destTransform; - destTransform.Translate(-aRect.x, -aRect.y); - dest->SetTransform(destTransform); + dest->SetTransform(Matrix::Translation(-aRect.x, -aRect.y)); // Get the bounds post-transform. new3DTransform = To3DMatrix(aTransform); @@ -274,7 +272,7 @@ BasicCompositor::DrawQuad(const gfx::Rect& aRect, transformBounds.RoundOut(); // Propagate the coordinate offset to our 2D draw target. - newTransform.Translate(transformBounds.x, transformBounds.y); + newTransform = Matrix::Translation(transformBounds.x, transformBounds.y); // When we apply the 3D transformation, we do it against a temporary // surface, so undo the coordinate offset. @@ -441,9 +439,8 @@ BasicCompositor::BeginFrame(const nsIntRegion& aInvalidRegion, // We only allocate a surface sized to the invalidated region, so we need to // translate future coordinates. - Matrix transform; - transform.Translate(-invalidRect.x, -invalidRect.y); - mRenderTarget->mDrawTarget->SetTransform(transform); + mRenderTarget->mDrawTarget->SetTransform(Matrix::Translation(-invalidRect.x, + -invalidRect.y)); gfxUtils::ClipToRegion(mRenderTarget->mDrawTarget, invalidRegionSafe); diff --git a/gfx/layers/d3d11/CompositorD3D11.cpp b/gfx/layers/d3d11/CompositorD3D11.cpp index 3f21f68f3c25..837645f44427 100644 --- a/gfx/layers/d3d11/CompositorD3D11.cpp +++ b/gfx/layers/d3d11/CompositorD3D11.cpp @@ -829,8 +829,7 @@ CompositorD3D11::PrepareViewport(const gfx::IntSize& aSize, mContext->RSSetViewports(1, &viewport); - Matrix viewMatrix; - viewMatrix.Translate(-1.0, 1.0); + 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); diff --git a/gfx/thebes/gfxContext.cpp b/gfx/thebes/gfxContext.cpp index 58daf12dabd5..eade3f97dee1 100644 --- a/gfx/thebes/gfxContext.cpp +++ b/gfx/thebes/gfxContext.cpp @@ -1055,9 +1055,8 @@ gfxContext::Paint(gfxFloat alpha) IntSize surfSize = state.sourceSurface->GetSize(); - Matrix mat; - mat.Translate(-state.deviceOffset.x, -state.deviceOffset.y); - mDT->SetTransform(mat); + mDT->SetTransform(Matrix::Translation(-state.deviceOffset.x, + -state.deviceOffset.y)); mDT->DrawSurface(state.sourceSurface, Rect(state.sourceSurfaceDeviceOffset, Size(surfSize.width, surfSize.height)), @@ -1619,9 +1618,8 @@ gfxContext::GetDeviceOffset() const Matrix gfxContext::GetDeviceTransform() const { - Matrix mat; - mat.Translate(-CurrentState().deviceOffset.x, -CurrentState().deviceOffset.y); - return mat; + return Matrix::Translation(-CurrentState().deviceOffset.x, + -CurrentState().deviceOffset.y); } Matrix diff --git a/gfx/thebes/gfxUtils.cpp b/gfx/thebes/gfxUtils.cpp index 44f07bb530d9..585c4fce8151 100644 --- a/gfx/thebes/gfxUtils.cpp +++ b/gfx/thebes/gfxUtils.cpp @@ -407,10 +407,10 @@ CreateSamplingRestrictedDrawable(gfxDrawable* aDrawable, nsRefPtr tmpCtx = new gfxContext(target); tmpCtx->SetOperator(OptimalFillOperator()); aDrawable->Draw(tmpCtx, needed - needed.TopLeft(), true, - GraphicsFilter::FILTER_FAST, 1.0, gfxMatrix().Translate(needed.TopLeft())); + GraphicsFilter::FILTER_FAST, 1.0, gfxMatrix::Translation(needed.TopLeft())); RefPtr surface = target->Snapshot(); - nsRefPtr drawable = new gfxSurfaceDrawable(surface, size, gfxMatrix().Translate(-needed.TopLeft())); + nsRefPtr drawable = new gfxSurfaceDrawable(surface, size, gfxMatrix::Translation(-needed.TopLeft())); return drawable.forget(); } #endif // !MOZ_GFX_OPTIMIZE_MOBILE diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp index 9b71bb0f170d..c0c66d66b62c 100644 --- a/layout/base/FrameLayerBuilder.cpp +++ b/layout/base/FrameLayerBuilder.cpp @@ -1725,8 +1725,7 @@ ContainerState::CreateOrRecycleThebesLayer(const nsIFrame* aAnimatedGeometryRoot RoundToMatchResidual(scaledOffset.y, data->mAnimatedGeometryRootPosition.y)); data->mTranslation = pixOffset; pixOffset += mParameters.mOffset; - Matrix matrix; - matrix.Translate(pixOffset.x, pixOffset.y); + Matrix matrix = Matrix::Translation(pixOffset.x, pixOffset.y); layer->SetBaseTransform(Matrix4x4::From2D(matrix)); // FIXME: Temporary workaround for bug 681192 and bug 724786. @@ -2567,8 +2566,8 @@ PaintInactiveLayer(nsDisplayListBuilder* aBuilder, itemVisibleRect.Size().ToIntSize(), SurfaceFormat::B8G8R8A8); context = new gfxContext(tempDT); - context->SetMatrix(gfxMatrix().Translate(-gfxPoint(itemVisibleRect.x, - itemVisibleRect.y))); + context->SetMatrix(gfxMatrix::Translation(-itemVisibleRect.x, + -itemVisibleRect.y)); } #endif basic->BeginTransaction(); @@ -4184,7 +4183,7 @@ static void DebugPaintItem(nsRenderingContext* aDest, IntSize(bounds.width, bounds.height), SurfaceFormat::B8G8R8A8); nsRefPtr context = new gfxContext(tempDT); - context->SetMatrix(gfxMatrix().Translate(-gfxPoint(bounds.x, bounds.y))); + context->SetMatrix(gfxMatrix::Translation(-gfxPoint(bounds.x, bounds.y))); nsRefPtr ctx = new nsRenderingContext(); ctx->Init(aDest->DeviceContext(), context); @@ -4617,9 +4616,9 @@ ContainerState::SetupMaskLayer(Layer *aLayer, // component of imageTransform), and its inverse used when the mask is used for // masking. // It is the transform from the masked layer's space to mask space - gfx::Matrix maskTransform; - maskTransform.Scale(surfaceSize.width/boundingRect.Width(), - surfaceSize.height/boundingRect.Height()); + gfx::Matrix maskTransform = + Matrix::Scaling(surfaceSize.width / boundingRect.Width(), + surfaceSize.height / boundingRect.Height()); gfx::Point p = boundingRect.TopLeft(); maskTransform.Translate(-p.x, -p.y); // imageTransform is only used when the clip is painted to the mask diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index 708112b0fc97..c236c1e82a0a 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -2179,8 +2179,7 @@ nsDisplayBackgroundImage::ConfigureLayer(ImageLayer* aLayer, const nsIntPoint& a NS_ASSERTION(imageSize.width != 0 && imageSize.height != 0, "Invalid image size!"); gfxPoint p = mDestRect.TopLeft() + aOffset; - gfx::Matrix transform; - transform.Translate(p.x, p.y); + Matrix transform = Matrix::Translation(p.x, p.y); transform.Scale(mDestRect.width/imageSize.width, mDestRect.height/imageSize.height); aLayer->SetBaseTransform(gfx::Matrix4x4::From2D(transform)); diff --git a/layout/generic/nsHTMLCanvasFrame.cpp b/layout/generic/nsHTMLCanvasFrame.cpp index 0a79a05354bb..c377415a6f97 100644 --- a/layout/generic/nsHTMLCanvasFrame.cpp +++ b/layout/generic/nsHTMLCanvasFrame.cpp @@ -19,6 +19,7 @@ using namespace mozilla; using namespace mozilla::dom; using namespace mozilla::layers; +using namespace mozilla::gfx; class nsDisplayCanvas : public nsDisplayItem { public: @@ -280,9 +281,8 @@ nsHTMLCanvasFrame::BuildLayer(nsDisplayListBuilder* aBuilder, presContext->AppUnitsToGfxUnits(area.height)); // Transform the canvas into the right place - gfx::Matrix transform; gfxPoint p = r.TopLeft() + aContainerParameters.mOffset; - transform.Translate(p.x, p.y); + Matrix transform = Matrix::Translation(p.x, p.y); transform.Scale(r.Width()/canvasSize.width, r.Height()/canvasSize.height); layer->SetBaseTransform(gfx::Matrix4x4::From2D(transform)); layer->SetFilter(nsLayoutUtils::GetGraphicsFilterForFrame(this)); diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index 31d5183f5f06..794ec8d36416 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -85,6 +85,7 @@ using namespace mozilla; using namespace mozilla::layers; using namespace mozilla::dom; +using namespace mozilla::gfx; // static icon information nsImageFrame::IconLoad* nsImageFrame::gIconLoad = nullptr; @@ -1442,9 +1443,8 @@ nsDisplayImage::ConfigureLayer(ImageLayer *aLayer, const nsIntPoint& aOffset) const gfxRect destRect = GetDestRect(); - gfx::Matrix transform; gfxPoint p = destRect.TopLeft() + aOffset; - transform.Translate(p.x, p.y); + Matrix transform = Matrix::Translation(p.x, p.y); transform.Scale(destRect.Width()/imageWidth, destRect.Height()/imageHeight); aLayer->SetBaseTransform(gfx::Matrix4x4::From2D(transform)); diff --git a/layout/generic/nsObjectFrame.cpp b/layout/generic/nsObjectFrame.cpp index 74d35cbff985..e6af65493038 100644 --- a/layout/generic/nsObjectFrame.cpp +++ b/layout/generic/nsObjectFrame.cpp @@ -1576,9 +1576,8 @@ nsObjectFrame::BuildLayer(nsDisplayListBuilder* aBuilder, } // Set a transform on the layer to draw the plugin in the right place - Matrix transform; gfxPoint p = r.TopLeft() + aContainerParameters.mOffset; - transform.Translate(p.x, p.y); + Matrix transform = Matrix::Translation(p.x, p.y); layer->SetBaseTransform(Matrix4x4::From2D(transform)); return layer.forget(); diff --git a/layout/generic/nsVideoFrame.cpp b/layout/generic/nsVideoFrame.cpp index b33390b0b34c..5a6c2ba108c3 100644 --- a/layout/generic/nsVideoFrame.cpp +++ b/layout/generic/nsVideoFrame.cpp @@ -222,9 +222,8 @@ nsVideoFrame::BuildLayer(nsDisplayListBuilder* aBuilder, layer->SetFilter(nsLayoutUtils::GetGraphicsFilterForFrame(this)); layer->SetContentFlags(Layer::CONTENT_OPAQUE); // Set a transform on the layer to draw the video in the right place - gfx::Matrix transform; gfxPoint p = r.TopLeft() + aContainerParameters.mOffset; - transform.Translate(p.x, p.y); + Matrix transform = Matrix::Translation(p.x, p.y); transform.Scale(r.Width()/frameSize.width, r.Height()/frameSize.height); layer->SetBaseTransform(gfx::Matrix4x4::From2D(transform)); nsRefPtr result = layer.forget(); diff --git a/layout/svg/nsFilterInstance.cpp b/layout/svg/nsFilterInstance.cpp index 412d8f6a68c8..f4ed44de5d5c 100644 --- a/layout/svg/nsFilterInstance.cpp +++ b/layout/svg/nsFilterInstance.cpp @@ -548,5 +548,5 @@ nsFilterInstance::FilterSpaceToFrameSpace(const nsIntRegion& aRegion) const gfxMatrix nsFilterInstance::GetUserSpaceToFrameSpaceInCSSPxTransform() const { - return gfxMatrix().Translate(-nsSVGUtils::FrameSpaceInCSSPxToUserSpaceOffset(mTargetFrame)); + return gfxMatrix::Translation(-nsSVGUtils::FrameSpaceInCSSPxToUserSpaceOffset(mTargetFrame)); } diff --git a/layout/svg/nsSVGIntegrationUtils.cpp b/layout/svg/nsSVGIntegrationUtils.cpp index 83df818b2dc8..ef6748c02846 100644 --- a/layout/svg/nsSVGIntegrationUtils.cpp +++ b/layout/svg/nsSVGIntegrationUtils.cpp @@ -643,7 +643,7 @@ PaintFrameCallback::operator()(gfxContext* aContext, int32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel(); nsPoint offset = GetOffsetToBoundingBox(mFrame); gfxPoint devPxOffset = gfxPoint(offset.x, offset.y) / appUnitsPerDevPixel; - aContext->Multiply(gfxMatrix().Translate(devPxOffset)); + aContext->Multiply(gfxMatrix::Translation(devPxOffset)); gfxSize paintServerSize = gfxSize(mPaintServerSize.width, mPaintServerSize.height) / @@ -653,8 +653,7 @@ PaintFrameCallback::operator()(gfxContext* aContext, // want it to render with mRenderSize, so we need to set up a scale transform. gfxFloat scaleX = mRenderSize.width / paintServerSize.width; gfxFloat scaleY = mRenderSize.height / paintServerSize.height; - gfxMatrix scaleMatrix = gfxMatrix().Scale(scaleX, scaleY); - aContext->Multiply(scaleMatrix); + aContext->Multiply(gfxMatrix::Scaling(scaleX, scaleY)); // Draw. nsRect dirty(-offset.x, -offset.y, diff --git a/layout/svg/nsSVGMaskFrame.cpp b/layout/svg/nsSVGMaskFrame.cpp index 2f8a1b023574..fb129936e2dc 100644 --- a/layout/svg/nsSVGMaskFrame.cpp +++ b/layout/svg/nsSVGMaskFrame.cpp @@ -223,7 +223,7 @@ nsSVGMaskFrame::GetMaskForMaskedFrame(gfxContext* aContext, } gfxMatrix maskSurfaceMatrix = - aContext->CurrentMatrix() * gfxMatrix().Translate(-maskSurfaceRect.TopLeft()); + aContext->CurrentMatrix() * gfxMatrix::Translation(-maskSurfaceRect.TopLeft()); nsRefPtr tmpCtx = new nsRenderingContext(); tmpCtx->Init(this->PresContext()->DeviceContext(), maskDT); diff --git a/layout/svg/nsSVGOuterSVGFrame.cpp b/layout/svg/nsSVGOuterSVGFrame.cpp index a5a0173ca557..35b42b7b2936 100644 --- a/layout/svg/nsSVGOuterSVGFrame.cpp +++ b/layout/svg/nsSVGOuterSVGFrame.cpp @@ -864,7 +864,7 @@ nsSVGOuterSVGFrame::GetCanvasTM() PresContext()->AppUnitsPerDevPixel()); gfxMatrix tm = content->PrependLocalTransformsTo( - gfxMatrix().Scale(devPxPerCSSPx, devPxPerCSSPx)); + gfxMatrix::Scaling(devPxPerCSSPx, devPxPerCSSPx)); mCanvasTM = new gfxMatrix(tm); } return *mCanvasTM; diff --git a/layout/svg/nsSVGUtils.cpp b/layout/svg/nsSVGUtils.cpp index e280a79977c6..ce416730aa1e 100644 --- a/layout/svg/nsSVGUtils.cpp +++ b/layout/svg/nsSVGUtils.cpp @@ -958,9 +958,8 @@ nsSVGUtils::GetBBox(nsIFrame *aFrame, uint32_t aFlags) static_cast(clipPathFrame->GetContent()); nsRefPtr units = clipContent->ClipPathUnits(); if (units->AnimVal() == SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) { - matrix = gfxMatrix().Scale(width, height) * - gfxMatrix().Translate(gfxPoint(x, y)) * - matrix; + matrix.Translate(gfxPoint(x, y)); + matrix.Scale(width, height); } else if (aFrame->GetType() == nsGkAtoms::svgForeignObjectFrame) { matrix.Reset(); } @@ -1072,9 +1071,10 @@ nsSVGUtils::AdjustMatrixForUnits(const gfxMatrix &aMatrix, if (aFrame && aUnits->GetAnimValue() == SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) { gfxRect bbox = GetBBox(aFrame); - return gfxMatrix().Scale(bbox.Width(), bbox.Height()) * - gfxMatrix().Translate(gfxPoint(bbox.X(), bbox.Y())) * - aMatrix; + gfxMatrix tm = aMatrix; + tm.Translate(gfxPoint(bbox.X(), bbox.Y())); + tm.Scale(bbox.Width(), bbox.Height()); + return tm; } return aMatrix; } diff --git a/layout/xul/nsImageBoxFrame.cpp b/layout/xul/nsImageBoxFrame.cpp index 8025e04c6aa5..6735ec3c90b2 100644 --- a/layout/xul/nsImageBoxFrame.cpp +++ b/layout/xul/nsImageBoxFrame.cpp @@ -54,6 +54,7 @@ #define ONLOAD_CALLED_TOO_EARLY 1 using namespace mozilla; +using namespace mozilla::gfx; using namespace mozilla::layers; class nsImageBoxFrameEvent : public nsRunnable @@ -402,8 +403,7 @@ nsDisplayXULImage::ConfigureLayer(ImageLayer* aLayer, const nsIntPoint& aOffset) NS_ASSERTION(imageWidth != 0 && imageHeight != 0, "Invalid image size!"); gfxPoint p = destRect.TopLeft() + aOffset; - gfx::Matrix transform; - transform.Translate(p.x, p.y); + Matrix transform = Matrix::Translation(p.x, p.y); transform.Scale(destRect.Width()/imageWidth, destRect.Height()/imageHeight); aLayer->SetBaseTransform(gfx::Matrix4x4::From2D(transform)); diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index 182a9cac713f..f634e6c7c4b5 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -3013,8 +3013,7 @@ 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; - viewMatrix.Translate(-1.0, 1.0); + 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);