diff --git a/cogl/cogl-atlas-texture-private.h b/cogl/cogl-atlas-texture-private.h index b7f7b035b..541cd3db6 100644 --- a/cogl/cogl-atlas-texture-private.h +++ b/cogl/cogl-atlas-texture-private.h @@ -55,9 +55,6 @@ struct _CoglAtlasTexture CoglHandle sub_texture; }; -GQuark -_cogl_handle_atlas_texture_get_type (void); - CoglHandle _cogl_atlas_texture_new_from_bitmap (CoglBitmap *bmp, CoglTextureFlags flags, diff --git a/cogl/cogl-buffer-private.h b/cogl/cogl-buffer-private.h index ed324f946..93c1c065b 100644 --- a/cogl/cogl-buffer-private.h +++ b/cogl/cogl-buffer-private.h @@ -102,13 +102,12 @@ struct _CoglBuffer /* This is used to register a type to the list of handle types that will be considered a texture in cogl_is_texture() */ void -_cogl_buffer_register_buffer_type (GQuark type); +_cogl_buffer_register_buffer_type (const CoglObjectClass *klass); #define COGL_BUFFER_DEFINE(TypeName, type_name) \ COGL_OBJECT_DEFINE_WITH_CODE \ (TypeName, type_name, \ - _cogl_buffer_register_buffer_type (_cogl_object_ \ - ## type_name ## _get_type ())) + _cogl_buffer_register_buffer_type (&_cogl_##type_name##_class)) void _cogl_buffer_initialize (CoglBuffer *buffer, diff --git a/cogl/cogl-buffer.c b/cogl/cogl-buffer.c index cb7d0a044..9b7f6766b 100644 --- a/cogl/cogl-buffer.c +++ b/cogl/cogl-buffer.c @@ -78,12 +78,11 @@ */ void -_cogl_buffer_register_buffer_type (GQuark type) +_cogl_buffer_register_buffer_type (const CoglObjectClass *klass) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); - ctx->buffer_types = g_slist_prepend (ctx->buffer_types, - GINT_TO_POINTER (type)); + ctx->buffer_types = g_slist_prepend (ctx->buffer_types, (void *) klass); } gboolean @@ -98,7 +97,7 @@ cogl_is_buffer (const void *object) return FALSE; for (l = ctx->buffer_types; l; l = l->next) - if (GPOINTER_TO_INT (l->data) == obj->klass->type) + if (l->data == obj->klass) return TRUE; return FALSE; diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c index 829b5c2a5..2e63681a7 100644 --- a/cogl/cogl-framebuffer.c +++ b/cogl/cogl-framebuffer.c @@ -109,7 +109,7 @@ typedef struct _CoglFramebufferStackEntry CoglFramebuffer *read_buffer; } CoglFramebufferStackEntry; -extern GQuark _cogl_object_onscreen_get_type (void); +extern CoglObjectClass _cogl_onscreen_class; static void _cogl_offscreen_free (CoglOffscreen *offscreen); @@ -136,8 +136,8 @@ _cogl_is_framebuffer (void *object) if (obj == NULL) return FALSE; - return obj->klass->type == _cogl_object_onscreen_get_type () - || obj->klass->type == _cogl_object_offscreen_get_type (); + return (obj->klass == &_cogl_onscreen_class || + obj->klass == &_cogl_offscreen_class); } void diff --git a/cogl/cogl-object-private.h b/cogl/cogl-object-private.h index 52fa9561c..d33558986 100644 --- a/cogl/cogl-object-private.h +++ b/cogl/cogl-object-private.h @@ -51,8 +51,8 @@ typedef void (*CoglUserDataDestroyInternalCallback) (void *user_data, typedef struct _CoglObjectClass { - GQuark type; - void *virt_free; + const char *name; + void *virt_free; } CoglObjectClass; #define COGL_OBJECT_N_PRE_ALLOCATED_USER_DATA_ENTRIES 2 @@ -95,18 +95,18 @@ struct _CoglObject #define _COGL_OBJECT_DEBUG_REF(type_name, object) G_STMT_START { \ CoglObject *__obj = (CoglObject *)object; \ COGL_NOTE (HANDLE, "COGL %s REF %p %i", \ - g_quark_to_string ((__obj)->klass->type), \ + (__obj)->klass->name, \ (__obj), (__obj)->ref_count); } G_STMT_END #define _COGL_OBJECT_DEBUG_UNREF(type_name, object) G_STMT_START { \ CoglObject *__obj = (CoglObject *)object; \ COGL_NOTE (HANDLE, "COGL %s UNREF %p %i", \ - g_quark_to_string ((__obj)->klass->type), \ + (__obj)->klass->name, \ (__obj), (__obj)->ref_count - 1); } G_STMT_END #define COGL_OBJECT_DEBUG_FREE(obj) \ COGL_NOTE (HANDLE, "COGL %s FREE %p", \ - g_quark_to_string ((obj)->klass->type), (obj)) + (obj)->klass->name, (obj)) #else /* !COGL_OBJECT_DEBUG */ @@ -125,7 +125,7 @@ struct _CoglObject #define COGL_OBJECT_COMMON_DEFINE_WITH_CODE(TypeName, type_name, code) \ \ -static CoglObjectClass _cogl_##type_name##_class; \ +CoglObjectClass _cogl_##type_name##_class; \ static unsigned long _cogl_object_##type_name##_count; \ \ static inline void \ @@ -147,34 +147,6 @@ _cogl_object_##type_name##_indirect_free (CoglObject *obj) \ _cogl_object_##type_name##_dec (); \ } \ \ -GQuark \ -_cogl_object_##type_name##_get_type (void) \ -{ \ - static GQuark type = 0; \ - if (!type) \ - { \ - type = g_quark_from_static_string ("Cogl"#TypeName); \ - _cogl_object_##type_name##_count = 0; \ - \ - if (_cogl_debug_instances == NULL) \ - _cogl_debug_instances = \ - g_hash_table_new (g_str_hash, g_str_equal); \ - \ - g_hash_table_insert (_cogl_debug_instances, \ - "Cogl"#TypeName, \ - &_cogl_object_##type_name##_count); \ - \ - { code; } \ - } \ - return type; \ -} \ - \ -GQuark \ -_cogl_handle_##type_name##_get_type (void) \ -{ \ - return _cogl_object_##type_name##_get_type (); \ -} \ - \ static Cogl##TypeName * \ _cogl_##type_name##_object_new (Cogl##TypeName *new_obj) \ { \ @@ -185,11 +157,23 @@ _cogl_##type_name##_object_new (Cogl##TypeName *new_obj) \ obj->user_data_array = NULL; \ \ obj->klass = &_cogl_##type_name##_class; \ - if (!obj->klass->type) \ + if (!obj->klass->virt_free) \ { \ - obj->klass->type = _cogl_object_##type_name##_get_type (); \ + _cogl_object_##type_name##_count = 0; \ + \ + if (_cogl_debug_instances == NULL) \ + _cogl_debug_instances = \ + g_hash_table_new (g_str_hash, g_str_equal); \ + \ obj->klass->virt_free = \ _cogl_object_##type_name##_indirect_free; \ + obj->klass->name = "Cogl"#TypeName, \ + \ + g_hash_table_insert (_cogl_debug_instances, \ + (void *) obj->klass->name, \ + &_cogl_object_##type_name##_count); \ + \ + { code; } \ } \ \ _cogl_object_##type_name##_inc (); \ @@ -215,8 +199,7 @@ cogl_is_##type_name (void *object) \ if (object == NULL) \ return FALSE; \ \ - return (obj->klass->type == \ - _cogl_object_##type_name##_get_type ()); \ + return obj->klass == &_cogl_##type_name##_class; \ } #define COGL_OBJECT_INTERNAL_DEFINE_WITH_CODE(TypeName, type_name, code) \ @@ -231,8 +214,7 @@ _cogl_is_##type_name (void *object) \ if (object == NULL) \ return FALSE; \ \ - return (obj->klass->type == \ - _cogl_object_##type_name##_get_type ()); \ + return obj->klass == &_cogl_##type_name##_class; \ } #define COGL_OBJECT_DEFINE_DEPRECATED_REF_COUNTING(type_name) \ diff --git a/cogl/cogl-onscreen-private.h b/cogl/cogl-onscreen-private.h index be789a53d..25d2235bc 100644 --- a/cogl/cogl-onscreen-private.h +++ b/cogl/cogl-onscreen-private.h @@ -50,6 +50,7 @@ struct _CoglOnscreen void *winsys; }; + CoglOnscreen * _cogl_onscreen_new (void); @@ -57,7 +58,4 @@ void _cogl_framebuffer_winsys_update_size (CoglFramebuffer *framebuffer, int width, int height); -GQuark -_cogl_object_onscreen_get_type (void); - #endif /* __COGL_ONSCREEN_PRIVATE_H */ diff --git a/cogl/cogl-pixel-buffer-private.h b/cogl/cogl-pixel-buffer-private.h index bccfb4bb8..6d79870c6 100644 --- a/cogl/cogl-pixel-buffer-private.h +++ b/cogl/cogl-pixel-buffer-private.h @@ -47,9 +47,6 @@ struct _CoglPixelBuffer unsigned int stride; }; -GQuark -_cogl_handle_pixel_buffer_get_type (void); - G_END_DECLS #endif /* __COGL_PIXEL_BUFFER_PRIVATE_H__ */ diff --git a/cogl/cogl-sub-texture-private.h b/cogl/cogl-sub-texture-private.h index b3fb76150..3b66e3bdd 100644 --- a/cogl/cogl-sub-texture-private.h +++ b/cogl/cogl-sub-texture-private.h @@ -54,7 +54,4 @@ struct _CoglSubTexture int sub_height; }; -GQuark -_cogl_handle_sub_texture_get_type (void); - #endif /* __COGL_SUB_TEXTURE_PRIVATE_H */ diff --git a/cogl/cogl-texture-2d-private.h b/cogl/cogl-texture-2d-private.h index 97fee0745..701cec0c6 100644 --- a/cogl/cogl-texture-2d-private.h +++ b/cogl/cogl-texture-2d-private.h @@ -52,9 +52,6 @@ struct _CoglTexture2D CoglTexturePixel first_pixel; }; -GQuark -_cogl_handle_texture_2d_get_type (void); - CoglHandle _cogl_texture_2d_new_from_bitmap (CoglBitmap *bmp, CoglTextureFlags flags, diff --git a/cogl/cogl-texture-2d-sliced-private.h b/cogl/cogl-texture-2d-sliced-private.h index 1cd09fe41..0a388ee78 100644 --- a/cogl/cogl-texture-2d-sliced-private.h +++ b/cogl/cogl-texture-2d-sliced-private.h @@ -43,9 +43,6 @@ struct _CoglTexture2DSliced int height; }; -GQuark -_cogl_handle_texture_2d_sliced_get_type (void); - CoglTexture2DSliced * _cogl_texture_2d_sliced_new_from_foreign (GLuint gl_handle, GLenum gl_target, diff --git a/cogl/cogl-texture-3d-private.h b/cogl/cogl-texture-3d-private.h index 7fa29ae89..b6c992350 100644 --- a/cogl/cogl-texture-3d-private.h +++ b/cogl/cogl-texture-3d-private.h @@ -58,9 +58,6 @@ struct _CoglTexture3D CoglTexturePixel first_pixel; }; -GQuark -_cogl_handle_texture_3d_get_type (void); - /* * cogl_texture_3d_new_from_bitmap: * @bmp_handle: A #CoglHandle to a bitmap. diff --git a/cogl/cogl-texture-private.h b/cogl/cogl-texture-private.h index 1ca056105..1048b210f 100644 --- a/cogl/cogl-texture-private.h +++ b/cogl/cogl-texture-private.h @@ -168,19 +168,17 @@ _cogl_texture_free (CoglTexture *texture); /* This is used to register a type to the list of handle types that will be considered a texture in cogl_is_texture() */ void -_cogl_texture_register_texture_type (GQuark type); +_cogl_texture_register_texture_type (const CoglObjectClass *klass); #define COGL_TEXTURE_DEFINE(TypeName, type_name) \ COGL_HANDLE_DEFINE_WITH_CODE \ (TypeName, type_name, \ - _cogl_texture_register_texture_type (_cogl_handle_ \ - ## type_name ## _get_type ())) + _cogl_texture_register_texture_type (&_cogl_##type_name##_class)) #define COGL_TEXTURE_INTERNAL_DEFINE(TypeName, type_name) \ COGL_HANDLE_INTERNAL_DEFINE_WITH_CODE \ (TypeName, type_name, \ - _cogl_texture_register_texture_type (_cogl_handle_ \ - ## type_name ## _get_type ())) + _cogl_texture_register_texture_type (&_cogl_##type_name##_class)) gboolean _cogl_texture_can_hardware_repeat (CoglTexture *texture); diff --git a/cogl/cogl-texture-rectangle-private.h b/cogl/cogl-texture-rectangle-private.h index dde910970..21bcf3f34 100644 --- a/cogl/cogl-texture-rectangle-private.h +++ b/cogl/cogl-texture-rectangle-private.h @@ -47,9 +47,6 @@ struct _CoglTextureRectangle gboolean is_foreign; }; -GQuark -_cogl_handle_texture_rectangle_get_type (void); - CoglTextureRectangle * _cogl_texture_rectangle_new_from_bitmap (CoglBitmap *bmp, CoglTextureFlags flags, diff --git a/cogl/cogl-texture.c b/cogl/cogl-texture.c index a072d911d..bb8930a39 100644 --- a/cogl/cogl-texture.c +++ b/cogl/cogl-texture.c @@ -70,12 +70,11 @@ cogl_texture_error_quark (void) */ void -_cogl_texture_register_texture_type (GQuark type) +_cogl_texture_register_texture_type (const CoglObjectClass *klass) { _COGL_GET_CONTEXT (ctxt, NO_RETVAL); - ctxt->texture_types = g_slist_prepend (ctxt->texture_types, - GINT_TO_POINTER (type)); + ctxt->texture_types = g_slist_prepend (ctxt->texture_types, (void *) klass); } gboolean @@ -90,7 +89,7 @@ cogl_is_texture (void *object) return FALSE; for (l = ctxt->texture_types; l; l = l->next) - if (GPOINTER_TO_INT (l->data) == obj->klass->type) + if (l->data == obj->klass) return TRUE; return FALSE; diff --git a/cogl/winsys/cogl-texture-pixmap-x11-private.h b/cogl/winsys/cogl-texture-pixmap-x11-private.h index 60c11b9d9..699baf74a 100644 --- a/cogl/winsys/cogl-texture-pixmap-x11-private.h +++ b/cogl/winsys/cogl-texture-pixmap-x11-private.h @@ -81,7 +81,4 @@ struct _CoglTexturePixmapX11 gboolean use_winsys_texture; }; -GQuark -_cogl_handle_texture_pixmap_x11_get_type (void); - #endif /* __COGL_TEXTURE_PIXMAP_X11_PRIVATE_H */