[gimp/goat-invasion: 551/608] app: change the maskPR in gimp_drawable_replace_buffer() to GeglBuffer



commit 6518b0e9003ef7606865c6d368adce6ead10aa0c
Author: Michael Natterer <mitch gimp org>
Date:   Mon Apr 23 00:32:14 2012 +0200

    app: change the maskPR in gimp_drawable_replace_buffer() to GeglBuffer

 app/core/gimpchannel.c          |    8 ++++--
 app/core/gimpdrawable-combine.c |   28 ++++++++++++++++++++++--
 app/core/gimpdrawable-combine.h |    3 +-
 app/core/gimpdrawable.c         |    8 ++++--
 app/core/gimpdrawable.h         |   44 ++++++++++++++++++++------------------
 app/paint/gimppaintcore.c       |   25 ++++++++--------------
 6 files changed, 69 insertions(+), 47 deletions(-)
---
diff --git a/app/core/gimpchannel.c b/app/core/gimpchannel.c
index b4e3cf7..8c533fd 100644
--- a/app/core/gimpchannel.c
+++ b/app/core/gimpchannel.c
@@ -152,7 +152,8 @@ static void      gimp_channel_replace_buffer (GimpDrawable        *drawable,
                                               gboolean             push_undo,
                                               const gchar         *undo_desc,
                                               gdouble              opacity,
-                                              PixelRegion          *maskPR,
+                                              GeglBuffer          *mask,
+                                              const GeglRectangle *mask_region,
                                               gint                 x,
                                               gint                 y);
 static void      gimp_channel_set_buffer     (GimpDrawable        *drawable,
@@ -835,7 +836,8 @@ gimp_channel_replace_buffer (GimpDrawable        *drawable,
                              gboolean             push_undo,
                              const gchar         *undo_desc,
                              gdouble              opacity,
-                             PixelRegion         *maskPR,
+                             GeglBuffer          *mask,
+                             const GeglRectangle *mask_region,
                              gint                 x,
                              gint                 y)
 {
@@ -845,7 +847,7 @@ gimp_channel_replace_buffer (GimpDrawable        *drawable,
                                                       buffer_region,
                                                       push_undo, undo_desc,
                                                       opacity,
-                                                      maskPR,
+                                                      mask, mask_region,
                                                       x, y);
 
   GIMP_CHANNEL (drawable)->bounds_known = FALSE;
diff --git a/app/core/gimpdrawable-combine.c b/app/core/gimpdrawable-combine.c
index d3db220..f9a0e9f 100644
--- a/app/core/gimpdrawable-combine.c
+++ b/app/core/gimpdrawable-combine.c
@@ -252,7 +252,8 @@ gimp_drawable_real_replace_buffer (GimpDrawable        *drawable,
                                    gboolean             push_undo,
                                    const gchar         *undo_desc,
                                    gdouble              opacity,
-                                   PixelRegion         *maskPR,
+                                   GeglBuffer          *mask_buffer,
+                                   const GeglRectangle *mask_buffer_region,
                                    gint                 dest_x,
                                    gint                 dest_y)
 {
@@ -261,6 +262,7 @@ gimp_drawable_real_replace_buffer (GimpDrawable        *drawable,
   GimpChannel     *mask  = gimp_image_get_mask (image);
   GimpTempBuf     *temp_buf;
   PixelRegion      src2PR;
+  PixelRegion      maskPR;
   gint             x, y, width, height;
   gint             offset_x, offset_y;
   PixelRegion      src1PR, destPR;
@@ -283,6 +285,26 @@ gimp_drawable_real_replace_buffer (GimpDrawable        *drawable,
                          FALSE);
     }
 
+  temp_buf = gimp_gegl_buffer_get_temp_buf (mask_buffer);
+
+  if (temp_buf)
+    {
+      pixel_region_init_temp_buf (&maskPR, temp_buf,
+                                  mask_buffer_region->x,
+                                  mask_buffer_region->y,
+                                  mask_buffer_region->width,
+                                  mask_buffer_region->height);
+    }
+  else
+    {
+      pixel_region_init (&maskPR, gimp_gegl_buffer_get_tiles (mask_buffer),
+                         mask_buffer_region->x,
+                         mask_buffer_region->y,
+                         mask_buffer_region->width,
+                         mask_buffer_region->height,
+                         FALSE);
+    }
+
   /*  don't apply the mask to itself and don't apply an empty mask  */
   if (GIMP_DRAWABLE (mask) == drawable || gimp_channel_is_empty (mask))
     mask = NULL;
@@ -366,7 +388,7 @@ gimp_drawable_real_replace_buffer (GimpDrawable        *drawable,
 
       pixel_region_init_temp_buf (&tempPR, temp_buf, 0, 0, width, height);
 
-      apply_mask_to_region (&tempPR, maskPR, OPAQUE_OPACITY);
+      apply_mask_to_region (&tempPR, &maskPR, OPAQUE_OPACITY);
 
       pixel_region_init_temp_buf (&tempPR, temp_buf, 0, 0, width, height);
 
@@ -379,7 +401,7 @@ gimp_drawable_real_replace_buffer (GimpDrawable        *drawable,
     }
   else
     {
-      combine_regions_replace (&src1PR, &src2PR, &destPR, maskPR, NULL,
+      combine_regions_replace (&src1PR, &src2PR, &destPR, &maskPR, NULL,
                                opacity * 255.999,
                                active_components,
                                operation);
diff --git a/app/core/gimpdrawable-combine.h b/app/core/gimpdrawable-combine.h
index 7541c18..16a7d56 100644
--- a/app/core/gimpdrawable-combine.h
+++ b/app/core/gimpdrawable-combine.h
@@ -40,7 +40,8 @@ void   gimp_drawable_real_replace_buffer (GimpDrawable         *drawable,
                                           gboolean              push_undo,
                                           const gchar          *undo_desc,
                                           gdouble               opacity,
-                                          PixelRegion          *maskPR,
+                                          GeglBuffer           *mask,
+                                          const GeglRectangle  *mask_region,
                                           gint                  x,
                                           gint                  y);
 
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index b152233..68efb20 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -1207,19 +1207,21 @@ gimp_drawable_replace_buffer (GimpDrawable        *drawable,
                               gboolean             push_undo,
                               const gchar         *undo_desc,
                               gdouble              opacity,
-                              PixelRegion         *maskPR,
+                              GeglBuffer          *mask,
+                              const GeglRectangle *mask_region,
                               gint                 x,
                               gint                 y)
 {
   g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
   g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
   g_return_if_fail (GEGL_IS_BUFFER (buffer));
-  g_return_if_fail (maskPR != NULL);
+  g_return_if_fail (GEGL_IS_BUFFER (mask));
 
   GIMP_DRAWABLE_GET_CLASS (drawable)->replace_buffer (drawable, buffer,
                                                       buffer_region,
                                                       push_undo, undo_desc,
-                                                      opacity, maskPR,
+                                                      opacity,
+                                                      mask, mask_region,
                                                       x, y);
 }
 
diff --git a/app/core/gimpdrawable.h b/app/core/gimpdrawable.h
index 2f44bd6..46d2fda 100644
--- a/app/core/gimpdrawable.h
+++ b/app/core/gimpdrawable.h
@@ -82,7 +82,8 @@ struct _GimpDrawableClass
                                            gboolean              push_undo,
                                            const gchar          *undo_desc,
                                            gdouble               opacity,
-                                           PixelRegion          *maskPR,
+                                           GeglBuffer           *mask,
+                                           const GeglRectangle  *mask_region,
                                            gint                  x,
                                            gint                  y);
   void           (* project_region)       (GimpDrawable         *drawable,
@@ -144,28 +145,29 @@ void            gimp_drawable_convert_type       (GimpDrawable       *drawable,
                                                   GimpImageBaseType   new_base_type,
                                                   gboolean            push_undo);
 
-void            gimp_drawable_apply_buffer       (GimpDrawable       *drawable,
-                                                  GeglBuffer         *buffer,
+void            gimp_drawable_apply_buffer       (GimpDrawable        *drawable,
+                                                  GeglBuffer          *buffer,
                                                   const GeglRectangle *buffer_rect,
-                                                  gboolean            push_undo,
-                                                  const gchar        *undo_desc,
-                                                  gdouble             opacity,
-                                                  GimpLayerModeEffects  mode,
-                                                  GeglBuffer         *base_buffer,
-                                                  gint                base_x,
-                                                  gint                base_y,
-                                                  GeglBuffer         *dest_buffer,
-                                                  gint                dest_x,
-                                                  gint                dest_y);
-void            gimp_drawable_replace_buffer     (GimpDrawable       *drawable,
-                                                  GeglBuffer         *buffer,
+                                                  gboolean             push_undo,
+                                                  const gchar         *undo_desc,
+                                                  gdouble              opacity,
+                                                  GimpLayerModeEffects mode,
+                                                  GeglBuffer          *base_buffer,
+                                                  gint                 base_x,
+                                                  gint                 base_y,
+                                                  GeglBuffer          *dest_buffer,
+                                                  gint                 dest_x,
+                                                  gint                 dest_y);
+void            gimp_drawable_replace_buffer     (GimpDrawable        *drawable,
+                                                  GeglBuffer          *buffer,
                                                   const GeglRectangle *buffer_region,
-                                                  gboolean            push_undo,
-                                                  const gchar        *undo_desc,
-                                                  gdouble             opacity,
-                                                  PixelRegion        *maskPR,
-                                                  gint                x,
-                                                  gint                y);
+                                                  gboolean             push_undo,
+                                                  const gchar         *undo_desc,
+                                                  gdouble              opacity,
+                                                  GeglBuffer          *mask,
+                                                  const GeglRectangle *mask_region,
+                                                  gint                 x,
+                                                  gint                 y);
 void            gimp_drawable_project_region     (GimpDrawable       *drawable,
                                                   gint                x,
                                                   gint                y,
diff --git a/app/paint/gimppaintcore.c b/app/paint/gimppaintcore.c
index 7dce950..9642c4a 100644
--- a/app/paint/gimppaintcore.c
+++ b/app/paint/gimppaintcore.c
@@ -795,8 +795,8 @@ gimp_paint_core_replace (GimpPaintCore            *core,
                          gdouble                   image_opacity,
                          GimpPaintApplicationMode  mode)
 {
-  PixelRegion paint_maskPR;
-  gint        width, height;
+  GeglRectangle  mask_rect;
+  gint           width, height;
 
   if (! gimp_drawable_has_alpha (drawable))
     {
@@ -823,22 +823,15 @@ gimp_paint_core_replace (GimpPaintCore            *core,
                                    paint_opacity);
 
       /* initialize the maskPR from the canvas buffer */
-      pixel_region_init (&paint_maskPR,
-                         gimp_gegl_buffer_get_tiles (core->canvas_buffer),
-                         core->paint_buffer_x,
-                         core->paint_buffer_y,
-                         width, height,
-                         FALSE);
+      paint_mask = core->canvas_buffer;
+
+      mask_rect = *GEGL_RECTANGLE (core->paint_buffer_x,
+                                   core->paint_buffer_y,
+                                   width, height);
     }
   else
     {
-      /* The mask is just the paint_mask */
-      pixel_region_init_temp_buf (&paint_maskPR,
-                                  gimp_gegl_buffer_get_temp_buf (paint_mask),
-                                  paint_mask_rect->x,
-                                  paint_mask_rect->y,
-                                  paint_mask_rect->width,
-                                  paint_mask_rect->height);
+      mask_rect = *paint_mask_rect;
     }
 
   /*  apply the paint area to the image  */
@@ -846,7 +839,7 @@ gimp_paint_core_replace (GimpPaintCore            *core,
                                 GEGL_RECTANGLE (0, 0, width, height),
                                 FALSE, NULL,
                                 image_opacity,
-                                &paint_maskPR,
+                                paint_mask, &mask_rect,
                                 core->paint_buffer_x,
                                 core->paint_buffer_y);
 



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