[gimp] app: in GimpTileHandlerValidate, fix tile-data pointer for negative coords



commit d39822bcd7a40f4b8e2e515dbafd072cde7f8f81
Author: Ell <ell_se yahoo com>
Date:   Thu Jan 16 01:56:30 2020 +0200

    app: in GimpTileHandlerValidate, fix tile-data pointer for negative coords
    
    In gimp_tile_handler_validate_validate_tile(), when validating a
    partial tile with negative coordinates, make sure to adjust the
    result of the modulo when calculating the tile-realtive coordinates
    so that they're non-negative, to fix the tile-data pointer offset.

 app/gegl/gimptilehandlervalidate.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/app/gegl/gimptilehandlervalidate.c b/app/gegl/gimptilehandlervalidate.c
index ebac465c02..037c1c8129 100644
--- a/app/gegl/gimptilehandlervalidate.c
+++ b/app/gegl/gimptilehandlervalidate.c
@@ -374,9 +374,17 @@ gimp_tile_handler_validate_validate_tile (GeglTileSource *source,
       for (i = 0; i < n_rects; i++)
         {
           cairo_rectangle_int_t blit_rect;
+          gint                  tile_x;
+          gint                  tile_y;
 
           cairo_region_get_rectangle (tile_region, i, &blit_rect);
 
+          tile_x = blit_rect.x % validate->tile_width;
+          if (tile_x < 0) tile_x += validate->tile_width;
+
+          tile_y = blit_rect.y % validate->tile_height;
+          if (tile_y < 0) tile_y += validate->tile_height;
+
           GIMP_TILE_HANDLER_VALIDATE_GET_CLASS (validate)->validate
             (validate,
              GEGL_RECTANGLE (blit_rect.x,
@@ -385,8 +393,8 @@ gimp_tile_handler_validate_validate_tile (GeglTileSource *source,
                              blit_rect.height),
              validate->format,
              gegl_tile_get_data (tile) +
-             (blit_rect.y % validate->tile_height) * tile_stride +
-             (blit_rect.x % validate->tile_width)  * tile_bpp,
+             tile_y * tile_stride      +
+             tile_x * tile_bpp,
              tile_stride);
         }
 


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