1
0
Fork 0

cogl-atlas: Convert to be a CoglObject subclass

To implement multiple atlases it will be useful to have ref-counting
on the CoglAtlas so it makes sense to convert it to be a CoglObject.
This commit is contained in:
Neil Roberts 2010-11-27 13:06:38 +00:00
parent 03d33a6f4d
commit 0f0f763570
4 changed files with 16 additions and 8 deletions

View file

@ -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)

View file

@ -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,

View file

@ -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);

View file

@ -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;
}