diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c index 8f54c61fe..8d02050e8 100644 --- a/clutter/clutter/clutter-actor.c +++ b/clutter/clutter/clutter-actor.c @@ -3185,7 +3185,7 @@ _clutter_actor_draw_paint_volume_full (ClutterActor *self, "ClutterActor (paint volume outline)"); clutter_paint_node_add_primitive (pipeline_node, prim); clutter_paint_node_add_child (node, pipeline_node); - cogl_object_unref (prim); + g_object_unref (prim); if (label) { diff --git a/clutter/clutter/clutter-deform-effect.c b/clutter/clutter/clutter-deform-effect.c index 034cc277e..f8251f7d2 100644 --- a/clutter/clutter/clutter-deform-effect.c +++ b/clutter/clutter/clutter-deform-effect.c @@ -338,8 +338,8 @@ clutter_deform_effect_free_arrays (ClutterDeformEffect *self) ClutterDeformEffectPrivate *priv = self->priv; g_clear_object (&priv->buffer); - cogl_clear_object (&priv->primitive); - cogl_clear_object (&priv->lines_primitive); + g_clear_object (&priv->primitive); + g_clear_object (&priv->lines_primitive); } static void diff --git a/clutter/clutter/clutter-paint-node.c b/clutter/clutter/clutter-paint-node.c index 37804194c..aadeafa09 100644 --- a/clutter/clutter/clutter-paint-node.c +++ b/clutter/clutter/clutter-paint-node.c @@ -736,7 +736,7 @@ clutter_paint_operation_clear (ClutterPaintOperation *op) case PAINT_OP_PRIMITIVE: if (op->op.primitive != NULL) - cogl_object_unref (op->op.primitive); + g_object_unref (op->op.primitive); break; } } @@ -820,7 +820,7 @@ clutter_paint_op_init_primitive (ClutterPaintOperation *op, clutter_paint_operation_clear (op); op->opcode = PAINT_OP_PRIMITIVE; - op->op.primitive = cogl_object_ref (primitive); + op->op.primitive = g_object_ref (primitive); } static inline void @@ -989,7 +989,7 @@ clutter_paint_node_add_texture_rectangles (ClutterPaintNode *node, * Adds a region described by a Cogl primitive to the @node. * * This function acquires a reference on @primitive, so it is safe - * to call cogl_object_unref() when it returns. + * to call g_object_unref() when it returns. */ void clutter_paint_node_add_primitive (ClutterPaintNode *node, @@ -998,7 +998,7 @@ clutter_paint_node_add_primitive (ClutterPaintNode *node, ClutterPaintOperation operation = PAINT_OP_INIT; g_return_if_fail (CLUTTER_IS_PAINT_NODE (node)); - g_return_if_fail (cogl_is_primitive (primitive)); + g_return_if_fail (COGL_IS_PRIMITIVE (primitive)); clutter_paint_node_maybe_init_operations (node); diff --git a/cogl/cogl-pango/cogl-pango-display-list.c b/cogl/cogl-pango/cogl-pango-display-list.c index 99582246d..69b50139c 100644 --- a/cogl/cogl-pango/cogl-pango-display-list.c +++ b/cogl/cogl-pango/cogl-pango-display-list.c @@ -154,7 +154,7 @@ _cogl_pango_display_list_add_texture (CoglPangoDisplayList *dl, /* Get rid of the vertex buffer so that it will be recreated */ if (node->d.texture.primitive != NULL) { - cogl_object_unref (node->d.texture.primitive); + g_object_unref (node->d.texture.primitive); node->d.texture.primitive = NULL; } } @@ -463,10 +463,10 @@ _cogl_pango_display_list_node_free (CoglPangoDisplayListNode *node) if (node->d.texture.texture != NULL) g_object_unref (node->d.texture.texture); if (node->d.texture.primitive != NULL) - cogl_object_unref (node->d.texture.primitive); + g_object_unref (node->d.texture.primitive); } else if (node->type == COGL_PANGO_DISPLAY_LIST_TRAPEZOID) - cogl_object_unref (node->d.trapezoid.primitive); + g_object_unref (node->d.trapezoid.primitive); if (node->pipeline) g_object_unref (node->pipeline); diff --git a/cogl/cogl/cogl-blit.h b/cogl/cogl/cogl-blit.h index 8a0edfd09..6a987356d 100644 --- a/cogl/cogl/cogl-blit.h +++ b/cogl/cogl/cogl-blit.h @@ -30,7 +30,6 @@ #include -#include "cogl/cogl-object-private.h" #include "cogl/cogl-texture.h" #include "cogl/cogl-framebuffer.h" diff --git a/cogl/cogl/cogl-clip-stack.c b/cogl/cogl/cogl-clip-stack.c index 067f7d36b..15daeae6a 100644 --- a/cogl/cogl/cogl-clip-stack.c +++ b/cogl/cogl/cogl-clip-stack.c @@ -245,7 +245,7 @@ _cogl_clip_stack_push_primitive (CoglClipStack *stack, sizeof (CoglClipStackPrimitive), COGL_CLIP_STACK_PRIMITIVE); - entry->primitive = cogl_object_ref (primitive); + entry->primitive = g_object_ref (primitive); entry->matrix_entry = cogl_matrix_entry_ref (modelview_entry); @@ -329,7 +329,7 @@ _cogl_clip_stack_unref (CoglClipStack *entry) CoglClipStackPrimitive *primitive_entry = (CoglClipStackPrimitive *) entry; cogl_matrix_entry_unref (primitive_entry->matrix_entry); - cogl_object_unref (primitive_entry->primitive); + g_object_unref (primitive_entry->primitive); g_free (entry); break; } diff --git a/cogl/cogl/cogl-closure-list-private.h b/cogl/cogl/cogl-closure-list-private.h index 82c6039fa..40e08d555 100644 --- a/cogl/cogl/cogl-closure-list-private.h +++ b/cogl/cogl/cogl-closure-list-private.h @@ -29,8 +29,8 @@ #pragma once -#include "cogl/cogl-object.h" #include "cogl/cogl-list.h" +#include "cogl/cogl-macros.h" /* * This implements a list of callbacks that can be used a bit like diff --git a/cogl/cogl/cogl-context.c b/cogl/cogl/cogl-context.c index 0826aa19a..34353c0ae 100644 --- a/cogl/cogl/cogl-context.c +++ b/cogl/cogl/cogl-context.c @@ -31,7 +31,6 @@ #include "cogl-config.h" #include "cogl/cogl-mutter.h" -#include "cogl/cogl-object.h" #include "cogl/cogl-private.h" #include "cogl/cogl-profile.h" #include "cogl/cogl-util.h" @@ -46,7 +45,6 @@ #include "cogl/cogl-onscreen-private.h" #include "cogl/cogl-attribute-private.h" #include "cogl/cogl1-context.h" -#include "cogl/cogl-gtype-private.h" #include "cogl/winsys/cogl-winsys-private.h" #include diff --git a/cogl/cogl/cogl-dma-buf-handle.c b/cogl/cogl/cogl-dma-buf-handle.c index fadfb659a..3158b907d 100644 --- a/cogl/cogl/cogl-dma-buf-handle.c +++ b/cogl/cogl/cogl-dma-buf-handle.c @@ -32,7 +32,6 @@ #include "cogl-config.h" #include "cogl/cogl-dma-buf-handle.h" -#include "cogl/cogl-object.h" #include #include diff --git a/cogl/cogl/cogl-framebuffer-private.h b/cogl/cogl/cogl-framebuffer-private.h index d6c1784f0..519eb7b8e 100644 --- a/cogl/cogl/cogl-framebuffer-private.h +++ b/cogl/cogl/cogl-framebuffer-private.h @@ -32,7 +32,6 @@ #pragma once #include "cogl/cogl-framebuffer-driver.h" -#include "cogl/cogl-object-private.h" #include "cogl/cogl-matrix-stack-private.h" #include "cogl/cogl-journal-private.h" #include "cogl/winsys/cogl-winsys-private.h" diff --git a/cogl/cogl/cogl-framebuffer.c b/cogl/cogl/cogl-framebuffer.c index a4c7edb54..a6b9c47be 100644 --- a/cogl/cogl/cogl-framebuffer.c +++ b/cogl/cogl/cogl-framebuffer.c @@ -37,7 +37,6 @@ #include "cogl/cogl-context-private.h" #include "cogl/cogl-display-private.h" #include "cogl/cogl-renderer-private.h" -#include "cogl/cogl-object-private.h" #include "cogl/cogl-util.h" #include "cogl/cogl-texture-private.h" #include "cogl/cogl-framebuffer-private.h" @@ -50,7 +49,6 @@ #include "cogl/cogl1-context.h" #include "cogl/cogl-private.h" #include "cogl/cogl-primitives-private.h" -#include "cogl/cogl-gtype-private.h" #include "cogl/winsys/cogl-winsys-private.h" enum diff --git a/cogl/cogl/cogl-gtype-private.h b/cogl/cogl/cogl-gtype-private.h deleted file mode 100644 index 815c62e9e..000000000 --- a/cogl/cogl/cogl-gtype-private.h +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Cogl - * - * A Low Level GPU Graphics and Utilities API - * - * Copyright (C) 2010 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * - */ - -#pragma once - -#include "cogl-config.h" - -#include -#include - -#include "cogl/cogl-object-private.h" - -/* Move this to public headers? */ -typedef struct _CoglGtypeObject CoglGtypeObject; -typedef struct _CoglGtypeClass CoglGtypeClass; - -struct _CoglGtypeObject -{ - GTypeInstance parent_instance; - - guint dummy; -}; - -struct _CoglGtypeClass -{ - GTypeClass base_class; - - guint dummy; -}; - -#define I_(str) (g_intern_static_string ((str))) - -/**/ - -#define _COGL_GTYPE_DEFINE_BASE_CLASS_BEGIN(Name,name) \ -GType \ -cogl_##name##_get_gtype (void) \ -{ \ - static size_t g_type_id = 0; \ - if (g_once_init_enter (&g_type_id)) \ - { \ - static const GTypeFundamentalInfo finfo = { \ - (G_TYPE_FLAG_CLASSED | \ - G_TYPE_FLAG_INSTANTIATABLE | \ - G_TYPE_FLAG_DERIVABLE | \ - G_TYPE_FLAG_DEEP_DERIVABLE), \ - }; \ - static const GTypeValueTable value_table = { \ - _cogl_gtype_object_init_value, \ - _cogl_gtype_object_free_value, \ - _cogl_gtype_object_copy_value, \ - _cogl_gtype_object_peek_pointer, \ - "p", \ - _cogl_gtype_object_collect_value, \ - "p", \ - _cogl_gtype_object_lcopy_value, \ - }; \ - const GTypeInfo node_info = { \ - sizeof (CoglObjectClass), \ - (GBaseInitFunc) _cogl_gtype_object_class_base_init, \ - (GBaseFinalizeFunc) _cogl_gtype_object_class_base_finalize, \ - (GClassInitFunc) _cogl_gtype_object_class_init, \ - (GClassFinalizeFunc) NULL, \ - NULL, \ - sizeof (CoglObject), \ - 0, \ - (GInstanceInitFunc) _cogl_gtype_object_init, \ - &value_table, \ - }; \ - GType fundamental_type_id = \ - g_type_register_fundamental (g_type_fundamental_next (), \ - I_("Cogl" # Name), \ - &node_info, &finfo, \ - G_TYPE_FLAG_ABSTRACT); \ - g_once_init_leave (&g_type_id, \ - fundamental_type_id); - -#define _COGL_GTYPE_DEFINE_BASE_CLASS_END() \ - } \ - return g_type_id; \ - } - -#define COGL_GTYPE_DEFINE_BASE_CLASS(Name,name,...) \ - _COGL_GTYPE_DEFINE_BASE_CLASS_BEGIN(Name,name) \ - {__VA_ARGS__;} \ - _COGL_GTYPE_DEFINE_BASE_CLASS_END() - -#define _COGL_GTYPE_DEFINE_TYPE_EXTENDED_BEGIN(Name,name,parent,flags) \ - \ - static void name##_init (Name *self); \ - static void name##_class_init (Name##Class *klass); \ - static gpointer name##_parent_class = NULL; \ - static gint Name##_private_offset; \ - \ - static void \ - name##_class_intern_init (gpointer klass) \ - { \ - name##_parent_class = g_type_class_peek_parent (klass); \ - name##_class_init ((Name##Class*) klass); \ - } \ - \ - static inline gpointer \ - name##_get_instance_private (Name *self) \ - { \ - return (G_STRUCT_MEMBER_P (self, Name ##_private_offset)); \ - } \ - \ - GType \ - name##_get_gtype (void) \ - { \ - static size_t g_type_id = 0; \ - if (g_once_init_enter (&g_type_id)) \ - { \ - GType fundamental_type_id = \ - g_type_register_static_simple (parent, \ - g_intern_static_string (#Name), \ - sizeof (Name##Class), \ - (GClassInitFunc) name##_class_intern_init, \ - sizeof (Name), \ - (GInstanceInitFunc) name##_init, \ - (GTypeFlags) flags); \ - { /* custom code follows */ - -#define _COGL_GTYPE_DEFINE_TYPE_EXTENDED_END() \ - /* following custom code */ \ - } \ - g_once_init_leave (&g_type_id, \ - fundamental_type_id); \ - } \ - return g_type_id; \ - } /* closes name##_get_type() */ - - -#define COGL_GTYPE_DEFINE_CLASS(Name,name,...) \ - typedef struct _Cogl##Name##Class Cogl##Name##Class; \ - struct _Cogl##Name##Class { \ - CoglObjectClass parent_class; \ - }; \ - _COGL_GTYPE_DEFINE_TYPE_EXTENDED_BEGIN(Cogl##Name, \ - cogl_##name, \ - cogl_object_get_gtype(), \ - 0) \ - {__VA_ARGS__;} \ - _COGL_GTYPE_DEFINE_TYPE_EXTENDED_END() \ - static void \ - cogl_##name##_init (Cogl##Name *instance) \ - { \ - } \ - static void \ - cogl_##name##_class_init (Cogl##Name##Class *klass) \ - { \ - } - -void _cogl_gtype_object_init_value (GValue *value); -void _cogl_gtype_object_free_value (GValue *value); -void _cogl_gtype_object_copy_value (const GValue *src, - GValue *dst); -gpointer _cogl_gtype_object_peek_pointer (const GValue *value); -gchar *_cogl_gtype_object_collect_value (GValue *value, - guint n_collect_values, - GTypeCValue *collect_values, - guint collect_flags); -gchar *_cogl_gtype_object_lcopy_value (const GValue *value, - guint n_collect_values, - GTypeCValue *collect_values, - guint collect_flags); - -void _cogl_gtype_object_class_base_init (CoglObjectClass *klass); -void _cogl_gtype_object_class_base_finalize (CoglObjectClass *klass); -void _cogl_gtype_object_class_init (CoglObjectClass *klass); -void _cogl_gtype_object_init (CoglObject *object); - -COGL_EXPORT -void cogl_object_value_set_object (GValue *value, - gpointer object); -COGL_EXPORT -gpointer cogl_object_value_get_object (const GValue *value); - -void _cogl_gtype_dummy_iface_init (gpointer iface); diff --git a/cogl/cogl/cogl-gtype.c b/cogl/cogl/cogl-gtype.c deleted file mode 100644 index 3ebc8a9b7..000000000 --- a/cogl/cogl/cogl-gtype.c +++ /dev/null @@ -1,153 +0,0 @@ -#include "cogl/cogl-gtype-private.h" - -#include - -void -_cogl_gtype_object_init_value (GValue *value) -{ - value->data[0].v_pointer = NULL; -} - -void -_cogl_gtype_object_free_value (GValue *value) -{ - if (value->data[0].v_pointer != NULL) - cogl_object_unref (value->data[0].v_pointer); -} - -void -_cogl_gtype_object_copy_value (const GValue *src, - GValue *dst) -{ - if (src->data[0].v_pointer != NULL) - dst->data[0].v_pointer = cogl_object_ref (src->data[0].v_pointer); - else - dst->data[0].v_pointer = NULL; -} - -gpointer -_cogl_gtype_object_peek_pointer (const GValue *value) -{ - return value->data[0].v_pointer; -} - -gchar * -_cogl_gtype_object_collect_value (GValue *value, - guint n_collect_values, - GTypeCValue *collect_values, - guint collect_flags) -{ - CoglObject *object; - - object = collect_values[0].v_pointer; - - if (object == NULL) - { - value->data[0].v_pointer = NULL; - return NULL; - } - - if (object->klass == NULL) - return g_strconcat ("invalid unclassed CoglObject pointer for " - "value type '", - G_VALUE_TYPE_NAME (value), - "'", - NULL); - - value->data[0].v_pointer = cogl_object_ref (object); - - return NULL; -} - -gchar * -_cogl_gtype_object_lcopy_value (const GValue *value, - guint n_collect_values, - GTypeCValue *collect_values, - guint collect_flags) -{ - CoglObject **object_p = collect_values[0].v_pointer; - - if (object_p == NULL) - return g_strconcat ("value location for '", - G_VALUE_TYPE_NAME (value), - "' passed as NULL", - NULL); - - if (value->data[0].v_pointer == NULL) - *object_p = NULL; - else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) - *object_p = value->data[0].v_pointer; - else - *object_p = cogl_object_ref (value->data[0].v_pointer); - - return NULL; -} - -void -_cogl_gtype_object_class_base_init (CoglObjectClass *klass) -{ -} - -void -_cogl_gtype_object_class_base_finalize (CoglObjectClass *klass) -{ -} - -void -_cogl_gtype_object_class_init (CoglObjectClass *klass) -{ -} - -void -_cogl_gtype_object_init (CoglObject *object) -{ -} - -void -_cogl_gtype_dummy_iface_init (gpointer iface) -{ -} - -/** - * cogl_object_value_set_object: - * @value: a #GValue initialized with %COGL_GTYPE_TYPE_OBJECT - * @object: (type Cogl.GtypeObject) (allow-none): a #CoglGtypeObject, or %NULL - * - * Sets the contents of a #GValue initialized with %COGL_GTYPE_TYPE_OBJECT. - * - */ -void -cogl_object_value_set_object (GValue *value, - gpointer object) -{ - CoglObject *old_object; - - old_object = value->data[0].v_pointer; - - if (object != NULL) - { - /* take over ownership */ - value->data[0].v_pointer = object; - } - else - value->data[0].v_pointer = NULL; - - if (old_object != NULL) - cogl_object_unref (old_object); -} - -/** - * cogl_object_value_get_object: - * @value: a #GValue initialized with %COGL_GTYPE_TYPE_OBJECT - * - * Retrieves a pointer to the #CoglGtypeObject contained inside - * the passed #GValue. - * - * Return value: (transfer none) (type Cogl.GtypeObject): a pointer to - * a #CoglGtypeObject, or %NULL - */ -gpointer -cogl_object_value_get_object (const GValue *value) -{ - return value->data[0].v_pointer; -} diff --git a/cogl/cogl/cogl-object-private.h b/cogl/cogl/cogl-object-private.h deleted file mode 100644 index d48ef330c..000000000 --- a/cogl/cogl/cogl-object-private.h +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Cogl - * - * A Low Level GPU Graphics and Utilities API - * - * Copyright (C) 2008,2009,2010 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Authors: - * Robert Bragg - */ - -#pragma once - -#include - -#include "cogl/cogl-types.h" -#include "cogl/cogl-object.h" -#include "cogl/cogl-debug.h" - -/* XXX: sadly we didn't fully consider when we copied the cairo API - * for _set_user_data that the callback doesn't get a pointer to the - * instance which is desired in most cases. This means you tend to end - * up creating micro allocations for the private data just so you can - * pair up the data of interest with the original instance for - * identification when it is later destroyed. - * - * Internally we use a small hack to avoid needing these micro - * allocations by actually passing the instance as a second argument - * to the callback */ -typedef void (*CoglUserDataDestroyInternalCallback) (void *user_data, - void *instance); - -typedef struct _CoglObjectClass -{ - GTypeClass base_class; - const char *name; - void *virt_free; - void *virt_unref; -} CoglObjectClass; - - -/* All Cogl objects inherit from this base object by adding a member: - * - * CoglObject _parent; - * - * at the top of its main structure. This structure is initialized - * when you call _cogl_#type_name#_object_new (new_object); - */ -struct _CoglObject -{ - CoglObjectClass *klass; /* equivalent to GTypeInstance */ - - unsigned int ref_count; -}; - -/* Helper macro to encapsulate the common code for COGL reference - counted objects */ - -#ifdef COGL_OBJECT_DEBUG - -#define _COGL_OBJECT_DEBUG_NEW(type_name, obj) \ - COGL_NOTE (OBJECT, "COGL " G_STRINGIFY (type_name) " NEW %p %i", \ - (obj), (obj)->ref_count) - -#define _COGL_OBJECT_DEBUG_REF(type_name, object) G_STMT_START { \ - CoglObject *__obj = (CoglObject *)object; \ - COGL_NOTE (OBJECT, "COGL %s REF %p %i", \ - (__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 (OBJECT, "COGL %s UNREF %p %i", \ - (__obj)->klass->name, \ - (__obj), (__obj)->ref_count - 1); } G_STMT_END - -#define COGL_OBJECT_DEBUG_FREE(obj) \ - COGL_NOTE (OBJECT, "COGL %s FREE %p", \ - (obj)->klass->name, (obj)) - -#else /* !COGL_OBJECT_DEBUG */ - -#define _COGL_OBJECT_DEBUG_NEW(type_name, obj) -#define _COGL_OBJECT_DEBUG_REF(type_name, obj) -#define _COGL_OBJECT_DEBUG_UNREF(type_name, obj) -#define COGL_OBJECT_DEBUG_FREE(obj) - -#endif /* COGL_OBJECT_DEBUG */ - -#define _COGL_GTYPE_INIT_CLASS(type_name) do { \ - _cogl_##type_name##_class.base_class.g_type = cogl_##type_name##_get_gtype (); \ -} while (0) - -#define COGL_OBJECT_COMMON_DEFINE_WITH_CODE(TypeName, type_name, code) \ - \ -CoglObjectClass _cogl_##type_name##_class; \ -static unsigned long _cogl_object_##type_name##_count; \ - \ -static inline void \ -_cogl_object_##type_name##_inc (void) \ -{ \ - _cogl_object_##type_name##_count++; \ -} \ - \ -static inline void \ -_cogl_object_##type_name##_dec (void) \ -{ \ - _cogl_object_##type_name##_count--; \ -} \ - \ -static void \ -_cogl_object_##type_name##_indirect_free (CoglObject *obj) \ -{ \ - _cogl_##type_name##_free ((Cogl##TypeName *) obj); \ - _cogl_object_##type_name##_dec (); \ -} \ - \ -static void \ -_cogl_object_##type_name##_class_init (void) \ -{ \ - _cogl_object_##type_name##_count = 0; \ - \ - if (_cogl_debug_instances == NULL) \ - _cogl_debug_instances = \ - g_hash_table_new (g_str_hash, g_str_equal); \ - \ - _cogl_##type_name##_class.virt_free = \ - _cogl_object_##type_name##_indirect_free; \ - _cogl_##type_name##_class.virt_unref = \ - _cogl_object_default_unref; \ - _cogl_##type_name##_class.name = "Cogl"#TypeName; \ - \ - g_hash_table_insert (_cogl_debug_instances, \ - (void *) _cogl_##type_name##_class.name, \ - &_cogl_object_##type_name##_count); \ - \ - { code; } \ -} \ - \ -static Cogl##TypeName * \ -_cogl_##type_name##_object_new (Cogl##TypeName *new_obj) \ -{ \ - CoglObject *obj = (CoglObject *)&new_obj->_parent; \ - obj->ref_count = 0; \ - cogl_object_ref (obj); \ - \ - obj->klass = &_cogl_##type_name##_class; \ - if (!obj->klass->virt_free) \ - { \ - _cogl_object_##type_name##_class_init (); \ - } \ - \ - _cogl_object_##type_name##_inc (); \ - _COGL_OBJECT_DEBUG_NEW (TypeName, obj); \ - return new_obj; \ -} - -#define COGL_OBJECT_DEFINE_WITH_CODE_GTYPE(TypeName, type_name, code) \ - \ -COGL_OBJECT_COMMON_DEFINE_WITH_CODE(TypeName, \ - type_name, \ - do { code; } while (0); \ - _COGL_GTYPE_INIT_CLASS (type_name)) \ - \ -gboolean \ -cogl_is_##type_name (void *object) \ -{ \ - CoglObject *obj = object; \ - \ - if (object == NULL) \ - return FALSE; \ - \ - return obj->klass == &_cogl_##type_name##_class; \ -} - -#define COGL_OBJECT_DEFINE_WITH_CODE(TypeName, type_name, code) \ - \ -COGL_OBJECT_COMMON_DEFINE_WITH_CODE(TypeName, type_name, code) \ - \ -gboolean \ -cogl_is_##type_name (void *object) \ -{ \ - CoglObject *obj = object; \ - \ - if (object == NULL) \ - return FALSE; \ - \ - return obj->klass == &_cogl_##type_name##_class; \ -} - -#define COGL_OBJECT_INTERNAL_DEFINE_WITH_CODE(TypeName, type_name, code) \ - \ -COGL_OBJECT_COMMON_DEFINE_WITH_CODE(TypeName, type_name, code) \ - \ -gboolean \ -_cogl_is_##type_name (void *object) \ -{ \ - CoglObject *obj = object; \ - \ - if (object == NULL) \ - return FALSE; \ - \ - return obj->klass == &_cogl_##type_name##_class; \ -} - -#define COGL_OBJECT_DEFINE(TypeName, type_name) \ - COGL_OBJECT_DEFINE_WITH_CODE_GTYPE (TypeName, type_name, (void) 0) - -#define COGL_OBJECT_INTERNAL_DEFINE(TypeName, type_name) \ - COGL_OBJECT_INTERNAL_DEFINE_WITH_CODE (TypeName, type_name, (void) 0) - -COGL_EXPORT void -_cogl_object_default_unref (void *obj); diff --git a/cogl/cogl/cogl-object.c b/cogl/cogl/cogl-object.c deleted file mode 100644 index 3a759904d..000000000 --- a/cogl/cogl/cogl-object.c +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Cogl - * - * A Low Level GPU Graphics and Utilities API - * - * Copyright (C) 2007,2008,2009,2010 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Authors: - * Robert Bragg - */ - -#include "cogl-config.h" - -#include -#include - -#include "cogl/cogl-util.h" -#include "cogl/cogl-types.h" -#include "cogl/cogl-object-private.h" -#include "cogl/cogl-gtype-private.h" - -COGL_GTYPE_DEFINE_BASE_CLASS (Object, object); - -void * -cogl_object_ref (void *object) -{ - CoglObject *obj = object; - - g_return_val_if_fail (object != NULL, NULL); - - obj->ref_count++; - return object; -} - -void -_cogl_object_default_unref (void *object) -{ - CoglObject *obj = object; - - g_return_if_fail (object != NULL); - g_return_if_fail (obj->ref_count > 0); - - if (--obj->ref_count < 1) - { - void (*free_func)(void *obj); - - COGL_OBJECT_DEBUG_FREE (obj); - free_func = obj->klass->virt_free; - free_func (obj); - } -} - -void -cogl_object_unref (void *obj) -{ - void (* unref_func) (void *); - - g_return_if_fail (obj != NULL); - - unref_func = ((CoglObject *) obj)->klass->virt_unref; - unref_func (obj); -} - -void -cogl_debug_object_foreach_type (CoglDebugObjectForeachTypeCallback func, - void *user_data) -{ - GHashTableIter iter; - unsigned long *instance_count; - CoglDebugObjectTypeInfo info; - - g_hash_table_iter_init (&iter, _cogl_debug_instances); - while (g_hash_table_iter_next (&iter, - (void *) &info.name, - (void *) &instance_count)) - { - info.instance_count = *instance_count; - func (&info, user_data); - } -} - -static void -print_instances_cb (const CoglDebugObjectTypeInfo *info, - void *user_data) -{ - g_print ("\t%s: %lu\n", info->name, info->instance_count); -} - -void -cogl_debug_object_print_instances (void) -{ - g_print ("Cogl instances:\n"); - - cogl_debug_object_foreach_type (print_instances_cb, NULL); -} diff --git a/cogl/cogl/cogl-object.h b/cogl/cogl/cogl-object.h deleted file mode 100644 index c856b8514..000000000 --- a/cogl/cogl/cogl-object.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Cogl - * - * A Low Level GPU Graphics and Utilities API - * - * Copyright (C) 2009,2010 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * - */ - -#pragma once - -#include "cogl/cogl-types.h" - -#include - -G_BEGIN_DECLS - -typedef struct _CoglObject CoglObject; - -#define COGL_OBJECT(X) ((CoglObject *)X) - -/** - * CoglObject: (ref-func cogl_object_ref) (unref-func cogl_object_unref) - * (set-value-func cogl_object_value_set_object) - * (get-value-func cogl_object_value_get_object) - */ - -/** - * cogl_object_get_gtype: - * - * Returns: a #GType that can be used with the GLib type system. - */ -COGL_EXPORT -GType cogl_object_get_gtype (void); - -/** - * cogl_object_ref: (skip) - * @object: a #CoglObject - * - * Increases the reference count of @object by 1 - * - * Returns: the @object, with its reference count increased - */ -COGL_EXPORT void * -cogl_object_ref (void *object); - -/** - * cogl_object_unref: (skip) - * @object: a #CoglObject - * - * Drecreases the reference count of @object by 1; if the reference - * count reaches 0, the resources allocated by @object will be freed - */ -COGL_EXPORT void -cogl_object_unref (void *object); - -/** - * cogl_clear_object: (skip) - * @object_ptr: a pointer to a #CoglObject reference - * - * Clears a reference to a #CoglObject. - * - * @object_ptr must not be %NULL. - * - * If the reference is %NULL then this function does nothing. - * Otherwise, the reference count of the object is decreased using - * cogl_object_unref() and the pointer is set to %NULL. - */ -#define cogl_clear_object(object_ptr) g_clear_pointer ((object_ptr), cogl_object_unref) - -/** - * CoglDebugObjectTypeInfo: - * @name: A human readable name for the type. - * @instance_count: The number of objects of this type that are - * currently in use - * - * This struct is used to pass information to the callback when - * cogl_debug_object_foreach_type() is called. - */ -typedef struct { - const char *name; - unsigned long instance_count; -} CoglDebugObjectTypeInfo; - -/** - * CoglDebugObjectForeachTypeCallback: - * @info: A pointer to a struct containing information about the type. - * - * A callback function to use for cogl_debug_object_foreach_type(). - */ -typedef void -(* CoglDebugObjectForeachTypeCallback) (const CoglDebugObjectTypeInfo *info, - void *user_data); - -/** - * cogl_debug_object_foreach_type: - * @func: (scope call): A callback function for each type - * @user_data: (closure): A pointer to pass to @func - * - * Invokes @func once for each type of object that Cogl uses and - * passes a count of the number of objects for that type. This is - * intended to be used solely for debugging purposes to track down - * issues with objects leaking. - */ -COGL_EXPORT void -cogl_debug_object_foreach_type (CoglDebugObjectForeachTypeCallback func, - void *user_data); - -/** - * cogl_debug_object_print_instances: - * - * Prints a list of all the object types that Cogl uses along with the - * number of objects of that type that are currently in use. This is - * intended to be used solely for debugging purposes to track down - * issues with objects leaking. - */ -COGL_EXPORT void -cogl_debug_object_print_instances (void); - -G_END_DECLS diff --git a/cogl/cogl/cogl-onscreen.c b/cogl/cogl/cogl-onscreen.c index d4429ded6..4a03f485b 100644 --- a/cogl/cogl/cogl-onscreen.c +++ b/cogl/cogl/cogl-onscreen.c @@ -38,11 +38,9 @@ #include "cogl/cogl-framebuffer-private.h" #include "cogl/cogl-onscreen-template-private.h" #include "cogl/cogl-context-private.h" -#include "cogl/cogl-object-private.h" #include "cogl/cogl1-context.h" #include "cogl/cogl-closure-list-private.h" #include "cogl/cogl-poll-private.h" -#include "cogl/cogl-gtype-private.h" typedef struct _CoglOnscreenPrivate { diff --git a/cogl/cogl/cogl-onscreen.h b/cogl/cogl/cogl-onscreen.h index 5b1f8ded8..6e2c9ef85 100644 --- a/cogl/cogl/cogl-onscreen.h +++ b/cogl/cogl/cogl-onscreen.h @@ -40,7 +40,6 @@ #include "cogl/cogl-context.h" #include "cogl/cogl-framebuffer.h" #include "cogl/cogl-frame-info.h" -#include "cogl/cogl-object.h" #include diff --git a/cogl/cogl/cogl-pixel-buffer-private.h b/cogl/cogl/cogl-pixel-buffer-private.h index 235217254..308562673 100644 --- a/cogl/cogl/cogl-pixel-buffer-private.h +++ b/cogl/cogl/cogl-pixel-buffer-private.h @@ -34,7 +34,6 @@ #pragma once -#include "cogl/cogl-object-private.h" #include "cogl/cogl-buffer-private.h" #include diff --git a/cogl/cogl/cogl-primitive-private.h b/cogl/cogl/cogl-primitive-private.h index 73067b86c..63e235f2b 100644 --- a/cogl/cogl/cogl-primitive-private.h +++ b/cogl/cogl/cogl-primitive-private.h @@ -33,14 +33,13 @@ #pragma once -#include "cogl/cogl-object-private.h" #include "cogl/cogl-attribute-buffer-private.h" #include "cogl/cogl-attribute-private.h" #include "cogl/cogl-framebuffer.h" struct _CoglPrimitive { - CoglObject _parent; + GObject parent_instance; CoglIndices *indices; CoglVerticesMode mode; @@ -49,11 +48,8 @@ struct _CoglPrimitive int immutable_ref; - CoglAttribute **attributes; + GPtrArray *attributes; int n_attributes; - - int n_embedded_attributes; - CoglAttribute *embedded_attribute; }; CoglPrimitive * diff --git a/cogl/cogl/cogl-primitive.c b/cogl/cogl/cogl-primitive.c index 20a6d6cc1..38f3a54e2 100644 --- a/cogl/cogl/cogl-primitive.c +++ b/cogl/cogl/cogl-primitive.c @@ -34,20 +34,45 @@ #include "cogl-config.h" #include "cogl/cogl-util.h" -#include "cogl/cogl-object-private.h" #include "cogl/cogl-primitive.h" #include "cogl/cogl-primitive-private.h" #include "cogl/cogl-attribute-private.h" #include "cogl/cogl-framebuffer-private.h" -#include "cogl/cogl-gtype-private.h" #include #include -static void _cogl_primitive_free (CoglPrimitive *primitive); +G_DEFINE_TYPE (CoglPrimitive, cogl_primitive, G_TYPE_OBJECT); -COGL_OBJECT_DEFINE (Primitive, primitive); -COGL_GTYPE_DEFINE_CLASS (Primitive, primitive); +static void +cogl_primitive_dispose (GObject *object) +{ + CoglPrimitive *primitive = COGL_PRIMITIVE (object); + + g_ptr_array_free (primitive->attributes, TRUE); + + if (primitive->indices) + g_object_unref (primitive->indices); + + G_OBJECT_CLASS (cogl_primitive_parent_class)->dispose (object); +} + +static void +cogl_primitive_class_init (CoglPrimitiveClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->dispose = cogl_primitive_dispose; +} + +static void +cogl_primitive_init (CoglPrimitive *primitive) +{ + primitive->first_vertex = 0; + primitive->immutable_ref = 0; + primitive->indices = NULL; + primitive->attributes = g_ptr_array_new_with_free_func (g_object_unref); +} CoglPrimitive * cogl_primitive_new_with_attributes (CoglVerticesMode mode, @@ -58,17 +83,11 @@ cogl_primitive_new_with_attributes (CoglVerticesMode mode, CoglPrimitive *primitive; int i; - primitive = g_malloc0 (sizeof (CoglPrimitive) + - sizeof (CoglAttribute *) * (n_attributes - 1)); + primitive = g_object_new (COGL_TYPE_PRIMITIVE, NULL); primitive->mode = mode; - primitive->first_vertex = 0; primitive->n_vertices = n_vertices; - primitive->indices = NULL; - primitive->immutable_ref = 0; primitive->n_attributes = n_attributes; - primitive->n_embedded_attributes = n_attributes; - primitive->attributes = &primitive->embedded_attribute; for (i = 0; i < n_attributes; i++) { CoglAttribute *attribute = attributes[i]; @@ -76,10 +95,10 @@ cogl_primitive_new_with_attributes (CoglVerticesMode mode, g_return_val_if_fail (COGL_IS_ATTRIBUTE (attribute), NULL); - primitive->attributes[i] = attribute; + g_ptr_array_add (primitive->attributes, attribute); } - return _cogl_primitive_object_new (primitive); + return primitive; } /* This is just an internal convenience wrapper around @@ -375,23 +394,6 @@ cogl_primitive_new_p3t2c4 (CoglContext *ctx, 3); } -static void -_cogl_primitive_free (CoglPrimitive *primitive) -{ - int i; - - for (i = 0; i < primitive->n_attributes; i++) - g_object_unref (primitive->attributes[i]); - - if (primitive->attributes != &primitive->embedded_attribute) - g_free (primitive->attributes); - - if (primitive->indices) - g_object_unref (primitive->indices); - - g_free (primitive); -} - static void warn_about_midscene_changes (void) { @@ -404,61 +406,10 @@ warn_about_midscene_changes (void) } } -void -cogl_primitive_set_attributes (CoglPrimitive *primitive, - CoglAttribute **attributes, - int n_attributes) -{ - int i; - - g_return_if_fail (cogl_is_primitive (primitive)); - - if (G_UNLIKELY (primitive->immutable_ref)) - { - warn_about_midscene_changes (); - return; - } - - /* NB: we don't unref the previous attributes before refing the new - * in case we would end up releasing the last reference for an - * attribute that's actually in the new list too. */ - for (i = 0; i < n_attributes; i++) - { - g_return_if_fail (COGL_IS_ATTRIBUTE (attributes[i])); - g_object_ref (attributes[i]); - } - - for (i = 0; i < primitive->n_attributes; i++) - g_object_unref (primitive->attributes[i]); - - /* First try to use the embedded storage associated with the - * primitive, else fallback to slice allocating separate storage for - * the attribute pointers... */ - - if (n_attributes <= primitive->n_embedded_attributes) - { - if (primitive->attributes != &primitive->embedded_attribute) - g_free (primitive->attributes); - primitive->attributes = &primitive->embedded_attribute; - } - else - { - if (primitive->attributes != &primitive->embedded_attribute) - g_free (primitive->attributes); - primitive->attributes = - g_malloc0 (sizeof (CoglAttribute *) * n_attributes); - } - - memcpy (primitive->attributes, attributes, - sizeof (CoglAttribute *) * n_attributes); - - primitive->n_attributes = n_attributes; -} - int cogl_primitive_get_first_vertex (CoglPrimitive *primitive) { - g_return_val_if_fail (cogl_is_primitive (primitive), 0); + g_return_val_if_fail (COGL_IS_PRIMITIVE (primitive), 0); return primitive->first_vertex; } @@ -467,7 +418,7 @@ void cogl_primitive_set_first_vertex (CoglPrimitive *primitive, int first_vertex) { - g_return_if_fail (cogl_is_primitive (primitive)); + g_return_if_fail (COGL_IS_PRIMITIVE (primitive)); if (G_UNLIKELY (primitive->immutable_ref)) { @@ -481,7 +432,7 @@ cogl_primitive_set_first_vertex (CoglPrimitive *primitive, int cogl_primitive_get_n_vertices (CoglPrimitive *primitive) { - g_return_val_if_fail (cogl_is_primitive (primitive), 0); + g_return_val_if_fail (COGL_IS_PRIMITIVE (primitive), 0); return primitive->n_vertices; } @@ -490,7 +441,7 @@ void cogl_primitive_set_n_vertices (CoglPrimitive *primitive, int n_vertices) { - g_return_if_fail (cogl_is_primitive (primitive)); + g_return_if_fail (COGL_IS_PRIMITIVE (primitive)); primitive->n_vertices = n_vertices; } @@ -498,7 +449,7 @@ cogl_primitive_set_n_vertices (CoglPrimitive *primitive, CoglVerticesMode cogl_primitive_get_mode (CoglPrimitive *primitive) { - g_return_val_if_fail (cogl_is_primitive (primitive), 0); + g_return_val_if_fail (COGL_IS_PRIMITIVE (primitive), 0); return primitive->mode; } @@ -507,7 +458,7 @@ void cogl_primitive_set_mode (CoglPrimitive *primitive, CoglVerticesMode mode) { - g_return_if_fail (cogl_is_primitive (primitive)); + g_return_if_fail (COGL_IS_PRIMITIVE (primitive)); if (G_UNLIKELY (primitive->immutable_ref)) { @@ -523,7 +474,7 @@ cogl_primitive_set_indices (CoglPrimitive *primitive, CoglIndices *indices, int n_indices) { - g_return_if_fail (cogl_is_primitive (primitive)); + g_return_if_fail (COGL_IS_PRIMITIVE (primitive)); if (G_UNLIKELY (primitive->immutable_ref)) { @@ -552,7 +503,7 @@ cogl_primitive_copy (CoglPrimitive *primitive) copy = cogl_primitive_new_with_attributes (primitive->mode, primitive->n_vertices, - primitive->attributes, + (CoglAttribute **)primitive->attributes->pdata, primitive->n_attributes); cogl_primitive_set_indices (copy, primitive->indices, primitive->n_vertices); @@ -566,12 +517,12 @@ _cogl_primitive_immutable_ref (CoglPrimitive *primitive) { int i; - g_return_val_if_fail (cogl_is_primitive (primitive), NULL); + g_return_val_if_fail (COGL_IS_PRIMITIVE (primitive), NULL); primitive->immutable_ref++; for (i = 0; i < primitive->n_attributes; i++) - _cogl_attribute_immutable_ref (primitive->attributes[i]); + _cogl_attribute_immutable_ref (primitive->attributes->pdata[i]); return primitive; } @@ -581,13 +532,13 @@ _cogl_primitive_immutable_unref (CoglPrimitive *primitive) { int i; - g_return_if_fail (cogl_is_primitive (primitive)); + g_return_if_fail (COGL_IS_PRIMITIVE (primitive)); g_return_if_fail (primitive->immutable_ref > 0); primitive->immutable_ref--; for (i = 0; i < primitive->n_attributes; i++) - _cogl_attribute_immutable_unref (primitive->attributes[i]); + _cogl_attribute_immutable_unref (primitive->attributes->pdata[i]); } void @@ -596,9 +547,8 @@ cogl_primitive_foreach_attribute (CoglPrimitive *primitive, void *user_data) { int i; - for (i = 0; i < primitive->n_attributes; i++) - if (!callback (primitive, primitive->attributes[i], user_data)) + if (!callback (primitive, primitive->attributes->pdata[i], user_data)) break; } @@ -615,7 +565,7 @@ _cogl_primitive_draw (CoglPrimitive *primitive, primitive->first_vertex, primitive->n_vertices, primitive->indices, - primitive->attributes, + (CoglAttribute **) primitive->attributes->pdata, primitive->n_attributes, flags); else @@ -624,7 +574,7 @@ _cogl_primitive_draw (CoglPrimitive *primitive, primitive->mode, primitive->first_vertex, primitive->n_vertices, - primitive->attributes, + (CoglAttribute **) primitive->attributes->pdata, primitive->n_attributes, flags); } diff --git a/cogl/cogl/cogl-primitive.h b/cogl/cogl/cogl-primitive.h index 3d02b9392..ff3e0090d 100644 --- a/cogl/cogl/cogl-primitive.h +++ b/cogl/cogl/cogl-primitive.h @@ -51,27 +51,19 @@ typedef struct _CoglPrimitive CoglPrimitive; G_BEGIN_DECLS /** - * SECTION:cogl-primitive - * @short_description: Functions for creating, manipulating and drawing - * primitives + * CoglPrimitive: * - * FIXME + *Functions for creating, manipulating and drawing primitives */ -/** - * CoglPrimitive: (ref-func cogl_object_ref) (unref-func cogl_object_unref) - * (set-value-func cogl_object_value_set_object) - * (get-value-func cogl_object_value_get_object) - */ +#define COGL_TYPE_PRIMITIVE (cogl_primitive_get_type ()) -/** - * cogl_primitive_get_gtype: - * - * Returns: a #GType that can be used with the GLib type system. - */ COGL_EXPORT -GType cogl_primitive_get_gtype (void); - +G_DECLARE_FINAL_TYPE (CoglPrimitive, + cogl_primitive, + COGL, + PRIMITIVE, + GObject) /** * CoglVertexP2: * @x: The x component of a position attribute @@ -293,7 +285,7 @@ cogl_primitive_new_with_attributes (CoglVerticesMode mode, * * * Return value: (transfer full): A newly allocated #CoglPrimitive - * with a reference of 1. This can be freed using cogl_object_unref(). + * with a reference of 1. This can be freed using g_object_unref(). */ COGL_EXPORT CoglPrimitive * cogl_primitive_new_p2 (CoglContext *context, @@ -343,7 +335,7 @@ cogl_primitive_new_p2 (CoglContext *context, * * * Return value: (transfer full): A newly allocated #CoglPrimitive - * with a reference of 1. This can be freed using cogl_object_unref(). + * with a reference of 1. This can be freed using g_object_unref(). */ COGL_EXPORT CoglPrimitive * cogl_primitive_new_p3 (CoglContext *context, @@ -395,7 +387,7 @@ cogl_primitive_new_p3 (CoglContext *context, * * * Return value: (transfer full): A newly allocated #CoglPrimitive - * with a reference of 1. This can be freed using cogl_object_unref(). + * with a reference of 1. This can be freed using g_object_unref(). */ COGL_EXPORT CoglPrimitive * cogl_primitive_new_p2c4 (CoglContext *context, @@ -447,7 +439,7 @@ cogl_primitive_new_p2c4 (CoglContext *context, * * * Return value: (transfer full): A newly allocated #CoglPrimitive - * with a reference of 1. This can be freed using cogl_object_unref(). + * with a reference of 1. This can be freed using g_object_unref(). */ COGL_EXPORT CoglPrimitive * cogl_primitive_new_p3c4 (CoglContext *context, @@ -499,7 +491,7 @@ cogl_primitive_new_p3c4 (CoglContext *context, * * * Return value: (transfer full): A newly allocated #CoglPrimitive - * with a reference of 1. This can be freed using cogl_object_unref(). + * with a reference of 1. This can be freed using g_object_unref(). */ COGL_EXPORT CoglPrimitive * cogl_primitive_new_p2t2 (CoglContext *context, @@ -551,7 +543,7 @@ cogl_primitive_new_p2t2 (CoglContext *context, * * * Return value: (transfer full): A newly allocated #CoglPrimitive - * with a reference of 1. This can be freed using cogl_object_unref(). + * with a reference of 1. This can be freed using g_object_unref(). */ COGL_EXPORT CoglPrimitive * cogl_primitive_new_p3t2 (CoglContext *context, @@ -603,7 +595,7 @@ cogl_primitive_new_p3t2 (CoglContext *context, * * * Return value: (transfer full): A newly allocated #CoglPrimitive - * with a reference of 1. This can be freed using cogl_object_unref(). + * with a reference of 1. This can be freed using g_object_unref(). */ COGL_EXPORT CoglPrimitive * cogl_primitive_new_p2t2c4 (CoglContext *context, @@ -655,7 +647,7 @@ cogl_primitive_new_p2t2c4 (CoglContext *context, * * * Return value: (transfer full): A newly allocated #CoglPrimitive - * with a reference of 1. This can be freed using cogl_object_unref(). + * with a reference of 1. This can be freed using g_object_unref(). */ COGL_EXPORT CoglPrimitive * cogl_primitive_new_p3t2c4 (CoglContext *context, @@ -717,19 +709,6 @@ COGL_EXPORT void cogl_primitive_set_mode (CoglPrimitive *primitive, CoglVerticesMode mode); -/** - * cogl_primitive_set_attributes: (skip) - * @primitive: A #CoglPrimitive object - * @attributes: an array of #CoglAttribute pointers - * @n_attributes: the number of elements in @attributes - * - * Replaces all the attributes of the given #CoglPrimitive object. - */ -COGL_EXPORT void -cogl_primitive_set_attributes (CoglPrimitive *primitive, - CoglAttribute **attributes, - int n_attributes); - /** * cogl_primitive_set_indices: (skip) * @primitive: A #CoglPrimitive @@ -783,18 +762,6 @@ cogl_primitive_get_indices (CoglPrimitive *primitive); COGL_EXPORT CoglPrimitive * cogl_primitive_copy (CoglPrimitive *primitive); -/** - * cogl_is_primitive: - * @object: A #CoglObject - * - * Gets whether the given object references a #CoglPrimitive. - * - * Returns: %TRUE if the @object references a #CoglPrimitive, - * %FALSE otherwise - */ -COGL_EXPORT gboolean -cogl_is_primitive (void *object); - /** * CoglPrimitiveAttributeCallback: * @primitive: The #CoglPrimitive whose attributes are being iterated diff --git a/cogl/cogl/cogl-private.h b/cogl/cogl/cogl-private.h index 772303959..7aebd673f 100644 --- a/cogl/cogl/cogl-private.h +++ b/cogl/cogl/cogl-private.h @@ -36,6 +36,8 @@ G_BEGIN_DECLS +#define I_(str) (g_intern_static_string ((str))) + typedef enum { COGL_PRIVATE_FEATURE_TEXTURE_2D_FROM_EGL_IMAGE, diff --git a/cogl/cogl/cogl-spans.h b/cogl/cogl/cogl-spans.h index dbaacfecf..f245d0cfb 100644 --- a/cogl/cogl/cogl-spans.h +++ b/cogl/cogl/cogl-spans.h @@ -30,7 +30,6 @@ #pragma once -#include "cogl/cogl-object-private.h" #include "cogl/cogl-pipeline-layer-state.h" typedef struct _CoglSpan diff --git a/cogl/cogl/cogl-xlib-renderer-private.h b/cogl/cogl/cogl-xlib-renderer-private.h index ee288f291..3574fdc1b 100644 --- a/cogl/cogl/cogl-xlib-renderer-private.h +++ b/cogl/cogl/cogl-xlib-renderer-private.h @@ -32,7 +32,6 @@ #include -#include "cogl/cogl-object-private.h" #include "cogl/cogl-x11-renderer-private.h" #include "cogl/cogl-context.h" #include "cogl/cogl-output.h" diff --git a/cogl/cogl/cogl-xlib-renderer.c b/cogl/cogl/cogl-xlib-renderer.c index 7c080dc9f..204004c3f 100644 --- a/cogl/cogl/cogl-xlib-renderer.c +++ b/cogl/cogl/cogl-xlib-renderer.c @@ -33,7 +33,6 @@ #include "cogl/cogl-xlib-renderer.h" #include "cogl/cogl-util.h" -#include "cogl/cogl-object.h" #include "cogl/cogl-output-private.h" #include "cogl/cogl-renderer-private.h" diff --git a/cogl/cogl/cogl.h b/cogl/cogl/cogl.h index f6dca44fa..fb3c09283 100644 --- a/cogl/cogl/cogl.h +++ b/cogl/cogl/cogl.h @@ -56,7 +56,6 @@ #include "cogl/cogl-defines.h" #include "cogl/cogl-macros.h" -#include "cogl/cogl-object.h" #include "cogl/cogl1-context.h" #include "cogl/cogl-bitmap.h" #include "cogl/cogl-color.h" diff --git a/cogl/cogl/driver/gl/cogl-bitmap-gl.c b/cogl/cogl/driver/gl/cogl-bitmap-gl.c index 2b46338cc..4005fac93 100644 --- a/cogl/cogl/driver/gl/cogl-bitmap-gl.c +++ b/cogl/cogl/driver/gl/cogl-bitmap-gl.c @@ -37,7 +37,6 @@ #include "cogl/cogl-buffer-private.h" #include "cogl/cogl-pixel-buffer.h" #include "cogl/cogl-context-private.h" -#include "cogl/cogl-gtype-private.h" #include "cogl/driver/gl/cogl-buffer-gl-private.h" #include "cogl/driver/gl/cogl-bitmap-gl-private.h" diff --git a/cogl/cogl/driver/gl/cogl-pipeline-fragend-glsl.c b/cogl/cogl/driver/gl/cogl-pipeline-fragend-glsl.c index 9b530daba..0806d6a85 100644 --- a/cogl/cogl/driver/gl/cogl-pipeline-fragend-glsl.c +++ b/cogl/cogl/driver/gl/cogl-pipeline-fragend-glsl.c @@ -46,7 +46,6 @@ #include "cogl/driver/gl/cogl-pipeline-opengl-private.h" #include "cogl/cogl-context-private.h" -#include "cogl/cogl-object-private.h" #include "cogl/cogl-pipeline-cache.h" #include "cogl/driver/gl/cogl-pipeline-fragend-glsl-private.h" #include "deprecated/cogl-shader-private.h" diff --git a/cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c b/cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c index 573cf85f5..4014d3e10 100644 --- a/cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c +++ b/cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c @@ -43,7 +43,6 @@ #include "cogl/driver/gl/cogl-pipeline-opengl-private.h" #include "cogl/cogl-context-private.h" -#include "cogl/cogl-object-private.h" #include "cogl/cogl-pipeline-cache.h" #include "cogl/cogl-pipeline-state-private.h" #include "cogl/cogl-attribute-private.h" diff --git a/cogl/cogl/driver/gl/cogl-pipeline-vertend-glsl.c b/cogl/cogl/driver/gl/cogl-pipeline-vertend-glsl.c index bd91a3210..09bc929c2 100644 --- a/cogl/cogl/driver/gl/cogl-pipeline-vertend-glsl.c +++ b/cogl/cogl/driver/gl/cogl-pipeline-vertend-glsl.c @@ -41,7 +41,6 @@ #include "cogl/driver/gl/cogl-pipeline-opengl-private.h" #include "cogl/cogl-context-private.h" -#include "cogl/cogl-object-private.h" #include "cogl/cogl-pipeline-state-private.h" #include "cogl/cogl-glsl-shader-boilerplate.h" #include "cogl/driver/gl/cogl-pipeline-vertend-glsl-private.h" diff --git a/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl.c b/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl.c index 2c04f834c..4fb6a300c 100644 --- a/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl.c +++ b/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl.c @@ -42,7 +42,6 @@ #include "cogl/cogl-texture-private.h" #include "cogl/cogl-pipeline.h" #include "cogl/cogl-context-private.h" -#include "cogl/cogl-object-private.h" #include "cogl/driver/gl/cogl-pipeline-opengl-private.h" #include "cogl/driver/gl/cogl-util-gl-private.h" #include "cogl/driver/gl/cogl-texture-gl-private.h" diff --git a/cogl/cogl/driver/gl/gles/cogl-texture-driver-gles.c b/cogl/cogl/driver/gl/gles/cogl-texture-driver-gles.c index 01d7afb8a..9e261905b 100644 --- a/cogl/cogl/driver/gl/gles/cogl-texture-driver-gles.c +++ b/cogl/cogl/driver/gl/gles/cogl-texture-driver-gles.c @@ -42,7 +42,6 @@ #include "cogl/cogl-texture-private.h" #include "cogl/cogl-pipeline.h" #include "cogl/cogl-context-private.h" -#include "cogl/cogl-object-private.h" #include "cogl/driver/gl/cogl-pipeline-opengl-private.h" #include "cogl/driver/gl/cogl-util-gl-private.h" #include "cogl/driver/gl/cogl-texture-gl-private.h" diff --git a/cogl/cogl/meson.build b/cogl/cogl/meson.build index 0ff027b48..8d40cc571 100644 --- a/cogl/cogl/meson.build +++ b/cogl/cogl/meson.build @@ -70,7 +70,6 @@ cogl_headers = [ 'cogl-context.h', 'cogl-frame-info.h', 'cogl-framebuffer.h', - 'cogl-object.h', 'cogl-offscreen.h', 'cogl-onscreen.h', 'cogl-pipeline.h', @@ -109,7 +108,6 @@ cogl_nonintrospected_headers = [ 'cogl-pixel-buffer.h', 'cogl-macros.h', 'cogl-fence.h', - 'cogl-gtype-private.h', 'cogl-glib-source.h', 'cogl-scanout.h', 'cogl-graphene.h', @@ -219,9 +217,6 @@ cogl_sources = [ 'cogl-driver.h', 'cogl.c', 'cogl-pixel-format.c', - 'cogl-object-private.h', - 'cogl-object.h', - 'cogl-object.c', 'cogl-util.h', 'cogl-util.c', 'cogl-bitmap-private.h', @@ -319,8 +314,6 @@ cogl_sources = [ 'cogl-flags.h', 'cogl-bitmask.h', 'cogl-bitmask.c', - 'cogl-gtype.c', - 'cogl-gtype-private.h', 'cogl-point-in-poly-private.h', 'cogl-point-in-poly.c', 'cogl-list.c', diff --git a/cogl/cogl/winsys/cogl-glx-display-private.h b/cogl/cogl/winsys/cogl-glx-display-private.h index 63ffb6ac3..87767cd45 100644 --- a/cogl/cogl/winsys/cogl-glx-display-private.h +++ b/cogl/cogl/winsys/cogl-glx-display-private.h @@ -30,7 +30,6 @@ #pragma once -#include "cogl/cogl-object-private.h" typedef struct _CoglGLXCachedConfig { diff --git a/cogl/cogl/winsys/cogl-glx-renderer-private.h b/cogl/cogl/winsys/cogl-glx-renderer-private.h index d996a4755..321bad821 100644 --- a/cogl/cogl/winsys/cogl-glx-renderer-private.h +++ b/cogl/cogl/winsys/cogl-glx-renderer-private.h @@ -32,7 +32,6 @@ #include -#include "cogl/cogl-object-private.h" #include "cogl/cogl-xlib-renderer-private.h" typedef struct _CoglGLXRenderer diff --git a/src/tests/clutter/interactive/test-cogl-tex-polygon.c b/src/tests/clutter/interactive/test-cogl-tex-polygon.c index 46bf3b956..5d7f573be 100644 --- a/src/tests/clutter/interactive/test-cogl-tex-polygon.c +++ b/src/tests/clutter/interactive/test-cogl-tex-polygon.c @@ -101,7 +101,7 @@ test_coglbox_fade_texture (CoglFramebuffer *framebuffer, 4, vertices); cogl_primitive_draw (primitive, framebuffer, pipeline); - cogl_object_unref (primitive); + g_object_unref (primitive); } static void @@ -144,7 +144,7 @@ test_coglbox_triangle_texture (CoglFramebuffer *framebuffer, 3, vertices); cogl_primitive_draw (primitive, framebuffer, pipeline); - cogl_object_unref (primitive); + g_object_unref (primitive); } static void diff --git a/src/tests/cogl/conform/test-backface-culling.c b/src/tests/cogl/conform/test-backface-culling.c index 0d829004d..cca954b55 100644 --- a/src/tests/cogl/conform/test-backface-culling.c +++ b/src/tests/cogl/conform/test-backface-culling.c @@ -131,7 +131,7 @@ paint_test_backface_culling (TestState *state, 4, verts); cogl_primitive_draw (primitive, framebuffer, pipeline); - cogl_object_unref (primitive); + g_object_unref (primitive); x1 = x2; x2 = x1 + (float)(TEXTURE_RENDER_SIZE); @@ -151,7 +151,7 @@ paint_test_backface_culling (TestState *state, 4, verts); cogl_primitive_draw (primitive, framebuffer, pipeline); - cogl_object_unref (primitive); + g_object_unref (primitive); x1 = x2; x2 = x1 + (float)(TEXTURE_RENDER_SIZE); diff --git a/src/tests/cogl/conform/test-custom-attributes.c b/src/tests/cogl/conform/test-custom-attributes.c index 32e230d69..72268086a 100644 --- a/src/tests/cogl/conform/test-custom-attributes.c +++ b/src/tests/cogl/conform/test-custom-attributes.c @@ -68,7 +68,7 @@ test_float_verts (TestState *state, int offset_x, int offset_y) attributes, 2); /* n_attributes */ cogl_primitive_draw (primitive, test_fb, state->pipeline); - cogl_object_unref (primitive); + g_object_unref (primitive); cogl_framebuffer_pop_matrix (test_fb); @@ -129,7 +129,7 @@ test_byte_verts (TestState *state, int offset_x, int offset_y) attributes, 2); /* n_attributes */ cogl_primitive_draw (primitive, test_fb, state->pipeline); - cogl_object_unref (primitive); + g_object_unref (primitive); g_object_unref (attributes[1]); @@ -151,7 +151,7 @@ test_byte_verts (TestState *state, int offset_x, int offset_y) attributes, 2); /* n_attributes */ cogl_primitive_draw (primitive, test_fb, state->pipeline); - cogl_object_unref (primitive); + g_object_unref (primitive); cogl_framebuffer_pop_matrix (test_fb); @@ -213,7 +213,7 @@ test_short_verts (TestState *state, int offset_x, int offset_y) attributes, 2); /* n_attributes */ cogl_primitive_draw (primitive, test_fb, pipeline); - cogl_object_unref (primitive); + g_object_unref (primitive); cogl_framebuffer_pop_matrix (test_fb); @@ -248,7 +248,7 @@ test_short_verts (TestState *state, int offset_x, int offset_y) attributes, 1); /* n_attributes */ cogl_primitive_draw (primitive, test_fb, pipeline2); - cogl_object_unref (primitive); + g_object_unref (primitive); cogl_framebuffer_pop_matrix (test_fb); diff --git a/src/tests/cogl/conform/test-map-buffer-range.c b/src/tests/cogl/conform/test-map-buffer-range.c index df8c6d733..a7a52925f 100644 --- a/src/tests/cogl/conform/test-map-buffer-range.c +++ b/src/tests/cogl/conform/test-map-buffer-range.c @@ -108,7 +108,7 @@ test_map_buffer_range (void) tex_coord_attribute, NULL); cogl_primitive_draw (primitive, test_fb, pipeline); - cogl_object_unref (primitive); + g_object_unref (primitive); /* Top left pixel should be the one that is replaced to be green */ test_utils_check_pixel (test_fb, 1, 1, 0x00ff00ff); diff --git a/src/tests/cogl/conform/test-point-size-attribute.c b/src/tests/cogl/conform/test-point-size-attribute.c index 9357e4de4..2379af08e 100644 --- a/src/tests/cogl/conform/test-point-size-attribute.c +++ b/src/tests/cogl/conform/test-point-size-attribute.c @@ -125,7 +125,7 @@ do_test (const char *attribute_name, pipeline_setup_func (pipeline); cogl_primitive_draw (primitive, test_fb, pipeline); g_object_unref (pipeline); - cogl_object_unref (primitive); + g_object_unref (primitive); /* Verify all of the points where drawn at the right size */ for (i = 0; i < N_POINTS; i++) diff --git a/src/tests/cogl/conform/test-point-size.c b/src/tests/cogl/conform/test-point-size.c index 1c7713811..69efef232 100644 --- a/src/tests/cogl/conform/test-point-size.c +++ b/src/tests/cogl/conform/test-point-size.c @@ -82,7 +82,7 @@ test_point_size (void) cogl_pipeline_set_color4ub (pipeline, 0, 255, 0, 255); cogl_primitive_draw (prim, test_fb, pipeline); - cogl_object_unref (prim); + g_object_unref (prim); g_object_unref (pipeline); } diff --git a/src/tests/cogl/conform/test-point-sprite-known-failure.c b/src/tests/cogl/conform/test-point-sprite-known-failure.c index fbb6b765f..5808fea51 100644 --- a/src/tests/cogl/conform/test-point-sprite-known-failure.c +++ b/src/tests/cogl/conform/test-point-sprite-known-failure.c @@ -133,7 +133,7 @@ do_test (gboolean check_orientation, cogl_primitive_draw (prim, test_fb, solid_pipeline); cogl_framebuffer_pop_matrix (test_fb); - cogl_object_unref (prim); + g_object_unref (prim); g_object_unref (solid_pipeline); g_object_unref (pipeline); g_object_unref (tex_2d); diff --git a/src/tests/cogl/conform/test-point-sprite.c b/src/tests/cogl/conform/test-point-sprite.c index 7ad6363c8..688a74ddc 100644 --- a/src/tests/cogl/conform/test-point-sprite.c +++ b/src/tests/cogl/conform/test-point-sprite.c @@ -133,7 +133,7 @@ do_test (gboolean check_orientation, cogl_primitive_draw (prim, test_fb, solid_pipeline); cogl_framebuffer_pop_matrix (test_fb); - cogl_object_unref (prim); + g_object_unref (prim); g_object_unref (solid_pipeline); g_object_unref (pipeline); g_object_unref (tex_2d); diff --git a/src/tests/cogl/conform/test-primitive.c b/src/tests/cogl/conform/test-primitive.c index a10b9c025..5c7488083 100644 --- a/src/tests/cogl/conform/test-primitive.c +++ b/src/tests/cogl/conform/test-primitive.c @@ -199,7 +199,7 @@ test_paint (TestState *state) test_utils_check_pixel (test_fb, i * 10 + 2, 2, expected_color); - cogl_object_unref (prim); + g_object_unref (prim); } g_object_unref (pipeline); @@ -301,8 +301,8 @@ test_copy (TestState *state) g_assert (cogl_primitive_get_indices (prim_a) == cogl_primitive_get_indices (prim_b)); - cogl_object_unref (prim_a); - cogl_object_unref (prim_b); + g_object_unref (prim_a); + g_object_unref (prim_b); g_object_unref (indices); for (i = 0; i < N_ATTRIBS; i++) diff --git a/src/tests/cogl/conform/test-wrap-modes.c b/src/tests/cogl/conform/test-wrap-modes.c index d433a19e4..f4ab2d294 100644 --- a/src/tests/cogl/conform/test-wrap-modes.c +++ b/src/tests/cogl/conform/test-wrap-modes.c @@ -129,7 +129,7 @@ draw_tests_polygon (TestState *state) G_N_ELEMENTS (vertices), vertices); cogl_primitive_draw (primitive, test_fb, pipeline); - cogl_object_unref (primitive); + g_object_unref (primitive); g_object_unref (pipeline); cogl_framebuffer_pop_matrix (test_fb); }