From 8398ed873502b9158aa3648f6246f05f032d7851 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Sun, 21 Jan 2007 19:54:57 +0000 Subject: [PATCH] maintain an is_drawn boolean which indicates whether the drawn stuff is 2007-01-21 Michael Natterer * app/tools/gimpdrawtool.[ch]: maintain an is_drawn boolean which indicates whether the drawn stuff is currently visible. Added gimp_draw_tool_is_drawn() to obtain it. * app/tools/gimpbrushtool.c (gimp_brush_tool_draw): don't create the brush outline segments for the purpose of undrawing (if we don't have the segments, we can hardly have drawn them before). Fixes artifacts when the brush is being scaled or changed. * app/core/gimpbrush.c: don't call brush_scale_mask() and brush_scale_pixmap() with zero width or height. Fixes warnings from these functions. svn path=/trunk/; revision=21749 --- ChangeLog | 15 +++++++++++++++ app/core/gimpbrush.c | 10 ++++++++-- app/tools/gimpbrushtool.c | 6 +++++- app/tools/gimpdrawtool.c | 11 +++++++++++ app/tools/gimpdrawtool.h | 5 ++++- 5 files changed, 43 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 894d6f9eae..23478aa359 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2007-01-21 Michael Natterer + + * app/tools/gimpdrawtool.[ch]: maintain an is_drawn boolean which + indicates whether the drawn stuff is currently visible. Added + gimp_draw_tool_is_drawn() to obtain it. + + * app/tools/gimpbrushtool.c (gimp_brush_tool_draw): don't create + the brush outline segments for the purpose of undrawing (if we + don't have the segments, we can hardly have drawn them before). + Fixes artifacts when the brush is being scaled or changed. + + * app/core/gimpbrush.c: don't call brush_scale_mask() and + brush_scale_pixmap() with zero width or height. Fixes warnings + from these functions. + 2007-01-21 Tor Lillqvist * configure.in: Add AC_MSG_RESULT([no]) to the fail branch of diff --git a/app/core/gimpbrush.c b/app/core/gimpbrush.c index 5668351cd1..951606401e 100644 --- a/app/core/gimpbrush.c +++ b/app/core/gimpbrush.c @@ -373,7 +373,10 @@ gimp_brush_real_scale_mask (GimpBrush *brush, width = (gint) (brush->mask->width * scale + 0.5); height = (gint) (brush->mask->height * scale + 0.5); - return brush_scale_mask (brush->mask, width, height); + if (width > 0 && height > 0) + return brush_scale_mask (brush->mask, width, height); + + return NULL; } static TempBuf * @@ -386,7 +389,10 @@ gimp_brush_real_scale_pixmap (GimpBrush *brush, width = (gint) (brush->pixmap->width * scale + 0.5); height = (gint) (brush->pixmap->height * scale + 0.5); - return brush_scale_pixmap (brush->pixmap, width, height); + if (width > 0 && height > 0) + return brush_scale_pixmap (brush->pixmap, width, height); + + return NULL; } diff --git a/app/tools/gimpbrushtool.c b/app/tools/gimpbrushtool.c index c81bc3078b..c51c7b370d 100644 --- a/app/tools/gimpbrushtool.c +++ b/app/tools/gimpbrushtool.c @@ -263,7 +263,11 @@ gimp_brush_tool_draw (GimpDrawTool *draw_tool) GimpPaintOptions *paint_options = GIMP_PAINT_TOOL_GET_OPTIONS (draw_tool); GimpBrushCore *brush_core = GIMP_BRUSH_CORE (paint_tool->core); - if (! brush_core->brush_bound_segs && brush_core->main_brush) + /* don't create the segments for the purpose of undrawing (if we + * don't have the segments, we can hardly have drawn them before) + */ + if (! brush_core->brush_bound_segs && brush_core->main_brush && + ! gimp_draw_tool_is_drawn (draw_tool)) { gimp_brush_core_create_bound_segs (brush_core, paint_options); } diff --git a/app/tools/gimpdrawtool.c b/app/tools/gimpdrawtool.c index 1bb011061a..b697278161 100644 --- a/app/tools/gimpdrawtool.c +++ b/app/tools/gimpdrawtool.c @@ -98,6 +98,7 @@ gimp_draw_tool_init (GimpDrawTool *draw_tool) draw_tool->display = NULL; draw_tool->paused_count = 0; + draw_tool->is_drawn = FALSE; draw_tool->vectors = NULL; draw_tool->transform = NULL; @@ -187,6 +188,8 @@ gimp_draw_tool_draw (GimpDrawTool *draw_tool) if (draw_tool->paused_count == 0 && draw_tool->display) { GIMP_DRAW_TOOL_GET_CLASS (draw_tool)->draw (draw_tool); + + draw_tool->is_drawn = ! draw_tool->is_drawn; } } @@ -301,6 +304,14 @@ gimp_draw_tool_resume (GimpDrawTool *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_set_vectors (GimpDrawTool *draw_tool, GList *vectors) diff --git a/app/tools/gimpdrawtool.h b/app/tools/gimpdrawtool.h index bd347ef9c2..0b24c7b12f 100644 --- a/app/tools/gimpdrawtool.h +++ b/app/tools/gimpdrawtool.h @@ -52,9 +52,10 @@ struct _GimpDrawTool */ gint paused_count; /* count to keep track of multiple pauses */ + gboolean is_drawn; /* is the stuff we draw currently visible */ GList *vectors; /* GimpVectors to render */ - GimpMatrix3 *transform; /* Transformation matrix fof the vectors */ + GimpMatrix3 *transform; /* Transformation matrix of the vectors */ }; struct _GimpDrawToolClass @@ -78,6 +79,8 @@ 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_set_vectors (GimpDrawTool *draw_tool, GList *vectors); void gimp_draw_tool_set_transform (GimpDrawTool *draw_tool,