Bug 1379404 - Part 2. Prevent using gfxContext::Save/Restore in gfxFont.
MozReview-Commit-ID: 7uIQDfK8gG2
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -2065,20 +2065,22 @@ gfxFont::Draw(const gfxTextRun *aTextRun
fontParams.haveSVGGlyphs = GetFontEntry()->TryGetSVGData(this);
fontParams.haveColorGlyphs = GetFontEntry()->TryGetColorGlyphs();
fontParams.contextPaint = aRunParams.runContextPaint;
fontParams.isVerticalFont =
aOrientation == gfx::ShapedTextFlags::TEXT_ORIENT_VERTICAL_UPRIGHT;
bool sideways = false;
+ gfxContextMatrixAutoSaveRestore matrixRestore;
+
gfxPoint origPt = *aPt;
if (aRunParams.isVerticalRun && !fontParams.isVerticalFont) {
sideways = true;
- aRunParams.context->Save();
+ matrixRestore.SetContext(aRunParams.context);
gfxPoint p(aPt->x * aRunParams.devPerApp,
aPt->y * aRunParams.devPerApp);
const Metrics& metrics = GetMetrics(eHorizontal);
// Get a matrix we can use to draw the (horizontally-shaped) textrun
// with 90-degree CW rotation.
const gfxFloat
rotation = (aOrientation ==
gfx::ShapedTextFlags::TEXT_ORIENT_VERTICAL_SIDEWAYS_LEFT)
@@ -2193,17 +2195,16 @@ gfxFont::Draw(const gfxTextRun *aTextRun
if (aRunParams.callbacks && emittedGlyphs) {
aRunParams.callbacks->NotifyGlyphPathEmitted();
}
aRunParams.dt->SetTransform(oldMat);
aRunParams.dt->SetPermitSubpixelAA(oldSubpixelAA);
if (sideways) {
- aRunParams.context->Restore();
// adjust updated aPt to account for the transform we were using
gfxFloat advance = aPt->x - origPt.x;
if (aOrientation ==
gfx::ShapedTextFlags::TEXT_ORIENT_VERTICAL_SIDEWAYS_LEFT) {
*aPt = gfxPoint(origPt.x, origPt.y - advance);
} else {
*aPt = gfxPoint(origPt.x, origPt.y + advance);
}
@@ -2217,25 +2218,23 @@ gfxFont::RenderSVGGlyph(gfxContext *aCon
if (!GetFontEntry()->HasSVGGlyph(aGlyphId)) {
return false;
}
const gfxFloat devUnitsPerSVGUnit =
GetAdjustedSize() / GetFontEntry()->UnitsPerEm();
gfxContextMatrixAutoSaveRestore matrixRestore(aContext);
- aContext->Save();
aContext->SetMatrix(
aContext->CurrentMatrix().PreTranslate(aPoint.x, aPoint.y).
PreScale(devUnitsPerSVGUnit, devUnitsPerSVGUnit));
aContextPaint->InitStrokeGeometry(aContext, devUnitsPerSVGUnit);
GetFontEntry()->RenderSVGGlyph(aContext, aGlyphId, aContextPaint);
- aContext->Restore();
aContext->NewPath();
return true;
}
bool
gfxFont::RenderSVGGlyph(gfxContext *aContext, gfxPoint aPoint,
uint32_t aGlyphId, SVGContextPaint* aContextPaint,
gfxTextRunDrawCallbacks *aCallbacks,