From d928a80b7faf48f637315b89eb6107647ff9d05b Mon Sep 17 00:00:00 2001 From: Ell Date: Sat, 1 Jun 2019 13:18:14 -0400 Subject: [PATCH] app: avoid unnecessarily updating drawable after merging filter In gimp_drawable_merge_filter(), add an "update" parameter, which specifies whether to update the affected region of the drawable after applying the filter. Avoid updating the drawable when commiting a GimpDrawableFilter (and manually update the drawable if filter application was cancelled), and when anchoring a floating selection, since in both cases the relevant region of the drawable has already been updated. --- app/core/gimpdrawable-filters.c | 12 ++++++++---- app/core/gimpdrawable-filters.h | 3 ++- app/core/gimpdrawablefilter.c | 6 +++++- app/core/gimplayer-floating-selection.c | 2 +- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/core/gimpdrawable-filters.c b/app/core/gimpdrawable-filters.c index c771c26ca7..b39753ef86 100644 --- a/app/core/gimpdrawable-filters.c +++ b/app/core/gimpdrawable-filters.c @@ -109,7 +109,8 @@ gimp_drawable_merge_filter (GimpDrawable *drawable, GimpFilter *filter, GimpProgress *progress, const gchar *undo_desc, - gboolean cancellable) + gboolean cancellable, + gboolean update) { GimpImage *image; GimpApplicator *applicator; @@ -225,9 +226,12 @@ gimp_drawable_merge_filter (GimpDrawable *drawable, gimp_applicator_set_output_format (applicator, applicator_output_format); } - gimp_drawable_update (drawable, - rect.x, rect.y, - rect.width, rect.height); + if (update) + { + gimp_drawable_update (drawable, + rect.x, rect.y, + rect.width, rect.height); + } return success; } diff --git a/app/core/gimpdrawable-filters.h b/app/core/gimpdrawable-filters.h index f7041e062b..a2c6972d6c 100644 --- a/app/core/gimpdrawable-filters.h +++ b/app/core/gimpdrawable-filters.h @@ -37,7 +37,8 @@ gboolean gimp_drawable_merge_filter (GimpDrawable *drawable, GimpFilter *filter, GimpProgress *progress, const gchar *undo_desc, - gboolean cancellable); + gboolean cancellable, + gboolean update); #endif /* __GIMP_DRAWABLE_FILTERS_H__ */ diff --git a/app/core/gimpdrawablefilter.c b/app/core/gimpdrawablefilter.c index 21b522b1c9..4b1e634dae 100644 --- a/app/core/gimpdrawablefilter.c +++ b/app/core/gimpdrawablefilter.c @@ -448,10 +448,14 @@ gimp_drawable_filter_commit (GimpDrawableFilter *filter, GIMP_FILTER (filter), progress, gimp_object_get_name (filter), - cancellable); + cancellable, + FALSE); gimp_drawable_filter_remove_filter (filter); + if (! success) + gimp_drawable_filter_update_drawable (filter, NULL); + g_signal_emit (filter, drawable_filter_signals[FLUSH], 0); } diff --git a/app/core/gimplayer-floating-selection.c b/app/core/gimplayer-floating-selection.c index f43ce985b3..84d1fea0a3 100644 --- a/app/core/gimplayer-floating-selection.c +++ b/app/core/gimplayer-floating-selection.c @@ -135,7 +135,7 @@ floating_sel_anchor (GimpLayer *layer) } if (filter) - gimp_drawable_merge_filter (drawable, filter, NULL, NULL, FALSE); + gimp_drawable_merge_filter (drawable, filter, NULL, NULL, FALSE, FALSE); gimp_image_remove_layer (image, layer, TRUE, NULL);