[gimp/gimp-2-10] app: speed up layer-group preview rendering



commit cd4c81133a910ef4a52f55f21de5b4b82aa8f9c1
Author: Ell <ell_se yahoo com>
Date:   Sat Mar 14 13:24:50 2020 +0200

    app: speed up layer-group preview rendering
    
    In gimp_drawable_get_sub_preview_async(), when the drawable buffer
    has a validate handler (i.e., when the drawable is a group layer),
    validate the requested area before calling gegl_buffer_get(), so
    that the buffer is validated in a single step, instead of tile-by-
    tile.
    
    (cherry picked from commit 919ddce77389c1c4d69d26832bcbc9a6b2fa285e)

 app/core/gimpdrawable-preview.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
---
diff --git a/app/core/gimpdrawable-preview.c b/app/core/gimpdrawable-preview.c
index 2a54d615bf..93ff17d742 100644
--- a/app/core/gimpdrawable-preview.c
+++ b/app/core/gimpdrawable-preview.c
@@ -330,11 +330,30 @@ static void
 gimp_drawable_get_sub_preview_async_func (GimpAsync      *async,
                                           SubPreviewData *data)
 {
-  GimpTempBuf *preview;
+  GimpTempBuf             *preview;
+  GimpTileHandlerValidate *validate;
 
   preview = gimp_temp_buf_new (data->rect.width, data->rect.height,
                                data->format);
 
+  validate = gimp_tile_handler_validate_get_assigned (data->buffer);
+
+  if (validate)
+    {
+      GeglRectangle rect;
+
+      rect.x      = floor (data->rect.x / data->scale);
+      rect.y      = floor (data->rect.y / data->scale);
+      rect.width  = ceil ((data->rect.x + data->rect.width)  / data->scale) -
+                    rect.x;
+      rect.height = ceil ((data->rect.x + data->rect.height) / data->scale) -
+                    rect.y;
+
+      gimp_tile_handler_validate_validate (validate,
+                                           data->buffer, &rect,
+                                           TRUE, TRUE);
+    }
+
   gegl_buffer_get (data->buffer, &data->rect, data->scale,
                    gimp_temp_buf_get_format (preview),
                    gimp_temp_buf_get_data (preview),


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