[gegl/wip/rishi/buffer-set-abyss-bottom-negative] buffer: Fix handling of the bottom abyss edge for negative co-ordinates
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl/wip/rishi/buffer-set-abyss-bottom-negative] buffer: Fix handling of the bottom abyss edge for negative co-ordinates
- Date: Sun, 23 Dec 2018 08:57:26 +0000 (UTC)
commit d21356c8b69212e7a540cc3a4facd4b8ff6df8c8
Author: Debarshi Ray <debarshir gnome org>
Date: Sun Dec 23 09:28:51 2018 +0100
buffer: Fix handling of the bottom abyss edge for negative co-ordinates
The bufy value is an offset relative to the beginning of the memory
buffer. It indicates the number of rows that've already been written
and the index of the next row. On the other hand, the abyss_y_total
value is the absolute vertical co-ordinate that lies just beyond the
bottom edge of the abyss. It's the sum of the top edge and height of
the abyss. In short, they lie in two different co-ordinate spaces - one
relative, the other absolute.
Therefore, bufy can only be used with abyss_y_total if the vertical
co-ordinate of the top edge is used to normalize the spaces.
Consider writing to [(-160,-160) 640x640] that matches the extent and
abyss of a GeglBuffer with 80x80 tiles. When bufy equals 480 at the
beginning of the 480th row in the buffer, the target absolute
co-ordinate in the buffer would be (0, 320) at the top left corner of
the seventh row of tiles. The abyss_y_total of this buffer is also 480.
Here, the existing calculation breaks down and the writes get
truncated.
Fallout from 52e28c101f0d908b7170352ef72541e3b3c1f007
https://gitlab.gnome.org/GNOME/gegl/merge_requests/15
gegl/buffer/gegl-buffer-access.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-access.c b/gegl/buffer/gegl-buffer-access.c
index eb4c6e97f..04d9a1e38 100644
--- a/gegl/buffer/gegl-buffer-access.c
+++ b/gegl/buffer/gegl-buffer-access.c
@@ -470,8 +470,12 @@ gegl_buffer_iterate_write (GeglBuffer *buffer,
if (fish)
{
- int skip = 0, rows = MIN(height - bufy, tile_height - offsety);
- rows = MIN(abyss_y_total - bufy, rows);
+ int bskip, skip = 0;
+ int rows = MIN(height - bufy, tile_height - offsety);
+
+ bskip = (buffer_y + bufy + rows) - abyss_y_total;
+ bskip = CLAMP (bskip, 0, rows);
+ rows -= bskip;
/*
XXX XXX XXX
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]