removed "width", "height" and "antialias" from the GimpScanConvert struct

2003-09-30  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpscanconvert.[ch]: removed "width", "height" and
	"antialias" from the GimpScanConvert struct and from
	gimp_scan_convert_new(). Removed gimp_scan_convert_to_channel().
	Added "gboolean antialias" to gimp_scan_convert_render().
	Some general cleanup.

	* app/core/gimpdrawable-stroke.c
	* app/core/gimpimage-mask-select.c
	* app/tools/gimpiscissorstool.c: changed accordingly.

	* app/core/gimpdrawable-stroke.c: renamed
	gimp_drawable_stroke_scanconvert_stroke() to
	gimp_drawable_stroke_scan_convert() and removed the "gboolean
	use_mask_bounds" parameter since we can't decide if it's the
	selection's boundary which is stroked. Instead use
	gimp_channel_is_empty() on the selection which will return FALSE
	while the selection is being stroked.

	* app/paint/gimppaintcore-stroke.c: cleanup.

	(gimp_paint_core_stroke_boundary): don't use "gint i" twice.

	(gimp_paint_core_stroke_vectors): no need to manually close a
	closed stroke.
This commit is contained in:
Michael Natterer
2003-09-30 18:06:19 +00:00
committed by Michael Natterer
parent 5426aba926
commit 657b49b402
8 changed files with 134 additions and 154 deletions

View File

@ -1,3 +1,30 @@
2003-09-30 Michael Natterer <mitch@gimp.org>
* app/core/gimpscanconvert.[ch]: removed "width", "height" and
"antialias" from the GimpScanConvert struct and from
gimp_scan_convert_new(). Removed gimp_scan_convert_to_channel().
Added "gboolean antialias" to gimp_scan_convert_render().
Some general cleanup.
* app/core/gimpdrawable-stroke.c
* app/core/gimpimage-mask-select.c
* app/tools/gimpiscissorstool.c: changed accordingly.
* app/core/gimpdrawable-stroke.c: renamed
gimp_drawable_stroke_scanconvert_stroke() to
gimp_drawable_stroke_scan_convert() and removed the "gboolean
use_mask_bounds" parameter since we can't decide if it's the
selection's boundary which is stroked. Instead use
gimp_channel_is_empty() on the selection which will return FALSE
while the selection is being stroked.
* app/paint/gimppaintcore-stroke.c: cleanup.
(gimp_paint_core_stroke_boundary): don't use "gint i" twice.
(gimp_paint_core_stroke_vectors): no need to manually close a
closed stroke.
2003-09-30 Michael Natterer <mitch@gimp.org>
* app/core/gimpchannel.c (gimp_channel_stroke): pass the channel's

View File

@ -167,13 +167,13 @@ gimp_image_mask_select_polygon (GimpImage *gimage,
else
gimp_channel_push_undo (selection, undo_desc);
scan_convert = gimp_scan_convert_new (gimage->width,
gimage->height,
antialias);
scan_convert = gimp_scan_convert_new ();
gimp_scan_convert_add_polyline (scan_convert, n_points, points, TRUE);
mask = gimp_scan_convert_to_channel (scan_convert, gimage);
mask = gimp_channel_new_mask (gimage, gimage->width, gimage->height);
gimp_scan_convert_render (scan_convert, GIMP_DRAWABLE (mask)->tiles,
antialias);
gimp_scan_convert_free (scan_convert);
@ -223,9 +223,7 @@ gimp_image_mask_select_vectors (GimpImage *gimage,
else
gimp_channel_push_undo (selection, undo_desc);
scan_convert = gimp_scan_convert_new (gimage->width,
gimage->height,
antialias);
scan_convert = gimp_scan_convert_new ();
for (stroke = vectors->strokes; stroke; stroke = stroke->next)
{
@ -257,7 +255,11 @@ gimp_image_mask_select_vectors (GimpImage *gimage,
}
if (num_coords)
mask = gimp_scan_convert_to_channel (scan_convert, gimage);
{
mask = gimp_channel_new_mask (gimage, gimage->width, gimage->height);
gimp_scan_convert_render (scan_convert, GIMP_DRAWABLE (mask)->tiles,
antialias);
}
gimp_scan_convert_free (scan_convert);
@ -282,7 +284,7 @@ gimp_image_mask_select_channel (GimpImage *gimage,
GimpChannel *channel,
gint offset_x,
gint offset_y,
GimpChannelOps op,
GimpChannelOps op,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y)

View File

@ -35,8 +35,8 @@
#include "paint-funcs/paint-funcs.h"
#include "gimp.h"
#include "gimpchannel.h"
#include "gimpcontext.h"
#include "gimpdrawable.h"
#include "gimpdrawable-stroke.h"
#include "gimpimage.h"
#include "gimppattern.h"
@ -50,11 +50,12 @@
#include "gimp-intl.h"
static void gimp_drawable_stroke_scanconvert_stroke
(GimpDrawable *drawable,
GimpStrokeOptions *options,
GimpScanConvert *scan_convert,
gboolean use_mask_bounds);
/* local function prototypes */
static void gimp_drawable_stroke_scan_convert (GimpDrawable *drawable,
GimpStrokeOptions *options,
GimpScanConvert *scan_convert);
/* public functions */
@ -72,21 +73,20 @@ gimp_drawable_stroke_boundary (GimpDrawable *drawable,
GimpVector2 *points;
gint n_points;
gint seg;
gint i, x1, x2, y1, y2;
gint i;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (GIMP_IS_STROKE_OPTIONS (options));
g_return_if_fail (bound_segs != NULL);
g_return_if_fail (n_bound_segs > 0);
gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
scan_convert = gimp_scan_convert_new (x2-x1, y2-y1, options->antialias);
stroke_segs = sort_boundary (bound_segs, n_bound_segs, &n_stroke_segs);
if (n_stroke_segs == 0)
return;
scan_convert = gimp_scan_convert_new ();
points = g_new0 (GimpVector2, n_bound_segs + 4);
seg = 0;
@ -132,8 +132,7 @@ gimp_drawable_stroke_boundary (GimpDrawable *drawable,
g_free (points);
g_free (stroke_segs);
gimp_drawable_stroke_scanconvert_stroke (drawable, options,
scan_convert, FALSE);
gimp_drawable_stroke_scan_convert (drawable, options, scan_convert);
gimp_scan_convert_free (scan_convert);
}
@ -143,18 +142,15 @@ gimp_drawable_stroke_vectors (GimpDrawable *drawable,
GimpStrokeOptions *options,
GimpVectors *vectors)
{
gint num_coords = 0;
GimpStroke *stroke;
GimpScanConvert *scan_convert;
gint x1, x2, y1, y2;
GimpStroke *stroke;
gint num_coords = 0;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (GIMP_IS_STROKE_OPTIONS (options));
g_return_if_fail (GIMP_IS_VECTORS (vectors));
gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
scan_convert = gimp_scan_convert_new (x2-x1, y2-y1, options->antialias);
scan_convert = gimp_scan_convert_new ();
/* For each Stroke in the vector, interpolate it, and add it to the
* ScanConvert
@ -189,25 +185,24 @@ gimp_drawable_stroke_vectors (GimpDrawable *drawable,
g_free (points);
}
if (coords)
g_array_free (coords, TRUE);
}
if (num_coords == 0)
{
gimp_scan_convert_free (scan_convert);
return;
}
gimp_drawable_stroke_scanconvert_stroke (drawable, options,
scan_convert, TRUE);
if (num_coords > 0)
gimp_drawable_stroke_scan_convert (drawable, options, scan_convert);
gimp_scan_convert_free (scan_convert);
}
/* private functions */
static void
gimp_drawable_stroke_scanconvert_stroke (GimpDrawable *drawable,
GimpStrokeOptions *options,
GimpScanConvert *scan_convert,
gboolean use_mask_bounds)
gimp_drawable_stroke_scan_convert (GimpDrawable *drawable,
GimpStrokeOptions *options,
GimpScanConvert *scan_convert)
{
/* Stroke options */
gdouble width;
@ -217,14 +212,15 @@ gimp_drawable_stroke_scanconvert_stroke (GimpDrawable *drawable,
gint x1, x2, y1, y2, bytes, w, h;
guchar bg[1] = { 0, };
PixelRegion maskPR, basePR;
GimpImage *gimage;
GimpContext *context;
GimpImage *gimage;
context = GIMP_CONTEXT (options);
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
/* what area do we operate on? */
if (use_mask_bounds)
if (! gimp_channel_is_empty (gimp_image_get_mask (gimage)))
{
gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
@ -262,12 +258,12 @@ gimp_drawable_stroke_scanconvert_stroke (GimpDrawable *drawable,
* of the stroke.
*/
mask = tile_manager_new (w, h, 1);
tile_manager_set_offsets (mask, x1+x2, y1+y2);
tile_manager_set_offsets (mask, x1 + x2, y1 + y2);
pixel_region_init (&maskPR, mask, 0, 0, w, h, TRUE);
color_region (&maskPR, bg);
/* render the stroke into it */
gimp_scan_convert_render (scan_convert, mask);
gimp_scan_convert_render (scan_convert, mask, options->antialias);
bytes = drawable->bytes;
if (!gimp_drawable_has_alpha (drawable))
@ -331,5 +327,3 @@ gimp_drawable_stroke_scanconvert_stroke (GimpDrawable *drawable,
gimp_drawable_update (drawable, x1, y1, w, h);
}

View File

@ -167,13 +167,13 @@ gimp_image_mask_select_polygon (GimpImage *gimage,
else
gimp_channel_push_undo (selection, undo_desc);
scan_convert = gimp_scan_convert_new (gimage->width,
gimage->height,
antialias);
scan_convert = gimp_scan_convert_new ();
gimp_scan_convert_add_polyline (scan_convert, n_points, points, TRUE);
mask = gimp_scan_convert_to_channel (scan_convert, gimage);
mask = gimp_channel_new_mask (gimage, gimage->width, gimage->height);
gimp_scan_convert_render (scan_convert, GIMP_DRAWABLE (mask)->tiles,
antialias);
gimp_scan_convert_free (scan_convert);
@ -223,9 +223,7 @@ gimp_image_mask_select_vectors (GimpImage *gimage,
else
gimp_channel_push_undo (selection, undo_desc);
scan_convert = gimp_scan_convert_new (gimage->width,
gimage->height,
antialias);
scan_convert = gimp_scan_convert_new ();
for (stroke = vectors->strokes; stroke; stroke = stroke->next)
{
@ -257,7 +255,11 @@ gimp_image_mask_select_vectors (GimpImage *gimage,
}
if (num_coords)
mask = gimp_scan_convert_to_channel (scan_convert, gimage);
{
mask = gimp_channel_new_mask (gimage, gimage->width, gimage->height);
gimp_scan_convert_render (scan_convert, GIMP_DRAWABLE (mask)->tiles,
antialias);
}
gimp_scan_convert_free (scan_convert);
@ -282,7 +284,7 @@ gimp_image_mask_select_channel (GimpImage *gimage,
GimpChannel *channel,
gint offset_x,
gint offset_y,
GimpChannelOps op,
GimpChannelOps op,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y)

View File

@ -31,19 +31,12 @@
#include "base/pixel-region.h"
#include "base/tile-manager.h"
#include "gimpchannel.h"
#include "gimpimage.h"
#include "gimpscanconvert.h"
struct _GimpScanConvert
{
guint width;
guint height;
gdouble ratio_xy;
gboolean antialias; /* do we want antialiasing? */
/* stuff necessary for the _add_polygons API... :-/ */
gboolean got_first;
@ -59,27 +52,23 @@ struct _GimpScanConvert
(extension no longer possible) */
};
/* Private functions */
static void gimp_scan_convert_finish (GimpScanConvert *sc);
static void gimp_scan_convert_close_add_points (GimpScanConvert *sc);
/* private functions */
static void gimp_scan_convert_finish (GimpScanConvert *sc);
static void gimp_scan_convert_close_add_points (GimpScanConvert *sc);
/* public functions */
GimpScanConvert *
gimp_scan_convert_new (guint width,
guint height,
gboolean antialias)
gimp_scan_convert_new (void)
{
GimpScanConvert *sc;
g_return_val_if_fail (width > 0, NULL);
g_return_val_if_fail (height > 0, NULL);
sc = g_new0 (GimpScanConvert, 1);
sc->width = width;
sc->height = height;
sc->ratio_xy = 1.0;
sc->antialias = antialias;
return sc;
}
@ -249,7 +238,7 @@ gimp_scan_convert_add_polyline (GimpScanConvert *sc,
/* Stroke the content of a GimpScanConvert. The next
* gimp_scan_convert_to_channel will result in the outline of the polygon
* gimp_scan_convert_render() will result in the outline of the polygon
* defined with the commands above.
*
* You cannot add additional polygons after this command.
@ -275,36 +264,35 @@ gimp_scan_convert_stroke (GimpScanConvert *sc,
switch (join)
{
case GIMP_JOIN_MITER:
artjoin = ART_PATH_STROKE_JOIN_MITER;
break;
artjoin = ART_PATH_STROKE_JOIN_MITER;
break;
case GIMP_JOIN_ROUND:
artjoin = ART_PATH_STROKE_JOIN_ROUND;
break;
artjoin = ART_PATH_STROKE_JOIN_ROUND;
break;
case GIMP_JOIN_BEVEL:
artjoin = ART_PATH_STROKE_JOIN_BEVEL;
break;
artjoin = ART_PATH_STROKE_JOIN_BEVEL;
break;
}
switch (cap)
{
case GIMP_CAP_BUTT:
artcap = ART_PATH_STROKE_CAP_BUTT;
break;
artcap = ART_PATH_STROKE_CAP_BUTT;
break;
case GIMP_CAP_ROUND:
artcap = ART_PATH_STROKE_CAP_ROUND;
break;
artcap = ART_PATH_STROKE_CAP_ROUND;
break;
case GIMP_CAP_SQUARE:
artcap = ART_PATH_STROKE_CAP_SQUARE;
break;
artcap = ART_PATH_STROKE_CAP_SQUARE;
break;
}
if (sc->ratio_xy != 1.0)
{
gint i;
for (i = 0; i < sc->num_nodes; i++)
{
sc->vpath[i].x *= sc->ratio_xy;
}
sc->vpath[i].x *= sc->ratio_xy;
}
if (dash_info)
@ -337,9 +325,9 @@ gimp_scan_convert_stroke (GimpScanConvert *sc,
if (sc->ratio_xy != 1.0)
{
ArtSVPSeg *segment;
ArtPoint *point;
gint i, j;
ArtPoint *point;
gint i, j;
for (i = 0; i < stroke->n_segs; i++)
{
segment = stroke->segs + i;
@ -357,26 +345,6 @@ gimp_scan_convert_stroke (GimpScanConvert *sc,
sc->svp = stroke;
}
/* Return a new Channel according to the polygonal shapes defined with
* the commands above.
*
* You cannot add additional polygons after this command.
*/
GimpChannel *
gimp_scan_convert_to_channel (GimpScanConvert *sc,
GimpImage *gimage)
{
GimpChannel *mask;
mask = gimp_channel_new_mask (gimage, sc->width, sc->height);
gimp_scan_convert_render (sc, gimp_drawable_data (GIMP_DRAWABLE (mask)));
mask->bounds_known = FALSE;
return mask;
}
/* This is a more low level version. Expects a tile manager of depth 1.
*
@ -384,7 +352,8 @@ gimp_scan_convert_to_channel (GimpScanConvert *sc,
*/
void
gimp_scan_convert_render (GimpScanConvert *sc,
TileManager *tile_manager)
TileManager *tile_manager,
gboolean antialias)
{
PixelRegion maskPR;
gpointer pr;
@ -410,14 +379,16 @@ gimp_scan_convert_render (GimpScanConvert *sc,
pr != NULL;
pr = pixel_regions_process (pr))
{
art_gray_svp_aa (sc->svp, x0 + maskPR.x, y0 + maskPR.y,
art_gray_svp_aa (sc->svp,
x0 + maskPR.x,
y0 + maskPR.y,
x0 + maskPR.x + maskPR.w,
y0 + maskPR.y + maskPR.h,
maskPR.data, maskPR.rowstride);
if (sc->antialias == FALSE)
if (! antialias)
{
/*
* Ok, the user didn't want to have antialiasing, so just
/* Ok, the user didn't want to have antialiasing, so just
* remove the results from lots of CPU-Power...
*/
dest = maskPR.data;
@ -443,8 +414,8 @@ gimp_scan_convert_render (GimpScanConvert *sc,
static void
gimp_scan_convert_finish (GimpScanConvert *sc)
{
ArtVpath *pert_vpath;
ArtSVP *svp, *svp2;
ArtVpath *pert_vpath;
ArtSVP *svp, *svp2;
g_return_if_fail (sc->vpath != NULL);
@ -469,6 +440,7 @@ gimp_scan_convert_finish (GimpScanConvert *sc)
if (sc->have_open)
{
gint i;
for (i = 0; i < sc->num_nodes; i++)
if (sc->vpath[i].code == ART_MOVETO_OPEN)
{
@ -498,4 +470,3 @@ gimp_scan_convert_finish (GimpScanConvert *sc)
sc->svp = svp;
}

View File

@ -23,12 +23,9 @@
typedef struct _GimpScanConvert GimpScanConvert;
/* Create a new scan conversion context. Set "antialias" to 1 for no
* supersampling, or the amount to supersample by otherwise.
/* Create a new scan conversion context.
*/
GimpScanConvert * gimp_scan_convert_new (guint width,
guint height,
gboolean antialias);
GimpScanConvert * gimp_scan_convert_new (void);
void gimp_scan_convert_free (GimpScanConvert *scan_converter);
@ -77,20 +74,14 @@ void gimp_scan_convert_stroke (GimpScanConvert *sc,
gdouble dash_offset,
GArray *dash_info);
/* Return a new Channel according to the polygonal shapes defined with
* the commands above.
*
* You cannot add additional polygons after this command.
*/
GimpChannel * gimp_scan_convert_to_channel (GimpScanConvert *scan_converter,
GimpImage *gimage);
/* This is a more low level version. Expects a tile manager of depth 1.
*
* You cannot add additional polygons after this command.
*/
void gimp_scan_convert_render (GimpScanConvert *scan_converter,
TileManager *tile_manager);
TileManager *tile_manager,
gboolean antialias);
#endif /* __GIMP_SCAN_CONVERT_H__ */

View File

@ -98,7 +98,7 @@ gimp_paint_core_stroke_boundary (GimpPaintCore *core,
gboolean initialized = FALSE;
gint n_coords;
gint seg;
gint i;
gint s;
g_return_val_if_fail (GIMP_IS_PAINT_CORE (core), FALSE);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
@ -133,10 +133,9 @@ gimp_paint_core_stroke_boundary (GimpPaintCore *core,
n_coords++;
for (i = 0; i < n_stroke_segs; i++)
for (s = 0; s < n_stroke_segs; s++)
{
GimpBrush *current_brush;
gint i;
while (stroke_segs[seg].x1 != -1 ||
stroke_segs[seg].x2 != -1 ||
@ -162,9 +161,10 @@ gimp_paint_core_stroke_boundary (GimpPaintCore *core,
n_coords++;
if (initialized ||
gimp_paint_core_start (core, drawable, paint_options,
&coords[0]))
gimp_paint_core_start (core, drawable, paint_options, &coords[0]))
{
gint i;
initialized = TRUE;
core->start_coords = coords[0];
@ -254,8 +254,7 @@ gimp_paint_core_stroke_vectors (GimpPaintCore *core,
if (initialized ||
gimp_paint_core_start (core, drawable, paint_options,
&g_array_index (coords,
GimpCoords, 0)))
&g_array_index (coords, GimpCoords, 0)))
{
initialized = TRUE;
@ -276,13 +275,6 @@ gimp_paint_core_stroke_vectors (GimpPaintCore *core,
gimp_paint_core_interpolate (core, drawable, paint_options);
}
if (closed)
{
core->cur_coords = g_array_index (coords, GimpCoords, 0);
gimp_paint_core_interpolate (core, drawable, paint_options);
}
gimp_paint_core_paint (core, drawable, paint_options,
FINISH_PAINT);
}

View File

@ -539,9 +539,7 @@ iscissors_convert (GimpIscissorsTool *iscissors,
gint i;
gint index;
sc = gimp_scan_convert_new (gdisp->gimage->width,
gdisp->gimage->height,
TRUE);
sc = gimp_scan_convert_new ();
/* go over the curves in reverse order, adding the points we have */
list = iscissors->curves;
@ -568,7 +566,10 @@ iscissors_convert (GimpIscissorsTool *iscissors,
if (iscissors->mask)
g_object_unref (iscissors->mask);
iscissors->mask = gimp_scan_convert_to_channel (sc, gdisp->gimage);
iscissors->mask = gimp_channel_new_mask (gdisp->gimage,
gdisp->gimage->width,
gdisp->gimage->height);
gimp_scan_convert_render (sc, GIMP_DRAWABLE (iscissors)->tiles, TRUE);
gimp_scan_convert_free (sc);
}