[gimp/gimp-2-10] app: add gimp_gegl_buffer_copy()



commit 1878543cf88e101e271c407d3fceabb388264656
Author: Ell <ell_se yahoo com>
Date:   Thu May 24 10:20:20 2018 -0400

    app: add gimp_gegl_buffer_copy()
    
    ... which is a drop-in replacement for gegl_buffer_copy(),
    parallelizing the copy operation when the source and destination
    formats are different, requiring a conversion.
    
    (cherry picked from commit fded25b38cbf03f0f94e695621bf215e36f8d79b)

 app/gegl/gimp-gegl-loops.cc | 35 +++++++++++++++++++++++++++++++++++
 app/gegl/gimp-gegl-loops.h  |  6 ++++++
 2 files changed, 41 insertions(+)
---
diff --git a/app/gegl/gimp-gegl-loops.cc b/app/gegl/gimp-gegl-loops.cc
index bb6ddb677f..93cc7291af 100644
--- a/app/gegl/gimp-gegl-loops.cc
+++ b/app/gegl/gimp-gegl-loops.cc
@@ -57,6 +57,41 @@ extern "C"
   const GeglRectangle * const dest##_area = &dest##_area_
 
 
+void
+gimp_gegl_buffer_copy (GeglBuffer          *src_buffer,
+                       const GeglRectangle *src_rect,
+                       GeglAbyssPolicy      abyss_policy,
+                       GeglBuffer          *dest_buffer,
+                       const GeglRectangle *dest_rect)
+{
+  g_return_if_fail (GEGL_IS_BUFFER (src_buffer));
+  g_return_if_fail (GEGL_IS_BUFFER (dest_buffer));
+
+  if (gegl_buffer_get_format (src_buffer) ==
+      gegl_buffer_get_format (dest_buffer))
+    {
+      gegl_buffer_copy (src_buffer, src_rect, abyss_policy,
+                        dest_buffer, dest_rect);
+    }
+  else
+    {
+      if (! src_rect)
+        src_rect = gegl_buffer_get_extent (src_buffer);
+
+      if (! dest_rect)
+        dest_rect = src_rect;
+
+      gimp_parallel_distribute_area (src_rect, MIN_PARALLEL_SUB_AREA,
+                                     [=] (const GeglRectangle *src_area)
+        {
+          SHIFTED_AREA (dest, src);
+
+          gegl_buffer_copy (src_buffer, src_area, abyss_policy,
+                            dest_buffer, dest_area);
+        });
+    }
+}
+
 void
 gimp_gegl_convolve (GeglBuffer          *src_buffer,
                     const GeglRectangle *src_rect,
diff --git a/app/gegl/gimp-gegl-loops.h b/app/gegl/gimp-gegl-loops.h
index 093f12aaee..e40a30942f 100644
--- a/app/gegl/gimp-gegl-loops.h
+++ b/app/gegl/gimp-gegl-loops.h
@@ -22,6 +22,12 @@
 #define __GIMP_GEGL_LOOPS_H__
 
 
+void   gimp_gegl_buffer_copy           (GeglBuffer               *src_buffer,
+                                        const GeglRectangle      *src_rect,
+                                        GeglAbyssPolicy           abyss_policy,
+                                        GeglBuffer               *dest_buffer,
+                                        const GeglRectangle      *dest_rect);
+
 /*  this is a pretty stupid port of concolve_region() that only works
  *  on a linear source buffer
  */


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