diff --git a/cogl/cogl-path-private.h b/cogl/cogl-path-private.h index b215e3fe9..a5a249ce1 100644 --- a/cogl/cogl-path-private.h +++ b/cogl/cogl-path-private.h @@ -56,7 +56,6 @@ typedef struct _CoglBezCubic floatVec2 p4; } CoglBezCubic; -typedef struct _CoglPath CoglPath; typedef struct _CoglPathData CoglPathData; struct _CoglPath @@ -81,11 +80,11 @@ struct _CoglPathData /* This is an internal version of cogl_path_new that doesn't affect the current path and just creates a new handle */ -CoglHandle +CoglPath * _cogl_path_new (void); void -_cogl_add_path_to_stencil_buffer (CoglHandle path, +_cogl_add_path_to_stencil_buffer (CoglPath *path, gboolean merge, gboolean need_clear); diff --git a/cogl/cogl-path.c b/cogl/cogl-path.c index 7b8023e1e..b89d29fab 100644 --- a/cogl/cogl-path.c +++ b/cogl/cogl-path.c @@ -26,6 +26,7 @@ #endif #include "cogl.h" +#include "cogl-object.h" #include "cogl-internal.h" #include "cogl-context.h" #include "cogl-journal-private.h" @@ -44,7 +45,7 @@ static void _cogl_path_free (CoglPath *path); -COGL_HANDLE_DEFINE (Path, path); +COGL_OBJECT_DEFINE (Path, path); static void _cogl_path_data_unref (CoglPathData *data) @@ -179,7 +180,7 @@ _cogl_path_get_bounds (floatVec2 nodes_min, } void -_cogl_add_path_to_stencil_buffer (CoglHandle path_handle, +_cogl_add_path_to_stencil_buffer (CoglPath *path, gboolean merge, gboolean need_clear) { @@ -190,17 +191,14 @@ _cogl_add_path_to_stencil_buffer (CoglHandle path_handle, float bounds_h; unsigned long enable_flags = COGL_ENABLE_VERTEX_ARRAY; CoglHandle prev_source; - CoglHandle framebuffer = _cogl_get_framebuffer (); + CoglFramebuffer *framebuffer = _cogl_get_framebuffer (); CoglMatrixStack *modelview_stack = _cogl_framebuffer_get_modelview_stack (framebuffer); CoglMatrixStack *projection_stack = _cogl_framebuffer_get_projection_stack (framebuffer); - CoglPath *path; _COGL_GET_CONTEXT (ctx, NO_RETVAL); - path = COGL_PATH (path_handle); - /* We don't track changes to the stencil buffer in the journal * so we need to flush any batched geometry first */ _cogl_journal_flush (); @@ -211,7 +209,7 @@ _cogl_add_path_to_stencil_buffer (CoglHandle path_handle, _cogl_framebuffer_flush_state (framebuffer, 0); /* Just setup a simple material that doesn't use texturing... */ - prev_source = cogl_handle_ref (ctx->source_material); + prev_source = cogl_object_ref (ctx->source_material); cogl_set_source (ctx->stencil_material); _cogl_material_flush_gl_state (ctx->source_material, NULL); @@ -316,7 +314,7 @@ _cogl_add_path_to_stencil_buffer (CoglHandle path_handle, /* restore the original material */ cogl_set_source (prev_source); - cogl_handle_unref (prev_source); + cogl_object_unref (prev_source); } static int @@ -525,7 +523,7 @@ _cogl_path_fill_nodes (void) if (G_LIKELY (!(cogl_debug_flags & COGL_DEBUG_FORCE_SCANLINE_PATHS)) && cogl_features_available (COGL_FEATURE_STENCIL_BUFFER)) { - CoglHandle framebuffer; + CoglFramebuffer *framebuffer; CoglClipState *clip_state; _cogl_journal_flush (); @@ -689,7 +687,7 @@ cogl_path_new (void) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); - cogl_handle_unref (ctx->current_path); + cogl_object_unref (ctx->current_path); ctx->current_path = _cogl_path_new (); } @@ -1062,7 +1060,7 @@ cogl_path_rel_curve_to (float x_1, data->path_pen.y + y_3); } -CoglHandle +CoglPath * cogl_path_get (void) { _COGL_GET_CONTEXT (ctx, NULL); @@ -1071,21 +1069,21 @@ cogl_path_get (void) } void -cogl_path_set (CoglHandle handle) +cogl_path_set (CoglPath *path) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); - if (!cogl_is_path (handle)) + if (!cogl_is_path (path)) return; - /* Reference the new handle first in case it is the same as the old - handle */ - cogl_handle_ref (handle); - cogl_handle_unref (ctx->current_path); - ctx->current_path = handle; + /* Reference the new object first in case it is the same as the old + object */ + cogl_object_ref (path); + cogl_object_unref (ctx->current_path); + ctx->current_path = path; } -CoglHandle +CoglPath * _cogl_path_new (void) { CoglPath *path; @@ -1098,26 +1096,24 @@ _cogl_path_new (void) data->path_nodes = g_array_new (FALSE, FALSE, sizeof (CoglPathNode)); data->last_path = 0; - return _cogl_path_handle_new (path); + return _cogl_path_object_new (path); } -CoglHandle -cogl_path_copy (CoglHandle handle) +CoglPath * +cogl_path_copy (CoglPath *old_path) { - CoglPath *old_path, *new_path; + CoglPath *new_path; _COGL_GET_CONTEXT (ctx, NULL); - if (!cogl_is_path (handle)) - return COGL_INVALID_HANDLE; - - old_path = COGL_PATH (handle); + if (!cogl_is_path (old_path)) + return NULL; new_path = g_slice_new (CoglPath); new_path->data = old_path->data; new_path->data->ref_count++; - return _cogl_path_handle_new (new_path); + return _cogl_path_object_new (new_path); } static void diff --git a/cogl/cogl-path.h b/cogl/cogl-path.h index f63865282..618f320c7 100644 --- a/cogl/cogl-path.h +++ b/cogl/cogl-path.h @@ -51,6 +51,8 @@ G_BEGIN_DECLS * rather then in the absolute coordinates. */ +typedef struct _CoglPath CoglPath; + /** * cogl_path_fill: * @@ -368,49 +370,50 @@ cogl_path_round_rectangle (float x_1, /** * cogl_path_get: * - * Gets a handle to the current path. The path can later be used again - * by calling cogl_path_set(). Note that the path isn't copied so if - * you later call any functions to add to the path it will affect the - * returned handle too. No reference is taken on the path so if you - * want to retain it you should take your own reference with - * cogl_handle_ref(). + * Gets a pointer to the current path. The path can later be used + * again by calling cogl_path_set(). Note that the path isn't copied + * so if you later call any functions to add to the path it will + * affect the returned object too. No reference is taken on the path + * so if you want to retain it you should take your own reference with + * cogl_object_ref(). * - * Return value: a handle to the current path. + * Return value: a pointer to the current path. * * Since: 1.4 */ -CoglHandle +CoglPath * cogl_path_get (void); /** * cogl_path_set: - * @handle: A %CoglHandle to a path + * @path: A #CoglPath object * - * Replaces the current path with @handle. A reference is taken on the - * handle so if you no longer need the path you should unref with - * cogl_handle_unref(). + * Replaces the current path with @path. A reference is taken on the + * object so if you no longer need the path you should unref with + * cogl_object_unref(). * * Since: 1.4 */ void -cogl_path_set (CoglHandle handle); +cogl_path_set (CoglPath *path); /** * cogl_path_copy: - * @handle: A %CoglHandle to a path + * @path: A #CoglPath object * - * Returns a new copy of the path in @handle. The new path has a + * Returns a new copy of the path in @path. The new path has a * reference count of 1 so you should unref it with - * cogl_handle_unref() if you no longer need it. + * cogl_object_unref() if you no longer need it. * * Internally the path will share the data until one of the paths is * modified so copying paths should be relatively cheap. * - * Return value: a copy of the path in @handle. + * Return value: a copy of the path in @path. */ -CoglHandle -cogl_path_copy (CoglHandle handle); +CoglPath * +cogl_path_copy (CoglPath *path); G_END_DECLS #endif /* __COGL_PATH_H__ */ + diff --git a/cogl/cogl.c b/cogl/cogl.c index 41dfa53b7..35055f2d4 100644 --- a/cogl/cogl.c +++ b/cogl/cogl.c @@ -389,7 +389,7 @@ cogl_set_viewport (int x, int width, int height) { - CoglHandle framebuffer; + CoglFramebuffer *framebuffer; _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -514,7 +514,7 @@ cogl_features_available (CoglFeatureFlags features) void cogl_get_viewport (float v[4]) { - CoglHandle framebuffer; + CoglFramebuffer *framebuffer; int viewport[4]; int i; @@ -621,7 +621,7 @@ cogl_read_pixels (int x, CoglPixelFormat format, guint8 *pixels) { - CoglHandle framebuffer; + CoglFramebuffer *framebuffer; int framebuffer_height; int bpp; CoglBitmap bmp; @@ -1110,7 +1110,7 @@ cogl_set_projection_matrix (CoglMatrix *matrix) CoglClipState * _cogl_get_clip_state (void) { - CoglHandle framebuffer; + CoglFramebuffer *framebuffer; framebuffer = _cogl_get_framebuffer (); return _cogl_framebuffer_get_clip_state (framebuffer); @@ -1147,7 +1147,7 @@ cogl_set_source_texture (CoglHandle texture_handle) _COGL_GET_CONTEXT (ctx, NO_RETVAL); - g_return_if_fail (texture_handle != COGL_INVALID_HANDLE); + g_return_if_fail (texture_handle != NULL); cogl_material_set_layer (ctx->simple_material, 0, texture_handle); cogl_color_set_from_4ub (&white, 0xff, 0xff, 0xff, 0xff);