[gimp] app: update projection-buffer extent when projectable size changes



commit 1577174739b5dfed30bcccc08854695fb1c59a39
Author: Ell <ell_se yahoo com>
Date:   Tue Aug 13 17:39:14 2019 +0300

    app: update projection-buffer extent when projectable size changes
    
    In GimpProjection, when the projectable's size changes, while its
    offset remains the same, simply update the projection buffer's
    extent, instead of allocating a new buffer and copying the contents
    over.

 app/core/gimpprojection.c | 45 +++++++++++++++++++++++++--------------------
 1 file changed, 25 insertions(+), 20 deletions(-)
---
diff --git a/app/core/gimpprojection.c b/app/core/gimpprojection.c
index f29bd008f6..d1ec176c6e 100644
--- a/app/core/gimpprojection.c
+++ b/app/core/gimpprojection.c
@@ -1042,33 +1042,38 @@ gimp_projection_projectable_bounds_changed (GimpProjectable *projectable,
 
   gimp_projection_chunk_render_stop (proj, TRUE);
 
-  old_validate_handler = proj->priv->validate_handler;
-
-  proj->priv->buffer           = NULL;
-  proj->priv->validate_handler = NULL;
+  if (dx == 0 && dy == 0)
+    {
+      gimp_tile_handler_validate_buffer_set_extent (old_buffer, &bounding_box);
+    }
+  else
+    {
+      old_validate_handler = proj->priv->validate_handler;
 
-  gimp_projection_allocate_buffer (proj);
+      proj->priv->buffer           = NULL;
+      proj->priv->validate_handler = NULL;
 
-  gimp_tile_handler_validate_buffer_copy (old_buffer,
-                                          GEGL_RECTANGLE (int_bounds.x - old_x,
-                                                          int_bounds.y - old_y,
-                                                          int_bounds.width,
-                                                          int_bounds.height),
-                                          proj->priv->buffer,
-                                          GEGL_RECTANGLE (int_bounds.x - x,
-                                                          int_bounds.y - y,
-                                                          int_bounds.width,
-                                                          int_bounds.height));
+      gimp_projection_allocate_buffer (proj);
 
-  if (old_validate_handler)
-    {
-      gimp_tile_handler_validate_unassign (old_validate_handler, old_buffer);
+      gimp_tile_handler_validate_buffer_copy (
+        old_buffer,
+        GEGL_RECTANGLE (int_bounds.x - old_x,
+                        int_bounds.y - old_y,
+                        int_bounds.width,
+                        int_bounds.height),
+        proj->priv->buffer,
+        GEGL_RECTANGLE (int_bounds.x - x,
+                        int_bounds.y - y,
+                        int_bounds.width,
+                        int_bounds.height));
+
+      gimp_tile_handler_validate_unassign (old_validate_handler,
+                                           old_buffer);
 
       g_object_unref (old_validate_handler);
+      g_object_unref (old_buffer);
     }
 
-  g_object_unref (old_buffer);
-
   if (proj->priv->update_region)
     {
       cairo_region_translate (proj->priv->update_region, dx, dy);


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