[gimp] app: in gimp_gegl_buffer_set_extent(), clear full OOB region



commit 564afeda8b6cf829bc856d7244a435ef36a0167c
Author: Ell <ell_se yahoo com>
Date:   Wed Sep 4 12:32:10 2019 +0300

    app: in gimp_gegl_buffer_set_extent(), clear full OOB region
    
    In gimp_gegl_buffer_set_extent(), clear the full now-out-of-bounds
    region of the buffer, instead of only full out-of-bounds tiles;
    however, we still make sure to clear full tiles, instead of partial
    tiles, as much as possible.  This prevents (parts of) the old
    content of the buffer from showing when it's enlarged again.  This
    is especially relevant for the image projection, once we add
    support for a dynamically-expanding canvas in the following
    commits, since the projection of a reexpanded buffer can be
    temporarily rendered to the display before it's fully
    reconstructed, exposing parts of the old content.

 app/gegl/gimp-gegl-utils.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
---
diff --git a/app/gegl/gimp-gegl-utils.c b/app/gegl/gimp-gegl-utils.c
index 0340358ff0..c2d5c15cbe 100644
--- a/app/gegl/gimp-gegl-utils.c
+++ b/app/gegl/gimp-gegl-utils.c
@@ -290,6 +290,7 @@ gimp_gegl_buffer_set_extent (GeglBuffer          *buffer,
 {
   GeglRectangle aligned_old_extent;
   GeglRectangle aligned_extent;
+  GeglRectangle old_extent_rem;
   GeglRectangle diff_rects[4];
   gint          n_diff_rects;
   gint          i;
@@ -305,10 +306,23 @@ gimp_gegl_buffer_set_extent (GeglBuffer          *buffer,
                                   GEGL_RECTANGLE_ALIGNMENT_SUPERSET);
 
   n_diff_rects = gegl_rectangle_subtract (diff_rects,
-                                          &aligned_old_extent, &aligned_extent);
+                                          &aligned_old_extent,
+                                          &aligned_extent);
 
   for (i = 0; i < n_diff_rects; i++)
     gegl_buffer_clear (buffer, &diff_rects[i]);
 
+  if (gegl_rectangle_intersect (&old_extent_rem,
+                                gegl_buffer_get_extent (buffer),
+                                &aligned_extent))
+    {
+      n_diff_rects = gegl_rectangle_subtract (diff_rects,
+                                              &old_extent_rem,
+                                              extent);
+
+      for (i = 0; i < n_diff_rects; i++)
+        gegl_buffer_clear (buffer, &diff_rects[i]);
+    }
+
   return gegl_buffer_set_extent (buffer, extent);
 }


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