1
0
Fork 0

clutter/cogl: Use more of memory management helpers

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3193>
This commit is contained in:
Bilal Elmoussaoui 2023-09-13 10:12:01 +02:00 committed by Marge Bot
parent 75023d96bc
commit 586c43d5a9
12 changed files with 25 additions and 110 deletions

View file

@ -259,17 +259,8 @@ clutter_backend_do_real_create_context (ClutterBackend *backend,
return TRUE; return TRUE;
error: error:
if (backend->cogl_display != NULL) g_clear_object (&backend->cogl_display);
{ g_clear_object (&backend->cogl_renderer);
g_object_unref (backend->cogl_display);
backend->cogl_display = NULL;
}
if (backend->cogl_renderer != NULL)
{
g_object_unref (backend->cogl_renderer);
backend->cogl_renderer = NULL;
}
if (swap_chain != NULL) if (swap_chain != NULL)
g_object_unref (swap_chain); g_object_unref (swap_chain);

View file

@ -147,11 +147,7 @@ clutter_blur_effect_dispose (GObject *gobject)
{ {
ClutterBlurEffect *self = CLUTTER_BLUR_EFFECT (gobject); ClutterBlurEffect *self = CLUTTER_BLUR_EFFECT (gobject);
if (self->pipeline != NULL) cogl_clear_object (&self->pipeline);
{
cogl_object_unref (self->pipeline);
self->pipeline = NULL;
}
G_OBJECT_CLASS (clutter_blur_effect_parent_class)->dispose (gobject); G_OBJECT_CLASS (clutter_blur_effect_parent_class)->dispose (gobject);
} }

View file

@ -230,7 +230,7 @@ create_fbo (ClutterBlur *blur,
float height; float height;
float width; float width;
g_clear_pointer (&pass->texture, cogl_object_unref); cogl_clear_object (&pass->texture);
g_clear_object (&pass->framebuffer); g_clear_object (&pass->framebuffer);
width = cogl_texture_get_width (blur->source_texture); width = cogl_texture_get_width (blur->source_texture);
@ -326,8 +326,8 @@ apply_blur_pass (BlurPass *pass)
static void static void
clear_blur_pass (BlurPass *pass) clear_blur_pass (BlurPass *pass)
{ {
g_clear_pointer (&pass->pipeline, cogl_object_unref); cogl_clear_object (&pass->pipeline);
g_clear_pointer (&pass->texture, cogl_object_unref); cogl_clear_object (&pass->texture);
g_clear_object (&pass->framebuffer); g_clear_object (&pass->framebuffer);
} }

View file

@ -155,11 +155,7 @@ clutter_brightness_contrast_effect_dispose (GObject *gobject)
{ {
ClutterBrightnessContrastEffect *self = CLUTTER_BRIGHTNESS_CONTRAST_EFFECT (gobject); ClutterBrightnessContrastEffect *self = CLUTTER_BRIGHTNESS_CONTRAST_EFFECT (gobject);
if (self->pipeline != NULL) cogl_clear_object (&self->pipeline);
{
cogl_object_unref (self->pipeline);
self->pipeline = NULL;
}
G_OBJECT_CLASS (clutter_brightness_contrast_effect_parent_class)->dispose (gobject); G_OBJECT_CLASS (clutter_brightness_contrast_effect_parent_class)->dispose (gobject);
} }

View file

@ -127,13 +127,8 @@ clutter_canvas_finalize (GObject *gobject)
{ {
ClutterCanvasPrivate *priv = CLUTTER_CANVAS (gobject)->priv; ClutterCanvasPrivate *priv = CLUTTER_CANVAS (gobject)->priv;
if (priv->buffer != NULL) g_clear_object (&priv->buffer);
{ cogl_clear_object (&priv->texture);
g_object_unref (priv->buffer);
priv->buffer = NULL;
}
g_clear_pointer (&priv->texture, cogl_object_unref);
G_OBJECT_CLASS (clutter_canvas_parent_class)->finalize (gobject); G_OBJECT_CLASS (clutter_canvas_parent_class)->finalize (gobject);
} }
@ -322,7 +317,7 @@ clutter_canvas_paint_content (ClutterContent *content,
return; return;
if (priv->dirty) if (priv->dirty)
g_clear_pointer (&priv->texture, cogl_object_unref); cogl_clear_object (&priv->texture);
if (priv->texture == NULL) if (priv->texture == NULL)
priv->texture = COGL_TEXTURE (cogl_texture_2d_new_from_bitmap (priv->buffer)); priv->texture = COGL_TEXTURE (cogl_texture_2d_new_from_bitmap (priv->buffer));
@ -443,11 +438,7 @@ clutter_canvas_invalidate (ClutterContent *content)
ClutterCanvas *self = CLUTTER_CANVAS (content); ClutterCanvas *self = CLUTTER_CANVAS (content);
ClutterCanvasPrivate *priv = self->priv; ClutterCanvasPrivate *priv = self->priv;
if (priv->buffer != NULL) g_clear_object (&priv->buffer);
{
g_object_unref (priv->buffer);
priv->buffer = NULL;
}
if (priv->width <= 0 || priv->height <= 0) if (priv->width <= 0 || priv->height <= 0)
return; return;

View file

@ -113,11 +113,7 @@ clutter_colorize_effect_dispose (GObject *gobject)
{ {
ClutterColorizeEffect *self = CLUTTER_COLORIZE_EFFECT (gobject); ClutterColorizeEffect *self = CLUTTER_COLORIZE_EFFECT (gobject);
if (self->pipeline != NULL) cogl_clear_object (&self->pipeline);
{
cogl_object_unref (self->pipeline);
self->pipeline = NULL;
}
G_OBJECT_CLASS (clutter_colorize_effect_parent_class)->dispose (gobject); G_OBJECT_CLASS (clutter_colorize_effect_parent_class)->dispose (gobject);
} }

View file

@ -337,23 +337,9 @@ clutter_deform_effect_free_arrays (ClutterDeformEffect *self)
{ {
ClutterDeformEffectPrivate *priv = self->priv; ClutterDeformEffectPrivate *priv = self->priv;
if (priv->buffer) cogl_clear_object (&priv->buffer);
{ cogl_clear_object (&priv->primitive);
cogl_object_unref (priv->buffer); cogl_clear_object (&priv->lines_primitive);
priv->buffer = NULL;
}
if (priv->primitive)
{
cogl_object_unref (priv->primitive);
priv->primitive = NULL;
}
if (priv->lines_primitive)
{
cogl_object_unref (priv->lines_primitive);
priv->lines_primitive = NULL;
}
} }
static void static void
@ -501,11 +487,7 @@ clutter_deform_effect_free_back_pipeline (ClutterDeformEffect *self)
{ {
ClutterDeformEffectPrivate *priv = self->priv; ClutterDeformEffectPrivate *priv = self->priv;
if (priv->back_pipeline != NULL) cogl_clear_object (&priv->back_pipeline);
{
cogl_object_unref (priv->back_pipeline);
priv->back_pipeline = NULL;
}
} }
static void static void

View file

@ -124,11 +124,7 @@ clutter_desaturate_effect_dispose (GObject *gobject)
{ {
ClutterDesaturateEffect *self = CLUTTER_DESATURATE_EFFECT (gobject); ClutterDesaturateEffect *self = CLUTTER_DESATURATE_EFFECT (gobject);
if (self->pipeline != NULL) cogl_clear_object (&self->pipeline);
{
cogl_object_unref (self->pipeline);
self->pipeline = NULL;
}
G_OBJECT_CLASS (clutter_desaturate_effect_parent_class)->dispose (gobject); G_OBJECT_CLASS (clutter_desaturate_effect_parent_class)->dispose (gobject);
} }

View file

@ -111,11 +111,7 @@ clutter_image_finalize (GObject *gobject)
ClutterImage *image = CLUTTER_IMAGE (gobject); ClutterImage *image = CLUTTER_IMAGE (gobject);
ClutterImagePrivate *priv = clutter_image_get_instance_private (image); ClutterImagePrivate *priv = clutter_image_get_instance_private (image);
if (priv->texture != NULL) cogl_clear_object (&priv->texture);
{
cogl_object_unref (priv->texture);
priv->texture = NULL;
}
G_OBJECT_CLASS (clutter_image_parent_class)->finalize (gobject); G_OBJECT_CLASS (clutter_image_parent_class)->finalize (gobject);
} }
@ -395,8 +391,7 @@ clutter_image_set_area (ClutterImage *image,
if (!res) if (!res)
{ {
cogl_object_unref (priv->texture); cogl_clear_object (&priv->texture);
priv->texture = NULL;
} }
} }

View file

@ -134,11 +134,7 @@ clutter_path_constraint_dispose (GObject *gobject)
{ {
ClutterPathConstraint *self = CLUTTER_PATH_CONSTRAINT (gobject); ClutterPathConstraint *self = CLUTTER_PATH_CONSTRAINT (gobject);
if (self->path != NULL) g_clear_object (&self->path);
{
g_object_unref (self->path);
self->path = NULL;
}
G_OBJECT_CLASS (clutter_path_constraint_parent_class)->dispose (gobject); G_OBJECT_CLASS (clutter_path_constraint_parent_class)->dispose (gobject);
} }
@ -298,11 +294,7 @@ clutter_path_constraint_set_path (ClutterPathConstraint *constraint,
if (constraint->path == path) if (constraint->path == path)
return; return;
if (constraint->path != NULL) g_clear_object (&constraint->path);
{
g_object_unref (constraint->path);
constraint->path = NULL;
}
if (path != NULL) if (path != NULL)
constraint->path = g_object_ref_sink (path); constraint->path = g_object_ref_sink (path);

View file

@ -175,19 +175,8 @@ clutter_shader_effect_clear (ClutterShaderEffect *self,
{ {
ClutterShaderEffectPrivate *priv = self->priv; ClutterShaderEffectPrivate *priv = self->priv;
if (priv->shader != NULL) g_clear_object (&priv->shader);
{ g_clear_object (&priv->program);
g_object_unref (priv->shader);
priv->shader = NULL;
}
if (priv->program != NULL)
{
g_object_unref (priv->program);
priv->program = NULL;
}
if (reset_uniforms && priv->uniforms != NULL) if (reset_uniforms && priv->uniforms != NULL)
{ {

View file

@ -62,17 +62,8 @@ cogl_display_dispose (GObject *object)
display->setup = FALSE; display->setup = FALSE;
} }
if (display->renderer) g_clear_object (&display->renderer);
{ g_clear_object (&display->onscreen_template);
g_object_unref (display->renderer);
display->renderer = NULL;
}
if (display->onscreen_template)
{
g_object_unref (display->onscreen_template);
display->onscreen_template = NULL;
}
G_OBJECT_CLASS (cogl_display_parent_class)->dispose (object); G_OBJECT_CLASS (cogl_display_parent_class)->dispose (object);
} }