[gimp] app: replace more copy_region() by gegl_buffer_copy()



commit 7bab13c9a0406ef9112c66ed82c81c68562a1b4e
Author: Michael Natterer <mitch gimp org>
Date:   Thu Mar 15 01:39:23 2012 +0100

    app: replace more copy_region() by gegl_buffer_copy()

 app/core/gimpimagemap.c  |   56 +++++++++++++++++++++++++--------------------
 app/core/gimplayer.c     |   32 ++++++++++++++++----------
 app/core/gimpselection.c |   20 +++++++---------
 3 files changed, 60 insertions(+), 48 deletions(-)
---
diff --git a/app/core/gimpimagemap.c b/app/core/gimpimagemap.c
index ff681d6..f9d1f27 100644
--- a/app/core/gimpimagemap.c
+++ b/app/core/gimpimagemap.c
@@ -638,6 +638,10 @@ gimp_image_map_update_undo_tiles (GimpImageMap        *image_map,
       undo_width    != rect->width ||
       undo_height   != rect->height)
     {
+      GeglBuffer    *src;
+      GeglBuffer    *dest;
+      GeglRectangle  dest_rect = { 0, };
+
       /* If either the extents changed or the tiles don't exist,
        * allocate new
        */
@@ -656,18 +660,13 @@ gimp_image_map_update_undo_tiles (GimpImageMap        *image_map,
         }
 
       /*  Copy from the image to the new tiles  */
-      pixel_region_init (&image_map->srcPR,
-                         gimp_drawable_get_tiles (image_map->drawable),
-                         rect->x, rect->y,
-                         rect->width, rect->height,
-                         FALSE);
-      pixel_region_init (&image_map->destPR,
-                         image_map->undo_tiles,
-                         0, 0,
-                         rect->width, rect->height,
-                         TRUE);
+      src = gimp_drawable_create_buffer (image_map->drawable, TRUE);
+      dest = gimp_tile_manager_create_buffer (image_map->undo_tiles, FALSE);
 
-      copy_region (&image_map->srcPR, &image_map->destPR);
+      gegl_buffer_copy (src, rect, dest, &dest_rect);
+
+      g_object_unref (src);
+      g_object_unref (dest);
 
       /*  Set the offsets  */
       image_map->undo_offset_x = rect->x;
@@ -805,26 +804,33 @@ gimp_image_map_data_written (GObject             *operation,
 {
   GimpImage   *image;
   PixelRegion  srcPR;
-  PixelRegion  destPR;
 
   image = gimp_item_get_image (GIMP_ITEM (image_map->drawable));
 
   if (! gimp_channel_is_empty (gimp_image_get_mask (image)))
     {
       /* Reset to initial drawable conditions. */
-      pixel_region_init (&srcPR, image_map->undo_tiles,
-                         extent->x - image_map->undo_offset_x,
-                         extent->y - image_map->undo_offset_y,
-                         extent->width,
-                         extent->height,
-                         FALSE);
-      pixel_region_init (&destPR, gimp_drawable_get_tiles (image_map->drawable),
-                         extent->x,
-                         extent->y,
-                         extent->width,
-                         extent->height,
-                         TRUE);
-      copy_region (&srcPR, &destPR);
+
+      GeglBuffer    *src;
+      GeglBuffer    *dest;
+      GeglRectangle  src_rect;
+      GeglRectangle  dest_rect;
+
+      src = gimp_tile_manager_create_buffer (image_map->undo_tiles, FALSE);
+      dest = gimp_drawable_create_buffer (image_map->drawable, TRUE);
+
+      src_rect.x      = extent->x - image_map->undo_offset_x;
+      src_rect.y      = extent->y - image_map->undo_offset_y;
+      src_rect.width  = extent->width;
+      src_rect.height = extent->height;
+
+      dest_rect.x = extent->x;
+      dest_rect.y = extent->y;
+
+      gegl_buffer_copy (src, &src_rect, dest, &dest_rect);
+
+      g_object_unref (src);
+      g_object_unref (dest);
     }
 
   /* Apply the result of the gegl graph. */
diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c
index 3816fff..9c66a2d 100644
--- a/app/core/gimplayer.c
+++ b/app/core/gimplayer.c
@@ -1687,18 +1687,26 @@ gimp_layer_create_mask (const GimpLayer *layer,
 
         if ((copy_width || copy_height) && ! channel_empty)
           {
-            pixel_region_init (&srcPR,
-                               gimp_drawable_get_tiles (GIMP_DRAWABLE (channel)),
-                               copy_x, copy_y,
-                               copy_width, copy_height,
-                               FALSE);
-            pixel_region_init (&destPR,
-                               gimp_drawable_get_tiles (GIMP_DRAWABLE (mask)),
-                               copy_x - offset_x, copy_y - offset_y,
-                               copy_width, copy_height,
-                               TRUE);
+            GeglBuffer    *src;
+            GeglBuffer    *dest;
+            GeglRectangle  src_rect;
+            GeglRectangle  dest_rect;
 
-            copy_region (&srcPR, &destPR);
+            src  = gimp_drawable_create_buffer (GIMP_DRAWABLE (channel), FALSE);
+            dest = gimp_drawable_create_buffer (GIMP_DRAWABLE (mask), TRUE);
+
+            src_rect.x      = copy_x;
+            src_rect.y      = copy_y;
+            src_rect.width  = copy_width;
+            src_rect.height = copy_height;
+
+            dest_rect.x = copy_x - offset_x;
+            dest_rect.y = copy_y - offset_y;
+
+            gegl_buffer_copy (src, &src_rect, dest, &dest_rect);
+
+            g_object_unref (src);
+            g_object_unref (dest);
 
             GIMP_CHANNEL (mask)->bounds_known = FALSE;
           }
diff --git a/app/core/gimpselection.c b/app/core/gimpselection.c
index 07cee4f..5e15f77 100644
--- a/app/core/gimpselection.c
+++ b/app/core/gimpselection.c
@@ -564,8 +564,8 @@ void
 gimp_selection_load (GimpSelection *selection,
                      GimpChannel   *channel)
 {
-  PixelRegion srcPR;
-  PixelRegion destPR;
+  GeglBuffer *src;
+  GeglBuffer *dest;
   gint        width;
   gint        height;
 
@@ -582,15 +582,13 @@ gimp_selection_load (GimpSelection *selection,
                           C_("undo-type", "Channel to Selection"));
 
   /*  copy the channel to the mask  */
-  pixel_region_init (&srcPR,
-                     gimp_drawable_get_tiles (GIMP_DRAWABLE (channel)),
-                     0, 0, width, height,
-                     FALSE);
-  pixel_region_init (&destPR,
-                     gimp_drawable_get_tiles (GIMP_DRAWABLE (selection)),
-                     0, 0, width, height,
-                     TRUE);
-  copy_region (&srcPR, &destPR);
+  src  = gimp_drawable_create_buffer (GIMP_DRAWABLE (channel), FALSE);
+  dest = gimp_drawable_create_buffer (GIMP_DRAWABLE (selection), TRUE);
+
+  gegl_buffer_copy (src, NULL, dest, NULL);
+
+  g_object_unref (src);
+  g_object_unref (dest);
 
   GIMP_CHANNEL (selection)->bounds_known = FALSE;
 



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