b=597147 part 12: un-inline some of gfxPangoFcFont r=jfkthame a=blocking
authorKarl Tomlinson <karlt+@karlt.net>
Thu, 11 Nov 2010 09:04:19 +1300
changeset 57272 85b93f3ea9d1252ed24ff2cfcdccc05ee44bdb03
parent 57271 b58fc686e2d45483c10433135a06e4cc05d20bcb
child 57273 49a7555a77cc03e2d84312f304dbe51eb47ef083
push id16852
push userktomlinson@mozilla.com
push dateWed, 10 Nov 2010 20:06:29 +0000
treeherdermozilla-central@85b93f3ea9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame, blocking
bugs597147
milestone2.0b8pre
first release with
nightly win64
85b93f3ea9d1 / 4.0b8pre / 20101110140021 / 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
b=597147 part 12: un-inline some of gfxPangoFcFont r=jfkthame a=blocking
gfx/thebes/gfxPangoFonts.cpp
--- a/gfx/thebes/gfxPangoFonts.cpp
+++ b/gfx/thebes/gfxPangoFonts.cpp
@@ -564,123 +564,131 @@ GType gfx_pango_fc_font_get_type (void);
 struct gfxPangoFcFont {
     PangoFcFont parent_instance;
 
     FcPattern *mRequestedPattern;
     PangoCoverage *mCoverage;
     gfxFcFont *mGfxFont;
 
     static nsReturnRef<PangoFont>
-    NewFont(FcPattern *aRequestedPattern, FcPattern *aFontPattern)
-    {
-        // A pattern is needed for pango_fc_font_finalize.
-        //
-        // Adding a ref to the requested pattern and one of fontconfig's
-        // patterns uses much less memory than using the fully resolved
-        // pattern here, and saves calling FcFontRenderPrepare when the
-        // PangoFont is only tested for character coverage.
-        //
-        // Normally the is_hinted field of the PangoFcFont is set based on the
-        // FC_HINTING property on the pattern at construction, but this
-        // property is not known until after RenderPrepare.  is_hinted is used
-        // by pango_fc_font_kern_glyphs, which is sometimes used by
-        // pango_ot_buffer_output.  is_hinted will be set when the gfxFont is
-        // constructed for PangoFcFont::lock_face.
-        gfxPangoFcFont *font = static_cast<gfxPangoFcFont*>
-            (g_object_new(GFX_TYPE_PANGO_FC_FONT,
-                          "pattern", aFontPattern, NULL));
-
-        // Save the requested pattern for FcFontRenderPrepare.
-        FcPatternReference(aRequestedPattern);
-        font->mRequestedPattern = aRequestedPattern;
-
-        // PangoFcFont::get_coverage wants a PangoFcFontMap.  (PangoFcFontMap
-        // would usually set this after calling PangoFcFontMap::create_font()
-        // or new_font().)
-        PangoFontMap *fontmap = GetPangoFontMap();
-        // In Pango-1.24.4, we can use the "fontmap" property; by setting the
-        // property, the PangoFcFont base class manages the pointer (as a weak
-        // reference).
-        PangoFcFont *fc_font = &font->parent_instance;
-        if (gUseFontMapProperty) {
-            g_object_set(font, "fontmap", fontmap, NULL);
-        } else {
-            // In Pango versions up to 1.20.5, the parent class will decrement
-            // the reference count of the fontmap during shutdown() or
-            // finalize() of the font.  In Pango versions from 1.22.0 this no
-            // longer happens, so we'll end up leaking the (singleton)
-            // fontmap.
-            fc_font->fontmap = fontmap;
-            g_object_ref(fc_font->fontmap);
-        }
-
-        return nsReturnRef<PangoFont>(PANGO_FONT(font));
-    }
+    NewFont(FcPattern *aRequestedPattern, FcPattern *aFontPattern);
 
     gfxFcFont *GfxFont()
     {
         if (!mGfxFont) {
-            PangoFcFont *fc_font = &parent_instance;
-
-            if (NS_LIKELY(mRequestedPattern)) {
-                // Created with gfxPangoFcFont::NewFont()
-                nsAutoRef<FcPattern> renderPattern
-                    (FcFontRenderPrepare(NULL, mRequestedPattern,
-                                         fc_font->font_pattern));
-                if (!renderPattern)
-                    return nsnull;
-
-                FcBool hinting = FcTrue;
-                FcPatternGetBool(renderPattern, FC_HINTING, 0, &hinting);
-                fc_font->is_hinted = hinting;
-
-                // is_transformed does not appear to be used anywhere but looks
-                // like it should be set.
-                FcMatrix *matrix;
-                FcResult result = FcPatternGetMatrix(renderPattern,
-                                                     FC_MATRIX, 0, &matrix);
-                fc_font->is_transformed =
-                    result == FcResultMatch &&
-                    (matrix->xy != 0.0 || matrix->yx != 0.0 ||
-                     matrix->xx != 1.0 || matrix->yy != 1.0);
-
-                mGfxFont = gfxFcFont::GetOrMakeFont(renderPattern).get();
-                if (mGfxFont) {
-                    // Finished with the requested pattern
-                    FcPatternDestroy(mRequestedPattern);
-                    mRequestedPattern = NULL;
-                }
-
-            } else {
-                // Created with gfxPangoFontMap::create_font()
-                mGfxFont =
-                    gfxFcFont::GetOrMakeFont(fc_font->font_pattern).get();
-            }                
+            SetGfxFont();
         }
         return mGfxFont;
     }
 
     cairo_scaled_font_t *CairoFont()
     {
         return GfxFont()->CairoScaledFont();
     }
+
+private:
+    void SetGfxFont();
 };
 
 struct gfxPangoFcFontClass {
     PangoFcFontClass parent_class;
 };
 
 G_DEFINE_TYPE (gfxPangoFcFont, gfx_pango_fc_font, PANGO_TYPE_FC_FONT)
 
+/* static */ nsReturnRef<PangoFont>
+gfxPangoFcFont::NewFont(FcPattern *aRequestedPattern, FcPattern *aFontPattern)
+{
+    // A pattern is needed for pango_fc_font_finalize.
+    //
+    // Adding a ref to the requested pattern and one of fontconfig's
+    // patterns uses much less memory than using the fully resolved
+    // pattern here, and saves calling FcFontRenderPrepare when the
+    // PangoFont is only tested for character coverage.
+    //
+    // Normally the is_hinted field of the PangoFcFont is set based on the
+    // FC_HINTING property on the pattern at construction, but this
+    // property is not known until after RenderPrepare.  is_hinted is used
+    // by pango_fc_font_kern_glyphs, which is sometimes used by
+    // pango_ot_buffer_output.  is_hinted will be set when the gfxFont is
+    // constructed for PangoFcFont::lock_face.
+    gfxPangoFcFont *font = static_cast<gfxPangoFcFont*>
+        (g_object_new(GFX_TYPE_PANGO_FC_FONT, "pattern", aFontPattern, NULL));
+
+    // Save the requested pattern for FcFontRenderPrepare.
+    FcPatternReference(aRequestedPattern);
+    font->mRequestedPattern = aRequestedPattern;
+
+    // PangoFcFont::get_coverage wants a PangoFcFontMap.  (PangoFcFontMap
+    // would usually set this after calling PangoFcFontMap::create_font()
+    // or new_font().)
+    PangoFontMap *fontmap = GetPangoFontMap();
+    // In Pango-1.24.4, we can use the "fontmap" property; by setting the
+    // property, the PangoFcFont base class manages the pointer (as a weak
+    // reference).
+    PangoFcFont *fc_font = &font->parent_instance;
+    if (gUseFontMapProperty) {
+        g_object_set(font, "fontmap", fontmap, NULL);
+    } else {
+        // In Pango versions up to 1.20.5, the parent class will decrement
+        // the reference count of the fontmap during shutdown() or
+        // finalize() of the font.  In Pango versions from 1.22.0 this no
+        // longer happens, so we'll end up leaking the (singleton)
+        // fontmap.
+        fc_font->fontmap = fontmap;
+        g_object_ref(fc_font->fontmap);
+    }
+
+    return nsReturnRef<PangoFont>(PANGO_FONT(font));
+}
+
+void
+gfxPangoFcFont::SetGfxFont() {
+    PangoFcFont *fc_font = &parent_instance;
+
+    if (NS_LIKELY(mRequestedPattern)) {
+        // Created with gfxPangoFcFont::NewFont()
+        nsAutoRef<FcPattern> renderPattern
+            (FcFontRenderPrepare(NULL, mRequestedPattern,
+                                 fc_font->font_pattern));
+        if (!renderPattern)
+            return;
+
+        FcBool hinting = FcTrue;
+        FcPatternGetBool(renderPattern, FC_HINTING, 0, &hinting);
+        fc_font->is_hinted = hinting;
+
+        // is_transformed does not appear to be used anywhere but looks
+        // like it should be set.
+        FcMatrix *matrix;
+        FcResult result = FcPatternGetMatrix(renderPattern,
+                                             FC_MATRIX, 0, &matrix);
+        fc_font->is_transformed =
+            result == FcResultMatch &&
+            (matrix->xy != 0.0 || matrix->yx != 0.0 ||
+             matrix->xx != 1.0 || matrix->yy != 1.0);
+
+        mGfxFont = gfxFcFont::GetOrMakeFont(renderPattern).get();
+        if (mGfxFont) {
+            // Finished with the requested pattern
+            FcPatternDestroy(mRequestedPattern);
+            mRequestedPattern = NULL;
+        }
+
+    } else {
+        // Created with gfxPangoFontMap::create_font()
+        mGfxFont = gfxFcFont::GetOrMakeFont(fc_font->font_pattern).get();
+    }
+}
+
 static void
 gfx_pango_fc_font_init(gfxPangoFcFont *font)
 {
 }
 
-
 static void
 gfx_pango_fc_font_finalize(GObject *object)
 {
     gfxPangoFcFont *self = GFX_PANGO_FC_FONT(object);
 
     if (self->mRequestedPattern)
         FcPatternDestroy(self->mRequestedPattern);
     if (self->mCoverage)