1
0
Fork 0

cogl: Port MatrixStack away from CoglObject

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3193>
This commit is contained in:
Bilal Elmoussaoui 2023-08-18 10:29:42 +02:00 committed by Marge Bot
parent d71fe5c55e
commit 4afc187062
6 changed files with 41 additions and 38 deletions

View file

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

View file

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

View file

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

View file

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

View file

@ -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);
*
* <note>#CoglMatrixEntry<!-- -->s are reference counted using
* cogl_matrix_entry_ref() and cogl_matrix_entry_unref() not with
* cogl_object_ref() and cogl_object_unref().</note>
* g_object_ref() and g_object_unref().</note>
*/
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

View file

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