diff --git a/layout/svg/SVGGeometryFrame.cpp b/layout/svg/SVGGeometryFrame.cpp index 3909522952c1..99c84c30008f 100644 --- a/layout/svg/SVGGeometryFrame.cpp +++ b/layout/svg/SVGGeometryFrame.cpp @@ -119,7 +119,7 @@ nsDisplaySVGGeometry::Paint(nsDisplayListBuilder* aBuilder, gfxPoint devPixelOffset = nsLayoutUtils::PointToGfxPoint(offset, appUnitsPerDevPixel); - gfxMatrix tm = nsSVGIntegrationUtils::GetCSSPxToDevPxMatrix(mFrame) * + gfxMatrix tm = nsSVGUtils::GetCSSPxToDevPxMatrix(mFrame) * gfxMatrix::Translation(devPixelOffset); DrawResult result = static_cast(mFrame)->PaintSVG(*aCtx->ThebesContext(), tm); diff --git a/layout/svg/SVGTextFrame.cpp b/layout/svg/SVGTextFrame.cpp index ccccfdfa7e08..c05ab1958768 100644 --- a/layout/svg/SVGTextFrame.cpp +++ b/layout/svg/SVGTextFrame.cpp @@ -3115,7 +3115,7 @@ nsDisplaySVGText::Paint(nsDisplayListBuilder* aBuilder, gfxPoint devPixelOffset = nsLayoutUtils::PointToGfxPoint(offset, appUnitsPerDevPixel); - gfxMatrix tm = nsSVGIntegrationUtils::GetCSSPxToDevPxMatrix(mFrame) * + gfxMatrix tm = nsSVGUtils::GetCSSPxToDevPxMatrix(mFrame) * gfxMatrix::Translation(devPixelOffset); gfxContext* ctx = aCtx->ThebesContext(); diff --git a/layout/svg/nsSVGIntegrationUtils.cpp b/layout/svg/nsSVGIntegrationUtils.cpp index 65670eebde0e..3fa3a4e5474f 100644 --- a/layout/svg/nsSVGIntegrationUtils.cpp +++ b/layout/svg/nsSVGIntegrationUtils.cpp @@ -447,7 +447,7 @@ PaintMaskSurface(const PaintFramesParams& aParams, const nsStyleSVGReset *svgReset = aSC->StyleSVGReset(); gfxMatrix cssPxToDevPxMatrix = - nsSVGIntegrationUtils::GetCSSPxToDevPxMatrix(aParams.frame); + nsSVGUtils::GetCSSPxToDevPxMatrix(aParams.frame); nsPresContext* presContext = aParams.frame->PresContext(); gfxPoint devPixelOffsetToUserSpace = @@ -546,7 +546,7 @@ CreateAndPaintMaskSurface(const PaintFramesParams& aParams, // Optimization for single SVG mask. if (((aMaskFrames.Length() == 1) && aMaskFrames[0])) { gfxMatrix cssPxToDevPxMatrix = - nsSVGIntegrationUtils::GetCSSPxToDevPxMatrix(aParams.frame); + nsSVGUtils::GetCSSPxToDevPxMatrix(aParams.frame); paintResult.opacityApplied = true; nsSVGMaskFrame::MaskParams params(&ctx, aParams.frame, cssPxToDevPxMatrix, aOpacity, &paintResult.maskTransform, @@ -864,7 +864,7 @@ nsSVGIntegrationUtils::PaintMask(const PaintFramesParams& aParams) MoveContextOriginToUserSpace(firstFrame, aParams); Matrix clipMaskTransform; - gfxMatrix cssPxToDevPxMatrix = GetCSSPxToDevPxMatrix(frame); + gfxMatrix cssPxToDevPxMatrix = nsSVGUtils::GetCSSPxToDevPxMatrix(frame); nsSVGClipPathFrame *clipPathFrame = effectProperties.GetClipPathFrame(); RefPtr maskSurface = @@ -924,7 +924,7 @@ nsSVGIntegrationUtils::PaintMaskAndClipPath(const PaintFramesParams& aParams) nsSVGClipPathFrame *clipPathFrame = effectProperties.GetClipPathFrame(); - gfxMatrix cssPxToDevPxMatrix = GetCSSPxToDevPxMatrix(frame); + gfxMatrix cssPxToDevPxMatrix = nsSVGUtils::GetCSSPxToDevPxMatrix(frame); nsTArray maskFrames = effectProperties.GetMaskFrames(); bool shouldGenerateMask = (maskUsage.opacity != 1.0f || @@ -1123,7 +1123,7 @@ nsSVGIntegrationUtils::PaintFilter(const PaintFramesParams& aParams) RegularFramePaintCallback callback(aParams.builder, aParams.layerManager, offsets.offsetToUserSpaceInDevPx); nsRegion dirtyRegion = aParams.dirtyRect - offsets.offsetToBoundingBox; - gfxMatrix tm = nsSVGIntegrationUtils::GetCSSPxToDevPxMatrix(frame); + gfxMatrix tm = nsSVGUtils::GetCSSPxToDevPxMatrix(frame); DrawResult result = nsFilterInstance::PaintFilteredFrame(frame, context.GetDrawTarget(), tm, &callback, &dirtyRegion); @@ -1135,18 +1135,6 @@ nsSVGIntegrationUtils::PaintFilter(const PaintFramesParams& aParams) return result; } -gfxMatrix -nsSVGIntegrationUtils::GetCSSPxToDevPxMatrix(nsIFrame* aNonSVGFrame) -{ - int32_t appUnitsPerDevPixel = aNonSVGFrame->PresContext()->AppUnitsPerDevPixel(); - float devPxPerCSSPx = - 1 / nsPresContext::AppUnitsToFloatCSSPixels(appUnitsPerDevPixel); - - return gfxMatrix(devPxPerCSSPx, 0.0, - 0.0, devPxPerCSSPx, - 0.0, 0.0); -} - class PaintFrameCallback : public gfxDrawingCallback { public: PaintFrameCallback(nsIFrame* aFrame, diff --git a/layout/svg/nsSVGIntegrationUtils.h b/layout/svg/nsSVGIntegrationUtils.h index 6620db04704b..e0c47db9f50a 100644 --- a/layout/svg/nsSVGIntegrationUtils.h +++ b/layout/svg/nsSVGIntegrationUtils.h @@ -180,15 +180,6 @@ public: static DrawResult PaintFilter(const PaintFramesParams& aParams); - /** - * SVG frames expect to paint in SVG user units, which are equal to CSS px - * units. This method provides a transform matrix to multiply onto a - * gfxContext's current transform to convert the context's current units from - * its usual dev pixels to SVG user units/CSS px to keep the SVG code happy. - */ - static gfxMatrix - GetCSSPxToDevPxMatrix(nsIFrame* aNonSVGFrame); - /** * @param aRenderingContext the target rendering context in which the paint * server will be rendered diff --git a/layout/svg/nsSVGOuterSVGFrame.cpp b/layout/svg/nsSVGOuterSVGFrame.cpp index 2201f2effbc5..46fd127f9c30 100644 --- a/layout/svg/nsSVGOuterSVGFrame.cpp +++ b/layout/svg/nsSVGOuterSVGFrame.cpp @@ -626,7 +626,7 @@ nsDisplayOuterSVG::Paint(nsDisplayListBuilder* aBuilder, aContext->ThebesContext()->Save(); // We include the offset of our frame and a scale from device pixels to user // units (i.e. CSS px) in the matrix that we pass to our children): - gfxMatrix tm = nsSVGIntegrationUtils::GetCSSPxToDevPxMatrix(mFrame) * + gfxMatrix tm = nsSVGUtils::GetCSSPxToDevPxMatrix(mFrame) * gfxMatrix::Translation(devPixelOffset); DrawResult result = nsSVGUtils::PaintFrameWithEffects(mFrame, *aContext->ThebesContext(), tm, diff --git a/layout/svg/nsSVGUtils.cpp b/layout/svg/nsSVGUtils.cpp index f11c55c17995..77500d9f40c5 100644 --- a/layout/svg/nsSVGUtils.cpp +++ b/layout/svg/nsSVGUtils.cpp @@ -399,7 +399,7 @@ nsSVGUtils::GetCanvasTM(nsIFrame *aFrame) // XXX yuck, we really need a common interface for GetCanvasTM if (!aFrame->IsFrameOfType(nsIFrame::eSVG)) { - return nsSVGIntegrationUtils::GetCSSPxToDevPxMatrix(aFrame); + return GetCSSPxToDevPxMatrix(aFrame); } nsIAtom* type = aFrame->GetType(); @@ -407,7 +407,7 @@ nsSVGUtils::GetCanvasTM(nsIFrame *aFrame) return static_cast(aFrame)->GetCanvasTM(); } if (type == nsGkAtoms::svgOuterSVGFrame) { - return nsSVGIntegrationUtils::GetCSSPxToDevPxMatrix(aFrame); + return GetCSSPxToDevPxMatrix(aFrame); } nsSVGContainerFrame *containerFrame = do_QueryFrame(aFrame); @@ -1864,3 +1864,15 @@ nsSVGUtils::ToCanvasBounds(const gfxRect &aUserspaceRect, aToCanvas.TransformBounds(aUserspaceRect), presContext->AppUnitsPerDevPixel()); } + +gfxMatrix +nsSVGUtils::GetCSSPxToDevPxMatrix(nsIFrame* aNonSVGFrame) +{ + int32_t appUnitsPerDevPixel = aNonSVGFrame->PresContext()->AppUnitsPerDevPixel(); + float devPxPerCSSPx = + 1 / nsPresContext::AppUnitsToFloatCSSPixels(appUnitsPerDevPixel); + + return gfxMatrix(devPxPerCSSPx, 0.0, + 0.0, devPxPerCSSPx, + 0.0, 0.0); +} \ No newline at end of file diff --git a/layout/svg/nsSVGUtils.h b/layout/svg/nsSVGUtils.h index 96b69717307c..b5aaf4e5df5b 100644 --- a/layout/svg/nsSVGUtils.h +++ b/layout/svg/nsSVGUtils.h @@ -597,6 +597,15 @@ public: static float ComputeOpacity(nsIFrame* aFrame, bool aHandleOpacity); + + /** + * SVG frames expect to paint in SVG user units, which are equal to CSS px + * units. This method provides a transform matrix to multiply onto a + * gfxContext's current transform to convert the context's current units from + * its usual dev pixels to SVG user units/CSS px to keep the SVG code happy. + */ + static gfxMatrix + GetCSSPxToDevPxMatrix(nsIFrame* aNonSVGFrame); }; #endif