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.
This commit is contained in:
Ell 2019-09-04 12:32:10 +03:00
parent 7019eaa56b
commit 564afeda8b
1 changed files with 15 additions and 1 deletions

View File

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