[gegl] buffer: avoid negative extents for edge rects



commit 1db854ccec86b96fc5cf12b5aa3a82b4b158051d
Author: Ãyvind KolÃs <pippin gimp org>
Date:   Thu Apr 12 20:05:12 2012 +0200

    buffer: avoid negative extents for edge rects

 gegl/buffer/gegl-buffer-access.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-access.c b/gegl/buffer/gegl-buffer-access.c
index c0a4c87..6d7e5dd 100644
--- a/gegl/buffer/gegl-buffer-access.c
+++ b/gegl/buffer/gegl-buffer-access.c
@@ -1173,9 +1173,7 @@ gegl_buffer_copy2 (GeglBuffer          *src,
                                     GEGL_BUFFER_WRITE, GEGL_ABYSS_NONE);
       read = gegl_buffer_iterator_add (i, src, src_rect, 0, src->soft_format,
                                        GEGL_BUFFER_READ, GEGL_ABYSS_NONE);
-      while (gegl_buffer_iterator_next (i) &&
-             i->length > 0 /* XXX: <- looks suspicious */
-             )
+      while (gegl_buffer_iterator_next (i))
         babl_process (fish, i->data[read], i->data[0], i->length);
     }
 }
@@ -1234,6 +1232,7 @@ gegl_buffer_copy (GeglBuffer          *src,
 
         cow_rect.width  = cow_rect.width  - (cow_rect.width  % tile_width);
         cow_rect.height = cow_rect.height - (cow_rect.height % tile_height);
+
         {
           GeglRectangle top, bottom, left, right;
           
@@ -1313,6 +1312,9 @@ gegl_buffer_copy (GeglBuffer          *src,
           bottom.height = (dst_rect->y + dst_rect->height) -
                           (cow_rect.y  + cow_rect.height);
 
+          if (bottom.height < 0)
+            bottom.height = 0;
+
           right  =  *dst_rect;
           right.x = (cow_rect.x + cow_rect.width);
           right.width = (dst_rect->x + dst_rect->width) -
@@ -1320,6 +1322,9 @@ gegl_buffer_copy (GeglBuffer          *src,
           right.y = cow_rect.y;
           right.height = cow_rect.height;
 
+          if (right.width < 0)
+            right.width = 0;
+
           if (top.height)
           gegl_buffer_copy2 (src, 
                              GEGL_RECTANGLE (src_rect->x + (top.x-dst_rect->x),
@@ -1455,6 +1460,9 @@ gegl_buffer_clear (GeglBuffer          *dst,
           bottom.height = (dst_rect->y + dst_rect->height) -
                           (cow_rect.y  + cow_rect.height);
 
+          if (bottom.height < 0)
+            bottom.height = 0;
+
           right  =  *dst_rect;
           right.x = (cow_rect.x + cow_rect.width);
           right.width = (dst_rect->x + dst_rect->width) -
@@ -1462,6 +1470,9 @@ gegl_buffer_clear (GeglBuffer          *dst,
           right.y = cow_rect.y;
           right.height = cow_rect.height;
 
+          if (right.width < 0)
+            right.width = 0;
+
           if (top.height)     gegl_buffer_clear2 (dst, &top);
           if (bottom.height)  gegl_buffer_clear2 (dst, &bottom);
           if (left.width)     gegl_buffer_clear2 (dst, &left);



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