cogl: Port Texture* away from CoglObject
- Make Texture a parent GObject class and move the vtable funcs as vfuncs instead of an interface as we would like to have dispose free the TextureLoader. - Make the various texture sub-types inherit from it. - Make all the sub-types constructors return a CoglTexture instead of their respective specific type. As most of the times, the used functions accept a CoglTexture, like all the GTK widgets constructors returning GtkWidget. - Fix up the basics of gi-docgen for all these types. - Remove CoglPrimitiveTexture as it is useless: It is just a texture underhood. - Remove CoglMetaTexture: for the exact same reason as above. - Switch various memory management functions to use g_ variant instead of the cogl_ one Note we would still want to get rid of the _cogl_texture_init which is something for the next commit Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3193>
This commit is contained in:

committed by
Marge Bot

parent
586c43d5a9
commit
863163cc6e
@ -190,7 +190,7 @@ load_from_current_xcursor_image (MetaCursorSpriteXcursor *sprite_xcursor)
|
||||
CoglPixelFormat cogl_format;
|
||||
ClutterBackend *clutter_backend;
|
||||
CoglContext *cogl_context;
|
||||
CoglTexture2D *texture;
|
||||
CoglTexture *texture;
|
||||
GError *error = NULL;
|
||||
int hotspot_x, hotspot_y;
|
||||
|
||||
@ -234,10 +234,10 @@ load_from_current_xcursor_image (MetaCursorSpriteXcursor *sprite_xcursor)
|
||||
hotspot_y = xc_image->yhot;
|
||||
}
|
||||
meta_cursor_sprite_set_texture (sprite,
|
||||
COGL_TEXTURE (texture),
|
||||
texture,
|
||||
hotspot_x, hotspot_y);
|
||||
|
||||
g_clear_pointer (&texture, cogl_object_unref);
|
||||
g_clear_object (&texture);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -96,7 +96,7 @@ meta_cursor_sprite_clear_texture (MetaCursorSprite *sprite)
|
||||
MetaCursorSpritePrivate *priv =
|
||||
meta_cursor_sprite_get_instance_private (sprite);
|
||||
|
||||
g_clear_pointer (&priv->texture, cogl_object_unref);
|
||||
g_clear_object (&priv->texture);
|
||||
meta_cursor_sprite_invalidate (sprite);
|
||||
}
|
||||
|
||||
@ -109,9 +109,9 @@ meta_cursor_sprite_set_texture (MetaCursorSprite *sprite,
|
||||
MetaCursorSpritePrivate *priv =
|
||||
meta_cursor_sprite_get_instance_private (sprite);
|
||||
|
||||
g_clear_pointer (&priv->texture, cogl_object_unref);
|
||||
g_clear_object (&priv->texture);
|
||||
if (texture)
|
||||
priv->texture = cogl_object_ref (texture);
|
||||
priv->texture = g_object_ref (COGL_TEXTURE_2D (texture));
|
||||
priv->hot_x = hot_x;
|
||||
priv->hot_y = hot_y;
|
||||
|
||||
@ -264,7 +264,7 @@ meta_cursor_sprite_constructed (GObject *object)
|
||||
|
||||
meta_cursor_tracker_register_cursor_sprite (priv->cursor_tracker, sprite);
|
||||
|
||||
g_clear_pointer (&priv->texture, cogl_object_unref);
|
||||
g_clear_object (&priv->texture);
|
||||
|
||||
G_OBJECT_CLASS (meta_cursor_sprite_parent_class)->constructed (object);
|
||||
}
|
||||
@ -276,7 +276,7 @@ meta_cursor_sprite_finalize (GObject *object)
|
||||
MetaCursorSpritePrivate *priv =
|
||||
meta_cursor_sprite_get_instance_private (sprite);
|
||||
|
||||
g_clear_pointer (&priv->texture, cogl_object_unref);
|
||||
g_clear_object (&priv->texture);
|
||||
|
||||
meta_cursor_tracker_unregister_cursor_sprite (priv->cursor_tracker, sprite);
|
||||
g_clear_object (&priv->cursor_tracker);
|
||||
|
@ -313,7 +313,7 @@ draw_cursor_sprite_via_offscreen (MetaScreenCastStreamSrc *src,
|
||||
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
|
||||
CoglContext *cogl_context =
|
||||
clutter_backend_get_cogl_context (clutter_backend);
|
||||
CoglTexture2D *bitmap_texture;
|
||||
CoglTexture *bitmap_texture;
|
||||
CoglOffscreen *offscreen;
|
||||
CoglFramebuffer *fb;
|
||||
CoglPipeline *pipeline;
|
||||
@ -322,17 +322,16 @@ draw_cursor_sprite_via_offscreen (MetaScreenCastStreamSrc *src,
|
||||
|
||||
bitmap_texture = cogl_texture_2d_new_with_size (cogl_context,
|
||||
bitmap_width, bitmap_height);
|
||||
cogl_primitive_texture_set_auto_mipmap (COGL_PRIMITIVE_TEXTURE (bitmap_texture),
|
||||
FALSE);
|
||||
if (!cogl_texture_allocate (COGL_TEXTURE (bitmap_texture), error))
|
||||
cogl_primitive_texture_set_auto_mipmap (bitmap_texture, FALSE);
|
||||
if (!cogl_texture_allocate (bitmap_texture, error))
|
||||
{
|
||||
cogl_object_unref (bitmap_texture);
|
||||
g_object_unref (bitmap_texture);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
offscreen = cogl_offscreen_new_with_texture (COGL_TEXTURE (bitmap_texture));
|
||||
offscreen = cogl_offscreen_new_with_texture (bitmap_texture);
|
||||
fb = COGL_FRAMEBUFFER (offscreen);
|
||||
cogl_object_unref (bitmap_texture);
|
||||
g_object_unref (bitmap_texture);
|
||||
if (!cogl_framebuffer_allocate (fb, error))
|
||||
{
|
||||
g_object_unref (fb);
|
||||
|
@ -254,7 +254,7 @@ meta_drm_buffer_gbm_blit_to_framebuffer (CoglScanout *scanout,
|
||||
CoglPixelFormat cogl_format;
|
||||
CoglEglImageFlags flags;
|
||||
CoglOffscreen *cogl_fbo = NULL;
|
||||
CoglTexture2D *cogl_tex;
|
||||
CoglTexture *cogl_tex;
|
||||
uint32_t n_planes;
|
||||
uint64_t *modifiers;
|
||||
uint32_t *strides;
|
||||
@ -332,8 +332,8 @@ meta_drm_buffer_gbm_blit_to_framebuffer (CoglScanout *scanout,
|
||||
goto out;
|
||||
}
|
||||
|
||||
cogl_fbo = cogl_offscreen_new_with_texture (COGL_TEXTURE (cogl_tex));
|
||||
cogl_object_unref (cogl_tex);
|
||||
cogl_fbo = cogl_offscreen_new_with_texture (cogl_tex);
|
||||
g_object_unref (cogl_tex);
|
||||
|
||||
if (!cogl_framebuffer_allocate (COGL_FRAMEBUFFER (cogl_fbo), error))
|
||||
{
|
||||
|
@ -613,7 +613,7 @@ meta_renderer_native_create_dma_buf_framebuffer (MetaRendererNative *renderer_n
|
||||
uint64_t modifiers[1];
|
||||
CoglPixelFormat cogl_format;
|
||||
CoglEglImageFlags flags;
|
||||
CoglTexture2D *cogl_tex;
|
||||
CoglTexture *cogl_tex;
|
||||
CoglOffscreen *cogl_fbo;
|
||||
int ret;
|
||||
|
||||
@ -651,8 +651,8 @@ meta_renderer_native_create_dma_buf_framebuffer (MetaRendererNative *renderer_n
|
||||
if (!cogl_tex)
|
||||
return NULL;
|
||||
|
||||
cogl_fbo = cogl_offscreen_new_with_texture (COGL_TEXTURE (cogl_tex));
|
||||
cogl_object_unref (cogl_tex);
|
||||
cogl_fbo = cogl_offscreen_new_with_texture (cogl_tex);
|
||||
g_object_unref (cogl_tex);
|
||||
|
||||
if (!cogl_framebuffer_allocate (COGL_FRAMEBUFFER (cogl_fbo), error))
|
||||
{
|
||||
@ -1151,19 +1151,19 @@ meta_renderer_native_create_offscreen (MetaRendererNative *renderer,
|
||||
GError **error)
|
||||
{
|
||||
CoglOffscreen *fb;
|
||||
CoglTexture2D *tex;
|
||||
CoglTexture *tex;
|
||||
|
||||
tex = cogl_texture_2d_new_with_size (context, view_width, view_height);
|
||||
cogl_primitive_texture_set_auto_mipmap (COGL_PRIMITIVE_TEXTURE (tex), FALSE);
|
||||
cogl_primitive_texture_set_auto_mipmap (tex, FALSE);
|
||||
|
||||
if (!cogl_texture_allocate (COGL_TEXTURE (tex), error))
|
||||
if (!cogl_texture_allocate (tex, error))
|
||||
{
|
||||
cogl_object_unref (tex);
|
||||
g_object_unref (tex);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
fb = cogl_offscreen_new_with_texture (COGL_TEXTURE (tex));
|
||||
cogl_object_unref (tex);
|
||||
fb = cogl_offscreen_new_with_texture (tex);
|
||||
g_object_unref (tex);
|
||||
if (!cogl_framebuffer_allocate (COGL_FRAMEBUFFER (fb), error))
|
||||
{
|
||||
g_object_unref (fb);
|
||||
|
@ -125,7 +125,7 @@ meta_cursor_sprite_xfixes_initable_init (GInitable *initable,
|
||||
MetaX11Display *x11_display;
|
||||
Display *xdisplay;
|
||||
XFixesCursorImage *cursor_image;
|
||||
CoglTexture2D *texture;
|
||||
CoglTexture *texture;
|
||||
uint8_t *cursor_data;
|
||||
gboolean free_cursor_data;
|
||||
ClutterBackend *clutter_backend;
|
||||
@ -175,12 +175,12 @@ meta_cursor_sprite_xfixes_initable_init (GInitable *initable,
|
||||
clutter_backend = clutter_get_default_backend ();
|
||||
cogl_context = clutter_backend_get_cogl_context (clutter_backend);
|
||||
texture = cogl_texture_2d_new_from_data (cogl_context,
|
||||
cursor_image->width,
|
||||
cursor_image->height,
|
||||
COGL_PIXEL_FORMAT_CAIRO_ARGB32_COMPAT,
|
||||
cursor_image->width * 4, /* stride */
|
||||
cursor_data,
|
||||
error);
|
||||
cursor_image->width,
|
||||
cursor_image->height,
|
||||
COGL_PIXEL_FORMAT_CAIRO_ARGB32_COMPAT,
|
||||
cursor_image->width * 4, /* stride */
|
||||
cursor_data,
|
||||
error);
|
||||
|
||||
if (free_cursor_data)
|
||||
g_free (cursor_data);
|
||||
@ -189,10 +189,10 @@ meta_cursor_sprite_xfixes_initable_init (GInitable *initable,
|
||||
return FALSE;
|
||||
|
||||
meta_cursor_sprite_set_texture (sprite,
|
||||
COGL_TEXTURE (texture),
|
||||
texture,
|
||||
cursor_image->xhot,
|
||||
cursor_image->yhot);
|
||||
cogl_object_unref (texture);
|
||||
g_object_unref (texture);
|
||||
XFree (cursor_image);
|
||||
|
||||
return TRUE;
|
||||
|
@ -75,12 +75,12 @@ create_offscreen (CoglContext *cogl_context,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
CoglTexture2D *texture_2d;
|
||||
CoglTexture *texture_2d;
|
||||
CoglOffscreen *offscreen;
|
||||
GError *error = NULL;
|
||||
|
||||
texture_2d = cogl_texture_2d_new_with_size (cogl_context, width, height);
|
||||
offscreen = cogl_offscreen_new_with_texture (COGL_TEXTURE (texture_2d));
|
||||
offscreen = cogl_offscreen_new_with_texture (texture_2d);
|
||||
|
||||
if (!cogl_framebuffer_allocate (COGL_FRAMEBUFFER (offscreen), &error))
|
||||
meta_fatal ("Couldn't allocate framebuffer: %s", error->message);
|
||||
|
Reference in New Issue
Block a user