diff options
author | Robert Bragg <robert@linux.intel.com> | 2012-11-09 10:54:32 +0000 |
---|---|---|
committer | Robert Bragg <robert@linux.intel.com> | 2013-01-22 17:48:09 +0000 |
commit | fa5a9c88fe76069373c00f2caf286813196ef3ea (patch) | |
tree | d23f3904af0f94596151e077592d4bcbbef4efbc /cogl-pango | |
parent | 579db9083de35387544a15ecc8f35f54a084f4cf (diff) | |
download | mutter-fa5a9c88fe76069373c00f2caf286813196ef3ea.tar.gz |
atlas-texture: remove some use of _COGL_GET_CONTEXT
This removes several uses of _COGL_GET_CONTEXT in cogl-atlas-texture.c.
Notably this involved making CoglPangoGlyphCache track an associated
CoglContext pointer which cogl-pango can pass to
_cogl_atlas_texture_new_with_size().
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit d66afbd0758539330490945c699a05c0749c76aa)
Diffstat (limited to 'cogl-pango')
-rw-r--r-- | cogl-pango/cogl-pango-glyph-cache.c | 22 | ||||
-rw-r--r-- | cogl-pango/cogl-pango-glyph-cache.h | 3 | ||||
-rw-r--r-- | cogl-pango/cogl-pango-render.c | 6 |
3 files changed, 23 insertions, 8 deletions
diff --git a/cogl-pango/cogl-pango-glyph-cache.c b/cogl-pango/cogl-pango-glyph-cache.c index a46bfd984..14c8295a7 100644 --- a/cogl-pango/cogl-pango-glyph-cache.c +++ b/cogl-pango/cogl-pango-glyph-cache.c @@ -36,6 +36,8 @@ typedef struct _CoglPangoGlyphCacheKey CoglPangoGlyphCacheKey; struct _CoglPangoGlyphCache { + CoglContext *ctx; + /* Hash table to quickly check whether a particular glyph in a particular font is already cached */ GHashTable *hash_table; @@ -111,12 +113,17 @@ cogl_pango_glyph_cache_equal_func (const void *a, const void *b) } CoglPangoGlyphCache * -cogl_pango_glyph_cache_new (CoglBool use_mipmapping) +cogl_pango_glyph_cache_new (CoglContext *ctx, + CoglBool use_mipmapping) { CoglPangoGlyphCache *cache; cache = g_malloc (sizeof (CoglPangoGlyphCache)); + /* Note: as a rule we don't take references to a CoglContext + * internally since */ + cache->ctx = ctx; + cache->hash_table = g_hash_table_new_full (cogl_pango_glyph_cache_hash_func, cogl_pango_glyph_cache_equal_func, @@ -158,8 +165,11 @@ 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_atlas_texture_remove_reorganize_callback ( + cache->ctx, + cogl_pango_glyph_cache_reorganize_cb, cache); + } cogl_pango_glyph_cache_clear (cache); @@ -213,7 +223,8 @@ cogl_pango_glyph_cache_add_to_global_atlas (CoglPangoGlyphCache *cache, if (cache->use_mipmapping) return FALSE; - texture = _cogl_atlas_texture_new_with_size (value->draw_width, + texture = _cogl_atlas_texture_new_with_size (cache->ctx, + value->draw_width, value->draw_height, COGL_TEXTURE_NONE, COGL_PIXEL_FORMAT_RGBA_8888_PRE); @@ -236,7 +247,8 @@ cogl_pango_glyph_cache_add_to_global_atlas (CoglPangoGlyphCache *cache, if (!cache->using_global_atlas) { _cogl_atlas_texture_add_reorganize_callback - (cogl_pango_glyph_cache_reorganize_cb, cache); + (cache->ctx, + cogl_pango_glyph_cache_reorganize_cb, cache); cache->using_global_atlas = TRUE; } diff --git a/cogl-pango/cogl-pango-glyph-cache.h b/cogl-pango/cogl-pango-glyph-cache.h index 5ab057218..fc25a7197 100644 --- a/cogl-pango/cogl-pango-glyph-cache.h +++ b/cogl-pango/cogl-pango-glyph-cache.h @@ -60,7 +60,8 @@ typedef void (* CoglPangoGlyphCacheDirtyFunc) (PangoFont *font, CoglPangoGlyphCacheValue *value); CoglPangoGlyphCache * -cogl_pango_glyph_cache_new (CoglBool use_mipmapping); +cogl_pango_glyph_cache_new (CoglContext *ctx, + CoglBool use_mipmapping); void cogl_pango_glyph_cache_free (CoglPangoGlyphCache *cache); diff --git a/cogl-pango/cogl-pango-render.c b/cogl-pango/cogl-pango-render.c index 6c63ee64b..a5abaa646 100644 --- a/cogl-pango/cogl-pango-render.c +++ b/cogl-pango/cogl-pango-render.c @@ -214,8 +214,10 @@ _cogl_pango_renderer_constructed (GObject *gobject) renderer->mipmap_caches.pipeline_cache = _cogl_pango_pipeline_cache_new (ctx, TRUE); - renderer->no_mipmap_caches.glyph_cache = cogl_pango_glyph_cache_new (FALSE); - renderer->mipmap_caches.glyph_cache = cogl_pango_glyph_cache_new (TRUE); + renderer->no_mipmap_caches.glyph_cache = + cogl_pango_glyph_cache_new (ctx, FALSE); + renderer->mipmap_caches.glyph_cache = + cogl_pango_glyph_cache_new (ctx, TRUE); _cogl_pango_renderer_set_use_mipmapping (renderer, FALSE); |