[gimp/gimp-2-10] app: in GimpPaintCore, align copied undo rect to tile grid



commit f7f454341615c06b43f61f75e2417dc652b76ca5
Author: Ell <ell_se yahoo com>
Date:   Sun Dec 2 02:40:27 2018 -0500

    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.
    
    (cherry picked from commit 861f356b6354669781efbe9b3d342d2722bbf8f0)

 app/paint/gimppaintcore.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/app/paint/gimppaintcore.c b/app/paint/gimppaintcore.c
index ceedd16844..c4d88a9009 100644
--- a/app/paint/gimppaintcore.c
+++ b/app/paint/gimppaintcore.c
@@ -523,32 +523,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,
                                    core->undo_desc);
 
       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),
+                             &rect,
                              GEGL_ABYSS_NONE,
                              buffer,
                              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);
 


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