clutter/cogl: Use more of memory management helpers
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3193>
This commit is contained in:
parent
75023d96bc
commit
586c43d5a9
@ -259,17 +259,8 @@ clutter_backend_do_real_create_context (ClutterBackend *backend,
|
||||
return TRUE;
|
||||
|
||||
error:
|
||||
if (backend->cogl_display != NULL)
|
||||
{
|
||||
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;
|
||||
}
|
||||
g_clear_object (&backend->cogl_display);
|
||||
g_clear_object (&backend->cogl_renderer);
|
||||
|
||||
if (swap_chain != NULL)
|
||||
g_object_unref (swap_chain);
|
||||
|
@ -147,11 +147,7 @@ clutter_blur_effect_dispose (GObject *gobject)
|
||||
{
|
||||
ClutterBlurEffect *self = CLUTTER_BLUR_EFFECT (gobject);
|
||||
|
||||
if (self->pipeline != NULL)
|
||||
{
|
||||
cogl_object_unref (self->pipeline);
|
||||
self->pipeline = NULL;
|
||||
}
|
||||
cogl_clear_object (&self->pipeline);
|
||||
|
||||
G_OBJECT_CLASS (clutter_blur_effect_parent_class)->dispose (gobject);
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ create_fbo (ClutterBlur *blur,
|
||||
float height;
|
||||
float width;
|
||||
|
||||
g_clear_pointer (&pass->texture, cogl_object_unref);
|
||||
cogl_clear_object (&pass->texture);
|
||||
g_clear_object (&pass->framebuffer);
|
||||
|
||||
width = cogl_texture_get_width (blur->source_texture);
|
||||
@ -326,8 +326,8 @@ apply_blur_pass (BlurPass *pass)
|
||||
static void
|
||||
clear_blur_pass (BlurPass *pass)
|
||||
{
|
||||
g_clear_pointer (&pass->pipeline, cogl_object_unref);
|
||||
g_clear_pointer (&pass->texture, cogl_object_unref);
|
||||
cogl_clear_object (&pass->pipeline);
|
||||
cogl_clear_object (&pass->texture);
|
||||
g_clear_object (&pass->framebuffer);
|
||||
}
|
||||
|
||||
|
@ -155,11 +155,7 @@ clutter_brightness_contrast_effect_dispose (GObject *gobject)
|
||||
{
|
||||
ClutterBrightnessContrastEffect *self = CLUTTER_BRIGHTNESS_CONTRAST_EFFECT (gobject);
|
||||
|
||||
if (self->pipeline != NULL)
|
||||
{
|
||||
cogl_object_unref (self->pipeline);
|
||||
self->pipeline = NULL;
|
||||
}
|
||||
cogl_clear_object (&self->pipeline);
|
||||
|
||||
G_OBJECT_CLASS (clutter_brightness_contrast_effect_parent_class)->dispose (gobject);
|
||||
}
|
||||
|
@ -127,13 +127,8 @@ clutter_canvas_finalize (GObject *gobject)
|
||||
{
|
||||
ClutterCanvasPrivate *priv = CLUTTER_CANVAS (gobject)->priv;
|
||||
|
||||
if (priv->buffer != NULL)
|
||||
{
|
||||
g_object_unref (priv->buffer);
|
||||
priv->buffer = NULL;
|
||||
}
|
||||
|
||||
g_clear_pointer (&priv->texture, cogl_object_unref);
|
||||
g_clear_object (&priv->buffer);
|
||||
cogl_clear_object (&priv->texture);
|
||||
|
||||
G_OBJECT_CLASS (clutter_canvas_parent_class)->finalize (gobject);
|
||||
}
|
||||
@ -322,7 +317,7 @@ clutter_canvas_paint_content (ClutterContent *content,
|
||||
return;
|
||||
|
||||
if (priv->dirty)
|
||||
g_clear_pointer (&priv->texture, cogl_object_unref);
|
||||
cogl_clear_object (&priv->texture);
|
||||
|
||||
if (priv->texture == NULL)
|
||||
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);
|
||||
ClutterCanvasPrivate *priv = self->priv;
|
||||
|
||||
if (priv->buffer != NULL)
|
||||
{
|
||||
g_object_unref (priv->buffer);
|
||||
priv->buffer = NULL;
|
||||
}
|
||||
g_clear_object (&priv->buffer);
|
||||
|
||||
if (priv->width <= 0 || priv->height <= 0)
|
||||
return;
|
||||
|
@ -113,11 +113,7 @@ clutter_colorize_effect_dispose (GObject *gobject)
|
||||
{
|
||||
ClutterColorizeEffect *self = CLUTTER_COLORIZE_EFFECT (gobject);
|
||||
|
||||
if (self->pipeline != NULL)
|
||||
{
|
||||
cogl_object_unref (self->pipeline);
|
||||
self->pipeline = NULL;
|
||||
}
|
||||
cogl_clear_object (&self->pipeline);
|
||||
|
||||
G_OBJECT_CLASS (clutter_colorize_effect_parent_class)->dispose (gobject);
|
||||
}
|
||||
|
@ -337,23 +337,9 @@ clutter_deform_effect_free_arrays (ClutterDeformEffect *self)
|
||||
{
|
||||
ClutterDeformEffectPrivate *priv = self->priv;
|
||||
|
||||
if (priv->buffer)
|
||||
{
|
||||
cogl_object_unref (priv->buffer);
|
||||
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;
|
||||
}
|
||||
cogl_clear_object (&priv->buffer);
|
||||
cogl_clear_object (&priv->primitive);
|
||||
cogl_clear_object (&priv->lines_primitive);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -501,11 +487,7 @@ clutter_deform_effect_free_back_pipeline (ClutterDeformEffect *self)
|
||||
{
|
||||
ClutterDeformEffectPrivate *priv = self->priv;
|
||||
|
||||
if (priv->back_pipeline != NULL)
|
||||
{
|
||||
cogl_object_unref (priv->back_pipeline);
|
||||
priv->back_pipeline = NULL;
|
||||
}
|
||||
cogl_clear_object (&priv->back_pipeline);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -124,11 +124,7 @@ clutter_desaturate_effect_dispose (GObject *gobject)
|
||||
{
|
||||
ClutterDesaturateEffect *self = CLUTTER_DESATURATE_EFFECT (gobject);
|
||||
|
||||
if (self->pipeline != NULL)
|
||||
{
|
||||
cogl_object_unref (self->pipeline);
|
||||
self->pipeline = NULL;
|
||||
}
|
||||
cogl_clear_object (&self->pipeline);
|
||||
|
||||
G_OBJECT_CLASS (clutter_desaturate_effect_parent_class)->dispose (gobject);
|
||||
}
|
||||
|
@ -111,11 +111,7 @@ clutter_image_finalize (GObject *gobject)
|
||||
ClutterImage *image = CLUTTER_IMAGE (gobject);
|
||||
ClutterImagePrivate *priv = clutter_image_get_instance_private (image);
|
||||
|
||||
if (priv->texture != NULL)
|
||||
{
|
||||
cogl_object_unref (priv->texture);
|
||||
priv->texture = NULL;
|
||||
}
|
||||
cogl_clear_object (&priv->texture);
|
||||
|
||||
G_OBJECT_CLASS (clutter_image_parent_class)->finalize (gobject);
|
||||
}
|
||||
@ -395,8 +391,7 @@ clutter_image_set_area (ClutterImage *image,
|
||||
|
||||
if (!res)
|
||||
{
|
||||
cogl_object_unref (priv->texture);
|
||||
priv->texture = NULL;
|
||||
cogl_clear_object (&priv->texture);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -134,11 +134,7 @@ clutter_path_constraint_dispose (GObject *gobject)
|
||||
{
|
||||
ClutterPathConstraint *self = CLUTTER_PATH_CONSTRAINT (gobject);
|
||||
|
||||
if (self->path != NULL)
|
||||
{
|
||||
g_object_unref (self->path);
|
||||
self->path = NULL;
|
||||
}
|
||||
g_clear_object (&self->path);
|
||||
|
||||
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)
|
||||
return;
|
||||
|
||||
if (constraint->path != NULL)
|
||||
{
|
||||
g_object_unref (constraint->path);
|
||||
constraint->path = NULL;
|
||||
}
|
||||
g_clear_object (&constraint->path);
|
||||
|
||||
if (path != NULL)
|
||||
constraint->path = g_object_ref_sink (path);
|
||||
|
@ -175,19 +175,8 @@ clutter_shader_effect_clear (ClutterShaderEffect *self,
|
||||
{
|
||||
ClutterShaderEffectPrivate *priv = self->priv;
|
||||
|
||||
if (priv->shader != NULL)
|
||||
{
|
||||
g_object_unref (priv->shader);
|
||||
|
||||
priv->shader = NULL;
|
||||
}
|
||||
|
||||
if (priv->program != NULL)
|
||||
{
|
||||
g_object_unref (priv->program);
|
||||
|
||||
priv->program = NULL;
|
||||
}
|
||||
g_clear_object (&priv->shader);
|
||||
g_clear_object (&priv->program);
|
||||
|
||||
if (reset_uniforms && priv->uniforms != NULL)
|
||||
{
|
||||
|
@ -62,17 +62,8 @@ cogl_display_dispose (GObject *object)
|
||||
display->setup = FALSE;
|
||||
}
|
||||
|
||||
if (display->renderer)
|
||||
{
|
||||
g_object_unref (display->renderer);
|
||||
display->renderer = NULL;
|
||||
}
|
||||
|
||||
if (display->onscreen_template)
|
||||
{
|
||||
g_object_unref (display->onscreen_template);
|
||||
display->onscreen_template = NULL;
|
||||
}
|
||||
g_clear_object (&display->renderer);
|
||||
g_clear_object (&display->onscreen_template);
|
||||
|
||||
G_OBJECT_CLASS (cogl_display_parent_class)->dispose (object);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user