Commit 90610ac8 authored by Ell's avatar Ell

app: add gimp_gegl_buffer_set_extent()

.... as a drop-in replacement for gegl_buffer_set_extent(), which,
in addition to setting the buffer's extent, clears any now-out-of-
bounds tiles, to free memory.
parent b8ee7172
......@@ -283,3 +283,32 @@ gimp_gegl_buffer_dup (GeglBuffer *buffer)
return new_buffer;
gimp_gegl_buffer_set_extent (GeglBuffer *buffer,
const GeglRectangle *extent)
GeglRectangle aligned_old_extent;
GeglRectangle aligned_extent;
GeglRectangle diff_rects[4];
gint n_diff_rects;
gint i;
g_return_val_if_fail (GEGL_IS_BUFFER (buffer), FALSE);
g_return_val_if_fail (extent != NULL, FALSE);
gegl_rectangle_align_to_buffer (&aligned_old_extent,
gegl_buffer_get_extent (buffer), buffer,
gegl_rectangle_align_to_buffer (&aligned_extent,
extent, buffer,
n_diff_rects = gegl_rectangle_subtract (diff_rects,
&aligned_old_extent, &aligned_extent);
for (i = 0; i < n_diff_rects; i++)
gegl_buffer_clear (buffer, &diff_rects[i]);
return gegl_buffer_set_extent (buffer, extent);
......@@ -49,5 +49,8 @@ gboolean gimp_gegl_param_spec_has_key (GParamSpec *pspec
GeglBuffer * gimp_gegl_buffer_dup (GeglBuffer *buffer);
gboolean gimp_gegl_buffer_set_extent (GeglBuffer *buffer,
const GeglRectangle *extent);
#endif /* __GIMP_GEGL_UTILS_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment