diff --git a/clutter/cogl/cogl/cogl-atlas.c b/clutter/cogl/cogl/cogl-atlas.c index 7b0c9931e..4a10db136 100644 --- a/clutter/cogl/cogl/cogl-atlas.c +++ b/clutter/cogl/cogl/cogl-atlas.c @@ -63,6 +63,10 @@ #define GL_FRAMEBUFFER_COMPLETE 0x8CD5 #endif +static void _cogl_atlas_free (CoglAtlas *atlas); + +COGL_OBJECT_INTERNAL_DEFINE (Atlas, atlas); + /* If we want to do mulitple blits from a texture (such as when reorganizing the atlas) then it's quicker to download all of the data once and upload multiple times from that. This struct is used @@ -209,12 +213,14 @@ _cogl_atlas_new (CoglPixelFormat texture_format, atlas->texture_format = texture_format; _cogl_callback_list_init (&atlas->reorganize_callbacks); - return atlas; + return _cogl_atlas_object_new (atlas); } -void +static void _cogl_atlas_free (CoglAtlas *atlas) { + COGL_NOTE (ATLAS, "%p: Atlas destroyed", atlas); + if (atlas->texture) cogl_handle_unref (atlas->texture); if (atlas->map) diff --git a/clutter/cogl/cogl/cogl-atlas.h b/clutter/cogl/cogl/cogl-atlas.h index 42d383e1f..dbe7eb9f7 100644 --- a/clutter/cogl/cogl/cogl-atlas.h +++ b/clutter/cogl/cogl/cogl-atlas.h @@ -26,6 +26,7 @@ #include "cogl-rectangle-map.h" #include "cogl-callback-list.h" +#include "cogl-object-private.h" typedef void (* CoglAtlasUpdatePositionCallback) (void *user_data, @@ -40,8 +41,12 @@ typedef enum typedef struct _CoglAtlas CoglAtlas; +#define COGL_ATLAS(object) ((CoglAtlas *) object) + struct _CoglAtlas { + CoglObject _parent; + CoglRectangleMap *map; CoglHandle texture; @@ -68,9 +73,6 @@ void _cogl_atlas_remove (CoglAtlas *atlas, const CoglRectangleMapEntry *rectangle); -void -_cogl_atlas_free (CoglAtlas *atlas); - CoglHandle _cogl_atlas_copy_rectangle (CoglAtlas *atlas, unsigned int x, diff --git a/clutter/cogl/cogl/cogl-context.c b/clutter/cogl/cogl/cogl-context.c index 12cbc48a2..f94f8b713 100644 --- a/clutter/cogl/cogl/cogl-context.c +++ b/clutter/cogl/cogl/cogl-context.c @@ -363,7 +363,7 @@ _cogl_destroy_context (void) _cogl_clip_stack_unref (_context->current_clip_stack); if (_context->atlas) - _cogl_atlas_free (_context->atlas); + cogl_object_unref (_context->atlas); _cogl_bitmask_destroy (&_context->arrays_enabled); _cogl_bitmask_destroy (&_context->temp_bitmask); diff --git a/clutter/cogl/pango/cogl-pango-glyph-cache.c b/clutter/cogl/pango/cogl-pango-glyph-cache.c index 0bd81a1a9..1851b237c 100644 --- a/clutter/cogl/pango/cogl-pango-glyph-cache.c +++ b/clutter/cogl/pango/cogl-pango-glyph-cache.c @@ -125,7 +125,7 @@ cogl_pango_glyph_cache_new (void) void cogl_pango_glyph_cache_clear (CoglPangoGlyphCache *cache) { - g_slist_foreach (cache->atlases, (GFunc) _cogl_atlas_free, NULL); + g_slist_foreach (cache->atlases, (GFunc) cogl_object_unref, NULL); g_slist_free (cache->atlases); cache->atlases = NULL; cache->has_dirty_glyphs = FALSE; @@ -234,7 +234,7 @@ cogl_pango_glyph_cache_lookup (CoglPangoGlyphCache *cache, ink_rect.width + 1, ink_rect.height + 1, value)) { - _cogl_atlas_free (atlas); + cogl_object_unref (atlas); cogl_pango_glyph_cache_value_free (value); return NULL; }