mirror of
https://github.com/brl/mutter.git
synced 2025-07-10 04:34:31 +00:00
[cogl-handle] Optimize how we define cogl handles
The cogl_is_* functions were showing up quite high on profiles due to iterating through arrays of cogl handles. This does away with all the handle arrays and implements a simple struct inheritance scheme. All cogl objects now add a CoglHandleObject _parent; member to their main structures. The base object includes 2 members a.t.m; a ref_count, and a klass pointer. The klass in turn gives you a type and virtual function for freeing objects of that type. Each handle type has a _cogl_##handle_type##_get_type () function automatically defined which returns a GQuark of the handle type, so now implementing the cogl_is_* funcs is just a case of comparing with obj->klass->type. Another outcome of the re-work is that cogl_handle_{ref,unref} are also much more efficient, and no longer need extending for each handle type added to cogl. The cogl_##handle_type##_{ref,unref} functions are now deprecated and are no longer used internally to Clutter or Cogl. Potentially we can remove them completely before 1.0.
This commit is contained in:
@ -108,7 +108,7 @@ struct _CoglPangoGlyphCacheBand
|
||||
static void
|
||||
cogl_pango_glyph_cache_value_free (CoglPangoGlyphCacheValue *value)
|
||||
{
|
||||
cogl_texture_unref (value->texture);
|
||||
cogl_handle_unref (value->texture);
|
||||
g_slice_free (CoglPangoGlyphCacheValue, value);
|
||||
}
|
||||
|
||||
@ -156,7 +156,7 @@ cogl_pango_glyph_cache_free_textures (CoglPangoGlyphCacheTexture *node)
|
||||
while (node)
|
||||
{
|
||||
next = node->next;
|
||||
cogl_texture_unref (node->texture);
|
||||
cogl_handle_unref (node->texture);
|
||||
g_slice_free (CoglPangoGlyphCacheTexture, node);
|
||||
node = next;
|
||||
}
|
||||
@ -170,7 +170,7 @@ cogl_pango_glyph_cache_free_bands (CoglPangoGlyphCacheBand *node)
|
||||
while (node)
|
||||
{
|
||||
next = node->next;
|
||||
cogl_texture_unref (node->texture);
|
||||
cogl_handle_unref (node->texture);
|
||||
g_slice_free (CoglPangoGlyphCacheBand, node);
|
||||
node = next;
|
||||
}
|
||||
@ -323,7 +323,7 @@ cogl_pango_glyph_cache_set (CoglPangoGlyphCache *cache,
|
||||
band->top = texture->texture_size - texture->space_remaining;
|
||||
band->height = band_height;
|
||||
band->space_remaining = texture->texture_size;
|
||||
band->texture = cogl_texture_ref (texture->texture);
|
||||
band->texture = cogl_handle_ref (texture->texture);
|
||||
band->texture_size = texture->texture_size;
|
||||
band->next = cache->bands;
|
||||
cache->bands = band;
|
||||
@ -350,7 +350,7 @@ cogl_pango_glyph_cache_set (CoglPangoGlyphCache *cache,
|
||||
key->glyph = glyph;
|
||||
|
||||
value = g_slice_new (CoglPangoGlyphCacheValue);
|
||||
value->texture = cogl_texture_ref (band->texture);
|
||||
value->texture = cogl_handle_ref (band->texture);
|
||||
value->tx1 = (float)(band->space_remaining)
|
||||
/ band->texture_size;
|
||||
value->tx2 = (float)(band->space_remaining + width)
|
||||
|
Reference in New Issue
Block a user