[gimp] app: make gimp_item_mask_bounds() and _intersect() honor a suspended selection



commit 3c7fbe93b3a52fcf896415d788ef17b4fc77da50
Author: Michael Natterer <mitch gimp org>
Date:   Fri Nov 4 22:16:22 2016 +0100

    app: make gimp_item_mask_bounds() and _intersect() honor a suspended selection
    
    and remove the same check from the stroke and fill code.

 app/core/gimpdrawable-fill.c   |   19 ++-----------------
 app/core/gimpdrawable-stroke.c |   23 +++++++----------------
 app/core/gimpitem.c            |   12 ++++++++++--
 3 files changed, 19 insertions(+), 35 deletions(-)
---
diff --git a/app/core/gimpdrawable-fill.c b/app/core/gimpdrawable-fill.c
index 3d4caad..8dcb543 100644
--- a/app/core/gimpdrawable-fill.c
+++ b/app/core/gimpdrawable-fill.c
@@ -214,7 +214,6 @@ gimp_drawable_fill_scan_convert (GimpDrawable    *drawable,
                                  gboolean         push_undo)
 {
   GimpContext *context;
-  GimpImage   *image;
   GeglBuffer  *buffer;
   GeglBuffer  *mask_buffer;
   gint         x, y, w, h;
@@ -230,23 +229,9 @@ gimp_drawable_fill_scan_convert (GimpDrawable    *drawable,
                     gimp_context_get_pattern (GIMP_CONTEXT (options)) != NULL);
 
   context = GIMP_CONTEXT (options);
-  image   = gimp_item_get_image (GIMP_ITEM (drawable));
 
-  /*  must call gimp_channel_is_empty() instead of relying on
-   *  gimp_item_mask_intersect() because the selection pretends to
-   *  be empty while it is being stroked, to prevent masking itself.
-   */
-  if (gimp_channel_is_empty (gimp_image_get_mask (image)))
-    {
-      x = 0;
-      y = 0;
-      w = gimp_item_get_width  (GIMP_ITEM (drawable));
-      h = gimp_item_get_height (GIMP_ITEM (drawable));
-    }
-  else if (! gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &w, &h))
-    {
-      return;
-    }
+  if (! gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &w, &h))
+    return;
 
   /* fill a 1-bpp GeglBuffer with black, this will describe the shape
    * of the stroke.
diff --git a/app/core/gimpdrawable-stroke.c b/app/core/gimpdrawable-stroke.c
index 3e7dd7f..eb62b08 100644
--- a/app/core/gimpdrawable-stroke.c
+++ b/app/core/gimpdrawable-stroke.c
@@ -119,9 +119,8 @@ gimp_drawable_stroke_scan_convert (GimpDrawable      *drawable,
                                    GimpScanConvert   *scan_convert,
                                    gboolean           push_undo)
 {
-  GimpImage *image;
-  gdouble    width;
-  GimpUnit   unit;
+  gdouble  width;
+  GimpUnit unit;
 
   g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
   g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
@@ -131,25 +130,17 @@ gimp_drawable_stroke_scan_convert (GimpDrawable      *drawable,
                     GIMP_FILL_STYLE_PATTERN ||
                     gimp_context_get_pattern (GIMP_CONTEXT (options)) != NULL);
 
-  image = gimp_item_get_image (GIMP_ITEM (drawable));
-
-  /*  must call gimp_channel_is_empty() instead of relying on
-   *  gimp_item_mask_intersect() because the selection pretends to
-   *  be empty while it is being stroked, to prevent masking itself.
-   */
-  if (! gimp_channel_is_empty (gimp_image_get_mask (image)) &&
-      ! gimp_item_mask_intersect (GIMP_ITEM (drawable), NULL, NULL, NULL, NULL))
-    {
-      return;
-    }
+  if (! gimp_item_mask_intersect (GIMP_ITEM (drawable), NULL, NULL, NULL, NULL))
+    return;
 
   width = gimp_stroke_options_get_width (options);
   unit  = gimp_stroke_options_get_unit (options);
 
   if (unit != GIMP_UNIT_PIXEL)
     {
-      gdouble xres;
-      gdouble yres;
+      GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
+      gdouble    xres;
+      gdouble    yres;
 
       gimp_image_get_resolution (image, &xres, &yres);
 
diff --git a/app/core/gimpitem.c b/app/core/gimpitem.c
index f9e750c..7d705af 100644
--- a/app/core/gimpitem.c
+++ b/app/core/gimpitem.c
@@ -2275,7 +2275,11 @@ gimp_item_mask_bounds (GimpItem *item,
   image     = gimp_item_get_image (item);
   selection = gimp_image_get_mask (image);
 
-  if (GIMP_ITEM (selection) != item &&
+  /* check for is_empty() before intersecting so we ignore the
+   * selection if it is suspended (like when stroking)
+   */
+  if (GIMP_ITEM (selection) != item       &&
+      ! gimp_channel_is_empty (selection) &&
       gimp_item_bounds (GIMP_ITEM (selection), &x, &y, &width, &height))
     {
       gint off_x, off_y;
@@ -2345,7 +2349,11 @@ gimp_item_mask_intersect (GimpItem *item,
   image     = gimp_item_get_image (item);
   selection = gimp_image_get_mask (image);
 
-  if (GIMP_ITEM (selection) != item &&
+  /* check for is_empty() before intersecting so we ignore the
+   * selection if it is suspended (like when stroking)
+   */
+  if (GIMP_ITEM (selection) != item       &&
+      ! gimp_channel_is_empty (selection) &&
       gimp_item_bounds (GIMP_ITEM (selection),
                         &tmp_x, &tmp_y, &tmp_width, &tmp_height))
     {


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