[gimp/gimp-2-10] app: add "Synchronous preview" option to transform tools



commit f2715936cc9c5bffaf0f6c96acda815ed1e3bbcc
Author: Ell <ell_se yahoo com>
Date:   Thu Jan 16 11:34:17 2020 +0200

    app: add "Synchronous preview" option to transform tools
    
    Add a "Synchronous preview" option to the transform-grid tools,
    which renders the composited preview synchronously.  This reduces
    the lag for painting the preview, but can harm responsiveness for
    bigger images, where rendering the preview is slow.
    
    This is mostly an experimental option for now; it will become more
    interesting once we have mipmap rendering.
    
    (cherry picked from commit 52cd27f0d337c887dd260a85982b2cf20f2c2ffc)

 app/tools/gimptransformgridoptions.c | 23 ++++++++++++++++++++---
 app/tools/gimptransformgridoptions.h |  1 +
 app/tools/gimptransformgridtool.c    | 31 ++++++++++++++++++++++++++++++-
 3 files changed, 51 insertions(+), 4 deletions(-)
---
diff --git a/app/tools/gimptransformgridoptions.c b/app/tools/gimptransformgridoptions.c
index 74d5e8cd4a..e3f8184858 100644
--- a/app/tools/gimptransformgridoptions.c
+++ b/app/tools/gimptransformgridoptions.c
@@ -50,6 +50,7 @@ enum
   PROP_DIRECTION_LINKED,
   PROP_SHOW_PREVIEW,
   PROP_COMPOSITED_PREVIEW,
+  PROP_SYNCHRONOUS_PREVIEW,
   PROP_PREVIEW_OPACITY,
   PROP_GRID_TYPE,
   PROP_GRID_SIZE,
@@ -118,6 +119,13 @@ gimp_transform_grid_options_class_init (GimpTransformGridOptionsClass *klass)
                             FALSE,
                             GIMP_PARAM_STATIC_STRINGS);
 
+  GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_SYNCHRONOUS_PREVIEW,
+                            "synchronous-preview",
+                            _("Synchronous preview"),
+                            _("Render the preview synchronously"),
+                            FALSE,
+                            GIMP_PARAM_STATIC_STRINGS);
+
   GIMP_CONFIG_PROP_DOUBLE (object_class, PROP_PREVIEW_OPACITY,
                            "preview-opacity",
                            _("Image opacity"),
@@ -238,6 +246,9 @@ gimp_transform_grid_options_set_property (GObject      *object,
     case PROP_COMPOSITED_PREVIEW:
       options->composited_preview = g_value_get_boolean (value);
       break;
+    case PROP_SYNCHRONOUS_PREVIEW:
+      options->synchronous_preview = g_value_get_boolean (value);
+      break;
     case PROP_PREVIEW_OPACITY:
       options->preview_opacity = g_value_get_double (value);
       break;
@@ -306,6 +317,9 @@ gimp_transform_grid_options_get_property (GObject    *object,
     case PROP_COMPOSITED_PREVIEW:
       g_value_set_boolean (value, options->composited_preview);
       break;
+    case PROP_SYNCHRONOUS_PREVIEW:
+      g_value_set_boolean (value, options->synchronous_preview);
+      break;
     case PROP_PREVIEW_OPACITY:
       g_value_set_double (value, options->preview_opacity);
       break;
@@ -412,9 +426,12 @@ gimp_transform_grid_options_gui (GimpToolOptions *tool_options)
   /*  the preview frame  */
   vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
 
-  button = gimp_prop_check_button_new (config, "composited-preview", NULL);
-  gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
-  gtk_widget_show (button);
+  button = gimp_prop_check_button_new (config, "synchronous-preview", NULL);
+
+  frame = gimp_prop_expanding_frame_new (config, "composited-preview", NULL,
+                                         button, NULL);
+  gtk_box_pack_start (GTK_BOX (vbox2), frame, FALSE, FALSE, 0);
+  gtk_widget_show (frame);
 
   scale = gimp_prop_spin_scale_new (config, "preview-opacity", NULL,
                                     0.01, 0.1, 0);
diff --git a/app/tools/gimptransformgridoptions.h b/app/tools/gimptransformgridoptions.h
index d7c2df79ee..5f493e4777 100644
--- a/app/tools/gimptransformgridoptions.h
+++ b/app/tools/gimptransformgridoptions.h
@@ -40,6 +40,7 @@ struct _GimpTransformGridOptions
   gboolean              direction_linked;
   gboolean              show_preview;
   gboolean              composited_preview;
+  gboolean              synchronous_preview;
   gdouble               preview_opacity;
   GimpGuidesType        grid_type;
   gint                  grid_size;
diff --git a/app/tools/gimptransformgridtool.c b/app/tools/gimptransformgridtool.c
index fdf7431299..6af9059a9f 100644
--- a/app/tools/gimptransformgridtool.c
+++ b/app/tools/gimptransformgridtool.c
@@ -1514,6 +1514,7 @@ gimp_transform_grid_tool_update_preview (GimpTransformGridTool *tg_tool)
       GHashTableIter  iter;
       GimpDrawable   *drawable;
       Filter         *filter;
+      gboolean        flush = FALSE;
 
       if (! tg_tool->filters)
         {
@@ -1593,7 +1594,35 @@ gimp_transform_grid_tool_update_preview (GimpTransformGridTool *tg_tool)
             }
 
           if (update)
-            gimp_drawable_filter_apply (filter->filter, NULL);
+            {
+              if (tg_options->synchronous_preview)
+                {
+                  g_signal_handlers_block_by_func (
+                    filter->filter,
+                    G_CALLBACK (gimp_transform_grid_tool_filter_flush),
+                    tg_tool);
+                }
+
+              gimp_drawable_filter_apply (filter->filter, NULL);
+
+              if (tg_options->synchronous_preview)
+                {
+                  g_signal_handlers_unblock_by_func (
+                    filter->filter,
+                    G_CALLBACK (gimp_transform_grid_tool_filter_flush),
+                    tg_tool);
+
+                  flush = TRUE;
+                }
+            }
+        }
+
+      if (flush)
+        {
+          GimpImage *image = gimp_display_get_image (tool->display);
+
+          gimp_projection_flush_now (gimp_image_get_projection (image), TRUE);
+          gimp_display_flush_now (tool->display);
         }
     }
   else


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