[gimp/goat-invasion: 187/412] app: add gimp_gegl_buffer_dup() which creates a TileManager backed dup



commit 3d65511b679f9bc36e21f2db1cd91a8f1f2655a9
Author: Michael Natterer <mitch gimp org>
Date:   Wed Mar 21 18:58:17 2012 +0100

    app: add gimp_gegl_buffer_dup() which creates a TileManager backed dup

 app/gegl/gimp-gegl-utils.c |   19 +++++++++++++++++++
 app/gegl/gimp-gegl-utils.h |    2 ++
 2 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/app/gegl/gimp-gegl-utils.c b/app/gegl/gimp-gegl-utils.c
index 6c993b7..9889524 100644
--- a/app/gegl/gimp-gegl-utils.c
+++ b/app/gegl/gimp-gegl-utils.c
@@ -219,6 +219,25 @@ gimp_gegl_buffer_new (const GeglRectangle *rect,
 }
 
 GeglBuffer *
+gimp_gegl_buffer_dup (GeglBuffer *buffer)
+{
+  const Babl  *format = gegl_buffer_get_format (buffer);
+  TileManager *tiles;
+  GeglBuffer  *dup;
+
+  tiles = tile_manager_new (gegl_buffer_get_width (buffer),
+                            gegl_buffer_get_height (buffer),
+                            babl_format_get_bytes_per_pixel (format));
+
+  dup = gimp_tile_manager_create_buffer (tiles, format);
+  tile_manager_unref (tiles);
+
+  gegl_buffer_copy (buffer, NULL, dup, NULL);
+
+  return dup;
+}
+
+GeglBuffer *
 gimp_tile_manager_create_buffer (TileManager *tm,
                                  const Babl  *format)
 {
diff --git a/app/gegl/gimp-gegl-utils.h b/app/gegl/gimp-gegl-utils.h
index 70034fa..a61235c 100644
--- a/app/gegl/gimp-gegl-utils.h
+++ b/app/gegl/gimp-gegl-utils.h
@@ -35,6 +35,8 @@ const gchar * gimp_interpolation_to_gegl_filter  (GimpInterpolationType  interpo
 
 GeglBuffer  * gimp_gegl_buffer_new               (const GeglRectangle   *rect,
                                                   const Babl            *format);
+GeglBuffer  * gimp_gegl_buffer_dup               (GeglBuffer            *buffer);
+
 GeglBuffer  * gimp_tile_manager_create_buffer    (TileManager           *tm,
                                                   const Babl            *format);
 TileManager * gimp_gegl_buffer_get_tiles         (GeglBuffer            *buffer);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]