[gimp] app: add gimp_gegl_buffer_dup()
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add gimp_gegl_buffer_dup()
- Date: Tue, 30 Jul 2019 17:33:43 +0000 (UTC)
commit 5798cefe1b3941274f65098c71318a8da03a789d
Author: Ell <ell_se yahoo com>
Date: Tue Jul 30 20:19:21 2019 +0300
app: add gimp_gegl_buffer_dup()
... as a drop-in replacement for gegl_buffer_dup(), which COWs all
tiles of the source buffer, including ones that aren't fully
included within buffer's extent.
app/gegl/gimp-gegl-utils.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++
app/gegl/gimp-gegl-utils.h | 2 ++
2 files changed, 52 insertions(+)
---
diff --git a/app/gegl/gimp-gegl-utils.c b/app/gegl/gimp-gegl-utils.c
index bb26dc1009..acc06be313 100644
--- a/app/gegl/gimp-gegl-utils.c
+++ b/app/gegl/gimp-gegl-utils.c
@@ -29,6 +29,7 @@
#include "core/gimpprogress.h"
+#include "gimp-gegl-loops.h"
#include "gimp-gegl-utils.h"
@@ -233,3 +234,52 @@ gimp_gegl_param_spec_has_key (GParamSpec *pspec,
return FALSE;
}
+
+GeglBuffer *
+gimp_gegl_buffer_dup (GeglBuffer *buffer)
+{
+ GeglBuffer *new_buffer;
+ const GeglRectangle *extent;
+ const GeglRectangle *abyss;
+ GeglRectangle rect;
+ gint shift_x;
+ gint shift_y;
+ gint tile_width;
+ gint tile_height;
+
+ g_return_val_if_fail (GEGL_IS_BUFFER (buffer), NULL);
+
+ extent = gegl_buffer_get_extent (buffer);
+ abyss = gegl_buffer_get_abyss (buffer);
+
+ g_object_get (buffer,
+ "shift-x", &shift_x,
+ "shift-y", &shift_y,
+ "tile-width", &tile_width,
+ "tile-height", &tile_height,
+ NULL);
+
+ new_buffer = g_object_new (GEGL_TYPE_BUFFER,
+ "format", gegl_buffer_get_format (buffer),
+ "x", extent->x,
+ "y", extent->y,
+ "width", extent->width,
+ "height", extent->height,
+ "abyss-x", abyss->x,
+ "abyss-y", abyss->y,
+ "abyss-width", abyss->width,
+ "abyss-height", abyss->height,
+ "shift-x", shift_x,
+ "shift-y", shift_y,
+ "tile-width", tile_width,
+ "tile-height", tile_height,
+ NULL);
+
+ gegl_rectangle_align_to_buffer (&rect, extent, buffer,
+ GEGL_RECTANGLE_ALIGNMENT_SUPERSET);
+
+ gimp_gegl_buffer_copy (buffer, &rect, GEGL_ABYSS_NONE,
+ new_buffer, &rect);
+
+ return new_buffer;
+}
diff --git a/app/gegl/gimp-gegl-utils.h b/app/gegl/gimp-gegl-utils.h
index f5425f1458..29654c36f6 100644
--- a/app/gegl/gimp-gegl-utils.h
+++ b/app/gegl/gimp-gegl-utils.h
@@ -47,5 +47,7 @@ gboolean gimp_gegl_param_spec_has_key (GParamSpec *pspec
const gchar *key,
const gchar *value);
+GeglBuffer * gimp_gegl_buffer_dup (GeglBuffer *buffer);
+
#endif /* __GIMP_GEGL_UTILS_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]