diff options
-rw-r--r-- | modules/thai/Makefile.am | 1 | ||||
-rw-r--r-- | pango/Makefile.am | 1 | ||||
-rw-r--r-- | pango/mini-fribidi/Makefile.am | 1 | ||||
-rw-r--r-- | pango/opentype/Makefile.am | 1 | ||||
-rw-r--r-- | pango/pangofc-fontmap.c | 172 | ||||
-rw-r--r-- | pango/pangofc-fontmap.cI | 172 | ||||
-rw-r--r-- | pango/pangoft2-fontmap.c | 9 | ||||
-rw-r--r-- | pango/pangoft2-private.h | 8 | ||||
-rw-r--r-- | pango/pangoft2.c | 18 | ||||
-rw-r--r-- | pango/pangoxft-font.c | 18 | ||||
-rw-r--r-- | pango/pangoxft-fontmap.c | 9 | ||||
-rw-r--r-- | pango/pangoxft-private.h | 4 | ||||
-rw-r--r-- | tests/Makefile.am | 3 |
13 files changed, 210 insertions, 207 deletions
diff --git a/modules/thai/Makefile.am b/modules/thai/Makefile.am index 84d49a65..6e27c439 100644 --- a/modules/thai/Makefile.am +++ b/modules/thai/Makefile.am @@ -51,6 +51,7 @@ moduledir = $(libdir)/pango/$(PANGO_MODULE_VERSION)/modules INCLUDES = \ -DPANGO_ENABLE_ENGINE \ -DG_DISABLE_DEPRECATED \ + $(PANGO_DEBUG_FLAGS) \ -I$(top_srcdir) \ -I$(top_srcdir)/pango/ \ $(moddefine) \ diff --git a/pango/Makefile.am b/pango/Makefile.am index 27183dd2..6a4ca6a2 100644 --- a/pango/Makefile.am +++ b/pango/Makefile.am @@ -24,6 +24,7 @@ INCLUDES = \ -DLIBDIR=\"$(libdir)\" \ -DMODULE_VERSION=\"$(PANGO_MODULE_VERSION)\" \ -DG_DISABLE_DEPRECATED \ + $(PANGO_DEBUG_FLAGS) \ $(GLIB_CFLAGS) \ $(XFT_CFLAGS) \ $(FONTCONFIG_CFLAGS) \ diff --git a/pango/mini-fribidi/Makefile.am b/pango/mini-fribidi/Makefile.am index 362c04e8..fe2ee01f 100644 --- a/pango/mini-fribidi/Makefile.am +++ b/pango/mini-fribidi/Makefile.am @@ -4,6 +4,7 @@ INCLUDES = \ -DSYSCONFDIR=\"$(sysconfdir)\" \ -DLIBDIR=\"$(libdir)\" \ -DG_DISABLE_DEPRECATED \ + $(PANGO_DEBUG_FLAGS) \ -I$(top_srcdir) \ $(GLIB_CFLAGS) diff --git a/pango/opentype/Makefile.am b/pango/opentype/Makefile.am index 7374d030..3acf7546 100644 --- a/pango/opentype/Makefile.am +++ b/pango/opentype/Makefile.am @@ -5,6 +5,7 @@ INCLUDES = \ -DSYSCONFDIR=\"$(sysconfdir)\" \ -DLIBDIR=\"$(libdir)\" \ -DG_DISABLE_DEPRECATED \ + $(PANGO_DEBUG_FLAGS) \ $(GLIB_CFLAGS) \ $(FREETYPE_CFLAGS) \ $(X_CFLAGS) \ diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c index f277e80e..28d5fa20 100644 --- a/pango/pangofc-fontmap.c +++ b/pango/pangofc-fontmap.c @@ -24,8 +24,8 @@ * after making appropriate #defines for public symbols. */ -/* Number of freed fonts to keep around */ -#define MAX_FREED_FONTS 128 +/* Size of fontset cache */ +#define FONTSET_CACHE_SIZE 16 typedef struct _PangoFcCoverageKey PangoFcCoverageKey; typedef struct _PangoFcFace PangoFcFace; @@ -68,6 +68,8 @@ struct _PangoFcPatternSet { int n_patterns; FcPattern **patterns; + PangoFontset *fontset; + GList *cache_link; }; GType pango_fc_font_map_get_type (void); @@ -89,11 +91,9 @@ static void pango_fc_font_map_list_families (PangoFontMap int *n_families); -static void pango_fc_font_set_free (PangoFcPatternSet *font_set); +static void pango_fc_pattern_set_free (PangoFcPatternSet *patterns); static void pango_fc_font_map_cache_clear (PangoFcFontMap *fcfontmap); -static void pango_fc_font_map_cache_remove (PangoFontMap *fontmap, - PangoFcFont *xfont); static void pango_fc_default_substitute (PangoFcFontMap *fontmap, FcPattern *pattern); static void pango_fc_do_finalize (PangoFcFontMap *fontmap); @@ -145,9 +145,8 @@ pango_fc_font_map_init (PangoFcFontMap *fcfontmap) (GEqualFunc)pango_fc_coverage_key_equal, (GDestroyNotify)g_free, (GDestroyNotify)pango_coverage_unref); - fcfontmap->freed_fonts = g_queue_new (); + fcfontmap->fontset_cache = g_queue_new (); } - static void pango_fc_font_map_class_init (PangoFontMapClass *class) { @@ -262,7 +261,7 @@ pango_fc_get_fontset_hash (PangoFcFontMap *fcfontmap, g_hash_table_new_full ((GHashFunc)pango_font_description_hash, (GEqualFunc)pango_font_description_equal, (GDestroyNotify)pango_font_description_free, - (GDestroyNotify)pango_fc_font_set_free); + (GDestroyNotify)pango_fc_pattern_set_free); node->language = language; return node->fontset_hash; @@ -270,9 +269,11 @@ pango_fc_get_fontset_hash (PangoFcFontMap *fcfontmap, } static void -pango_fc_clear_fontset_hash_list (PangoFcFontMap *fcfontmap) +pango_fc_clear_pattern_hashes (PangoFcFontMap *fcfontmap) { - GList *tmp_list = fcfontmap->fontset_hash_list; + GList *tmp_list; + + tmp_list = fcfontmap->fontset_hash_list; while (tmp_list) { FontsetHashListNode *node = tmp_list->data; @@ -298,8 +299,7 @@ pango_fc_font_map_finalize (GObject *object) fcfontmap->substitute_destroy (fcfontmap->substitute_data); pango_fc_font_map_cache_clear (fcfontmap); - g_queue_free (fcfontmap->freed_fonts); - pango_fc_clear_fontset_hash_list (fcfontmap); + g_queue_free (fcfontmap->fontset_cache); g_hash_table_destroy (fcfontmap->coverage_hash); if (fcfontmap->fonts) @@ -512,15 +512,7 @@ pango_fc_font_map_new_font (PangoFontMap *fontmap, font = g_hash_table_lookup (fcfontmap->fonts, match); if (font) - { - g_object_ref (font); - - /* Revive font from cache */ - if (font->in_cache) - pango_fc_font_map_cache_remove (fontmap, font); - - return (PangoFont *)font; - } + return g_object_ref (font); FcPatternReference (match); return (PangoFont *)_pango_fc_font_new (fontmap, match); @@ -602,6 +594,8 @@ pango_fc_font_map_get_patterns (PangoFontMap *fontmap, patterns = g_new (PangoFcPatternSet, 1); patterns->patterns = g_new (FcPattern *, font_patterns->nfont); patterns->n_patterns = 0; + patterns->fontset = NULL; + patterns->cache_link = NULL; for (f = 0; f < font_patterns->nfont; f++) { @@ -646,89 +640,119 @@ pango_fc_font_map_load_font (PangoFontMap *fontmap, } static void -pango_fc_font_set_free (PangoFcPatternSet *font_set) +pango_fc_pattern_set_free (PangoFcPatternSet *patterns) { int i; + + if (patterns->fontset) + g_object_remove_weak_pointer (G_OBJECT (patterns->fontset), + (gpointer *)&patterns->fontset); - for (i = 0; i < font_set->n_patterns; i++) - FcPatternDestroy (font_set->patterns[i]); + for (i = 0; i < patterns->n_patterns; i++) + FcPatternDestroy (patterns->patterns[i]); - g_free (font_set->patterns); - g_free (font_set); + g_free (patterns->patterns); + g_free (patterns); } +static void +pango_fc_font_map_cache_fontset (PangoFcFontMap *fcfontmap, + PangoFcPatternSet *patterns) +{ + GQueue *cache = fcfontmap->fontset_cache; + + if (patterns->cache_link) + { + /* Already in cache, move to head + */ + if (patterns->cache_link == cache->tail) + cache->tail = patterns->cache_link->prev; + + cache->head = g_list_remove_link (cache->head, patterns->cache_link); + cache->length--; + } + else + { + /* Add to cache initially + */ + if (cache->length == FONTSET_CACHE_SIZE) + { + PangoFcPatternSet *tmp_patterns = g_queue_pop_tail (cache); + tmp_patterns->cache_link = NULL; + g_object_unref (tmp_patterns->fontset); + } + + g_object_ref (patterns->fontset); + patterns->cache_link = g_list_prepend (NULL, patterns); + } + + g_queue_push_head_link (cache, patterns->cache_link); +} static PangoFontset * pango_fc_font_map_load_fontset (PangoFontMap *fontmap, - PangoContext *context, - const PangoFontDescription *desc, - PangoLanguage *language) + PangoContext *context, + const PangoFontDescription *desc, + PangoLanguage *language) { - PangoFontsetSimple *simple; int i; PangoFcPatternSet *patterns = pango_fc_font_map_get_patterns (fontmap, context, desc, language); + PangoFcFontMap *fcfontmap = PANGO_FC_FONT_MAP (fontmap); if (!patterns) return NULL; - - simple = pango_fontset_simple_new (language); - for (i = 0; i < patterns->n_patterns; i++) + if (!patterns->fontset) { - PangoFont *font = pango_fc_font_map_new_font (fontmap, patterns->patterns[i]); - if (font) - pango_fontset_simple_append (simple, font); + PangoFontsetSimple *simple; + simple = pango_fontset_simple_new (language); + + for (i = 0; i < patterns->n_patterns; i++) + { + PangoFont *font = pango_fc_font_map_new_font (fontmap, patterns->patterns[i]); + if (font) + pango_fontset_simple_append (simple, font); + } + + patterns->fontset = PANGO_FONTSET (simple); + g_object_add_weak_pointer (G_OBJECT (patterns->fontset), + (gpointer *)&patterns->fontset); } + else + g_object_ref (patterns->fontset); - return PANGO_FONTSET (simple); -} + if (!patterns->cache_link || + patterns->cache_link != fcfontmap->fontset_cache->head) + pango_fc_font_map_cache_fontset (fcfontmap, patterns); + return patterns->fontset; +} -void -_pango_fc_font_map_cache_add (PangoFontMap *fontmap, - PangoFcFont *xfont) +static void +uncache_patterns (PangoFcPatternSet *patterns) { - PangoFcFontMap *fcfontmap = PANGO_FC_FONT_MAP (fontmap); - - g_object_ref (G_OBJECT (xfont)); - g_queue_push_head (fcfontmap->freed_fonts, xfont); - xfont->in_cache = TRUE; - - if (fcfontmap->freed_fonts->length > MAX_FREED_FONTS) - { - GObject *old_font = g_queue_pop_tail (fcfontmap->freed_fonts); - g_object_unref (old_font); - } + g_object_unref (patterns->fontset); } static void -pango_fc_font_map_cache_remove (PangoFontMap *fontmap, - PangoFcFont *xfont) +pango_fc_font_map_clear_fontset_cache (PangoFcFontMap *fcfontmap) { - PangoFcFontMap *fcfontmap = PANGO_FC_FONT_MAP (fontmap); - - GList *link = g_list_find (fcfontmap->freed_fonts->head, xfont); - if (link == fcfontmap->freed_fonts->tail) - { - fcfontmap->freed_fonts->tail = fcfontmap->freed_fonts->tail->prev; - if (fcfontmap->freed_fonts->tail) - fcfontmap->freed_fonts->tail->next = NULL; - } + GQueue *cache = fcfontmap->fontset_cache; - fcfontmap->freed_fonts->head = g_list_delete_link (fcfontmap->freed_fonts->head, link); - fcfontmap->freed_fonts->length--; - xfont->in_cache = FALSE; - - g_object_unref (G_OBJECT (xfont)); + g_list_foreach (cache->head, (GFunc)uncache_patterns, NULL); + g_list_free (cache->head); + cache->head = NULL; + cache->tail = NULL; + cache->length = 0; } static void -pango_fc_font_map_cache_clear (PangoFcFontMap *fcfontmap) +pango_fc_font_map_cache_clear (PangoFcFontMap *fcfontmap) { - g_list_foreach (fcfontmap->freed_fonts->head, (GFunc)g_object_unref, NULL); - g_list_free (fcfontmap->freed_fonts->head); - fcfontmap->freed_fonts->head = NULL; - fcfontmap->freed_fonts->tail = NULL; - fcfontmap->freed_fonts->length = 0; + /* Clear the fontset cache first, since any entries + * in the fontset_cache must also be in the pattern cache. + */ + pango_fc_font_map_clear_fontset_cache (fcfontmap); + pango_fc_clear_pattern_hashes (fcfontmap); } static void diff --git a/pango/pangofc-fontmap.cI b/pango/pangofc-fontmap.cI index f277e80e..28d5fa20 100644 --- a/pango/pangofc-fontmap.cI +++ b/pango/pangofc-fontmap.cI @@ -24,8 +24,8 @@ * after making appropriate #defines for public symbols. */ -/* Number of freed fonts to keep around */ -#define MAX_FREED_FONTS 128 +/* Size of fontset cache */ +#define FONTSET_CACHE_SIZE 16 typedef struct _PangoFcCoverageKey PangoFcCoverageKey; typedef struct _PangoFcFace PangoFcFace; @@ -68,6 +68,8 @@ struct _PangoFcPatternSet { int n_patterns; FcPattern **patterns; + PangoFontset *fontset; + GList *cache_link; }; GType pango_fc_font_map_get_type (void); @@ -89,11 +91,9 @@ static void pango_fc_font_map_list_families (PangoFontMap int *n_families); -static void pango_fc_font_set_free (PangoFcPatternSet *font_set); +static void pango_fc_pattern_set_free (PangoFcPatternSet *patterns); static void pango_fc_font_map_cache_clear (PangoFcFontMap *fcfontmap); -static void pango_fc_font_map_cache_remove (PangoFontMap *fontmap, - PangoFcFont *xfont); static void pango_fc_default_substitute (PangoFcFontMap *fontmap, FcPattern *pattern); static void pango_fc_do_finalize (PangoFcFontMap *fontmap); @@ -145,9 +145,8 @@ pango_fc_font_map_init (PangoFcFontMap *fcfontmap) (GEqualFunc)pango_fc_coverage_key_equal, (GDestroyNotify)g_free, (GDestroyNotify)pango_coverage_unref); - fcfontmap->freed_fonts = g_queue_new (); + fcfontmap->fontset_cache = g_queue_new (); } - static void pango_fc_font_map_class_init (PangoFontMapClass *class) { @@ -262,7 +261,7 @@ pango_fc_get_fontset_hash (PangoFcFontMap *fcfontmap, g_hash_table_new_full ((GHashFunc)pango_font_description_hash, (GEqualFunc)pango_font_description_equal, (GDestroyNotify)pango_font_description_free, - (GDestroyNotify)pango_fc_font_set_free); + (GDestroyNotify)pango_fc_pattern_set_free); node->language = language; return node->fontset_hash; @@ -270,9 +269,11 @@ pango_fc_get_fontset_hash (PangoFcFontMap *fcfontmap, } static void -pango_fc_clear_fontset_hash_list (PangoFcFontMap *fcfontmap) +pango_fc_clear_pattern_hashes (PangoFcFontMap *fcfontmap) { - GList *tmp_list = fcfontmap->fontset_hash_list; + GList *tmp_list; + + tmp_list = fcfontmap->fontset_hash_list; while (tmp_list) { FontsetHashListNode *node = tmp_list->data; @@ -298,8 +299,7 @@ pango_fc_font_map_finalize (GObject *object) fcfontmap->substitute_destroy (fcfontmap->substitute_data); pango_fc_font_map_cache_clear (fcfontmap); - g_queue_free (fcfontmap->freed_fonts); - pango_fc_clear_fontset_hash_list (fcfontmap); + g_queue_free (fcfontmap->fontset_cache); g_hash_table_destroy (fcfontmap->coverage_hash); if (fcfontmap->fonts) @@ -512,15 +512,7 @@ pango_fc_font_map_new_font (PangoFontMap *fontmap, font = g_hash_table_lookup (fcfontmap->fonts, match); if (font) - { - g_object_ref (font); - - /* Revive font from cache */ - if (font->in_cache) - pango_fc_font_map_cache_remove (fontmap, font); - - return (PangoFont *)font; - } + return g_object_ref (font); FcPatternReference (match); return (PangoFont *)_pango_fc_font_new (fontmap, match); @@ -602,6 +594,8 @@ pango_fc_font_map_get_patterns (PangoFontMap *fontmap, patterns = g_new (PangoFcPatternSet, 1); patterns->patterns = g_new (FcPattern *, font_patterns->nfont); patterns->n_patterns = 0; + patterns->fontset = NULL; + patterns->cache_link = NULL; for (f = 0; f < font_patterns->nfont; f++) { @@ -646,89 +640,119 @@ pango_fc_font_map_load_font (PangoFontMap *fontmap, } static void -pango_fc_font_set_free (PangoFcPatternSet *font_set) +pango_fc_pattern_set_free (PangoFcPatternSet *patterns) { int i; + + if (patterns->fontset) + g_object_remove_weak_pointer (G_OBJECT (patterns->fontset), + (gpointer *)&patterns->fontset); - for (i = 0; i < font_set->n_patterns; i++) - FcPatternDestroy (font_set->patterns[i]); + for (i = 0; i < patterns->n_patterns; i++) + FcPatternDestroy (patterns->patterns[i]); - g_free (font_set->patterns); - g_free (font_set); + g_free (patterns->patterns); + g_free (patterns); } +static void +pango_fc_font_map_cache_fontset (PangoFcFontMap *fcfontmap, + PangoFcPatternSet *patterns) +{ + GQueue *cache = fcfontmap->fontset_cache; + + if (patterns->cache_link) + { + /* Already in cache, move to head + */ + if (patterns->cache_link == cache->tail) + cache->tail = patterns->cache_link->prev; + + cache->head = g_list_remove_link (cache->head, patterns->cache_link); + cache->length--; + } + else + { + /* Add to cache initially + */ + if (cache->length == FONTSET_CACHE_SIZE) + { + PangoFcPatternSet *tmp_patterns = g_queue_pop_tail (cache); + tmp_patterns->cache_link = NULL; + g_object_unref (tmp_patterns->fontset); + } + + g_object_ref (patterns->fontset); + patterns->cache_link = g_list_prepend (NULL, patterns); + } + + g_queue_push_head_link (cache, patterns->cache_link); +} static PangoFontset * pango_fc_font_map_load_fontset (PangoFontMap *fontmap, - PangoContext *context, - const PangoFontDescription *desc, - PangoLanguage *language) + PangoContext *context, + const PangoFontDescription *desc, + PangoLanguage *language) { - PangoFontsetSimple *simple; int i; PangoFcPatternSet *patterns = pango_fc_font_map_get_patterns (fontmap, context, desc, language); + PangoFcFontMap *fcfontmap = PANGO_FC_FONT_MAP (fontmap); if (!patterns) return NULL; - - simple = pango_fontset_simple_new (language); - for (i = 0; i < patterns->n_patterns; i++) + if (!patterns->fontset) { - PangoFont *font = pango_fc_font_map_new_font (fontmap, patterns->patterns[i]); - if (font) - pango_fontset_simple_append (simple, font); + PangoFontsetSimple *simple; + simple = pango_fontset_simple_new (language); + + for (i = 0; i < patterns->n_patterns; i++) + { + PangoFont *font = pango_fc_font_map_new_font (fontmap, patterns->patterns[i]); + if (font) + pango_fontset_simple_append (simple, font); + } + + patterns->fontset = PANGO_FONTSET (simple); + g_object_add_weak_pointer (G_OBJECT (patterns->fontset), + (gpointer *)&patterns->fontset); } + else + g_object_ref (patterns->fontset); - return PANGO_FONTSET (simple); -} + if (!patterns->cache_link || + patterns->cache_link != fcfontmap->fontset_cache->head) + pango_fc_font_map_cache_fontset (fcfontmap, patterns); + return patterns->fontset; +} -void -_pango_fc_font_map_cache_add (PangoFontMap *fontmap, - PangoFcFont *xfont) +static void +uncache_patterns (PangoFcPatternSet *patterns) { - PangoFcFontMap *fcfontmap = PANGO_FC_FONT_MAP (fontmap); - - g_object_ref (G_OBJECT (xfont)); - g_queue_push_head (fcfontmap->freed_fonts, xfont); - xfont->in_cache = TRUE; - - if (fcfontmap->freed_fonts->length > MAX_FREED_FONTS) - { - GObject *old_font = g_queue_pop_tail (fcfontmap->freed_fonts); - g_object_unref (old_font); - } + g_object_unref (patterns->fontset); } static void -pango_fc_font_map_cache_remove (PangoFontMap *fontmap, - PangoFcFont *xfont) +pango_fc_font_map_clear_fontset_cache (PangoFcFontMap *fcfontmap) { - PangoFcFontMap *fcfontmap = PANGO_FC_FONT_MAP (fontmap); - - GList *link = g_list_find (fcfontmap->freed_fonts->head, xfont); - if (link == fcfontmap->freed_fonts->tail) - { - fcfontmap->freed_fonts->tail = fcfontmap->freed_fonts->tail->prev; - if (fcfontmap->freed_fonts->tail) - fcfontmap->freed_fonts->tail->next = NULL; - } + GQueue *cache = fcfontmap->fontset_cache; - fcfontmap->freed_fonts->head = g_list_delete_link (fcfontmap->freed_fonts->head, link); - fcfontmap->freed_fonts->length--; - xfont->in_cache = FALSE; - - g_object_unref (G_OBJECT (xfont)); + g_list_foreach (cache->head, (GFunc)uncache_patterns, NULL); + g_list_free (cache->head); + cache->head = NULL; + cache->tail = NULL; + cache->length = 0; } static void -pango_fc_font_map_cache_clear (PangoFcFontMap *fcfontmap) +pango_fc_font_map_cache_clear (PangoFcFontMap *fcfontmap) { - g_list_foreach (fcfontmap->freed_fonts->head, (GFunc)g_object_unref, NULL); - g_list_free (fcfontmap->freed_fonts->head); - fcfontmap->freed_fonts->head = NULL; - fcfontmap->freed_fonts->tail = NULL; - fcfontmap->freed_fonts->length = 0; + /* Clear the fontset cache first, since any entries + * in the fontset_cache must also be in the pattern cache. + */ + pango_fc_font_map_clear_fontset_cache (fcfontmap); + pango_fc_clear_pattern_hashes (fcfontmap); } static void diff --git a/pango/pangoft2-fontmap.c b/pango/pangoft2-fontmap.c index bcbdf438..a44b397d 100644 --- a/pango/pangoft2-fontmap.c +++ b/pango/pangoft2-fontmap.c @@ -62,7 +62,8 @@ struct _PangoFT2FontMap GHashTable *coverage_hash; /* Maps font file name -> PangoCoverage */ GHashTable *fonts; /* Maps XftPattern -> PangoFT2Font */ - GQueue *freed_fonts; /* Fonts in fonts that has been freed */ + + GQueue *fontset_cache; /* Recently used fontsets */ /* List of all families availible */ PangoFT2Family **families; @@ -95,8 +96,6 @@ struct _PangoFT2FontMap #define pango_fc_font_map_get_type pango_ft2_font_map_get_type #define _pango_fc_font_map_add _pango_ft2_font_map_add #define _pango_fc_font_map_remove _pango_ft2_font_map_remove -#define _pango_fc_font_map_cache_add _pango_ft2_font_map_cache_add -#define _pango_fc_font_map_cache_remove _pango_ft2_font_map_cache_remove #define _pango_fc_font_map_get_coverage _pango_ft2_font_map_get_coverage #define _pango_fc_font_map_set_coverage _pango_ft2_font_map_set_coverage #define _pango_fc_font_desc_from_pattern _pango_ft2_font_desc_from_pattern @@ -187,7 +186,7 @@ pango_ft2_font_map_set_default_substitute (PangoFT2FontMap *fontmap, fontmap->substitute_data = data; fontmap->substitute_destroy = notify; - pango_fc_clear_fontset_hash_list (fontmap); + pango_fc_font_map_cache_clear (fontmap); } /** @@ -205,7 +204,7 @@ pango_ft2_font_map_set_default_substitute (PangoFT2FontMap *fontmap, void pango_ft2_font_map_substitute_changed (PangoFT2FontMap *fontmap) { - pango_fc_clear_fontset_hash_list (fontmap); + pango_fc_font_map_cache_clear (fontmap); } /** diff --git a/pango/pangoft2-private.h b/pango/pangoft2-private.h index d8d20eae..9b506061 100644 --- a/pango/pangoft2-private.h +++ b/pango/pangoft2-private.h @@ -72,10 +72,6 @@ struct _PangoFT2Font GSList *metrics_by_lang; - /* If TRUE, font is in cache of recently unused fonts and not otherwise - * in use. */ - gboolean in_cache; - GHashTable *glyph_info; GDestroyNotify glyph_cache_destroy; }; @@ -93,10 +89,6 @@ PangoMap *_pango_ft2_get_shaper_map (PangoLanguage *language); PangoCoverage *_pango_ft2_font_map_get_coverage (PangoFontMap *fontmap, FcPattern *pattern); FT_Library _pango_ft2_font_map_get_library (PangoFontMap *fontmap); -void _pango_ft2_font_map_cache_add (PangoFontMap *fontmap, - PangoFT2Font *ft2font); -void _pango_ft2_font_map_cache_remove (PangoFontMap *fontmap, - PangoFT2Font *ft2font); void _pango_ft2_font_map_add (PangoFontMap *fontmap, PangoFT2Font *ft2font); void _pango_ft2_font_map_remove (PangoFontMap *fontmap, diff --git a/pango/pangoft2.c b/pango/pangoft2.c index 72f4cd1c..7428bb1a 100644 --- a/pango/pangoft2.c +++ b/pango/pangoft2.c @@ -66,7 +66,6 @@ static PangoFontClass *parent_class; /* Parent class structure for PangoFT2Font static void pango_ft2_font_class_init (PangoFT2FontClass *class); static void pango_ft2_font_init (PangoFT2Font *ft2font); -static void pango_ft2_font_dispose (GObject *object); static void pango_ft2_font_finalize (GObject *object); static PangoFontDescription *pango_ft2_font_describe (PangoFont *font); @@ -315,7 +314,6 @@ pango_ft2_font_class_init (PangoFT2FontClass *class) parent_class = g_type_class_peek_parent (class); object_class->finalize = pango_ft2_font_finalize; - object_class->dispose = pango_ft2_font_dispose; font_class->describe = pango_ft2_font_describe; font_class->get_coverage = pango_ft2_font_get_coverage; @@ -668,22 +666,6 @@ pango_ft2_font_get_metrics (PangoFont *font, return pango_font_metrics_ref (info->metrics); } -static void -pango_ft2_font_dispose (GObject *object) -{ - PangoFT2Font *ft2font = PANGO_FT2_FONT (object); - - /* If the font is not already in the freed-fonts cache, add it, - * if it is already there, do nothing and the font will be - * freed. - */ - if (!ft2font->in_cache && ft2font->fontmap) - _pango_ft2_font_map_cache_add (ft2font->fontmap, ft2font); - - G_OBJECT_CLASS (parent_class)->dispose (object); -} - - static gboolean pango_ft2_free_glyph_info_callback (gpointer key, gpointer value, gpointer data) { diff --git a/pango/pangoxft-font.c b/pango/pangoxft-font.c index addc27e4..262cbb05 100644 --- a/pango/pangoxft-font.c +++ b/pango/pangoxft-font.c @@ -53,7 +53,6 @@ static PangoFontClass *parent_class; /* Parent class structure for PangoXftFont static void pango_xft_font_class_init (PangoXftFontClass *class); static void pango_xft_font_init (PangoXftFont *xfont); -static void pango_xft_font_dispose (GObject *object); static void pango_xft_font_finalize (GObject *object); static PangoFontDescription *pango_xft_font_describe (PangoFont *font); @@ -103,7 +102,6 @@ static void pango_xft_font_init (PangoXftFont *xfont) { xfont->metrics_by_lang = NULL; - xfont->in_cache = FALSE; } static void @@ -115,7 +113,6 @@ pango_xft_font_class_init (PangoXftFontClass *class) parent_class = g_type_class_peek_parent (class); object_class->finalize = pango_xft_font_finalize; - object_class->dispose = pango_xft_font_dispose; font_class->describe = pango_xft_font_describe; font_class->get_coverage = pango_xft_font_get_coverage; @@ -495,21 +492,6 @@ pango_xft_font_get_metrics (PangoFont *font, } static void -pango_xft_font_dispose (GObject *object) -{ - PangoXftFont *xfont = PANGO_XFT_FONT (object); - - /* If the font is not already in the freed-fonts cache, add it, - * if it is already there, do nothing and the font will be - * freed. - */ - if (!xfont->in_cache && xfont->fontmap) - _pango_xft_font_map_cache_add (xfont->fontmap, xfont); - - G_OBJECT_CLASS (parent_class)->dispose (object); -} - -static void free_metrics_info (PangoXftMetricsInfo *info) { pango_font_metrics_unref (info->metrics); diff --git a/pango/pangoxft-fontmap.c b/pango/pangoxft-fontmap.c index 8b2030de..c7b16995 100644 --- a/pango/pangoxft-fontmap.c +++ b/pango/pangoxft-fontmap.c @@ -52,7 +52,8 @@ struct _PangoXftFontMap GHashTable *coverage_hash; /* Maps font file name/id -> PangoCoverage */ GHashTable *fonts; /* Maps XftPattern -> PangoXftFont */ - GQueue *freed_fonts; /* Fonts in fonts that has been freed */ + + GQueue *fontset_cache; /* Recently used fontsets */ /* List of all families availible */ PangoXftFamily **families; @@ -84,8 +85,6 @@ struct _PangoXftFontMap #define pango_fc_font_map_get_type pango_xft_font_map_get_type #define _pango_fc_font_map_add _pango_xft_font_map_add #define _pango_fc_font_map_remove _pango_xft_font_map_remove -#define _pango_fc_font_map_cache_add _pango_xft_font_map_cache_add -#define _pango_fc_font_map_cache_remove _pango_xft_font_map_cache_remove #define _pango_fc_font_map_get_coverage _pango_xft_font_map_get_coverage #define _pango_fc_font_map_set_coverage _pango_xft_font_map_set_coverage #define _pango_fc_font_desc_from_pattern _pango_xft_font_desc_from_pattern @@ -293,7 +292,7 @@ pango_xft_set_default_substitute (Display *display, xftfontmap->substitute_data = data; xftfontmap->substitute_destroy = notify; - pango_fc_clear_fontset_hash_list (xftfontmap); + pango_fc_font_map_cache_clear (xftfontmap); } /** @@ -315,7 +314,7 @@ pango_xft_substitute_changed (Display *display, { PangoXftFontMap *xftfontmap = (PangoXftFontMap *)pango_xft_get_font_map (display, screen); - pango_fc_clear_fontset_hash_list (xftfontmap); + pango_fc_font_map_cache_clear (xftfontmap); } void diff --git a/pango/pangoxft-private.h b/pango/pangoxft-private.h index 194c4f2b..787caff5 100644 --- a/pango/pangoxft-private.h +++ b/pango/pangoxft-private.h @@ -44,14 +44,10 @@ struct _PangoXftFont guint16 mini_width; /* metrics for missing glyph drawing */ guint16 mini_height; guint16 mini_pad; - - gboolean in_cache; }; PangoXftFont * _pango_xft_font_new (PangoFontMap *font, FcPattern *pattern); -void _pango_xft_font_map_cache_add (PangoFontMap *fontmap, - PangoXftFont *xfont); void _pango_xft_font_map_add (PangoFontMap *fontmap, PangoXftFont *xfont); void _pango_xft_font_map_remove (PangoFontMap *fontmap, diff --git a/tests/Makefile.am b/tests/Makefile.am index 4571afb4..513e46b0 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -35,7 +35,8 @@ INCLUDES = \ $(XFT_DEFINES) \ $(FT2_DEFINES) \ $(WIN32_DEFINES) \ - -DG_DISABLE_DEPRECATED + -DG_DISABLE_DEPRECATED \ + $(PANGO_DEBUG_FLAGS) TESTS=runtests.sh |