Bug 602792. Lazy initialize mUseFontGlyphWidths to avoid unnecessary font io. r=jkew, a=blocker

This commit is contained in:
John Daggett 2011-01-22 01:44:33 +09:00
parent 1adcf202e0
commit e872fa383e
6 changed files with 18 additions and 8 deletions

View File

@ -672,6 +672,16 @@ gfxDWriteFont::GetFontTable(PRUint32 aTag)
return nsnull;
}
PRBool
gfxDWriteFont::ProvidesGlyphWidths()
{
if (!mInitialized) {
Initialize();
}
return !mUseSubpixelPositions ||
(mFontFace->GetSimulations() & DWRITE_FONT_SIMULATIONS_BOLD);
}
PRInt32
gfxDWriteFont::GetGlyphWidth(gfxContext *aCtx, PRUint16 aGID)
{

View File

@ -84,10 +84,7 @@ public:
// use DWrite API to get direct access to system font data
virtual hb_blob_t *GetFontTable(PRUint32 aTag);
virtual PRBool ProvidesGlyphWidths() const {
return !mUseSubpixelPositions ||
(mFontFace->GetSimulations() & DWRITE_FONT_SIMULATIONS_BOLD);
}
virtual PRBool ProvidesGlyphWidths();
virtual PRInt32 GetGlyphWidth(gfxContext *aCtx, PRUint16 aGID);

View File

@ -63,7 +63,7 @@ public:
virtual hb_blob_t *GetFontTable(PRUint32 aTag);
virtual PRBool ProvidesGetGlyph() const { return PR_TRUE; }
virtual PRUint32 GetGlyph(PRUint32 unicode, PRUint32 variation_selector);
virtual PRBool ProvidesGlyphWidths() const { return PR_TRUE; }
virtual PRBool ProvidesGlyphWidths() { return PR_TRUE; }
virtual PRInt32 GetGlyphWidth(gfxContext *aCtx, PRUint16 aGID);
cairo_scaled_font_t *CairoScaledFont() { return mScaledFont; };

View File

@ -1013,7 +1013,7 @@ public:
// subclasses may provide (possibly hinted) glyph widths (in font units);
// if they do not override this, harfbuzz will use unhinted widths
// derived from the font tables
virtual PRBool ProvidesGlyphWidths() const {
virtual PRBool ProvidesGlyphWidths() {
return PR_FALSE;
}

View File

@ -76,7 +76,7 @@ public:
/* required for MathML to suppress effects of ClearType "padding" */
virtual gfxFont* CopyWithAntialiasOption(AntialiasOption anAAOption);
virtual PRBool ProvidesGlyphWidths() const { return PR_TRUE; }
virtual PRBool ProvidesGlyphWidths() { return PR_TRUE; }
// get hinted glyph width in pixels as 16.16 fixed-point value
virtual PRInt32 GetGlyphWidth(gfxContext *aCtx, PRUint16 aGID);

View File

@ -83,7 +83,7 @@ gfxHarfBuzzShaper::gfxHarfBuzzShaper(gfxFont *aFont)
mSubtableOffset(0),
mUVSTableOffset(0),
mUseFontGetGlyph(aFont->ProvidesGetGlyph()),
mUseFontGlyphWidths(aFont->ProvidesGlyphWidths())
mUseFontGlyphWidths(PR_FALSE)
{
}
@ -709,6 +709,9 @@ gfxHarfBuzzShaper::InitTextRun(gfxContext *aContext,
mFont->SetupCairoFont(aContext);
if (!mHBFace) {
mUseFontGlyphWidths = mFont->ProvidesGlyphWidths();
// set up the harfbuzz face etc the first time we use the font
if (!sHBFontFuncs) {