mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-14 02:31:59 +00:00
Bug 1224207 - Part 6. Move GetCSSPxToDevPxMatrix to nsSVGUtils. r=mstange
To use GetCSSPxToDevPxMatrix in nsFilterInstance, pull this untility function down to nsSVGUtils; Otherwise, we have to include nsSVGIntegrationUtils header in nsFilterIntance, which is ok but not good I think. MozReview-Commit-ID: 6SGtwj4EE1S --HG-- extra : rebase_source : ff6c6173c599afe630aa8b16330a0d1fc667ced8
This commit is contained in:
parent
36512021da
commit
0faeebe858
@ -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<SVGGeometryFrame*>(mFrame)->PaintSVG(*aCtx->ThebesContext(), tm);
|
||||
|
@ -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();
|
||||
|
@ -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<SourceSurface> maskSurface =
|
||||
@ -924,7 +924,7 @@ nsSVGIntegrationUtils::PaintMaskAndClipPath(const PaintFramesParams& aParams)
|
||||
|
||||
nsSVGClipPathFrame *clipPathFrame = effectProperties.GetClipPathFrame();
|
||||
|
||||
gfxMatrix cssPxToDevPxMatrix = GetCSSPxToDevPxMatrix(frame);
|
||||
gfxMatrix cssPxToDevPxMatrix = nsSVGUtils::GetCSSPxToDevPxMatrix(frame);
|
||||
nsTArray<nsSVGMaskFrame*> 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,
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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<nsSVGForeignObjectFrame*>(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);
|
||||
}
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user