[gimp/gimp-2-10] Issue #2287 - Weird things happen with dodge tool ...



commit fce08d2af7edb68d37778ff5496af1dfdaf6ad69
Author: Ell <ell_se yahoo com>
Date:   Sat Sep 29 10:11:43 2018 -0400

    Issue #2287 - Weird things happen with dodge tool ...
    
    ... (some sort of corruption)
    
    In gimp_drawable_real_replace_buffer(), adjust the processed buffer
    and mask_buffer regions according to the changes made to the
    application region, as calculated by intersecting it with the
    drawable and mask extents.  This fixes wrong application position
    when painting using the heal, dodge/burn, smudge, or convolve
    tools, on a drawable whose origin is above/to the left of the
    image's origin, and there's a selection active.
    
    (cherry picked from commit a782acab57e6c4c3fb7a2e9092afd3ed656af191)

 app/core/gimpdrawable-combine.c | 31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)
---
diff --git a/app/core/gimpdrawable-combine.c b/app/core/gimpdrawable-combine.c
index 1c62eeece5..cb904c41c5 100644
--- a/app/core/gimpdrawable-combine.c
+++ b/app/core/gimpdrawable-combine.c
@@ -176,10 +176,12 @@ gimp_drawable_real_replace_buffer (GimpDrawable        *drawable,
                                    gint                 dest_x,
                                    gint                 dest_y)
 {
-  GimpItem        *item  = GIMP_ITEM (drawable);
-  GimpImage       *image = gimp_item_get_image (item);
-  GimpChannel     *mask  = gimp_image_get_mask (image);
+  GimpItem        *item             = GIMP_ITEM (drawable);
+  GimpImage       *image            = gimp_item_get_image (item);
+  GimpChannel     *mask             = gimp_image_get_mask (image);
   GeglBuffer      *drawable_buffer;
+  GeglRectangle    buffer_rect      = *buffer_region;
+  GeglRectangle    mask_buffer_rect = *mask_buffer_region;
   gint             x, y, width, height;
   gint             offset_x, offset_y;
   gboolean         active_components[MAX_CHANNELS];
@@ -196,7 +198,7 @@ gimp_drawable_real_replace_buffer (GimpDrawable        *drawable,
 
   /*  make sure the image application coordinates are within drawable bounds  */
   gimp_rectangle_intersect (dest_x, dest_y,
-                            buffer_region->width, buffer_region->height,
+                            buffer_rect.width, buffer_rect.height,
                             0, 0,
                             gimp_item_get_width  (item),
                             gimp_item_get_height (item),
@@ -217,6 +219,19 @@ gimp_drawable_real_replace_buffer (GimpDrawable        *drawable,
                                 &x, &y, &width, &height);
     }
 
+  /*  adjust the original regions according to the application
+   *  offset and size
+   */
+  buffer_rect.x           += x - dest_x;
+  buffer_rect.y           += y - dest_y;
+  buffer_rect.width        = width;
+  buffer_rect.height       = height;
+
+  mask_buffer_rect.x      += x - dest_x;
+  mask_buffer_rect.y      += y - dest_y;
+  mask_buffer_rect.width   = width;
+  mask_buffer_rect.height  = height;
+
   /*  If the calling procedure specified an undo step...  */
   if (push_undo)
     gimp_drawable_push_undo (drawable, undo_desc,
@@ -241,11 +256,11 @@ gimp_drawable_real_replace_buffer (GimpDrawable        *drawable,
                              dest_buffer,
                              GEGL_RECTANGLE (0, 0, 0, 0));
 
-      gimp_gegl_combine_mask (mask_buffer, mask_buffer_region,
+      gimp_gegl_combine_mask (mask_buffer, &mask_buffer_rect,
                               dest_buffer, GEGL_RECTANGLE (0, 0, width, height),
                               1.0);
 
-      gimp_gegl_replace (buffer,          buffer_region,
+      gimp_gegl_replace (buffer,          &buffer_rect,
                          drawable_buffer, GEGL_RECTANGLE (x, y, width, height),
                          dest_buffer,     GEGL_RECTANGLE (0, 0, width, height),
                          drawable_buffer, GEGL_RECTANGLE (x, y, width, height),
@@ -256,9 +271,9 @@ gimp_drawable_real_replace_buffer (GimpDrawable        *drawable,
     }
   else
     {
-      gimp_gegl_replace (buffer,          buffer_region,
+      gimp_gegl_replace (buffer,          &buffer_rect,
                          drawable_buffer, GEGL_RECTANGLE (x, y, width, height),
-                         mask_buffer,     mask_buffer_region,
+                         mask_buffer,     &mask_buffer_rect,
                          drawable_buffer, GEGL_RECTANGLE (x, y, width, height),
                          opacity,
                          active_components);


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