[gimp/gimp-2-10] app: check the time before last selection draw before queuing a redraw.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: check the time before last selection draw before queuing a redraw.
- Date: Fri, 22 Oct 2021 21:29:08 +0000 (UTC)
commit 9314ba7051b7dbe546ebdd222192ec4e4cbc6edd
Author: Jehan <jehan girinstud io>
Date: Sun May 9 15:51:20 2021 +0200
app: check the time before last selection draw before queuing a redraw.
This way, we would queue a lot less canvas region unnecessary redraws.
We still remake the time-before-last-draw check in the draw() signal
handling before we want to update the marching ants index for draw
events coming for other reasons (canvas updates, moving/zooming on
canvas, exposition changes, etc.).
(cherry picked from commit 6466d46052b856b268d3e0c9230b14a20a3f21e5)
app/display/gimpdisplayshell-selection.c | 38 ++++++++++++++++++++------------
1 file changed, 24 insertions(+), 14 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-selection.c b/app/display/gimpdisplayshell-selection.c
index 357931a231..38756591e3 100644
--- a/app/display/gimpdisplayshell-selection.c
+++ b/app/display/gimpdisplayshell-selection.c
@@ -229,7 +229,7 @@ selection_start (Selection *selection)
selection_stop (selection);
/* If this selection is paused, do not start it */
- if (selection->paused == 0)
+ if (selection->paused == 0 && selection->timeout == 0)
{
selection->timeout = g_idle_add ((GSourceFunc) selection_start_timeout,
selection);
@@ -441,28 +441,38 @@ selection_free_segs (Selection *selection)
static gboolean
selection_start_timeout (Selection *selection)
{
- selection->timeout = 0;
-
/* Draw the ants */
if (gimp_display_get_image (selection->shell->display) &&
selection->show_selection)
{
- GdkWindow *window;
- cairo_rectangle_int_t rect;
- cairo_region_t *region;
+ GimpDisplayConfig *config = selection->shell->display->config;
+ gint64 time = g_get_monotonic_time ();
- window = gtk_widget_get_window (GTK_WIDGET (selection->shell));
+ if ((time - selection->shell->selection_update) / 1000 > config->marching_ants_speed)
+ {
+ GdkWindow *window;
+ cairo_rectangle_int_t rect;
+ cairo_region_t *region;
- rect.x = 0;
- rect.y = 0;
- rect.width = gdk_window_get_width (window);
- rect.height = gdk_window_get_height (window);
+ window = gtk_widget_get_window (GTK_WIDGET (selection->shell));
- region = cairo_region_create_rectangle (&rect);
- gtk_widget_queue_draw_region (GTK_WIDGET (selection->shell), region);
- cairo_region_destroy (region);
+ rect.x = 0;
+ rect.y = 0;
+ rect.width = gdk_window_get_width (window);
+ rect.height = gdk_window_get_height (window);
+
+ region = cairo_region_create_rectangle (&rect);
+ gtk_widget_queue_draw_region (GTK_WIDGET (selection->shell), region);
+ cairo_region_destroy (region);
+ }
+ else
+ {
+ return G_SOURCE_CONTINUE;
+ }
}
+ selection->timeout = 0;
+
return G_SOURCE_REMOVE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]