[gimp] app: use gimp_drawable_mask_intersect() instead of mask_bounds()



commit 24b6c27e42ccb19d76602cea6f9edaa07bd8537c
Author: Michael Natterer <mitch gimp org>
Date:   Tue Sep 7 17:43:39 2010 +0200

    app: use gimp_drawable_mask_intersect() instead of mask_bounds()

 app/core/gimpdrawable-blend.c     |   10 +++++-----
 app/core/gimpdrawable-histogram.c |   22 +++++++++++-----------
 2 files changed, 16 insertions(+), 16 deletions(-)
---
diff --git a/app/core/gimpdrawable-blend.c b/app/core/gimpdrawable-blend.c
index 9840d84..e1e54c7 100644
--- a/app/core/gimpdrawable-blend.c
+++ b/app/core/gimpdrawable-blend.c
@@ -587,14 +587,14 @@ gradient_precalc_shapeburst (GimpImage    *image,
   if (! gimp_channel_is_empty (mask))
     {
       PixelRegion maskR;
-      gint        x1, y1, x2, y2;
-      gint        offx, offy;
+      gint        x, y, width, height;
+      gint        off_x, off_y;
 
-      gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
-      gimp_item_get_offset (GIMP_ITEM (drawable), &offx, &offy);
+      gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height);
+      gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
 
       pixel_region_init (&maskR, gimp_drawable_get_tiles (GIMP_DRAWABLE (mask)),
-                         x1 + offx, y1 + offy, (x2 - x1), (y2 - y1), FALSE);
+                         x + off_x, y + off_y, width, height, FALSE);
 
       /*  copy the mask to the temp mask  */
       copy_region (&maskR, &tempR);
diff --git a/app/core/gimpdrawable-histogram.c b/app/core/gimpdrawable-histogram.c
index afce83e..2bdbef3 100644
--- a/app/core/gimpdrawable-histogram.c
+++ b/app/core/gimpdrawable-histogram.c
@@ -26,7 +26,7 @@
 #include "base/gimphistogram.h"
 #include "base/pixel-region.h"
 
-#include "gimpdrawable.h"
+#include "gimpchannel.h"
 #include "gimpdrawable-histogram.h"
 #include "gimpimage.h"
 
@@ -35,24 +35,24 @@ void
 gimp_drawable_calculate_histogram (GimpDrawable  *drawable,
                                    GimpHistogram *histogram)
 {
-  PixelRegion region;
-  PixelRegion mask;
-  gint        x1, y1, x2, y2;
-  gboolean    have_mask;
+  GimpImage   *image;
+  PixelRegion  region;
+  PixelRegion  mask;
+  gint         x, y, width, height;
 
   g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
   g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
   g_return_if_fail (histogram != NULL);
 
-  have_mask = gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
-
-  if ((x1 == x2) || (y1 == y2))
+  if (! gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
     return;
 
   pixel_region_init (&region, gimp_drawable_get_tiles (drawable),
-                     x1, y1, (x2 - x1), (y2 - y1), FALSE);
+                     x, y, width, height, FALSE);
+
+  image = gimp_item_get_image (GIMP_ITEM (drawable));
 
-  if (have_mask)
+  if (! gimp_channel_is_empty (gimp_image_get_mask (image)))
     {
       GimpChannel *sel_mask;
       GimpImage   *image;
@@ -64,7 +64,7 @@ gimp_drawable_calculate_histogram (GimpDrawable  *drawable,
       gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
       pixel_region_init (&mask,
                          gimp_drawable_get_tiles (GIMP_DRAWABLE (sel_mask)),
-                         x1 + off_x, y1 + off_y, (x2 - x1), (y2 - y1), FALSE);
+                         x + off_x, y + off_y, width, height, FALSE);
       gimp_histogram_calculate (histogram, &region, &mask);
     }
   else



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