clutter/paint-volume: Remove 'is_static'

And change clutter_paint_volume_free() to always free the paint volume.
Remove all calls to clutter_paint_volume_free() on static variables.

Having to call a free function on a static variable always seemed a bit
odd, and this genuinely confuses Coverity (and me).

Coverity CID: #1505838

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4175>
This commit is contained in:
Georges Basile Stavracas Neto 2024-12-10 08:30:59 -03:00
parent 38d4962c20
commit 7e24b9696a
5 changed files with 0 additions and 43 deletions

View File

@ -3140,8 +3140,6 @@ _clutter_actor_draw_paint_volume (ClutterActor *self,
_clutter_actor_draw_paint_volume_full (self, &fake_pv,
&COGL_COLOR_INIT (0, 0, 255, 255),
node);
clutter_paint_volume_free (&fake_pv);
}
else
{
@ -7787,8 +7785,6 @@ clutter_actor_queue_redraw_with_clip (ClutterActor *self,
clutter_paint_volume_set_height (&volume, clip->height);
_clutter_actor_queue_redraw_full (self, &volume, NULL);
clutter_paint_volume_free (&volume);
}
/**
@ -14288,7 +14284,6 @@ _clutter_actor_get_paint_volume_real (ClutterActor *self,
if (!CLUTTER_ACTOR_GET_CLASS (self)->get_paint_volume (self, pv))
{
clutter_paint_volume_free (pv);
CLUTTER_NOTE (CLIPPING, "Bail from get_paint_volume (%s): "
"Actor failed to report a volume",
_clutter_actor_get_debug_name (self));
@ -14314,7 +14309,6 @@ _clutter_actor_get_paint_volume_real (ClutterActor *self,
{
if (!_clutter_effect_modify_paint_volume (l->data, pv))
{
clutter_paint_volume_free (pv);
CLUTTER_NOTE (CLIPPING, "Bail from get_paint_volume (%s): "
"Effect (%s) failed to report a volume",
_clutter_actor_get_debug_name (self),
@ -14332,7 +14326,6 @@ _clutter_actor_get_paint_volume_real (ClutterActor *self,
for (l = effects; l != NULL; l = l->next)
if (!_clutter_effect_modify_paint_volume (l->data, pv))
{
clutter_paint_volume_free (pv);
CLUTTER_NOTE (CLIPPING, "Bail from get_paint_volume (%s): "
"Effect (%s) failed to report a volume",
_clutter_actor_get_debug_name (self),
@ -14404,10 +14397,6 @@ ensure_paint_volume (ClutterActor *self)
if (priv->needs_paint_volume_update)
{
priv->had_effects_on_last_paint_volume_update = has_paint_volume_override_effects;
if (priv->has_paint_volume)
clutter_paint_volume_free (&priv->paint_volume);
priv->has_paint_volume = FALSE;
if (_clutter_actor_get_paint_volume_real (self, &priv->paint_volume))

View File

@ -350,7 +350,6 @@ clutter_offscreen_effect_pre_paint (ClutterEffect *effect,
_clutter_paint_volume_copy_static (volume, &mutable_volume);
_clutter_paint_volume_get_bounding_box (&mutable_volume, &raw_box);
clutter_paint_volume_free (&mutable_volume);
box = raw_box;
_clutter_actor_box_enlarge_for_effects (&box);

View File

@ -59,11 +59,6 @@ struct _ClutterPaintVolume
*/
graphene_point3d_t vertices[8];
/* As an optimization for internally managed PaintVolumes we allow
* initializing ClutterPaintVolume variables allocated on the stack
* so we can avoid hammering the memory allocator. */
guint is_static:1;
/* A newly initialized PaintVolume is considered empty as it is
* degenerate on all three axis.
*

View File

@ -52,12 +52,6 @@ G_DEFINE_BOXED_TYPE (ClutterPaintVolume, clutter_paint_volume,
* We were seeing slice allocation take about 1% cumulative CPU time
* for some very simple clutter tests which although it isn't a *lot*
* this is an easy way to basically drop that to 0%.
*
* The PaintVolume will be internally marked as static and
* clutter_paint_volume_free should still be used to "free" static
* volumes. This allows us to potentially store dynamically allocated
* data inside paint volumes in the future since we would be able to
* free it during _paint_volume_free().
*/
void
_clutter_paint_volume_init_static (ClutterPaintVolume *pv,
@ -67,7 +61,6 @@ _clutter_paint_volume_init_static (ClutterPaintVolume *pv,
memset (pv->vertices, 0, 8 * sizeof (graphene_point3d_t));
pv->is_static = TRUE;
pv->is_empty = TRUE;
pv->is_axis_aligned = TRUE;
pv->is_complete = TRUE;
@ -82,7 +75,6 @@ _clutter_paint_volume_copy_static (const ClutterPaintVolume *src_pv,
g_return_if_fail (src_pv != NULL && dst_pv != NULL);
memcpy (dst_pv, src_pv, sizeof (ClutterPaintVolume));
dst_pv->is_static = TRUE;
}
/**
@ -101,7 +93,6 @@ clutter_paint_volume_copy (const ClutterPaintVolume *pv)
g_return_val_if_fail (pv != NULL, NULL);
copy = g_memdup2 (pv, sizeof (ClutterPaintVolume));
copy->is_static = FALSE;
return copy;
}
@ -110,9 +101,7 @@ void
_clutter_paint_volume_set_from_volume (ClutterPaintVolume *pv,
const ClutterPaintVolume *src)
{
gboolean is_static = pv->is_static;
memcpy (pv, src, sizeof (ClutterPaintVolume));
pv->is_static = is_static;
}
/**
@ -126,9 +115,6 @@ clutter_paint_volume_free (ClutterPaintVolume *pv)
{
g_return_if_fail (pv != NULL);
if (G_LIKELY (pv->is_static))
return;
g_free (pv);
}
@ -280,7 +266,6 @@ clutter_paint_volume_get_width (const ClutterPaintVolume *pv)
_clutter_paint_volume_copy_static (pv, &tmp);
_clutter_paint_volume_axis_align (&tmp);
width = tmp.vertices[1].x - tmp.vertices[0].x;
clutter_paint_volume_free (&tmp);
return width;
}
else
@ -368,7 +353,6 @@ clutter_paint_volume_get_height (const ClutterPaintVolume *pv)
_clutter_paint_volume_copy_static (pv, &tmp);
_clutter_paint_volume_axis_align (&tmp);
height = tmp.vertices[3].y - tmp.vertices[0].y;
clutter_paint_volume_free (&tmp);
return height;
}
else
@ -457,7 +441,6 @@ clutter_paint_volume_get_depth (const ClutterPaintVolume *pv)
_clutter_paint_volume_copy_static (pv, &tmp);
_clutter_paint_volume_axis_align (&tmp);
depth = tmp.vertices[4].z - tmp.vertices[0].z;
clutter_paint_volume_free (&tmp);
return depth;
}
else
@ -577,8 +560,6 @@ clutter_paint_volume_union_box (ClutterPaintVolume *pv,
clutter_paint_volume_set_height (&volume, box->y2 - box->y1);
clutter_paint_volume_union (pv, &volume);
clutter_paint_volume_free (&volume);
}
/* The paint_volume setters only update vertices 0, 1, 3 and
@ -1039,7 +1020,6 @@ _clutter_paint_volume_get_stage_paint_box (const ClutterPaintVolume *pv,
* good. We won't need to add any extra room for sub-pixel positioning
* in this case.
*/
clutter_paint_volume_free (&projected_pv);
clutter_round_to_256ths (&box->x1);
clutter_round_to_256ths (&box->y1);
clutter_round_to_256ths (&box->x2);
@ -1052,8 +1032,6 @@ _clutter_paint_volume_get_stage_paint_box (const ClutterPaintVolume *pv,
}
_clutter_actor_box_enlarge_for_effects (box);
clutter_paint_volume_free (&projected_pv);
}
void

View File

@ -2864,8 +2864,6 @@ add_selection_to_paint_volume (ClutterText *text,
clutter_paint_volume_set_height (&rect_volume, box->y2 - box->y1);
clutter_paint_volume_union (total_volume, &rect_volume);
clutter_paint_volume_free (&rect_volume);
}
static void
@ -2962,8 +2960,6 @@ clutter_text_get_paint_volume (ClutterActor *self,
clutter_paint_volume_union (volume,
&cursor_paint_volume);
clutter_paint_volume_free (&cursor_paint_volume);
}
return TRUE;