diff --git a/clutter/clutter/clutter-pick-stack.c b/clutter/clutter/clutter-pick-stack.c index 8cecb8adb..009ab8217 100644 --- a/clutter/clutter/clutter-pick-stack.c +++ b/clutter/clutter/clutter-pick-stack.c @@ -247,7 +247,7 @@ static void clutter_pick_stack_dispose (ClutterPickStack *pick_stack) { remove_pick_stack_weak_refs (pick_stack); - g_clear_pointer (&pick_stack->matrix_stack, cogl_object_unref); + g_clear_object (&pick_stack->matrix_stack); g_clear_pointer (&pick_stack->vertices_stack, g_array_unref); g_clear_pointer (&pick_stack->clip_stack, g_array_unref); } diff --git a/cogl/cogl/cogl-framebuffer.c b/cogl/cogl/cogl-framebuffer.c index 1b1df3a99..d9e6f7f08 100644 --- a/cogl/cogl/cogl-framebuffer.c +++ b/cogl/cogl/cogl-framebuffer.c @@ -344,8 +344,8 @@ cogl_framebuffer_dispose (GObject *object) } g_clear_pointer (&priv->clip_stack, _cogl_clip_stack_unref); - cogl_clear_object (&priv->modelview_stack); - cogl_clear_object (&priv->projection_stack); + g_clear_object (&priv->modelview_stack); + g_clear_object (&priv->projection_stack); g_clear_pointer (&priv->journal, _cogl_journal_free); ctx->framebuffers = g_list_remove (ctx->framebuffers, framebuffer); diff --git a/cogl/cogl/cogl-matrix-stack-private.h b/cogl/cogl/cogl-matrix-stack-private.h index 375c78230..b2f124202 100644 --- a/cogl/cogl/cogl-matrix-stack-private.h +++ b/cogl/cogl/cogl-matrix-stack-private.h @@ -34,7 +34,6 @@ #pragma once -#include "cogl/cogl-object-private.h" #include "cogl/cogl-matrix-stack.h" #include "cogl/cogl-context.h" #include "cogl/cogl-framebuffer.h" @@ -136,7 +135,7 @@ typedef union _CoglMatrixEntryFull struct _CoglMatrixStack { - CoglObject _parent; + GObject parent_instance; CoglContext *context; diff --git a/cogl/cogl/cogl-matrix-stack.c b/cogl/cogl/cogl-matrix-stack.c index 391d8db95..e750664b4 100644 --- a/cogl/cogl/cogl-matrix-stack.c +++ b/cogl/cogl/cogl-matrix-stack.c @@ -42,10 +42,6 @@ #include "cogl/cogl-magazine-private.h" #include "cogl/cogl-gtype-private.h" -static void _cogl_matrix_stack_free (CoglMatrixStack *stack); - -COGL_OBJECT_DEFINE (MatrixStack, matrix_stack); -COGL_GTYPE_DEFINE_CLASS (MatrixStack, matrix_stack); COGL_GTYPE_DEFINE_BOXED (MatrixEntry, matrix_entry, cogl_matrix_entry_ref, cogl_matrix_entry_unref); @@ -69,6 +65,32 @@ _cogl_matrix_entry_new (CoglMatrixOp operation) return entry; } +G_DEFINE_TYPE (CoglMatrixStack, cogl_matrix_stack, G_TYPE_OBJECT); + +static void +cogl_matrix_stack_dispose (GObject *object) +{ + CoglMatrixStack *stack = COGL_MATRIX_STACK (object); + + cogl_matrix_entry_unref (stack->last_entry); + + G_OBJECT_CLASS (cogl_matrix_stack_parent_class)->dispose (object); +} + +static void +cogl_matrix_stack_init (CoglMatrixStack *stack) +{ +} + +static void +cogl_matrix_stack_class_init (CoglMatrixStackClass *class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (class); + + object_class->dispose = cogl_matrix_stack_dispose; +} + + static void * _cogl_matrix_stack_push_entry (CoglMatrixStack *stack, CoglMatrixEntry *entry) @@ -509,17 +531,10 @@ cogl_matrix_stack_get (CoglMatrixStack *stack, return cogl_matrix_entry_get (stack->last_entry, matrix); } -static void -_cogl_matrix_stack_free (CoglMatrixStack *stack) -{ - cogl_matrix_entry_unref (stack->last_entry); - g_free (stack); -} - CoglMatrixStack * cogl_matrix_stack_new (CoglContext *ctx) { - CoglMatrixStack *stack = g_new0 (CoglMatrixStack, 1); + CoglMatrixStack *stack = g_object_new (COGL_TYPE_MATRIX_STACK, NULL); if (G_UNLIKELY (cogl_matrix_stack_magazine == NULL)) { @@ -533,7 +548,7 @@ cogl_matrix_stack_new (CoglContext *ctx) cogl_matrix_entry_ref (&ctx->identity_entry); _cogl_matrix_stack_push_entry (stack, &ctx->identity_entry); - return _cogl_matrix_stack_object_new (stack); + return stack; } static CoglMatrixEntry * diff --git a/cogl/cogl/cogl-matrix-stack.h b/cogl/cogl/cogl-matrix-stack.h index 6d2fc2a12..5ecb2e26d 100644 --- a/cogl/cogl/cogl-matrix-stack.h +++ b/cogl/cogl/cogl-matrix-stack.h @@ -133,13 +133,14 @@ */ typedef struct _CoglMatrixStack CoglMatrixStack; -/** - * cogl_matrix_stack_get_gtype: - * - * Returns: a #GType that can be used with the GLib type system. - */ +#define COGL_TYPE_MATRIX_STACK (cogl_matrix_stack_get_type ()) + COGL_EXPORT -GType cogl_matrix_stack_get_gtype (void); +G_DECLARE_FINAL_TYPE (CoglMatrixStack, + cogl_matrix_stack, + COGL, + MATRIX_STACK, + GObject) /** * CoglMatrixEntry: @@ -173,7 +174,7 @@ GType cogl_matrix_stack_get_gtype (void); * * #CoglMatrixEntrys are reference counted using * cogl_matrix_entry_ref() and cogl_matrix_entry_unref() not with - * cogl_object_ref() and cogl_object_unref(). + * g_object_ref() and g_object_unref(). */ typedef struct _CoglMatrixEntry CoglMatrixEntry; @@ -518,18 +519,6 @@ COGL_EXPORT void cogl_matrix_stack_set (CoglMatrixStack *stack, const graphene_matrix_t *matrix); -/** - * cogl_is_matrix_stack: - * @object: a #CoglObject - * - * Determines if the given #CoglObject refers to a #CoglMatrixStack. - * - * Return value: %TRUE if @object is a #CoglMatrixStack, otherwise - * %FALSE. - */ -COGL_EXPORT gboolean -cogl_is_matrix_stack (void *object); - /** * cogl_matrix_entry_calculate_translation: * @entry0: The first reference transform diff --git a/cogl/cogl/driver/gl/cogl-pipeline-opengl.c b/cogl/cogl/driver/gl/cogl-pipeline-opengl.c index 6fc6fa684..6c3ea2555 100644 --- a/cogl/cogl/driver/gl/cogl-pipeline-opengl.c +++ b/cogl/cogl/driver/gl/cogl-pipeline-opengl.c @@ -85,7 +85,7 @@ texture_unit_free (CoglTextureUnit *unit) { if (unit->layer) cogl_object_unref (unit->layer); - cogl_object_unref (unit->matrix_stack); + g_object_unref (unit->matrix_stack); } CoglTextureUnit *