mirror of https://github.com/GNOME/gimp.git
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.
This commit is contained in:
parent
14c20ef13a
commit
fd4e220c28
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue