[gimp/gimp-2-10] app: in gimp_gegl_buffer_set_extent(), clear full OOB region



commit e183b8e6ad69bc5231c7ce3820ccebe05d97f3c4
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 fe0cab3251..cd6925bbdf 100644
--- a/app/gegl/gimp-gegl-utils.c
+++ b/app/gegl/gimp-gegl-utils.c
@@ -287,6 +287,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;
@@ -302,10 +303,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]