Commit 861f356b authored by Ell's avatar Ell

app: in GimpPaintCore, align copied undo rect to tile grid

In gimp_paint_core_finish(), when copying the relevant region of
the cached undo buffer into a new buffer, align the region to the
buffer's tile grid, so that all copied tiles are COWed.  This
avoids lag when finishing a stroke.
parent bb9dd049
......@@ -524,32 +524,34 @@ gimp_paint_core_finish (GimpPaintCore *core,
if (push_undo)
GeglBuffer *buffer;
gint x, y, width, height;
GeglBuffer *buffer;
GeglRectangle rect;
gimp_rectangle_intersect (core->x1, core->y1,
core->x2 - core->x1, core->y2 - core->y1,
0, 0,
gimp_item_get_width (GIMP_ITEM (drawable)),
gimp_item_get_height (GIMP_ITEM (drawable)),
&x, &y, &width, &height);
&rect.x, &rect.y, &rect.width, &rect.height);
gimp_gegl_rectangle_align_to_tile_grid (&rect, &rect, core->undo_buffer);
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_PAINT,
GIMP_PAINT_CORE_GET_CLASS (core)->push_undo (core, image, NULL);
buffer = gegl_buffer_new (GEGL_RECTANGLE (0, 0, width, height),
buffer = gegl_buffer_new (GEGL_RECTANGLE (0, 0, rect.width, rect.height),
gimp_drawable_get_format (drawable));
gimp_gegl_buffer_copy (core->undo_buffer,
GEGL_RECTANGLE (x, y, width, height),
GEGL_RECTANGLE (0, 0, 0, 0));
gimp_drawable_push_undo (drawable, NULL,
buffer, x, y, width, height);
buffer, rect.x, rect.y, rect.width, rect.height);
g_object_unref (buffer);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment