From cbaf997ae22902319958275240db5c386fe3d8f1 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Fri, 24 Sep 2010 23:25:19 +0200 Subject: [PATCH] app: undraw the old canvas items only before drawing new ones or when the draw tool is really stopped. This seems to get rid of any remaining flickering and also reduces expose events. Also get rid of the "is_drawn" state and API because they make no sense any longer. --- app/tools/gimpdrawtool.c | 26 +++++--------------------- app/tools/gimpdrawtool.h | 3 --- 2 files changed, 5 insertions(+), 24 deletions(-) diff --git a/app/tools/gimpdrawtool.c b/app/tools/gimpdrawtool.c index 8eb23116c0..3da6930582 100644 --- a/app/tools/gimpdrawtool.c +++ b/app/tools/gimpdrawtool.c @@ -105,9 +105,8 @@ static void gimp_draw_tool_init (GimpDrawTool *draw_tool) { draw_tool->display = NULL; - draw_tool->paused_count = 0; - draw_tool->is_drawn = FALSE; + draw_tool->items = NULL; } static void @@ -201,29 +200,24 @@ gimp_draw_tool_clear_items (GimpDrawTool *draw_tool) static void gimp_draw_tool_draw (GimpDrawTool *draw_tool) { - if (draw_tool->paused_count == 0 && - draw_tool->display) + if (draw_tool->display && draw_tool->paused_count == 0) { + gimp_draw_tool_invalidate_items (draw_tool); gimp_draw_tool_clear_items (draw_tool); GIMP_DRAW_TOOL_GET_CLASS (draw_tool)->draw (draw_tool); gimp_draw_tool_invalidate_items (draw_tool); - - draw_tool->is_drawn = TRUE; } } static void gimp_draw_tool_undraw (GimpDrawTool *draw_tool) { - if (draw_tool->paused_count == 0 && - draw_tool->display) + if (draw_tool->display) { gimp_draw_tool_invalidate_items (draw_tool); gimp_draw_tool_clear_items (draw_tool); - - draw_tool->is_drawn = FALSE; } } @@ -270,8 +264,6 @@ gimp_draw_tool_pause (GimpDrawTool *draw_tool) { g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool)); - gimp_draw_tool_undraw (draw_tool); - draw_tool->paused_count++; } @@ -286,14 +278,6 @@ gimp_draw_tool_resume (GimpDrawTool *draw_tool) gimp_draw_tool_draw (draw_tool); } -gboolean -gimp_draw_tool_is_drawn (GimpDrawTool *draw_tool) -{ - g_return_val_if_fail (GIMP_IS_DRAW_TOOL (draw_tool), FALSE); - - return draw_tool->is_drawn; -} - void gimp_draw_tool_draw_items (GimpDrawTool *draw_tool, cairo_t *cr) @@ -306,7 +290,7 @@ gimp_draw_tool_draw_items (GimpDrawTool *draw_tool, g_return_if_fail (cr != NULL); if (! gimp_draw_tool_is_active (draw_tool) || - ! gimp_draw_tool_is_drawn (draw_tool)) + draw_tool->paused_count > 0) return; shell = gimp_display_get_shell (draw_tool->display); diff --git a/app/tools/gimpdrawtool.h b/app/tools/gimpdrawtool.h index 99746380d9..e10775b57f 100644 --- a/app/tools/gimpdrawtool.h +++ b/app/tools/gimpdrawtool.h @@ -41,7 +41,6 @@ struct _GimpDrawTool */ gint paused_count; /* count to keep track of multiple pauses */ - gboolean is_drawn; /* is the stuff we draw currently visible */ GList *items; }; @@ -67,8 +66,6 @@ gboolean gimp_draw_tool_is_active (GimpDrawTool *draw_tool) void gimp_draw_tool_pause (GimpDrawTool *draw_tool); void gimp_draw_tool_resume (GimpDrawTool *draw_tool); -gboolean gimp_draw_tool_is_drawn (GimpDrawTool *draw_tool); - void gimp_draw_tool_draw_items (GimpDrawTool *draw_tool, cairo_t *cr);