From c1e6948e42d57c28232c96a2683e7ff77fb5dbbd Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Fri, 18 Aug 2023 11:28:05 +0200 Subject: [PATCH] cogl: Port Bitmap away from CoglObject We still need to use set_qdata_full as CoglBitmapPixbuf would free the data itself by unrefing the pixbuf Part-of: --- clutter/clutter/clutter-canvas.c | 4 +- clutter/clutter/clutter-stage.c | 4 +- cogl/cogl/cogl-atlas-texture.c | 16 +++---- cogl/cogl/cogl-atlas.c | 2 +- cogl/cogl/cogl-bitmap-conversion.c | 6 +-- cogl/cogl/cogl-bitmap-private.h | 3 +- cogl/cogl/cogl-bitmap.c | 46 ++++++++++++------- cogl/cogl/cogl-bitmap.h | 33 ++++--------- cogl/cogl/cogl-framebuffer.c | 2 +- cogl/cogl/cogl-framebuffer.h | 2 +- cogl/cogl/cogl-texture-2d-sliced.c | 22 ++++----- cogl/cogl/cogl-texture-2d.c | 4 +- cogl/cogl/cogl-texture.c | 12 ++--- cogl/cogl/driver/gl/cogl-framebuffer-gl.c | 8 ++-- cogl/cogl/driver/gl/cogl-texture-2d-gl.c | 6 +-- .../driver/gl/gles/cogl-texture-driver-gles.c | 14 +++--- src/backends/native/meta-onscreen-native.c | 2 +- src/tests/clutter/test-utils.h | 16 ++++--- src/tests/cogl-test-utils.c | 2 +- src/tests/cogl/conform/test-pixel-buffer.c | 6 +-- src/tests/cogl/conform/test-premult.c | 7 +-- src/tests/meta-ref-test.c | 2 +- src/wayland/meta-wayland-buffer.c | 2 +- 23 files changed, 109 insertions(+), 112 deletions(-) diff --git a/clutter/clutter/clutter-canvas.c b/clutter/clutter/clutter-canvas.c index 736bcd033..8c6f7bc8d 100644 --- a/clutter/clutter/clutter-canvas.c +++ b/clutter/clutter/clutter-canvas.c @@ -129,7 +129,7 @@ clutter_canvas_finalize (GObject *gobject) if (priv->buffer != NULL) { - cogl_object_unref (priv->buffer); + g_object_unref (priv->buffer); priv->buffer = NULL; } @@ -445,7 +445,7 @@ clutter_canvas_invalidate (ClutterContent *content) if (priv->buffer != NULL) { - cogl_object_unref (priv->buffer); + g_object_unref (priv->buffer); priv->buffer = NULL; } diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c index 56b58cc26..07e934ee0 100644 --- a/clutter/clutter/clutter-stage.c +++ b/clutter/clutter/clutter-stage.c @@ -2824,7 +2824,7 @@ clutter_stage_paint_to_buffer (ClutterStage *stage, COGL_READ_PIXELS_COLOR_BUFFER, bitmap); - cogl_object_unref (bitmap); + g_object_unref (bitmap); g_object_unref (framebuffer); return TRUE; @@ -2928,7 +2928,7 @@ clutter_stage_capture_view_into (ClutterStage *stage, COGL_READ_PIXELS_COLOR_BUFFER, bitmap); - cogl_object_unref (bitmap); + g_object_unref (bitmap); } /** diff --git a/cogl/cogl/cogl-atlas-texture.c b/cogl/cogl/cogl-atlas-texture.c index d19e8dc8f..bef2db8ff 100644 --- a/cogl/cogl/cogl-atlas-texture.c +++ b/cogl/cogl/cogl-atlas-texture.c @@ -556,7 +556,7 @@ _cogl_atlas_texture_convert_bitmap_for_upload (CoglAtlasTexture *atlas_tex, cogl_bitmap_get_height (upload_bmp), cogl_bitmap_get_rowstride (upload_bmp)); - cogl_object_unref (upload_bmp); + g_object_unref (upload_bmp); return override_bmp; } @@ -599,7 +599,7 @@ _cogl_atlas_texture_set_region (CoglTexture *tex, upload_bmp, error); - cogl_object_unref (upload_bmp); + g_object_unref (upload_bmp); return ret; } @@ -836,7 +836,7 @@ allocate_from_bitmap (CoglAtlasTexture *atlas_tex, internal_format, error)) { - cogl_object_unref (upload_bmp); + g_object_unref (upload_bmp); return FALSE; } @@ -853,11 +853,11 @@ allocate_from_bitmap (CoglAtlasTexture *atlas_tex, error)) { _cogl_atlas_texture_remove_from_atlas (atlas_tex); - cogl_object_unref (upload_bmp); + g_object_unref (upload_bmp); return FALSE; } - cogl_object_unref (upload_bmp); + g_object_unref (upload_bmp); _cogl_texture_set_allocated (tex, internal_format, width, height); @@ -891,11 +891,11 @@ cogl_atlas_texture_new_from_bitmap (CoglBitmap *bmp) { CoglTextureLoader *loader; - g_return_val_if_fail (cogl_is_bitmap (bmp), NULL); + g_return_val_if_fail (COGL_IS_BITMAP (bmp), NULL); loader = _cogl_texture_create_loader (); loader->src_type = COGL_TEXTURE_SOURCE_TYPE_BITMAP; - loader->src.bitmap.bitmap = cogl_object_ref (bmp); + loader->src.bitmap.bitmap = g_object_ref (bmp); return _cogl_atlas_texture_create_base (_cogl_bitmap_get_context (bmp), cogl_bitmap_get_width (bmp), @@ -933,7 +933,7 @@ cogl_atlas_texture_new_from_data (CoglContext *ctx, atlas_tex = cogl_atlas_texture_new_from_bitmap (bmp); - cogl_object_unref (bmp); + g_object_unref (bmp); if (atlas_tex && !cogl_texture_allocate (COGL_TEXTURE (atlas_tex), error)) diff --git a/cogl/cogl/cogl-atlas.c b/cogl/cogl/cogl-atlas.c index ea0b8dd8a..98a2f042f 100644 --- a/cogl/cogl/cogl-atlas.c +++ b/cogl/cogl/cogl-atlas.c @@ -333,7 +333,7 @@ _cogl_atlas_create_texture (CoglAtlas *atlas, tex = NULL; } - cogl_object_unref (clear_bmp); + g_object_unref (clear_bmp); g_free (clear_data); } diff --git a/cogl/cogl/cogl-bitmap-conversion.c b/cogl/cogl/cogl-bitmap-conversion.c index 1c7bc378a..acaa240de 100644 --- a/cogl/cogl/cogl-bitmap-conversion.c +++ b/cogl/cogl/cogl-bitmap-conversion.c @@ -527,7 +527,7 @@ _cogl_bitmap_convert (CoglBitmap *src_bmp, if (!_cogl_bitmap_convert_into_bitmap (src_bmp, dst_bmp, error)) { - cogl_object_unref (dst_bmp); + g_object_unref (dst_bmp); return NULL; } @@ -596,7 +596,7 @@ _cogl_bitmap_convert_for_upload (CoglBitmap *src_bmp, return NULL; } else - dst_bmp = cogl_object_ref (src_bmp); + dst_bmp = g_object_ref (src_bmp); } else { @@ -612,7 +612,7 @@ _cogl_bitmap_convert_for_upload (CoglBitmap *src_bmp, if (closest_format != src_format) dst_bmp = _cogl_bitmap_convert (src_bmp, closest_format, error); else - dst_bmp = cogl_object_ref (src_bmp); + dst_bmp = g_object_ref (src_bmp); } return dst_bmp; diff --git a/cogl/cogl/cogl-bitmap-private.h b/cogl/cogl/cogl-bitmap-private.h index acbd41e04..916fe971d 100644 --- a/cogl/cogl/cogl-bitmap-private.h +++ b/cogl/cogl/cogl-bitmap-private.h @@ -32,13 +32,12 @@ #include -#include "cogl/cogl-object-private.h" #include "cogl/cogl-buffer.h" #include "cogl/cogl-bitmap.h" struct _CoglBitmap { - CoglObject _parent; + GObject parent_instance; /* Pointer back to the context that this bitmap was created with */ CoglContext *context; diff --git a/cogl/cogl/cogl-bitmap.c b/cogl/cogl/cogl-bitmap.c index d55bab833..69dda0fef 100644 --- a/cogl/cogl/cogl-bitmap.c +++ b/cogl/cogl/cogl-bitmap.c @@ -37,28 +37,42 @@ #include "cogl/cogl-buffer-private.h" #include "cogl/cogl-pixel-buffer.h" #include "cogl/cogl-context-private.h" -#include "cogl/cogl-gtype-private.h" #include -static void _cogl_bitmap_free (CoglBitmap *bmp); +static GQuark bitmap_free_key = 0; -COGL_OBJECT_DEFINE (Bitmap, bitmap); -COGL_GTYPE_DEFINE_CLASS (Bitmap, bitmap); +G_DEFINE_TYPE (CoglBitmap, cogl_bitmap, G_TYPE_OBJECT); static void -_cogl_bitmap_free (CoglBitmap *bmp) +cogl_bitmap_dispose (GObject *object) { + CoglBitmap *bmp = COGL_BITMAP (object); + g_assert (!bmp->mapped); g_assert (!bmp->bound); if (bmp->shared_bmp) - cogl_object_unref (bmp->shared_bmp); + g_object_unref (bmp->shared_bmp); if (bmp->buffer) cogl_object_unref (bmp->buffer); - g_free (bmp); + + G_OBJECT_CLASS (cogl_bitmap_parent_class)->dispose (object); +} + +static void +cogl_bitmap_init (CoglBitmap *bitmap) +{ +} + +static void +cogl_bitmap_class_init (CoglBitmapClass *class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (class); + + object_class->dispose = cogl_bitmap_dispose; } gboolean @@ -106,7 +120,7 @@ _cogl_bitmap_copy (CoglBitmap *src_bmp, width, height, error)) { - cogl_object_unref (dst_bmp); + g_object_unref (dst_bmp); return NULL; } @@ -182,7 +196,7 @@ cogl_bitmap_new_for_data (CoglContext *context, if (rowstride == 0) rowstride = width * cogl_pixel_format_get_bytes_per_pixel (format, 0); - bmp = g_new0 (CoglBitmap, 1); + bmp = g_object_new (COGL_TYPE_BITMAP, NULL); bmp->context = context; bmp->format = format; bmp->width = width; @@ -194,7 +208,7 @@ cogl_bitmap_new_for_data (CoglContext *context, bmp->shared_bmp = NULL; bmp->buffer = NULL; - return _cogl_bitmap_object_new (bmp); + return bmp; } CoglBitmap * @@ -204,7 +218,7 @@ _cogl_bitmap_new_with_malloc_buffer (CoglContext *context, CoglPixelFormat format, GError **error) { - static CoglUserDataKey bitmap_free_key; + bitmap_free_key = g_quark_from_static_string ("-cogl-bitmap-malloc-buffer-key"); int bpp; int rowstride; uint8_t *data; @@ -231,10 +245,10 @@ _cogl_bitmap_new_with_malloc_buffer (CoglContext *context, format, rowstride, data); - cogl_object_set_user_data (COGL_OBJECT (bitmap), - &bitmap_free_key, - data, - g_free); + g_object_set_qdata_full (G_OBJECT (bitmap), + bitmap_free_key, + data, + g_free); return bitmap; } @@ -254,7 +268,7 @@ _cogl_bitmap_new_shared (CoglBitmap *shared_bmp, rowstride, NULL /* data */); - bmp->shared_bmp = cogl_object_ref (shared_bmp); + bmp->shared_bmp = g_object_ref (shared_bmp); return bmp; } diff --git a/cogl/cogl/cogl-bitmap.h b/cogl/cogl/cogl-bitmap.h index 3a80a1969..a11928267 100644 --- a/cogl/cogl/cogl-bitmap.h +++ b/cogl/cogl/cogl-bitmap.h @@ -49,23 +49,22 @@ typedef struct _CoglBitmap CoglBitmap; G_BEGIN_DECLS /** - * cogl_bitmap_get_gtype: + * CoglBitmap: * - * Returns: a #GType that can be used with the GLib type system. - */ -COGL_EXPORT -GType cogl_bitmap_get_gtype (void); - -/** - * SECTION:cogl-bitmap - * @short_description: Functions for loading images + * Functions for loading images * * Cogl allows loading image data into memory as CoglBitmaps without * loading them immediately into GPU textures. - * - * #CoglBitmap is available since Cogl 1.0 */ +#define COGL_TYPE_BITMAP (cogl_bitmap_get_type ()) + +COGL_EXPORT +G_DECLARE_FINAL_TYPE (CoglBitmap, + cogl_bitmap, + COGL, + BITMAP, + GObject) /** * cogl_bitmap_new_from_buffer: (skip) @@ -197,18 +196,6 @@ cogl_bitmap_get_rowstride (CoglBitmap *bitmap); COGL_EXPORT CoglPixelBuffer * cogl_bitmap_get_buffer (CoglBitmap *bitmap); -/** - * cogl_is_bitmap: - * @object: a #CoglObject pointer - * - * Checks whether @object is a #CoglBitmap - * - * Return value: %TRUE if the passed @object represents a bitmap, - * and %FALSE otherwise - */ -COGL_EXPORT gboolean -cogl_is_bitmap (void *object); - /** * COGL_BITMAP_ERROR: * diff --git a/cogl/cogl/cogl-framebuffer.c b/cogl/cogl/cogl-framebuffer.c index d9e6f7f08..b5cf644fa 100644 --- a/cogl/cogl/cogl-framebuffer.c +++ b/cogl/cogl/cogl-framebuffer.c @@ -1559,7 +1559,7 @@ cogl_framebuffer_read_pixels (CoglFramebuffer *framebuffer, COGL_READ_PIXELS_COLOR_BUFFER, bitmap, NULL); - cogl_object_unref (bitmap); + g_object_unref (bitmap); return ret; } diff --git a/cogl/cogl/cogl-framebuffer.h b/cogl/cogl/cogl-framebuffer.h index 72807d642..00ac006db 100644 --- a/cogl/cogl/cogl-framebuffer.h +++ b/cogl/cogl/cogl-framebuffer.h @@ -1251,7 +1251,7 @@ cogl_framebuffer_read_pixels_into_bitmap (CoglFramebuffer *framebuffer, * x, y, * COGL_READ_PIXELS_COLOR_BUFFER, * bitmap); - * cogl_object_unref (bitmap); + * g_object_unref (bitmap); * ]| * * Return value: %TRUE if the read succeeded or %FALSE otherwise. diff --git a/cogl/cogl/cogl-texture-2d-sliced.c b/cogl/cogl/cogl-texture-2d-sliced.c index 84c3b8dc0..166d5084a 100644 --- a/cogl/cogl/cogl-texture-2d-sliced.c +++ b/cogl/cogl/cogl-texture-2d-sliced.c @@ -270,12 +270,12 @@ _cogl_texture_2d_sliced_set_waste (CoglTexture2DSliced *tex_2ds, 0, /* level */ error)) { - cogl_object_unref (waste_bmp); + g_object_unref (waste_bmp); _cogl_bitmap_unmap (source_bmp); return FALSE; } - cogl_object_unref (waste_bmp); + g_object_unref (waste_bmp); } if (need_y) @@ -330,12 +330,12 @@ _cogl_texture_2d_sliced_set_waste (CoglTexture2DSliced *tex_2ds, 0, /* level */ error)) { - cogl_object_unref (waste_bmp); + g_object_unref (waste_bmp); _cogl_bitmap_unmap (source_bmp); return FALSE; } - cogl_object_unref (waste_bmp); + g_object_unref (waste_bmp); } _cogl_bitmap_unmap (source_bmp); @@ -891,11 +891,11 @@ cogl_texture_2d_sliced_new_from_bitmap (CoglBitmap *bmp, { CoglTextureLoader *loader; - g_return_val_if_fail (cogl_is_bitmap (bmp), NULL); + g_return_val_if_fail (COGL_IS_BITMAP (bmp), NULL); loader = _cogl_texture_create_loader (); loader->src_type = COGL_TEXTURE_SOURCE_TYPE_BITMAP; - loader->src.bitmap.bitmap = cogl_object_ref (bmp); + loader->src.bitmap.bitmap = g_object_ref (bmp); return _cogl_texture_2d_sliced_create_base (_cogl_bitmap_get_context (bmp), cogl_bitmap_get_width (bmp), @@ -935,7 +935,7 @@ cogl_texture_2d_sliced_new_from_data (CoglContext *ctx, tex_2ds = cogl_texture_2d_sliced_new_from_bitmap (bmp, max_waste); - cogl_object_unref (bmp); + g_object_unref (bmp); if (tex_2ds && !cogl_texture_allocate (COGL_TEXTURE (tex_2ds), error)) @@ -1008,7 +1008,7 @@ allocate_from_bitmap (CoglTexture2DSliced *tex_2ds, internal_format, error)) { - cogl_object_unref (upload_bmp); + g_object_unref (upload_bmp); return FALSE; } @@ -1017,11 +1017,11 @@ allocate_from_bitmap (CoglTexture2DSliced *tex_2ds, error)) { free_slices (tex_2ds); - cogl_object_unref (upload_bmp); + g_object_unref (upload_bmp); return FALSE; } - cogl_object_unref (upload_bmp); + g_object_unref (upload_bmp); _cogl_texture_set_allocated (tex, internal_format, width, height); @@ -1256,7 +1256,7 @@ _cogl_texture_2d_sliced_set_region (CoglTexture *tex, dst_width, dst_height, upload_bmp, error); - cogl_object_unref (upload_bmp); + g_object_unref (upload_bmp); return status; } diff --git a/cogl/cogl/cogl-texture-2d.c b/cogl/cogl/cogl-texture-2d.c index b58a54b85..752b6cec6 100644 --- a/cogl/cogl/cogl-texture-2d.c +++ b/cogl/cogl/cogl-texture-2d.c @@ -168,7 +168,7 @@ cogl_texture_2d_new_from_bitmap (CoglBitmap *bmp) loader = _cogl_texture_create_loader (); loader->src_type = COGL_TEXTURE_SOURCE_TYPE_BITMAP; - loader->src.bitmap.bitmap = cogl_object_ref (bmp); + loader->src.bitmap.bitmap = g_object_ref (bmp); return _cogl_texture_2d_create_base (_cogl_bitmap_get_context (bmp), cogl_bitmap_get_width (bmp), @@ -206,7 +206,7 @@ cogl_texture_2d_new_from_data (CoglContext *ctx, tex_2d = cogl_texture_2d_new_from_bitmap (bmp); - cogl_object_unref (bmp); + g_object_unref (bmp); if (tex_2d && !cogl_texture_allocate (COGL_TEXTURE (tex_2d), error)) diff --git a/cogl/cogl/cogl-texture.c b/cogl/cogl/cogl-texture.c index 343ec4155..ec0fd0a54 100644 --- a/cogl/cogl/cogl-texture.c +++ b/cogl/cogl/cogl-texture.c @@ -152,7 +152,7 @@ _cogl_texture_free_loader (CoglTexture *texture) case COGL_TEXTURE_SOURCE_TYPE_EGL_IMAGE_EXTERNAL: break; case COGL_TEXTURE_SOURCE_TYPE_BITMAP: - cogl_object_unref (loader->src.bitmap.bitmap); + g_object_unref (loader->src.bitmap.bitmap); break; } g_free (loader); @@ -457,7 +457,7 @@ _cogl_texture_set_region (CoglTexture *texture, level, error); - cogl_object_unref (source_bmp); + g_object_unref (source_bmp); return ret; } @@ -594,7 +594,7 @@ get_texture_bits_via_offscreen (CoglTexture *meta_texture, g_clear_error (&ignore_error); - cogl_object_unref (bitmap); + g_object_unref (bitmap); g_object_unref (framebuffer); @@ -876,7 +876,7 @@ cogl_texture_get_data (CoglTexture *texture, */ if (!tg_data.success) { - cogl_object_unref (target_bmp); + g_object_unref (target_bmp); return 0; } @@ -902,10 +902,10 @@ cogl_texture_get_data (CoglTexture *texture, byte_size = 0; } - cogl_object_unref (new_bmp); + g_object_unref (new_bmp); } - cogl_object_unref (target_bmp); + g_object_unref (target_bmp); return byte_size; } diff --git a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c index d944f763f..c195c5e6d 100644 --- a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c +++ b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c @@ -547,7 +547,7 @@ cogl_gl_framebuffer_read_pixels_into_bitmap (CoglFramebufferDriver *driver, _cogl_bitmap_set_format (bitmap, format); - cogl_object_unref (tmp_bmp); + g_object_unref (tmp_bmp); if (!succeeded) goto EXIT; @@ -578,7 +578,7 @@ cogl_gl_framebuffer_read_pixels_into_bitmap (CoglFramebufferDriver *driver, width, height, rowstride); else - shared_bmp = cogl_object_ref (bitmap); + shared_bmp = g_object_ref (bitmap); bpp = cogl_pixel_format_get_bytes_per_pixel (bmp_format, 0); @@ -596,7 +596,7 @@ cogl_gl_framebuffer_read_pixels_into_bitmap (CoglFramebufferDriver *driver, * to know if there was a problem */ if (internal_error) { - cogl_object_unref (shared_bmp); + g_object_unref (shared_bmp); g_propagate_error (error, internal_error); goto EXIT; } @@ -615,7 +615,7 @@ cogl_gl_framebuffer_read_pixels_into_bitmap (CoglFramebufferDriver *driver, _cogl_bitmap_convert_premult_status (shared_bmp, format, error)) succeeded = TRUE; - cogl_object_unref (shared_bmp); + g_object_unref (shared_bmp); if (!succeeded) goto EXIT; diff --git a/cogl/cogl/driver/gl/cogl-texture-2d-gl.c b/cogl/cogl/driver/gl/cogl-texture-2d-gl.c index ed6762b3f..484589eca 100644 --- a/cogl/cogl/driver/gl/cogl-texture-2d-gl.c +++ b/cogl/cogl/driver/gl/cogl-texture-2d-gl.c @@ -245,13 +245,13 @@ allocate_from_bitmap (CoglTexture2D *tex_2d, gl_type, error)) { - cogl_object_unref (upload_bmp); + g_object_unref (upload_bmp); return FALSE; } tex_2d->gl_internal_format = gl_intformat; - cogl_object_unref (upload_bmp); + g_object_unref (upload_bmp); tex_2d->internal_format = internal_format; @@ -606,7 +606,7 @@ _cogl_texture_2d_gl_copy_from_bitmap (CoglTexture2D *tex_2d, gl_type, error); - cogl_object_unref (upload_bmp); + g_object_unref (upload_bmp); return status; } diff --git a/cogl/cogl/driver/gl/gles/cogl-texture-driver-gles.c b/cogl/cogl/driver/gl/gles/cogl-texture-driver-gles.c index 6abcd38dc..36f106157 100644 --- a/cogl/cogl/driver/gl/gles/cogl-texture-driver-gles.c +++ b/cogl/cogl/driver/gl/gles/cogl-texture-driver-gles.c @@ -164,7 +164,7 @@ prepare_bitmap_alignment_for_upload (CoglContext *ctx, if (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_UNPACK_SUBIMAGE) || src_rowstride == 0) - return cogl_object_ref (src_bmp); + return g_object_ref (src_bmp); /* Work out the alignment of the source rowstride */ alignment = 1 << (ffs (src_rowstride) - 1); @@ -173,7 +173,7 @@ prepare_bitmap_alignment_for_upload (CoglContext *ctx, /* If the aligned data equals the rowstride then we can upload from the bitmap directly using GL_UNPACK_ALIGNMENT */ if (((width * bpp + alignment - 1) & ~(alignment - 1)) == src_rowstride) - return cogl_object_ref (src_bmp); + return g_object_ref (src_bmp); /* Otherwise we need to copy the bitmap to pack the alignment because GLES has no GL_ROW_LENGTH */ else @@ -238,7 +238,7 @@ _cogl_texture_driver_upload_subregion_to_gl (CoglContext *ctx, width, height, error)) { - cogl_object_unref (slice_bmp); + g_object_unref (slice_bmp); return FALSE; } @@ -264,7 +264,7 @@ _cogl_texture_driver_upload_subregion_to_gl (CoglContext *ctx, if (internal_error) { g_propagate_error (error, internal_error); - cogl_object_unref (slice_bmp); + g_object_unref (slice_bmp); return FALSE; } @@ -330,7 +330,7 @@ _cogl_texture_driver_upload_subregion_to_gl (CoglContext *ctx, _cogl_bitmap_gl_unbind (slice_bmp); - cogl_object_unref (slice_bmp); + g_object_unref (slice_bmp); return status; } @@ -382,7 +382,7 @@ _cogl_texture_driver_upload_to_gl (CoglContext *ctx, * problems... */ if (internal_error) { - cogl_object_unref (bmp); + g_object_unref (bmp); g_propagate_error (error, internal_error); return FALSE; } @@ -403,7 +403,7 @@ _cogl_texture_driver_upload_to_gl (CoglContext *ctx, _cogl_bitmap_gl_unbind (bmp); - cogl_object_unref (bmp); + g_object_unref (bmp); return status; } diff --git a/src/backends/native/meta-onscreen-native.c b/src/backends/native/meta-onscreen-native.c index f439cc811..2e2d79e2f 100644 --- a/src/backends/native/meta-onscreen-native.c +++ b/src/backends/native/meta-onscreen-native.c @@ -865,7 +865,7 @@ copy_shared_framebuffer_cpu (CoglOnscreen *onscreen, dumb_bitmap)) g_warning ("Failed to CPU-copy to a secondary GPU output"); - cogl_object_unref (dumb_bitmap); + g_object_unref (dumb_bitmap); secondary_gpu_state->cpu.current_dumb_fb = buffer_dumb; diff --git a/src/tests/clutter/test-utils.h b/src/tests/clutter/test-utils.h index 62f394336..5b07ef28a 100644 --- a/src/tests/clutter/test-utils.h +++ b/src/tests/clutter/test-utils.h @@ -1,6 +1,8 @@ #include #include +static GQuark pixbuf_key = 0; + static inline ClutterActor * clutter_test_utils_create_texture_from_file (const char *filename, GError **error) @@ -34,7 +36,7 @@ clutter_test_create_bitmap_from_file (CoglContext *ctx, const char *filename, GError **error) { - static CoglUserDataKey pixbuf_key; + pixbuf_key = g_quark_from_static_string ("-cogl-bitmap-pixbuf-key"); GdkPixbuf *pixbuf; gboolean has_alpha; GdkColorspace color_space; @@ -101,10 +103,10 @@ clutter_test_create_bitmap_from_file (CoglContext *ctx, rowstride, gdk_pixbuf_get_pixels (pixbuf)); - cogl_object_set_user_data (COGL_OBJECT (bmp), - &pixbuf_key, - pixbuf, - g_object_unref); + g_object_set_qdata_full (G_OBJECT (bmp), + pixbuf_key, + pixbuf, + g_object_unref); return bmp; } @@ -125,7 +127,7 @@ clutter_test_texture_2d_sliced_new_from_file (CoglContext *ctx, tex_2ds = cogl_texture_2d_sliced_new_from_bitmap (bmp, COGL_TEXTURE_MAX_WASTE); - cogl_object_unref (bmp); + g_object_unref (bmp); return tex_2ds; } @@ -146,7 +148,7 @@ clutter_test_texture_2d_new_from_file (CoglContext *ctx, tex_2d = cogl_texture_2d_new_from_bitmap (bmp); - cogl_object_unref (bmp); + g_object_unref (bmp); return tex_2d; } diff --git a/src/tests/cogl-test-utils.c b/src/tests/cogl-test-utils.c index 14eb9f834..1cd75e956 100644 --- a/src/tests/cogl-test-utils.c +++ b/src/tests/cogl-test-utils.c @@ -342,7 +342,7 @@ test_utils_texture_new_from_data (CoglContext *ctx, tex = test_utils_texture_new_from_bitmap (bmp, flags, TRUE); - cogl_object_unref (bmp); + g_object_unref (bmp); return tex; } diff --git a/src/tests/cogl/conform/test-pixel-buffer.c b/src/tests/cogl/conform/test-pixel-buffer.c index 53799b1f0..446ef90a9 100644 --- a/src/tests/cogl/conform/test-pixel-buffer.c +++ b/src/tests/cogl/conform/test-pixel-buffer.c @@ -149,7 +149,7 @@ test_pixel_buffer_map (void) -1.0f, 1.0f, 1.0f, -1.0f); - cogl_object_unref (bitmap); + g_object_unref (bitmap); cogl_object_unref (texture); cogl_object_unref (pipeline); @@ -194,7 +194,7 @@ test_pixel_buffer_set_data (void) -1.0f, 1.0f, 1.0f, -1.0f); - cogl_object_unref (bitmap); + g_object_unref (bitmap); cogl_object_unref (texture); cogl_object_unref (pipeline); @@ -255,7 +255,7 @@ test_pixel_buffer_sub_region (void) -1.0f, 1.0f, 1.0f, -1.0f); - cogl_object_unref (bitmap); + g_object_unref (bitmap); cogl_object_unref (texture); cogl_object_unref (pipeline); diff --git a/src/tests/cogl/conform/test-premult.c b/src/tests/cogl/conform/test-premult.c index 690968b54..1755ca621 100644 --- a/src/tests/cogl/conform/test-premult.c +++ b/src/tests/cogl/conform/test-premult.c @@ -49,7 +49,6 @@ make_texture (uint32_t color, CoglPixelFormat src_format, MakeTextureFlags flags) { - static CoglUserDataKey bitmap_free_key; CoglTexture2D *tex_2d; guchar *tex_data = gen_tex_data (color); CoglBitmap *bmp = cogl_bitmap_new_for_data (test_ctx, @@ -58,10 +57,6 @@ make_texture (uint32_t color, src_format, QUAD_WIDTH * 4, tex_data); - cogl_object_set_user_data (COGL_OBJECT (bmp), - &bitmap_free_key, - tex_data, - g_free); tex_2d = cogl_texture_2d_new_from_bitmap (bmp); @@ -70,7 +65,7 @@ make_texture (uint32_t color, else if (flags & TEXTURE_FLAG_SET_UNPREMULTIPLIED) cogl_texture_set_premultiplied (tex_2d, FALSE); - cogl_object_unref (bmp); + g_object_unref (bmp); return tex_2d; } diff --git a/src/tests/meta-ref-test.c b/src/tests/meta-ref-test.c index 366a2ba4e..9459b4612 100644 --- a/src/tests/meta-ref-test.c +++ b/src/tests/meta-ref-test.c @@ -258,7 +258,7 @@ capture_view_into (ClutterStageView *view, COGL_READ_PIXELS_COLOR_BUFFER, bitmap); - cogl_object_unref (bitmap); + g_object_unref (bitmap); } typedef struct diff --git a/src/wayland/meta-wayland-buffer.c b/src/wayland/meta-wayland-buffer.c index 7a9858010..3fc7ee4ca 100644 --- a/src/wayland/meta-wayland-buffer.c +++ b/src/wayland/meta-wayland-buffer.c @@ -403,7 +403,7 @@ shm_buffer_attach (MetaWaylandBuffer *buffer, } } - cogl_object_unref (bitmap); + g_object_unref (bitmap); wl_shm_buffer_end_access (shm_buffer);