[clutter/wip/pango-share-atlas: 5/13] cogl-atlas-texture: Add a callback for when any atlas reorganizes
- From: Neil Roberts <nroberts src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter/wip/pango-share-atlas: 5/13] cogl-atlas-texture: Add a callback for when any atlas reorganizes
- Date: Wed, 30 Mar 2011 16:05:07 +0000 (UTC)
commit eb2b4f132392193aa62385313ffda4a508e2aaa7
Author: Neil Roberts <neil linux intel com>
Date: Wed Mar 30 12:53:50 2011 +0100
cogl-atlas-texture: Add a callback for when any atlas reorganizes
This adds cogl_atlas_texture_* functions to register a callback that
will get invoked whenever any of the CoglAtlas's the textures use get
reorganized. The callback is global and is not tied to any particular
atlas texture.
clutter/cogl/cogl/cogl-atlas-texture-private.h | 8 +++++
clutter/cogl/cogl/cogl-atlas-texture.c | 36 ++++++++++++++++++++++++
clutter/cogl/cogl/cogl-context.c | 2 +
clutter/cogl/cogl/cogl-context.h | 1 +
4 files changed, 47 insertions(+), 0 deletions(-)
---
diff --git a/clutter/cogl/cogl/cogl-atlas-texture-private.h b/clutter/cogl/cogl/cogl-atlas-texture-private.h
index 49d933c..b7f7b03 100644
--- a/clutter/cogl/cogl/cogl-atlas-texture-private.h
+++ b/clutter/cogl/cogl/cogl-atlas-texture-private.h
@@ -69,4 +69,12 @@ _cogl_atlas_texture_new_with_size (unsigned int width,
CoglTextureFlags flags,
CoglPixelFormat internal_format);
+void
+_cogl_atlas_texture_add_reorganize_callback (GHookFunc callback,
+ void *user_data);
+
+void
+_cogl_atlas_texture_remove_reorganize_callback (GHookFunc callback,
+ void *user_data);
+
#endif /* __COGL_ATLAS_TEXTURE_H */
diff --git a/clutter/cogl/cogl/cogl-atlas-texture.c b/clutter/cogl/cogl/cogl-atlas-texture.c
index 280fb8d..678b309 100644
--- a/clutter/cogl/cogl/cogl-atlas-texture.c
+++ b/clutter/cogl/cogl/cogl-atlas-texture.c
@@ -142,6 +142,8 @@ _cogl_atlas_texture_post_reorganize_cb (void *user_data)
{
CoglAtlas *atlas = user_data;
+ _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+
if (atlas->map)
{
CoglAtlasTextureGetRectanglesData data;
@@ -171,6 +173,9 @@ _cogl_atlas_texture_post_reorganize_cb (void *user_data)
g_free (data.textures);
}
+
+ /* Notify any listeners that an atlas has changed */
+ g_hook_list_invoke (&ctx->atlas_reorganize_callbacks, FALSE);
}
static void
@@ -746,6 +751,37 @@ _cogl_atlas_texture_new_from_bitmap (CoglBitmap *bmp,
return atlas_tex_handle;
}
+void
+_cogl_atlas_texture_add_reorganize_callback (GHookFunc callback,
+ void *user_data)
+{
+ GHook *hook;
+
+ _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+
+ hook = g_hook_alloc (&ctx->atlas_reorganize_callbacks);
+ hook->func = callback;
+ hook->data = user_data;
+ g_hook_prepend (&ctx->atlas_reorganize_callbacks, hook);
+}
+
+void
+_cogl_atlas_texture_remove_reorganize_callback (GHookFunc callback,
+ void *user_data)
+{
+ GHook *hook;
+
+ _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+
+ hook = g_hook_find_func_data (&ctx->atlas_reorganize_callbacks,
+ FALSE,
+ callback,
+ user_data);
+
+ if (hook)
+ g_hook_destroy_link (&ctx->atlas_reorganize_callbacks, hook);
+}
+
static const CoglTextureVtable
cogl_atlas_texture_vtable =
{
diff --git a/clutter/cogl/cogl/cogl-context.c b/clutter/cogl/cogl/cogl-context.c
index 115fc5c..984eb91 100644
--- a/clutter/cogl/cogl/cogl-context.c
+++ b/clutter/cogl/cogl/cogl-context.c
@@ -287,6 +287,7 @@ cogl_create_context (void)
_cogl_flush_face_winding ();
_context->atlases = NULL;
+ g_hook_list_init (&_context->atlas_reorganize_callbacks, sizeof (GHook));
_context->buffer_map_fallback_array = g_byte_array_new ();
_context->buffer_map_fallback_in_use = FALSE;
@@ -369,6 +370,7 @@ _cogl_destroy_context (void)
_cogl_clip_stack_unref (_context->current_clip_stack);
g_slist_free (_context->atlases);
+ g_hook_list_clear (&_context->atlas_reorganize_callbacks);
_cogl_bitmask_destroy (&_context->arrays_enabled);
_cogl_bitmask_destroy (&_context->temp_bitmask);
diff --git a/clutter/cogl/cogl/cogl-context.h b/clutter/cogl/cogl/cogl-context.h
index eead5dc..5bf157e 100644
--- a/clutter/cogl/cogl/cogl-context.h
+++ b/clutter/cogl/cogl/cogl-context.h
@@ -178,6 +178,7 @@ typedef struct
CoglPipeline *blit_texture_pipeline;
GSList *atlases;
+ GHookList atlas_reorganize_callbacks;
/* This debugging variable is used to pick a colour for visually
displaying the quad batches. It needs to be global so that it can
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]