[gimp/goat-invasion: 469/526] app: use gegl_buffer_copy() in gimp_drawable_real_replace_buffer()



commit 8c9e1b452825a15bab068db14a6cd0c5077bc25e
Author: Michael Natterer <mitch gimp org>
Date:   Mon Apr 9 01:20:58 2012 +0200

    app: use gegl_buffer_copy() in gimp_drawable_real_replace_buffer()

 app/core/gimpdrawable-combine.c |   34 +++++++++++++++++++---------------
 1 files changed, 19 insertions(+), 15 deletions(-)
---
diff --git a/app/core/gimpdrawable-combine.c b/app/core/gimpdrawable-combine.c
index d04e0b1..d3db220 100644
--- a/app/core/gimpdrawable-combine.c
+++ b/app/core/gimpdrawable-combine.c
@@ -38,6 +38,7 @@
 #include "gimpdrawableundo.h"
 #include "gimpimage.h"
 #include "gimpimage-undo.h"
+#include "gimptempbuf.h"
 
 
 void
@@ -343,35 +344,38 @@ gimp_drawable_real_replace_buffer (GimpDrawable        *drawable,
 
   if (mask)
     {
-      PixelRegion  mask2PR, tempPR;
-      guchar      *temp_data;
+      PixelRegion  tempPR;
+      GimpTempBuf *temp_buf;
+      GeglBuffer  *src_buffer;
+      GeglBuffer  *dest_buffer;
 
-      pixel_region_init (&mask2PR,
-                         gimp_drawable_get_tiles (GIMP_DRAWABLE (mask)),
-                         x + offset_x, y + offset_y, width, height,
-                         FALSE);
+      src_buffer = gimp_drawable_get_buffer (GIMP_DRAWABLE (mask));
+
+      temp_buf = gimp_temp_buf_new (width, height,
+                                    gegl_buffer_get_format (src_buffer));
 
-      temp_data = g_malloc (width * height);
+      dest_buffer = gimp_temp_buf_create_buffer (temp_buf);
 
-      pixel_region_init_data (&tempPR, temp_data, 1, width,
-                              0, 0, width, height);
+      gegl_buffer_copy (src_buffer,
+                        GEGL_RECTANGLE (x + offset_x, y + offset_y,
+                                        width, height),
+                        dest_buffer,
+                        GEGL_RECTANGLE (0, 0, 0, 0));
 
-      copy_region (&mask2PR, &tempPR);
+      g_object_unref (dest_buffer);
 
-      pixel_region_init_data (&tempPR, temp_data, 1, width,
-                              0, 0, width, height);
+      pixel_region_init_temp_buf (&tempPR, temp_buf, 0, 0, width, height);
 
       apply_mask_to_region (&tempPR, maskPR, OPAQUE_OPACITY);
 
-      pixel_region_init_data (&tempPR, temp_data, 1, width,
-                              0, 0, width, height);
+      pixel_region_init_temp_buf (&tempPR, temp_buf, 0, 0, width, height);
 
       combine_regions_replace (&src1PR, &src2PR, &destPR, &tempPR, NULL,
                                opacity * 255.999,
                                active_components,
                                operation);
 
-      g_free (temp_data);
+      gimp_temp_buf_unref (temp_buf);
     }
   else
     {



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