diff --git a/clutter/cogl/cogl/cogl-clip-state.c b/clutter/cogl/cogl/cogl-clip-state.c index 1be67f9e1..317089ef4 100644 --- a/clutter/cogl/cogl/cogl-clip-state.c +++ b/clutter/cogl/cogl/cogl-clip-state.c @@ -46,7 +46,7 @@ cogl_clip_push_window_rectangle (int x_offset, int width, int height) { - CoglHandle framebuffer; + CoglFramebuffer *framebuffer; CoglClipState *clip_state; CoglHandle stack; @@ -133,7 +133,7 @@ cogl_clip_push_rectangle (float x_1, float x_2, float y_2) { - CoglHandle framebuffer; + CoglFramebuffer *framebuffer; CoglClipState *clip_state; CoglHandle stack; CoglMatrix modelview_matrix; @@ -178,7 +178,7 @@ cogl_clip_push (float x_offset, void cogl_clip_push_from_path_preserve (void) { - CoglHandle framebuffer; + CoglFramebuffer *framebuffer; CoglClipState *clip_state; CoglHandle stack; CoglMatrix modelview_matrix; @@ -229,7 +229,7 @@ _cogl_clip_pop_real (CoglClipState *clip_state) void cogl_clip_pop (void) { - CoglHandle framebuffer; + CoglFramebuffer *framebuffer; CoglClipState *clip_state; _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -292,7 +292,7 @@ _cogl_clip_stack_save_real (CoglClipState *clip_state) void cogl_clip_stack_save (void) { - CoglHandle framebuffer; + CoglFramebuffer *framebuffer; CoglClipState *clip_state; _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -328,7 +328,7 @@ _cogl_clip_stack_restore_real (CoglClipState *clip_state) void cogl_clip_stack_restore (void) { - CoglHandle framebuffer; + CoglFramebuffer *framebuffer; CoglClipState *clip_state; _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -368,7 +368,7 @@ _cogl_clip_state_dirty (CoglClipState *clip_state) CoglHandle _cogl_get_clip_stack (void) { - CoglHandle framebuffer; + CoglFramebuffer *framebuffer; CoglClipState *clip_state; _COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE); @@ -382,7 +382,7 @@ _cogl_get_clip_stack (void) void _cogl_set_clip_stack (CoglHandle handle) { - CoglHandle framebuffer; + CoglFramebuffer *framebuffer; CoglClipState *clip_state; _COGL_GET_CONTEXT (ctx, NO_RETVAL); diff --git a/clutter/cogl/cogl/cogl-framebuffer-private.h b/clutter/cogl/cogl/cogl-framebuffer-private.h index 09a9cd824..adc2a92bb 100644 --- a/clutter/cogl/cogl/cogl-framebuffer-private.h +++ b/clutter/cogl/cogl/cogl-framebuffer-private.h @@ -33,9 +33,9 @@ typedef enum _CoglFramebufferType { COGL_FRAMEBUFFER_TYPE_OFFSCREEN } CoglFramebufferType; -typedef struct +struct _CoglFramebuffer { - CoglHandleObject _parent; + CoglObject _parent; CoglFramebufferType type; int width; int height; @@ -54,7 +54,7 @@ typedef struct int blue_bits; int green_bits; int alpha_bits; -} CoglFramebuffer; +}; #define COGL_FRAMEBUFFER(X) ((CoglFramebuffer *)(X)) @@ -79,40 +79,41 @@ void _cogl_framebuffer_state_init (void); int -_cogl_framebuffer_get_width (CoglHandle handle); +_cogl_framebuffer_get_width (CoglFramebuffer *framebuffer); int -_cogl_framebuffer_get_height (CoglHandle handle); +_cogl_framebuffer_get_height (CoglFramebuffer *framebuffer); CoglClipState * -_cogl_framebuffer_get_clip_state (CoglHandle handle); +_cogl_framebuffer_get_clip_state (CoglFramebuffer *framebuffer); void -_cogl_framebuffer_set_viewport (CoglHandle handle, +_cogl_framebuffer_set_viewport (CoglFramebuffer *framebuffer, int x, int y, int width, int height); int -_cogl_framebuffer_get_viewport_x (CoglHandle handle); +_cogl_framebuffer_get_viewport_x (CoglFramebuffer *framebuffer); int -_cogl_framebuffer_get_viewport_y (CoglHandle handle); +_cogl_framebuffer_get_viewport_y (CoglFramebuffer *framebuffer); int -_cogl_framebuffer_get_viewport_width (CoglHandle handle); +_cogl_framebuffer_get_viewport_width (CoglFramebuffer *framebuffer); int -_cogl_framebuffer_get_viewport_height (CoglHandle handle); +_cogl_framebuffer_get_viewport_height (CoglFramebuffer *framebuffer); void -_cogl_framebuffer_get_viewport4fv (CoglHandle handle, int *viewport); +_cogl_framebuffer_get_viewport4fv (CoglFramebuffer *framebuffer, + int *viewport); CoglMatrixStack * -_cogl_framebuffer_get_modelview_stack (CoglHandle handle); +_cogl_framebuffer_get_modelview_stack (CoglFramebuffer *framebuffer); CoglMatrixStack * -_cogl_framebuffer_get_projection_stack (CoglHandle handle); +_cogl_framebuffer_get_projection_stack (CoglFramebuffer *framebuffer); typedef enum _CoglFramebufferFlushFlags { @@ -124,13 +125,13 @@ typedef enum _CoglFramebufferFlushFlags } CoglFramebufferFlushFlags; void -_cogl_framebuffer_flush_state (CoglHandle handle, +_cogl_framebuffer_flush_state (CoglFramebuffer *framebuffer, CoglFramebufferFlushFlags flags); CoglHandle _cogl_onscreen_new (void); -CoglHandle +CoglFramebuffer * _cogl_get_framebuffer (void); GSList * diff --git a/clutter/cogl/cogl/cogl-framebuffer.c b/clutter/cogl/cogl/cogl-framebuffer.c index 032bf2209..517156ab9 100644 --- a/clutter/cogl/cogl/cogl-framebuffer.c +++ b/clutter/cogl/cogl/cogl-framebuffer.c @@ -29,6 +29,7 @@ #include "cogl-internal.h" #include "cogl-context.h" #include "cogl-handle.h" +#include "cogl-object-private.h" #include "cogl-util.h" #include "cogl-texture-private.h" #include "cogl-framebuffer-private.h" @@ -112,21 +113,21 @@ static void _cogl_framebuffer_free (CoglFramebuffer *framebuffer); static void _cogl_onscreen_free (CoglOnscreen *onscreen); static void _cogl_offscreen_free (CoglOffscreen *offscreen); -COGL_HANDLE_DEFINE (Onscreen, onscreen); -COGL_HANDLE_DEFINE (Offscreen, offscreen); +COGL_OBJECT_DEFINE (Onscreen, onscreen); +COGL_OBJECT_DEFINE (Offscreen, offscreen); /* XXX: - * The CoglHandle macros don't support any form of inheritance, so for - * now we implement the CoglHandle support for the CoglFramebuffer + * The CoglObject macros don't support any form of inheritance, so for + * now we implement the CoglObject support for the CoglFramebuffer * abstract class manually. */ gboolean -cogl_is_framebuffer (CoglHandle handle) +cogl_is_framebuffer (void *object) { - CoglHandleObject *obj = (CoglHandleObject *)handle; + CoglHandleObject *obj = object; - if (handle == COGL_INVALID_HANDLE) + if (obj == NULL) return FALSE; return obj->klass->type == _cogl_handle_onscreen_get_type () @@ -169,36 +170,30 @@ _cogl_framebuffer_free (CoglFramebuffer *framebuffer) } int -_cogl_framebuffer_get_width (CoglHandle handle) +_cogl_framebuffer_get_width (CoglFramebuffer *framebuffer) { - CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (handle); return framebuffer->width; } int -_cogl_framebuffer_get_height (CoglHandle handle) +_cogl_framebuffer_get_height (CoglFramebuffer *framebuffer) { - CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (handle); return framebuffer->height; } CoglClipState * -_cogl_framebuffer_get_clip_state (CoglHandle handle) +_cogl_framebuffer_get_clip_state (CoglFramebuffer *framebuffer) { - CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (handle); - return &framebuffer->clip_state; } void -_cogl_framebuffer_set_viewport (CoglHandle handle, +_cogl_framebuffer_set_viewport (CoglFramebuffer *framebuffer, int x, int y, int width, int height) { - CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (handle); - _COGL_GET_CONTEXT (ctx, NO_RETVAL); if (framebuffer->viewport_x == x && @@ -219,37 +214,32 @@ _cogl_framebuffer_set_viewport (CoglHandle handle, } int -_cogl_framebuffer_get_viewport_x (CoglHandle handle) +_cogl_framebuffer_get_viewport_x (CoglFramebuffer *framebuffer) { - CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (handle); return framebuffer->viewport_x; } int -_cogl_framebuffer_get_viewport_y (CoglHandle handle) +_cogl_framebuffer_get_viewport_y (CoglFramebuffer *framebuffer) { - CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (handle); return framebuffer->viewport_y; } int -_cogl_framebuffer_get_viewport_width (CoglHandle handle) +_cogl_framebuffer_get_viewport_width (CoglFramebuffer *framebuffer) { - CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (handle); return framebuffer->viewport_width; } int -_cogl_framebuffer_get_viewport_height (CoglHandle handle) +_cogl_framebuffer_get_viewport_height (CoglFramebuffer *framebuffer) { - CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (handle); return framebuffer->viewport_height; } void -_cogl_framebuffer_get_viewport4fv (CoglHandle handle, int *viewport) +_cogl_framebuffer_get_viewport4fv (CoglFramebuffer *framebuffer, int *viewport) { - CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (handle); viewport[0] = framebuffer->viewport_x; viewport[1] = framebuffer->viewport_y; viewport[2] = framebuffer->viewport_width; @@ -257,16 +247,14 @@ _cogl_framebuffer_get_viewport4fv (CoglHandle handle, int *viewport) } CoglMatrixStack * -_cogl_framebuffer_get_modelview_stack (CoglHandle handle) +_cogl_framebuffer_get_modelview_stack (CoglFramebuffer *framebuffer) { - CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (handle); return framebuffer->modelview_stack; } CoglMatrixStack * -_cogl_framebuffer_get_projection_stack (CoglHandle handle) +_cogl_framebuffer_get_projection_stack (CoglFramebuffer *framebuffer) { - CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (handle); return framebuffer->projection_stack; } @@ -501,7 +489,7 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle) cogl_texture_get_width (texhandle), cogl_texture_get_height (texhandle)); - return _cogl_offscreen_handle_new (offscreen); + return _cogl_offscreen_object_new (offscreen); } else { @@ -552,7 +540,7 @@ _cogl_onscreen_new (void) 0xdeadbeef, /* width */ 0xdeadbeef); /* height */ - return _cogl_onscreen_handle_new (onscreen); + return _cogl_onscreen_object_new (onscreen); } static void @@ -616,21 +604,21 @@ _cogl_free_framebuffer_stack (GSList *stack) static void _cogl_set_framebuffer_real (CoglFramebuffer *framebuffer) { - CoglHandle *entry; + CoglFramebuffer **entry; _COGL_GET_CONTEXT (ctx, NO_RETVAL); cogl_flush (); - entry = &ctx->framebuffer_stack->data; + entry = (CoglFramebuffer **)&ctx->framebuffer_stack->data; ctx->dirty_bound_framebuffer = 1; ctx->dirty_gl_viewport = 1; if (framebuffer != COGL_INVALID_HANDLE) - cogl_handle_ref (framebuffer); + cogl_object_ref (framebuffer); if (*entry != COGL_INVALID_HANDLE) - cogl_handle_unref (*entry); + cogl_object_unref (*entry); *entry = framebuffer; @@ -644,12 +632,12 @@ _cogl_set_framebuffer_real (CoglFramebuffer *framebuffer) } void -cogl_set_framebuffer (CoglHandle handle) +cogl_set_framebuffer (CoglFramebuffer *framebuffer) { - g_return_if_fail (cogl_is_framebuffer (handle)); + g_return_if_fail (cogl_is_framebuffer (framebuffer)); - if (_cogl_get_framebuffer () != handle) - _cogl_set_framebuffer_real (COGL_FRAMEBUFFER (handle)); + if (_cogl_get_framebuffer () != framebuffer) + _cogl_set_framebuffer_real (framebuffer); } /* XXX: deprecated API */ @@ -664,18 +652,18 @@ cogl_set_draw_buffer (CoglBufferTarget target, CoglHandle handle) cogl_set_framebuffer (handle); } -CoglHandle +CoglFramebuffer * _cogl_get_framebuffer (void) { _COGL_GET_CONTEXT (ctx, NULL); g_assert (ctx->framebuffer_stack); - return (CoglHandle)ctx->framebuffer_stack->data; + return ctx->framebuffer_stack->data; } void -cogl_push_framebuffer (CoglHandle buffer) +cogl_push_framebuffer (CoglFramebuffer *buffer) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -700,8 +688,8 @@ cogl_push_draw_buffer (void) void cogl_pop_framebuffer (void) { - CoglHandle to_pop; - CoglHandle to_restore; + CoglFramebuffer *to_pop; + CoglFramebuffer *to_restore; _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -713,7 +701,7 @@ cogl_pop_framebuffer (void) cogl_flush (); - cogl_handle_unref (to_pop); + cogl_object_unref (to_pop); ctx->framebuffer_stack = g_slist_remove_link (ctx->framebuffer_stack, ctx->framebuffer_stack); @@ -733,15 +721,11 @@ cogl_pop_draw_buffer (void) } void -_cogl_framebuffer_flush_state (CoglHandle handle, +_cogl_framebuffer_flush_state (CoglFramebuffer *framebuffer, CoglFramebufferFlushFlags flags) { - CoglFramebuffer *framebuffer; - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - framebuffer = COGL_FRAMEBUFFER (handle); - if (cogl_features_available (COGL_FEATURE_OFFSCREEN) && ctx->dirty_bound_framebuffer) { @@ -802,41 +786,34 @@ _cogl_framebuffer_flush_state (CoglHandle handle, } int -_cogl_framebuffer_get_red_bits (CoglHandle framebuffer) +_cogl_framebuffer_get_red_bits (CoglFramebuffer *framebuffer) { - CoglFramebuffer *fb = COGL_FRAMEBUFFER (framebuffer); + _cogl_framebuffer_init_bits (framebuffer); - _cogl_framebuffer_init_bits (fb); - - return fb->red_bits; + return framebuffer->red_bits; } int -_cogl_framebuffer_get_green_bits (CoglHandle framebuffer) +_cogl_framebuffer_get_green_bits (CoglFramebuffer *framebuffer) { - CoglFramebuffer *fb = COGL_FRAMEBUFFER (framebuffer); + _cogl_framebuffer_init_bits (framebuffer); - _cogl_framebuffer_init_bits (fb); - - return fb->green_bits; + return framebuffer->green_bits; } int -_cogl_framebuffer_get_blue_bits (CoglHandle framebuffer) +_cogl_framebuffer_get_blue_bits (CoglFramebuffer *framebuffer) { - CoglFramebuffer *fb = COGL_FRAMEBUFFER (framebuffer); + _cogl_framebuffer_init_bits (framebuffer); - _cogl_framebuffer_init_bits (fb); - - return fb->blue_bits; + return framebuffer->blue_bits; } int -_cogl_framebuffer_get_alpha_bits (CoglHandle framebuffer) +_cogl_framebuffer_get_alpha_bits (CoglFramebuffer *framebuffer) { - CoglFramebuffer *fb = COGL_FRAMEBUFFER (framebuffer); + _cogl_framebuffer_init_bits (framebuffer); - _cogl_framebuffer_init_bits (fb); - - return fb->alpha_bits; + return framebuffer->alpha_bits; } + diff --git a/clutter/cogl/cogl/cogl-journal.c b/clutter/cogl/cogl/cogl-journal.c index 01d61e44d..f8ee00402 100644 --- a/clutter/cogl/cogl/cogl-journal.c +++ b/clutter/cogl/cogl/cogl-journal.c @@ -548,7 +548,7 @@ _cogl_journal_flush (void) GLuint journal_vbo; gboolean vbo_fallback = (cogl_get_features () & COGL_FEATURE_VBOS) ? FALSE : TRUE; - CoglHandle framebuffer; + CoglFramebuffer *framebuffer; CoglMatrixStack *modelview_stack; COGL_STATIC_TIMER (flush_timer, "Mainloop", /* parent */ diff --git a/clutter/cogl/cogl/cogl-texture.c b/clutter/cogl/cogl/cogl-texture.c index 2a70ee5d5..dd24ad341 100644 --- a/clutter/cogl/cogl/cogl-texture.c +++ b/clutter/cogl/cogl/cogl-texture.c @@ -953,7 +953,7 @@ _cogl_texture_draw_and_read (CoglHandle handle, GLuint target_gl_type) { int bpp; - CoglHandle framebuffer; + CoglFramebuffer *framebuffer; int viewport[4]; CoglBitmap alpha_bmp; CoglHandle prev_source; diff --git a/clutter/cogl/cogl/cogl.c b/clutter/cogl/cogl/cogl.c index bcec7f0c2..8aa110e0c 100644 --- a/clutter/cogl/cogl/cogl.c +++ b/clutter/cogl/cogl/cogl.c @@ -552,7 +552,7 @@ cogl_get_bitmasks (int *red, int *blue, int *alpha) { - CoglHandle framebuffer; + CoglFramebuffer *framebuffer; framebuffer = _cogl_get_framebuffer (); diff --git a/clutter/cogl/cogl/cogl.h b/clutter/cogl/cogl/cogl.h index 47b25bf19..2e9774f26 100644 --- a/clutter/cogl/cogl/cogl.h +++ b/clutter/cogl/cogl/cogl.h @@ -65,6 +65,8 @@ G_BEGIN_DECLS * General utility functions for COGL. */ +typedef struct _CoglFramebuffer CoglFramebuffer; + /** * cogl_get_option_group: * @@ -172,7 +174,7 @@ cogl_get_bitmasks (int *red, * Since: 1.4 */ int -_cogl_framebuffer_get_red_bits (CoglHandle framebuffer); +_cogl_framebuffer_get_red_bits (CoglFramebuffer *framebuffer); /* * _cogl_framebuffer_get_green_bits: @@ -185,7 +187,7 @@ _cogl_framebuffer_get_red_bits (CoglHandle framebuffer); * Since: 1.4 */ int -_cogl_framebuffer_get_green_bits (CoglHandle framebuffer); +_cogl_framebuffer_get_green_bits (CoglFramebuffer *framebuffer); /* * _cogl_framebuffer_get_blue_bits: @@ -198,7 +200,7 @@ _cogl_framebuffer_get_green_bits (CoglHandle framebuffer); * Since: 1.4 */ int -_cogl_framebuffer_get_blue_bits (CoglHandle framebuffer); +_cogl_framebuffer_get_blue_bits (CoglFramebuffer *framebuffer); /* * _cogl_framebuffer_get_alpha_bits: @@ -211,7 +213,7 @@ _cogl_framebuffer_get_blue_bits (CoglHandle framebuffer); * Since: 1.4 */ int -_cogl_framebuffer_get_alpha_bits (CoglHandle framebuffer); +_cogl_framebuffer_get_alpha_bits (CoglFramebuffer *framebuffer); /** * cogl_perspective: @@ -910,8 +912,7 @@ cogl_clip_stack_restore (void) G_GNUC_DEPRECATED; /** * cogl_set_framebuffer: - * @buffer: The #CoglHandle of a Cogl framebuffer; either onscreen or - * offscreen. + * @buffer: A #CoglFramebuffer object, either onscreen or offscreen. * * This redirects all subsequent drawing to the specified framebuffer. This can * either be an offscreen buffer created with cogl_offscreen_new_to_texture () @@ -920,12 +921,11 @@ cogl_clip_stack_restore (void) G_GNUC_DEPRECATED; * Since: 1.2 */ void -cogl_set_framebuffer (CoglHandle buffer); +cogl_set_framebuffer (CoglFramebuffer *buffer); /** * cogl_push_framebuffer: - * @buffer: The #CoglHandle of a Cogl framebuffer; either onscreen or - * offscreen. + * @buffer: A #CoglFramebuffer object, either onscreen or offscreen. * * Redirects all subsequent drawing to the specified framebuffer. This can * either be an offscreen buffer created with cogl_offscreen_new_to_texture () @@ -979,7 +979,7 @@ cogl_set_framebuffer (CoglHandle buffer); * * static void * my_init_framebuffer (ClutterStage *stage, - * CoglHandle framebuffer, + * CoglFramebuffer *framebuffer, * unsigned int framebuffer_width, * unsigned int framebuffer_height) * { @@ -1002,7 +1002,7 @@ cogl_set_framebuffer (CoglHandle buffer); * Since: 1.2 */ void -cogl_push_framebuffer (CoglHandle buffer); +cogl_push_framebuffer (CoglFramebuffer *buffer); /** * cogl_pop_framebuffer: