app: use gimp_projectable_bounds_changed() when resizing group layers

In GimpGroupLayer, use gimp_projectable_bounds_changed() when
updating the group layer's size, instead of reconstructing the
projection, unless reallocation of the projection has been
requested.  This is more efficient, since it simply copies the
content of the projection's old buffer to the new buffer, rather
than re-rendering the graph.
This commit is contained in:
Ell 2018-08-03 13:03:03 -04:00
parent a4957c7c76
commit 1bb3e962f6
1 changed files with 31 additions and 31 deletions

View File

@ -1880,6 +1880,9 @@ gimp_group_layer_update_size (GimpGroupLayer *group)
if (private->reallocate_projection || size_changed)
{
GeglBuffer *buffer;
gboolean update_drawable = FALSE;
/* if the graph is already constructed, set the offset node's
* coordinates first, so the graph is in the right state when
* the projection is reallocated, see bug #730550.
@ -1896,47 +1899,44 @@ gimp_group_layer_update_size (GimpGroupLayer *group)
*/
gimp_item_set_offset (item, x, y);
if (private->reallocate_projection ||
width != old_width ||
height != old_height)
{
GeglBuffer *buffer;
/* temporarily change the return values of gimp_viewable_get_size()
* so the projection allocates itself correctly
*/
private->reallocate_width = width;
private->reallocate_height = height;
if (private->reallocate_projection)
{
private->reallocate_projection = FALSE;
/* temporarily change the return values of gimp_viewable_get_size()
* so the projection allocates itself correctly
*/
private->reallocate_width = width;
private->reallocate_height = height;
gimp_projectable_structure_changed (GIMP_PROJECTABLE (group));
gimp_group_layer_flush (group);
buffer = gimp_pickable_get_buffer (GIMP_PICKABLE (private->projection));
gimp_drawable_set_buffer_full (GIMP_DRAWABLE (group),
FALSE, NULL,
buffer,
x, y,
TRUE);
/* reset, the actual size is correct now */
private->reallocate_width = 0;
private->reallocate_height = 0;
update_drawable = TRUE;
}
else
{
/* invalidate the entire projection since the position of
* the children relative to each other might have changed
* in a way that happens to leave the group's width and
* height the same
/* when there's no need to reallocate the projection, we call
* gimp_projectable_bounds_changed(), rather than structure_chaned(),
* so that the projection simply copies the old content over to the
* new buffer with an offset, rather than re-renders the graph.
*/
gimp_projectable_invalidate (GIMP_PROJECTABLE (group),
x, y, width, height);
gimp_group_layer_flush (group);
gimp_projectable_bounds_changed (GIMP_PROJECTABLE (group),
old_x, old_y, old_width, old_height);
}
gimp_group_layer_flush (group);
buffer = gimp_pickable_get_buffer (GIMP_PICKABLE (private->projection));
gimp_drawable_set_buffer_full (GIMP_DRAWABLE (group),
FALSE, NULL,
buffer,
x, y,
update_drawable);
/* reset, the actual size is correct now */
private->reallocate_width = 0;
private->reallocate_height = 0;
}
/* resize the mask if not transforming (in which case, GimpLayer takes care