cogl-matrix-stack: Convert to be a CoglObject

We will want to use ref-counting on the CoglMatrixStack so it might as
well be a CoglObject.
This commit is contained in:
Neil Roberts 2010-12-10 16:06:16 +00:00
parent d678125dd4
commit c11f72fd6d
4 changed files with 13 additions and 9 deletions

View File

@ -166,10 +166,10 @@ _cogl_framebuffer_free (CoglFramebuffer *framebuffer)
{
_cogl_clip_state_destroy (&framebuffer->clip_state);
_cogl_matrix_stack_destroy (framebuffer->modelview_stack);
cogl_object_unref (framebuffer->modelview_stack);
framebuffer->modelview_stack = NULL;
_cogl_matrix_stack_destroy (framebuffer->projection_stack);
cogl_object_unref (framebuffer->projection_stack);
framebuffer->projection_stack = NULL;
}

View File

@ -34,6 +34,7 @@
#include "cogl-internal.h"
#include "cogl-matrix-stack.h"
#include "cogl-framebuffer-private.h"
#include "cogl-object-private.h"
typedef struct {
CoglMatrix matrix;
@ -53,6 +54,8 @@ typedef struct {
*/
struct _CoglMatrixStack
{
CoglObject _parent;
GArray *stack;
/* which state does GL have, NULL if unknown */
@ -62,6 +65,10 @@ struct _CoglMatrixStack
unsigned int age;
};
static void _cogl_matrix_stack_free (CoglMatrixStack *stack);
COGL_OBJECT_INTERNAL_DEFINE (MatrixStack, matrix_stack);
/* XXX: this doesn't initialize the matrix! */
static void
_cogl_matrix_state_init (CoglMatrixState *state)
@ -142,11 +149,11 @@ _cogl_matrix_stack_new (void)
stack->age = 0;
return stack;
return _cogl_matrix_stack_object_new (stack);
}
void
_cogl_matrix_stack_destroy (CoglMatrixStack *stack)
static void
_cogl_matrix_stack_free (CoglMatrixStack *stack)
{
g_array_free (stack->stack, TRUE);
g_slice_free (CoglMatrixStack, stack);

View File

@ -42,9 +42,6 @@ typedef enum {
CoglMatrixStack *
_cogl_matrix_stack_new (void);
void
_cogl_matrix_stack_destroy (CoglMatrixStack *stack);
void
_cogl_matrix_stack_push (CoglMatrixStack *stack);

View File

@ -102,7 +102,7 @@ texture_unit_free (CoglTextureUnit *unit)
{
if (unit->layer)
cogl_object_unref (unit->layer);
_cogl_matrix_stack_destroy (unit->matrix_stack);
cogl_object_unref (unit->matrix_stack);
}
CoglTextureUnit *