[gimp] app: add "Synchronous preview" option to transform tools
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add "Synchronous preview" option to transform tools
- Date: Thu, 16 Jan 2020 09:42:20 +0000 (UTC)
commit 52cd27f0d337c887dd260a85982b2cf20f2c2ffc
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.
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 bb4ce94c86..f1c0bedbd5 100644
--- a/app/tools/gimptransformgridoptions.c
+++ b/app/tools/gimptransformgridoptions.c
@@ -51,6 +51,7 @@ enum
PROP_DIRECTION_LINKED,
PROP_SHOW_PREVIEW,
PROP_COMPOSITED_PREVIEW,
+ PROP_SYNCHRONOUS_PREVIEW,
PROP_PREVIEW_OPACITY,
PROP_GRID_TYPE,
PROP_GRID_SIZE,
@@ -119,6 +120,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"),
@@ -239,6 +247,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;
@@ -307,6 +318,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;
@@ -413,9 +427,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 0c283a99f0..d0dd3313f3 100644
--- a/app/tools/gimptransformgridtool.c
+++ b/app/tools/gimptransformgridtool.c
@@ -1513,6 +1513,7 @@ gimp_transform_grid_tool_update_preview (GimpTransformGridTool *tg_tool)
GHashTableIter iter;
GimpDrawable *drawable;
Filter *filter;
+ gboolean flush = FALSE;
if (! tg_tool->filters)
{
@@ -1592,7 +1593,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]