Bug 1385861 - Part 4. Reduce usage of SetMatrix in SVGTextFrame::PaintSVG.
In while-loop [1],
1. The first SetMatrix call that I remvoed in this patch is totally useless,
we can just pass initialMatrix to contextPaint, instead of set initialMatrix
to aContenxt and read back from aContext and then pass it to contextPaint.
2. This function, SVGTextFrame::PaintSVG, is the only caller of
SetupStrokeGeometry, and it does not need SetupStrokeGeometry to setup matrix at
all, since it will be overwritten the transform matrix of aContext at several
lines below[2].
[1]
https://hg.mozilla.org/mozilla-central/file/5115e2dea29a/layout/svg/SVGTextFrame.cpp#l3658
[2]
https://hg.mozilla.org/mozilla-central/file/5115e2dea29a/layout/svg/SVGTextFrame.cpp#l3685
MozReview-Commit-ID: AlKQh4abbpa
--- a/layout/svg/SVGTextFrame.cpp
+++ b/layout/svg/SVGTextFrame.cpp
@@ -3656,23 +3656,19 @@ SVGTextFrame::PaintSVG(gfxContext& aCont
while (run.mFrame) {
nsTextFrame* frame = run.mFrame;
// Determine how much of the left and right edges of the text frame we
// need to ignore.
SVGCharClipDisplayItem item(run);
- // Set up the fill and stroke so that SVG glyphs can get painted correctly
- // when they use context-fill etc.
- aContext.SetMatrix(initialMatrix);
-
RefPtr<SVGContextPaintImpl> contextPaint = new SVGContextPaintImpl();
DrawMode drawMode = contextPaint->Init(&aDrawTarget,
- aContext.CurrentMatrix(),
+ initialMatrix,
frame, outerContextPaint,
aImgParams);
if (drawMode & DrawMode::GLYPH_STROKE) {
ctxSR.EnsureSaved(&aContext);
// This may change the gfxContext's transform (for non-scaling stroke),
// in which case this needs to happen before we call SetMatrix() below.
nsSVGUtils::SetupStrokeGeometry(frame, &aContext, outerContextPaint);
}
--- a/layout/svg/nsSVGUtils.cpp
+++ b/layout/svg/nsSVGUtils.cpp
@@ -1729,23 +1729,16 @@ nsSVGUtils::SetupStrokeGeometry(nsIFrame
gfxContext *aContext,
SVGContextPaint* aContextPaint)
{
float width = GetStrokeWidth(aFrame, aContextPaint);
if (width <= 0)
return;
aContext->SetLineWidth(width);
- // Apply any stroke-specific transform
- gfxMatrix outerSVGToUser;
- if (GetNonScalingStrokeTransform(aFrame, &outerSVGToUser) &&
- outerSVGToUser.Invert()) {
- aContext->Multiply(outerSVGToUser);
- }
-
const nsStyleSVG* style = aFrame->StyleSVG();
switch (style->mStrokeLinecap) {
case NS_STYLE_STROKE_LINECAP_BUTT:
aContext->SetLineCap(CapStyle::BUTT);
break;
case NS_STYLE_STROKE_LINECAP_ROUND:
aContext->SetLineCap(CapStyle::ROUND);