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



commit 456ede52e89cb3ebe6a08fd60b58f8407a602cfb
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.
    
    (cherry picked from commit d39822bcd7a40f4b8e2e515dbafd072cde7f8f81)

 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 ba2a214e03..1041a2c493 100644
--- a/app/gegl/gimptilehandlervalidate.c
+++ b/app/gegl/gimptilehandlervalidate.c
@@ -371,9 +371,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,
@@ -382,8 +390,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]