[gimp] app: throttle GimpCanvasProgress updates
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: throttle GimpCanvasProgress updates
- Date: Fri, 16 Mar 2018 08:34:27 +0000 (UTC)
commit dc1852049e95aa11d6be0b0f5a0d1a3f4f2cec79
Author: Ell <ell_se yahoo com>
Date: Fri Mar 16 04:23:15 2018 -0400
app: throttle GimpCanvasProgress updates
Avoid redrawing GimpCanvasProgress items upon
GimpProgress::set_value() if a minimal amount of time hasn't passed
since the last call. This notably improves performance of
frequently-updated GimpCanvasProgress items.
app/display/gimpcanvasprogress.c | 27 +++++++++++++++++++++------
1 files changed, 21 insertions(+), 6 deletions(-)
---
diff --git a/app/display/gimpcanvasprogress.c b/app/display/gimpcanvasprogress.c
index e275029..24fad4a 100644
--- a/app/display/gimpcanvasprogress.c
+++ b/app/display/gimpcanvasprogress.c
@@ -37,8 +37,10 @@
#include "gimpdisplayshell.h"
-#define BORDER 5
-#define RADIUS 20
+#define BORDER 5
+#define RADIUS 20
+
+#define MIN_UPDATE_INTERVAL 50000 /* microseconds */
enum
@@ -60,6 +62,8 @@ struct _GimpCanvasProgressPrivate
gchar *text;
gdouble value;
+
+ guint64 last_update_time;
};
#define GET_PRIVATE(progress) \
@@ -350,8 +354,12 @@ gimp_canvas_progress_start (GimpProgress *progress,
gboolean cancellable,
const gchar *message)
{
+ GimpCanvasProgressPrivate *private = GET_PRIVATE (progress);
+
gimp_canvas_progress_set_text (progress, message);
+ private->last_update_time = g_get_monotonic_time ();
+
return progress;
}
@@ -399,15 +407,22 @@ gimp_canvas_progress_set_value (GimpProgress *progress,
if (percentage != private->value)
{
- cairo_region_t *region;
+ guint64 time = g_get_monotonic_time ();
private->value = percentage;
- region = gimp_canvas_item_get_extents (GIMP_CANVAS_ITEM (progress));
+ if (time - private->last_update_time >= MIN_UPDATE_INTERVAL)
+ {
+ cairo_region_t *region;
+
+ private->last_update_time = time;
+
+ region = gimp_canvas_item_get_extents (GIMP_CANVAS_ITEM (progress));
- _gimp_canvas_item_update (GIMP_CANVAS_ITEM (progress), region);
+ _gimp_canvas_item_update (GIMP_CANVAS_ITEM (progress), region);
- cairo_region_destroy (region);
+ cairo_region_destroy (region);
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]