Bug 652754. Eliminate unnecessary font data enumerations at startup. r=jkew
authorJohn Daggett <jdaggett@mozilla.com>
Fri, 20 May 2011 15:09:30 +0900
changeset 69742 f2cac6e5a44488327c36344ca02b9b45a4939807
parent 69741 0bbb1318a394c87abf9884a166f4409ac77c92f7
child 69743 c36e2218c101f62bc97d7d999ea50a0179778bc9
push id20093
push userjkew@mozilla.com
push dateFri, 20 May 2011 09:42:38 +0000
treeherdermozilla-central@f2cac6e5a444 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjkew
bugs652754
milestone6.0a1
first release with
nightly win64
f2cac6e5a444 / 6.0a1 / 20110520030213 / files
nightly linux32
nightly linux64
nightly mac
nightly win32
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly win64
Bug 652754. Eliminate unnecessary font data enumerations at startup. r=jkew
gfx/thebes/gfxFont.cpp
gfx/thebes/gfxFont.h
gfx/thebes/gfxGDIFontList.cpp
gfx/thebes/gfxGDIFontList.h
modules/libpref/src/init/all.js
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -94,16 +94,21 @@ static PRUint32 gGlyphExtentsSetupLazyTi
 static PRUint32 gGlyphExtentsSetupFallBackToTight = 0;
 #endif
 
 gfxFontEntry::~gfxFontEntry() 
 {
     delete mUserFontData;
 }
 
+PRBool gfxFontEntry::IsSymbolFont() 
+{
+    return mSymbolFont;
+}
+
 PRBool gfxFontEntry::TestCharacterMap(PRUint32 aCh)
 {
     if (!mCmapInitialized) {
         ReadCMAP();
     }
     return mCharacterMap.test(aCh);
 }
 
--- a/gfx/thebes/gfxFont.h
+++ b/gfx/thebes/gfxFont.h
@@ -229,19 +229,20 @@ public:
     PRUint16 Weight() const { return mWeight; }
     PRInt16 Stretch() const { return mStretch; }
 
     PRBool IsUserFont() const { return mIsUserFont; }
     PRBool IsLocalUserFont() const { return mIsLocalUserFont; }
     PRBool IsFixedPitch() const { return mFixedPitch; }
     PRBool IsItalic() const { return mItalic; }
     PRBool IsBold() const { return mWeight >= 600; } // bold == weights 600 and above
-    PRBool IsSymbolFont() const { return mSymbolFont; }
     PRBool IgnoreGDEF() const { return mIgnoreGDEF; }
 
+    virtual PRBool IsSymbolFont();
+
     inline PRBool HasCmapTable() {
         if (!mCmapInitialized) {
             ReadCMAP();
         }
         return mHasCmapTable;
     }
 
     inline PRBool HasCharacter(PRUint32 ch) {
--- a/gfx/thebes/gfxGDIFontList.cpp
+++ b/gfx/thebes/gfxGDIFontList.cpp
@@ -210,17 +210,16 @@ FontTypeToOutPrecision(PRUint8 fontType)
  */
 
 GDIFontEntry::GDIFontEntry(const nsAString& aFaceName, gfxWindowsFontType aFontType,
                                    PRBool aItalic, PRUint16 aWeight, gfxUserFontData *aUserFontData) : 
     gfxFontEntry(aFaceName), 
     mWindowsFamily(0), mWindowsPitch(0),
     mFontType(aFontType),
     mForceGDI(PR_FALSE), mUnknownCMAP(PR_FALSE),
-    mUnicodeFont(PR_FALSE),
     mCharset(), mUnicodeRanges()
 {
     mUserFontData = aUserFontData;
     mItalic = aItalic;
     mWeight = aWeight;
     if (IsType1())
         mForceGDI = PR_TRUE;
     mIsUserFont = aUserFontData != nsnull;
@@ -249,27 +248,34 @@ GDIFontEntry::ReadCMAP()
     if (GetFontTable(kCmapTag, buffer) != NS_OK)
         return NS_ERROR_FAILURE;
     PRUint8 *cmap = buffer.Elements();
 
     PRPackedBool  unicodeFont = PR_FALSE, symbolFont = PR_FALSE;
     nsresult rv = gfxFontUtils::ReadCMAP(cmap, buffer.Length(),
                                          mCharacterMap, mUVSOffset,
                                          unicodeFont, symbolFont);
-    mUnicodeFont = unicodeFont;
     mSymbolFont = symbolFont;
     mHasCmapTable = NS_SUCCEEDED(rv);
 
 #ifdef PR_LOGGING
     LOG_FONTLIST(("(fontlist-cmap) name: %s, size: %d\n",
                   NS_ConvertUTF16toUTF8(mName).get(), mCharacterMap.GetSize()));
 #endif
     return rv;
 }
 
+PRBool
+GDIFontEntry::IsSymbolFont()
+{
+    // initialize cmap first
+    HasCmapTable();
+    return mSymbolFont;  
+}
+
 gfxFont *
 GDIFontEntry::CreateFontInstance(const gfxFontStyle* aFontStyle, PRBool aNeedsBold)
 {
     PRBool isXP = (gfxWindowsPlatform::WindowsOSVersion() 
                        < gfxWindowsPlatform::kWindowsVista);
 
     PRBool useClearType = isXP && !aFontStyle->systemFont &&
         (gfxWindowsPlatform::GetPlatform()->UseClearTypeAlways() ||
@@ -329,20 +335,16 @@ GDIFontEntry::FillLogFont(LOGFONTW *aLog
 
 #define MISSING_GLYPH 0x1F // glyph index returned for missing characters
                            // on WinXP with .fon fonts, but not Type1 (.pfb)
 
 PRBool 
 GDIFontEntry::TestCharacterMap(PRUint32 aCh)
 {
     if (ReadCMAP() != NS_OK) {
-        // Type1 fonts aren't necessarily Unicode but
-        // this is the best guess we can make here
-        mUnicodeFont = IsType1();
-
         // For fonts where we failed to read the character map,
         // we can take a slow path to look up glyphs character by character
         mUnknownCMAP = PR_TRUE;
     }
 
     if (mUnknownCMAP) {
         if (aCh > 0xFFFF)
             return PR_FALSE;
@@ -442,30 +444,16 @@ GDIFontEntry::CreateFontEntry(const nsAS
                                   PRBool aItalic, PRUint16 aWeight, 
                                   gfxUserFontData* aUserFontData)
 {
     // jtdfix - need to set charset, unicode ranges, pitch/family
 
     GDIFontEntry *fe = new GDIFontEntry(aName, aFontType, aItalic, aWeight,
                                         aUserFontData);
 
-    // ReadCMAP may change the values of mUnicodeFont and mSymbolFont
-    if (NS_FAILED(fe->ReadCMAP())) {
-        // Type1 fonts aren't necessarily Unicode but
-        // this is the best guess we can make here
-        if (fe->IsType1())
-            fe->mUnicodeFont = PR_TRUE;
-        else
-            fe->mUnicodeFont = PR_FALSE;
-
-        // For fonts where we failed to read the character map,
-        // we can take a slow path to look up glyphs character by character
-        fe->mUnknownCMAP = PR_TRUE;
-    } 
-
     return fe;
 }
 
 /***************************************************************
  *
  * GDIFontFamily
  *
  */
--- a/gfx/thebes/gfxGDIFontList.h
+++ b/gfx/thebes/gfxGDIFontList.h
@@ -139,16 +139,18 @@ enum gfxWindowsFontType {
 // This replaces FontEntry from gfxWindowsFonts.h/cpp.
 class GDIFontEntry : public gfxFontEntry
 {
 public:
     LPLOGFONTW GetLogFont() { return &mLogFont; }
 
     nsresult ReadCMAP();
 
+    virtual PRBool IsSymbolFont();
+
     void FillLogFont(LOGFONTW *aLogFont, PRBool aItalic,
                      PRUint16 aWeight, gfxFloat aSize, PRBool aUseCleartype);
 
     static gfxWindowsFontType DetermineFontType(const NEWTEXTMETRICW& metrics, 
                                                 DWORD fontType)
     {
         gfxWindowsFontType feType;
         if (metrics.ntmFlags & NTM_TYPE1)
@@ -174,21 +176,16 @@ public:
     }
 
     PRBool IsTrueType() const {
         return (mFontType == GFX_FONT_TYPE_TRUETYPE ||
                 mFontType == GFX_FONT_TYPE_PS_OPENTYPE ||
                 mFontType == GFX_FONT_TYPE_TT_OPENTYPE);
     }
 
-    PRBool IsCrappyFont() const {
-        /* return if it is a bitmap not a unicode font */
-        return (!mUnicodeFont || IsSymbolFont() || IsType1());
-    }
-
     virtual PRBool MatchesGenericFamily(const nsACString& aGeneric) const {
         if (aGeneric.IsEmpty()) {
             return PR_TRUE;
         }
 
         // Japanese 'Mincho' fonts do not belong to FF_MODERN even if
         // they are fixed pitch because they have variable stroke width.
         if (mWindowsFamily == FF_ROMAN && mWindowsPitch & FIXED_PITCH) {
@@ -288,17 +285,16 @@ public:
                                     const nsAString& aFullname);
 
     PRUint8 mWindowsFamily;
     PRUint8 mWindowsPitch;
 
     gfxWindowsFontType mFontType;
     PRPackedBool mForceGDI    : 1;
     PRPackedBool mUnknownCMAP : 1;
-    PRPackedBool mUnicodeFont : 1;
 
     gfxSparseBitSet mCharset;
     gfxSparseBitSet mUnicodeRanges;
 
 protected:
     friend class gfxWindowsFont;
 
     GDIFontEntry(const nsAString& aFaceName, gfxWindowsFontType aFontType,
--- a/modules/libpref/src/init/all.js
+++ b/modules/libpref/src/init/all.js
@@ -1427,32 +1427,32 @@ pref("font.name.cursive.el", "Comic Sans
 pref("font.name.serif.he", "Narkisim");
 pref("font.name.sans-serif.he", "Arial");
 pref("font.name.monospace.he", "Fixed Miriam Transparent");
 pref("font.name.cursive.he", "Guttman Yad");
 pref("font.name-list.serif.he", "Narkisim, David");
 pref("font.name-list.monospace.he", "Fixed Miriam Transparent, Miriam Fixed, Rod, Courier New");
 pref("font.name-list.cursive.he", "Guttman Yad, Ktav, Arial");
 
-pref("font.name.serif.ja", "MS P明朝"); // "MS PMincho"
-pref("font.name.sans-serif.ja", "MS Pゴシック"); // "MS PGothic"
-pref("font.name.monospace.ja", "MS ゴシック"); // "MS Gothic"
+pref("font.name.serif.ja", "MS PMincho");
+pref("font.name.sans-serif.ja", "MS PGothic");
+pref("font.name.monospace.ja", "MS Gothic");
 pref("font.name-list.serif.ja", "MS PMincho, MS Mincho, MS PGothic, MS Gothic");
 pref("font.name-list.sans-serif.ja", "MS PGothic, MS Gothic, MS PMincho, MS Mincho");
 pref("font.name-list.monospace.ja", "MS Gothic, MS Mincho, MS PGothic, MS PMincho");
 
-pref("font.name.serif.ko", "바탕"); // "Batang" 
-pref("font.name.sans-serif.ko", "굴림"); // "Gulim" 
-pref("font.name.monospace.ko", "굴림체"); // "GulimChe" 
-pref("font.name.cursive.ko", "궁서"); // "Gungseo"
-
-pref("font.name-list.serif.ko", "Batang, Gulim"); 
-pref("font.name-list.sans-serif.ko", "Gulim"); 
-pref("font.name-list.monospace.ko", "GulimChe"); 
-pref("font.name-list.cursive.ko", "Gungseo"); 
+pref("font.name.serif.ko", "Batang");
+pref("font.name.sans-serif.ko", "Gulim");
+pref("font.name.monospace.ko", "GulimChe");
+pref("font.name.cursive.ko", "Gungsuh");
+
+pref("font.name-list.serif.ko", "Batang, Gulim");
+pref("font.name-list.sans-serif.ko", "Gulim");
+pref("font.name-list.monospace.ko", "GulimChe");
+pref("font.name-list.cursive.ko", "Gungsuh");
 
 pref("font.name.serif.th", "Tahoma");
 pref("font.name.sans-serif.th", "Tahoma");
 pref("font.name.monospace.th", "Tahoma");
 pref("font.name.cursive.th", "Tahoma");
 
 pref("font.name.serif.tr", "Times New Roman");
 pref("font.name.sans-serif.tr", "Arial");
@@ -1479,39 +1479,39 @@ pref("font.name.sans-serif.x-unicode", "
 pref("font.name.monospace.x-unicode", "Courier New");
 pref("font.name.cursive.x-unicode", "Comic Sans MS");
 
 pref("font.name.serif.x-western", "Times New Roman");
 pref("font.name.sans-serif.x-western", "Arial");
 pref("font.name.monospace.x-western", "Courier New");
 pref("font.name.cursive.x-western", "Comic Sans MS");
 
-pref("font.name.serif.zh-CN", "宋体"); //MS Song
-pref("font.name.sans-serif.zh-CN", "宋体"); //MS Song
-pref("font.name.monospace.zh-CN", "宋体"); //MS Song
+pref("font.name.serif.zh-CN", "SimSun");
+pref("font.name.sans-serif.zh-CN", "SimSun");
+pref("font.name.monospace.zh-CN", "SimSun");
 pref("font.name-list.serif.zh-CN", "MS Song, SimSun");
 pref("font.name-list.sans-serif.zh-CN", "MS Song, SimSun");
 pref("font.name-list.monospace.zh-CN", "MS Song, SimSun");
 
 // Per Taiwanese users' demand. They don't want to use TC fonts for
 // rendering Latin letters. (bug 88579)
 pref("font.name.serif.zh-TW", "Times New Roman"); 
 pref("font.name.sans-serif.zh-TW", "Arial");
-pref("font.name.monospace.zh-TW", "細明體");  // MingLiU
+pref("font.name.monospace.zh-TW", "MingLiU");
 pref("font.name-list.serif.zh-TW", "PMingLiu, MingLiU"); 
 pref("font.name-list.sans-serif.zh-TW", "PMingLiU, MingLiU");
 pref("font.name-list.monospace.zh-TW", "MingLiU");
 
-// hkscsm3u.ttf (HKSCS-2001) :  http://www.microsoft.com/hk/hkscs 
-// Hong Kong users have the same demand about glyphs for Latin letters (bug 88579) 
-pref("font.name.serif.zh-HK", "Times New Roman"); 
+// hkscsm3u.ttf (HKSCS-2001) :  http://www.microsoft.com/hk/hkscs
+// Hong Kong users have the same demand about glyphs for Latin letters (bug 88579)
+pref("font.name.serif.zh-HK", "Times New Roman");
 pref("font.name.sans-serif.zh-HK", "Arial");
-pref("font.name.monospace.zh-HK", "細明體_HKSCS"); 
-pref("font.name-list.serif.zh-HK", "MingLiu_HKSCS, Ming(for ISO10646), MingLiU"); 
-pref("font.name-list.sans-serif.zh-HK", "MingLiU_HKSCS, Ming(for ISO10646), MingLiU");  
+pref("font.name.monospace.zh-HK", "MingLiu_HKSCS");
+pref("font.name-list.serif.zh-HK", "MingLiu_HKSCS, Ming(for ISO10646), MingLiU");
+pref("font.name-list.sans-serif.zh-HK", "MingLiU_HKSCS, Ming(for ISO10646), MingLiU");
 pref("font.name-list.monospace.zh-HK", "MingLiU_HKSCS, Ming(for ISO10646), MingLiU");
 
 pref("font.name.serif.x-devanagari", "Mangal");
 pref("font.name.sans-serif.x-devanagari", "Raghindi");
 pref("font.name.monospace.x-devanagari", "Mangal");
 pref("font.name-list.serif.x-devanagari", "Mangal, Raghindi");
 pref("font.name-list.monospace.x-devanagari", "Mangal, Raghindi");
 
@@ -1547,29 +1547,29 @@ pref("font.name.sans-serif.x-ethi", "GF 
 pref("font.name.cursive.x-ethi", "Visual Geez Unicode Title");
 pref("font.name.monospace.x-ethi", "Ethiopia Jiret");
 pref("font.name-list.serif.x-ethi", "Visual Geez Unicode, Visual Geez Unicode Agazian, Code2000");
 pref("font.name-list.monospace.x-ethi", "Ethiopia Jiret, Code2000");
 
 pref("font.name.serif.x-geor", "Sylfaen");
 pref("font.name.sans-serif.x-geor", "BPG Classic 99U");
 pref("font.name.monospace.x-geor", "Code2000");
-pref("font.name-list.serif.x-geor", "Sylfaen, BPG Paata Khutsuri U, TITUS Cyberbit Basic"); 
+pref("font.name-list.serif.x-geor", "Sylfaen, BPG Paata Khutsuri U, TITUS Cyberbit Basic");
 pref("font.name-list.monospace.x-geor", "BPG Classic 99U, Code2000, Arial Unicode MS");
 
 pref("font.name.serif.x-gujr", "Shruti");
 pref("font.name.sans-serif.x-gujr", "Shruti");
 pref("font.name.monospace.x-gujr", "Code2000");
-pref("font.name-list.serif.x-gujr", "Shruti, Code2000, Arial Unicode MS"); 
+pref("font.name-list.serif.x-gujr", "Shruti, Code2000, Arial Unicode MS");
 pref("font.name-list.monospace.x-gujr", "Code2000, Shruti, Arial Unicode MS");
 
 pref("font.name.serif.x-guru", "Raavi");
 pref("font.name.sans-serif.x-guru", "Code2000");
 pref("font.name.monospace.x-guru", "Code2000");
-pref("font.name-list.serif.x-guru", "Raavi, Saab, Code2000, Arial Unicode MS"); 
+pref("font.name-list.serif.x-guru", "Raavi, Saab, Code2000, Arial Unicode MS");
 pref("font.name-list.monospace.x-guru", "Code2000, Raavi, Saab, Arial Unicode MS");
 
 pref("font.name.serif.x-khmr", "PhnomPenh OT");
 pref("font.name.sans-serif.x-khmr", "Khmer OS");
 pref("font.name.monospace.x-khmr", "Code2000");
 pref("font.name-list.serif.x-khmr", "PhnomPenh OT,.Mondulkiri U GR 1.5, Khmer OS");
 pref("font.name-list.monospace.x-khmr", "Code2000, Khmer OS, Khmer OS System");