bug 564309 - cache non-antialiased font to fix MathML perf regression on Windows. r=roc

This commit is contained in:
Jonathan Kew 2010-05-12 13:17:55 +01:00
parent 2061850a0a
commit 901d200bbe
2 changed files with 12 additions and 6 deletions

View File

@ -948,6 +948,10 @@ protected:
// the AA setting requested for this font - may affect glyph bounds
AntialiasOption mAntialiasOption;
// a copy of the font without antialiasing, if needed for separate
// measurement by mathml code
nsAutoPtr<gfxFont> mNonAAFont;
nsAutoPtr<gfxFontShaper> mShaper;
// some fonts have bad metrics, this method sanitize them.

View File

@ -1074,16 +1074,18 @@ gfxFont::Measure(gfxTextRun *aTextRun,
// If aBoundingBoxType is TIGHT_HINTED_OUTLINE_EXTENTS
// and the underlying cairo font may be antialiased,
// we need to create a copy in order to avoid getting cached extents.
// This is inefficient, but only used by MathML layout at present.
// This is only used by MathML layout at present.
if (aBoundingBoxType == TIGHT_HINTED_OUTLINE_EXTENTS &&
mAntialiasOption != kAntialiasNone) {
nsAutoPtr<gfxFont> tempFont(CopyWithAntialiasOption(kAntialiasNone));
if (!mNonAAFont) {
mNonAAFont = CopyWithAntialiasOption(kAntialiasNone);
}
// if font subclass doesn't implement CopyWithAntialiasOption(),
// it will return null and we'll proceed to use the existing font
if (tempFont) {
return tempFont->Measure(aTextRun, aStart, aEnd,
TIGHT_HINTED_OUTLINE_EXTENTS,
aRefContext, aSpacing);
if (mNonAAFont) {
return mNonAAFont->Measure(aTextRun, aStart, aEnd,
TIGHT_HINTED_OUTLINE_EXTENTS,
aRefContext, aSpacing);
}
}