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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3193>
This commit is contained in:
Bilal Elmoussaoui
2023-08-18 11:28:05 +02:00
committed by Marge Bot
parent 3c6c6a0ea5
commit c1e6948e42
23 changed files with 109 additions and 112 deletions

View File

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

View File

@ -1,6 +1,8 @@
#include <clutter/clutter.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
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;
}

View File

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

View File

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

View File

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

View File

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

View File

@ -403,7 +403,7 @@ shm_buffer_attach (MetaWaylandBuffer *buffer,
}
}
cogl_object_unref (bitmap);
g_object_unref (bitmap);
wl_shm_buffer_end_access (shm_buffer);