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.
This commit is contained in:
Ell 2020-01-16 01:56:30 +02:00
parent a335827896
commit d39822bcd7
1 changed files with 10 additions and 2 deletions

View File

@ -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);
}