[gimp] app: add gimp_gegl_buffer_set_extent()
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add gimp_gegl_buffer_set_extent()
- Date: Tue, 13 Aug 2019 14:44:54 +0000 (UTC)
commit 90610ac87e2fa652c8d0c0b88e58810f036adedb
Author: Ell <ell_se yahoo com>
Date: Tue Aug 13 17:06:23 2019 +0300
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.
app/gegl/gimp-gegl-utils.c | 29 +++++++++++++++++++++++++++++
app/gegl/gimp-gegl-utils.h | 3 +++
2 files changed, 32 insertions(+)
---
diff --git a/app/gegl/gimp-gegl-utils.c b/app/gegl/gimp-gegl-utils.c
index acc06be313..0340358ff0 100644
--- a/app/gegl/gimp-gegl-utils.c
+++ b/app/gegl/gimp-gegl-utils.c
@@ -283,3 +283,32 @@ gimp_gegl_buffer_dup (GeglBuffer *buffer)
return new_buffer;
}
+
+gboolean
+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_ALIGNMENT_SUPERSET);
+ gegl_rectangle_align_to_buffer (&aligned_extent,
+ extent, buffer,
+ GEGL_RECTANGLE_ALIGNMENT_SUPERSET);
+
+ 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);
+}
diff --git a/app/gegl/gimp-gegl-utils.h b/app/gegl/gimp-gegl-utils.h
index 29654c36f6..a219736e18 100644
--- a/app/gegl/gimp-gegl-utils.h
+++ b/app/gegl/gimp-gegl-utils.h
@@ -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__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]