[clutter/wip/pango-share-atlas: 6/14] cogl-pango-glyph-cache: Notify of reorg for global atlased glyphs
- From: Neil Roberts <nroberts src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter/wip/pango-share-atlas: 6/14] cogl-pango-glyph-cache: Notify of reorg for global atlased glyphs
- Date: Thu, 5 May 2011 15:40:24 +0000 (UTC)
commit d0a615e17b0aa32f20cc7c1d4e0ab97193f85195
Author: Neil Roberts <neil linux intel com>
Date: Wed Mar 30 12:56:09 2011 +0100
cogl-pango-glyph-cache: Notify of reorg for global atlased glyphs
Whenever the glyph cache puts a glyph in the global atlas it will now
register for notifications of reorganisation of the global
atlases. When this happens it will forward this on as a notification
of reorganisation of the glyph cache.
clutter/cogl/pango/cogl-pango-glyph-cache.c | 36 +++++++++++++++++++++------
1 files changed, 28 insertions(+), 8 deletions(-)
---
diff --git a/clutter/cogl/pango/cogl-pango-glyph-cache.c b/clutter/cogl/pango/cogl-pango-glyph-cache.c
index 62be873..b1fbd92 100644
--- a/clutter/cogl/pango/cogl-pango-glyph-cache.c
+++ b/clutter/cogl/pango/cogl-pango-glyph-cache.c
@@ -46,6 +46,11 @@ struct _CoglPangoGlyphCache
/* List of callbacks to invoke when an atlas is reorganized */
GHookList reorganize_callbacks;
+ /* TRUE if we've ever stored a texture in the global atlas. This is
+ used to make sure we only register one callback to listen for
+ global atlas reorganizations */
+ gboolean using_global_atlas;
+
/* True if some of the glyphs are dirty. This is used as an
optimization in _cogl_pango_glyph_cache_set_dirty_glyphs to avoid
iterating the hash table if we know none of them are dirty */
@@ -128,6 +133,14 @@ cogl_pango_glyph_cache_new (gboolean use_mipmapping)
return cache;
}
+static void
+cogl_pango_glyph_cache_reorganize_cb (void *user_data)
+{
+ CoglPangoGlyphCache *cache = user_data;
+
+ g_hook_list_invoke (&cache->reorganize_callbacks, FALSE);
+}
+
void
cogl_pango_glyph_cache_clear (CoglPangoGlyphCache *cache)
{
@@ -142,6 +155,10 @@ cogl_pango_glyph_cache_clear (CoglPangoGlyphCache *cache)
void
cogl_pango_glyph_cache_free (CoglPangoGlyphCache *cache)
{
+ if (cache->using_global_atlas)
+ _cogl_atlas_texture_remove_reorganize_callback
+ (cogl_pango_glyph_cache_reorganize_cb, cache);
+
cogl_pango_glyph_cache_clear (cache);
g_hash_table_unref (cache->hash_table);
@@ -178,14 +195,6 @@ cogl_pango_glyph_cache_update_position_cb (void *user_data,
value->dirty = TRUE;
}
-static void
-cogl_pango_glyph_cache_reorganize_cb (void *user_data)
-{
- CoglPangoGlyphCache *cache = user_data;
-
- g_hook_list_invoke (&cache->reorganize_callbacks, FALSE);
-}
-
static gboolean
cogl_pango_glyph_cache_add_to_global_atlas (CoglPangoGlyphCache *cache,
PangoFont *font,
@@ -215,6 +224,17 @@ cogl_pango_glyph_cache_add_to_global_atlas (CoglPangoGlyphCache *cache,
value->tx_pixel = 0;
value->ty_pixel = 0;
+ /* The first time we store a texture in the global atlas we'll
+ register for notifications when the global atlas is reorganized
+ so we can forward the notification on as a glyph
+ reorganization */
+ if (!cache->using_global_atlas)
+ {
+ _cogl_atlas_texture_add_reorganize_callback
+ (cogl_pango_glyph_cache_reorganize_cb, cache);
+ cache->using_global_atlas = TRUE;
+ }
+
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]