Bug 1385861 - Part 4. Define contextPaint as a local variable.
To prevent heap allocation in painting.
MozReview-Commit-ID: DVssJdWuvk0
--- a/layout/svg/SVGTextFrame.cpp
+++ b/layout/svg/SVGTextFrame.cpp
@@ -3660,21 +3660,21 @@ SVGTextFrame::PaintSVG(gfxContext& aCont
// 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(),
- frame, outerContextPaint,
- aImgParams);
+ SVGContextPaintImpl contextPaint;
+ DrawMode drawMode = contextPaint.Init(&aDrawTarget,
+ aContext.CurrentMatrix(),
+ 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);
}
// Set up the transform for painting the text frame for the substring
@@ -3685,26 +3685,25 @@ SVGTextFrame::PaintSVG(gfxContext& aCont
aContext.SetMatrix(runTransform);
if (drawMode != DrawMode(0)) {
bool paintSVGGlyphs;
nsTextFrame::PaintTextParams params(&aContext);
params.framePt = gfxPoint();
params.dirtyRect = LayoutDevicePixel::
FromAppUnits(frame->GetVisualOverflowRect(), auPerDevPx);
- params.contextPaint = contextPaint;
+ params.contextPaint = &contextPaint;
if (ShouldRenderAsPath(frame, paintSVGGlyphs)) {
SVGTextDrawPathCallbacks callbacks(this, aContext, frame,
matrixForPaintServers,
paintSVGGlyphs);
params.callbacks = &callbacks;
- frame->PaintText(params, item);
- } else {
- frame->PaintText(params, item);
}
+
+ frame->PaintText(params, item);
}
if (frame == caretFrame && ShouldPaintCaret(run, caret)) {
ctxSR.EnsureSaved(&aContext);
// XXX Should we be looking at the fill/stroke colours to paint the
// caret with, rather than using the color property?
caret->PaintCaret(aDrawTarget, frame, nsPoint());
aContext.NewPath();