[gimp/gimp-2-8] Bug 663582 - Brush outline is too slow
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-8] Bug 663582 - Brush outline is too slow
- Date: Thu, 4 Oct 2012 18:48:17 +0000 (UTC)
commit b03591e4055ccf32631069cf95067a09bf698e42
Author: Michael Natterer <mitch gimp org>
Date: Thu Oct 4 20:42:13 2012 +0200
Bug 663582 - Brush outline is too slow
Keep around the last drawing time in GimpDrawTool and make sure we
draw at least with a frame rate of around 20 fps, which feels
reasonably non-laggy.
(cherry picked from commit fd4e220c28d42a3b0169df21dc803f5601a6691e)
app/tools/gimpdrawtool.c | 20 +++++++++++++++++---
app/tools/gimpdrawtool.h | 11 ++++++-----
2 files changed, 23 insertions(+), 8 deletions(-)
---
diff --git a/app/tools/gimpdrawtool.c b/app/tools/gimpdrawtool.c
index 531e46c..087c34f 100644
--- a/app/tools/gimpdrawtool.c
+++ b/app/tools/gimpdrawtool.c
@@ -59,8 +59,9 @@
#include "gimpdrawtool.h"
-#define DRAW_TIMEOUT 4
-#define USE_TIMEOUT 1
+#define DRAW_TIMEOUT 4
+#define USE_TIMEOUT 1
+#define MINIMUM_DRAW_INTERVAL 50 /* 50 microseconds == 20 fps */
static void gimp_draw_tool_dispose (GObject *object);
@@ -190,12 +191,21 @@ gimp_draw_tool_draw_timeout (GimpDrawTool *draw_tool)
static void
gimp_draw_tool_draw (GimpDrawTool *draw_tool)
{
+ guint64 now = g_get_monotonic_time ();
+
if (draw_tool->display &&
draw_tool->paused_count == 0 &&
- ! draw_tool->draw_timeout)
+ (! draw_tool->draw_timeout ||
+ (now - draw_tool->last_draw_time) > MINIMUM_DRAW_INTERVAL))
{
GimpDisplayShell *shell = gimp_display_get_shell (draw_tool->display);
+ if (draw_tool->draw_timeout)
+ {
+ g_source_remove (draw_tool->draw_timeout);
+ draw_tool->draw_timeout = 0;
+ }
+
gimp_draw_tool_undraw (draw_tool);
GIMP_DRAW_TOOL_GET_CLASS (draw_tool)->draw (draw_tool);
@@ -216,6 +226,8 @@ gimp_draw_tool_draw (GimpDrawTool *draw_tool)
if (draw_tool->item)
gimp_display_shell_add_tool_item (shell, draw_tool->item);
+
+ draw_tool->last_draw_time = now;
}
}
@@ -275,6 +287,8 @@ gimp_draw_tool_stop (GimpDrawTool *draw_tool)
draw_tool->draw_timeout = 0;
}
+ draw_tool->last_draw_time = 0;
+
draw_tool->display = NULL;
}
diff --git a/app/tools/gimpdrawtool.h b/app/tools/gimpdrawtool.h
index 705fae6..4cf3c38 100644
--- a/app/tools/gimpdrawtool.h
+++ b/app/tools/gimpdrawtool.h
@@ -42,12 +42,13 @@ struct _GimpDrawTool
{
GimpTool parent_instance;
- GimpDisplay *display; /* The display we are drawing to (may be
- * a different one than tool->display)
- */
+ GimpDisplay *display; /* The display we are drawing to (may be
+ * a different one than tool->display)
+ */
- gint paused_count; /* count to keep track of multiple pauses */
- guint draw_timeout; /* draw delay timeout ID */
+ gint paused_count; /* count to keep track of multiple pauses */
+ guint draw_timeout; /* draw delay timeout ID */
+ guint64 last_draw_time; /* time of last draw(), monotonically */
GimpCanvasItem *preview;
GimpCanvasItem *item;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]