app: namespace the ink blob

Blob -> GimpBlob, blob_foo() -> gimp_blob_foo() etc.
This commit is contained in:
Michael Natterer
2010-11-14 16:43:21 +01:00
parent c4cd420ef8
commit dc564954d5
7 changed files with 204 additions and 204 deletions

View File

@ -41,18 +41,18 @@ typedef enum
/* local function prototypes */ /* local function prototypes */
static Blob * blob_new (gint y, static GimpBlob * gimp_blob_new (gint y,
gint height); gint height);
static void blob_fill (Blob *b, static void gimp_blob_fill (GimpBlob *b,
EdgeType *present); EdgeType *present);
static void blob_make_convex (Blob *b, static void gimp_blob_make_convex (GimpBlob *b,
EdgeType *present); EdgeType *present);
#if 0 #if 0
static void blob_line_add_pixel (Blob *b, static void gimp_blob_line_add_pixel (GimpBlob *b,
gint x, gint x,
gint y); gint y);
static void blob_line (Blob *b, static void gimp_blob_line (GimpBlob *b,
gint x0, gint x0,
gint y0, gint y0,
gint x1, gint x1,
@ -64,11 +64,11 @@ static void blob_line (Blob *b,
/* Return blob for the given (convex) polygon /* Return blob for the given (convex) polygon
*/ */
Blob * GimpBlob *
blob_polygon (BlobPoint *points, gimp_blob_polygon (GimpBlobPoint *points,
gint npoints) gint n_points)
{ {
Blob *result; GimpBlob *result;
EdgeType *present; EdgeType *present;
gint i; gint i;
gint im1; gint im1;
@ -78,7 +78,7 @@ blob_polygon (BlobPoint *points,
ymax = points[0].y; ymax = points[0].y;
ymin = points[0].y; ymin = points[0].y;
for (i = 1; i < npoints; i++) for (i = 1; i < n_points; i++)
{ {
if (points[i].y > ymax) if (points[i].y > ymax)
ymax = points[i].y; ymax = points[i].y;
@ -86,14 +86,14 @@ blob_polygon (BlobPoint *points,
ymin = points[i].y; ymin = points[i].y;
} }
result = blob_new (ymin, ymax - ymin + 1); result = gimp_blob_new (ymin, ymax - ymin + 1);
present = g_new0 (EdgeType, result->height); present = g_new0 (EdgeType, result->height);
im1 = npoints - 1; im1 = n_points - 1;
i = 0; i = 0;
ip1 = 1; ip1 = 1;
for (; i < npoints ; i++) for (; i < n_points ; i++)
{ {
gint sides = 0; gint sides = 0;
gint j = points[i].y - ymin; gint j = points[i].y - ymin;
@ -136,11 +136,11 @@ blob_polygon (BlobPoint *points,
im1 = i; im1 = i;
ip1++; ip1++;
if (ip1 == npoints) if (ip1 == n_points)
ip1 = 0; ip1 = 0;
} }
blob_fill (result, present); gimp_blob_fill (result, present);
g_free (present); g_free (present);
return result; return result;
@ -149,15 +149,15 @@ blob_polygon (BlobPoint *points,
/* Scan convert a square specified by _offsets_ of major and minor /* Scan convert a square specified by _offsets_ of major and minor
* axes, and by center into a blob * axes, and by center into a blob
*/ */
Blob * GimpBlob *
blob_square (gdouble xc, gimp_blob_square (gdouble xc,
gdouble yc, gdouble yc,
gdouble xp, gdouble xp,
gdouble yp, gdouble yp,
gdouble xq, gdouble xq,
gdouble yq) gdouble yq)
{ {
BlobPoint points[4]; GimpBlobPoint points[4];
/* Make sure we order points ccw */ /* Make sure we order points ccw */
@ -176,21 +176,21 @@ blob_square (gdouble xc,
points[3].x = xc - xp + xq; points[3].x = xc - xp + xq;
points[3].y = yc - yp + yq; points[3].y = yc - yp + yq;
return blob_polygon (points, 4); return gimp_blob_polygon (points, 4);
} }
/* Scan convert a diamond specified by _offsets_ of major and minor /* Scan convert a diamond specified by _offsets_ of major and minor
* axes, and by center into a blob * axes, and by center into a blob
*/ */
Blob * GimpBlob *
blob_diamond (gdouble xc, gimp_blob_diamond (gdouble xc,
gdouble yc, gdouble yc,
gdouble xp, gdouble xp,
gdouble yp, gdouble yp,
gdouble xq, gdouble xq,
gdouble yq) gdouble yq)
{ {
BlobPoint points[4]; GimpBlobPoint points[4];
/* Make sure we order points ccw */ /* Make sure we order points ccw */
@ -209,7 +209,7 @@ blob_diamond (gdouble xc,
points[3].x = xc + xq; points[3].x = xc + xq;
points[3].y = yc + yq; points[3].y = yc + yq;
return blob_polygon (points, 4); return gimp_blob_polygon (points, 4);
} }
@ -241,15 +241,15 @@ static gint trig_table[TABLE_SIZE];
/* Scan convert an ellipse specified by _offsets_ of major and /* Scan convert an ellipse specified by _offsets_ of major and
* minor axes, and by center into a blob * minor axes, and by center into a blob
*/ */
Blob * GimpBlob *
blob_ellipse (gdouble xc, gimp_blob_ellipse (gdouble xc,
gdouble yc, gdouble yc,
gdouble xp, gdouble xp,
gdouble yp, gdouble yp,
gdouble xq, gdouble xq,
gdouble yq) gdouble yq)
{ {
Blob *result; GimpBlob *result;
EdgeType *present; EdgeType *present;
gint i; gint i;
gdouble r1, r2; gdouble r1, r2;
@ -282,7 +282,7 @@ blob_ellipse (gdouble xc,
maxy = ceil (yc + fabs (yp) + fabs (yq)); maxy = ceil (yc + fabs (yp) + fabs (yq));
miny = floor (yc - fabs (yp) - fabs (yq)); miny = floor (yc - fabs (yp) - fabs (yq));
result = blob_new (miny, maxy - miny + 1); result = gimp_blob_new (miny, maxy - miny + 1);
present = g_new0 (EdgeType, result->height); present = g_new0 (EdgeType, result->height);
/* Figure out a step that will draw most of the points */ /* Figure out a step that will draw most of the points */
@ -345,14 +345,14 @@ blob_ellipse (gdouble xc,
/* Now fill in missing points */ /* Now fill in missing points */
blob_fill (result, present); gimp_blob_fill (result, present);
g_free (present); g_free (present);
return result; return result;
} }
void void
blob_bounds (Blob *b, gimp_blob_bounds (GimpBlob *b,
gint *x, gint *x,
gint *y, gint *y,
gint *width, gint *width,
@ -392,11 +392,11 @@ blob_bounds (Blob *b,
*height = y1 - y0; *height = y1 - y0;
} }
Blob * GimpBlob *
blob_convex_union (Blob *b1, gimp_blob_convex_union (GimpBlob *b1,
Blob *b2) GimpBlob *b2)
{ {
Blob *result; GimpBlob *result;
gint y; gint y;
gint i, j; gint i, j;
EdgeType *present; EdgeType *present;
@ -404,7 +404,7 @@ blob_convex_union (Blob *b1,
/* Create the storage for the result */ /* Create the storage for the result */
y = MIN (b1->y, b2->y); y = MIN (b1->y, b2->y);
result = blob_new (y, MAX (b1->y + b1->height, b2->y + b2->height)-y); result = gimp_blob_new (y, MAX (b1->y + b1->height, b2->y + b2->height)-y);
if (result->height == 0) if (result->height == 0)
return result; return result;
@ -443,24 +443,24 @@ blob_convex_union (Blob *b1,
} }
} }
blob_make_convex (result, present); gimp_blob_make_convex (result, present);
g_free (present); g_free (present);
return result; return result;
} }
Blob * GimpBlob *
blob_duplicate (Blob *b) gimp_blob_duplicate (GimpBlob *b)
{ {
g_return_val_if_fail (b != NULL, NULL); g_return_val_if_fail (b != NULL, NULL);
return g_memdup (b, sizeof (Blob) + sizeof (BlobSpan) * (b->height - 1)); return g_memdup (b, sizeof (GimpBlob) + sizeof (GimpBlobSpan) * (b->height - 1));
} }
#if 0 #if 0
void void
blob_dump (Blob *b) gimp_blob_dump (GimpBlob *b)
{ {
gint i,j; gint i,j;
@ -480,13 +480,13 @@ blob_dump (Blob *b)
/* private functions */ /* private functions */
static Blob * static GimpBlob *
blob_new (gint y, gimp_blob_new (gint y,
gint height) gint height)
{ {
Blob *result; GimpBlob *result;
result = g_malloc (sizeof (Blob) + sizeof (BlobSpan) * (height - 1)); result = g_malloc (sizeof (GimpBlob) + sizeof (GimpBlobSpan) * (height - 1));
result->y = y; result->y = y;
result->height = height; result->height = height;
@ -495,7 +495,7 @@ blob_new (gint y,
} }
static void static void
blob_fill (Blob *b, gimp_blob_fill (GimpBlob *b,
EdgeType *present) EdgeType *present)
{ {
gint start; gint start;
@ -656,7 +656,7 @@ blob_fill (Blob *b,
} }
static void static void
blob_make_convex (Blob *b, gimp_blob_make_convex (GimpBlob *b,
EdgeType *present) EdgeType *present)
{ {
gint x1, x2, y1, y2, i1, i2; gint x1, x2, y1, y2, i1, i2;
@ -752,14 +752,14 @@ blob_make_convex (Blob *b,
i2 = i; i2 = i;
} }
blob_fill (b, present); gimp_blob_fill (b, present);
} }
#if 0 #if 0
static void static void
blob_line_add_pixel (Blob *b, gimp_blob_line_add_pixel (GimpBlob *b,
gint x, gint x,
gint y) gint y)
{ {
@ -775,7 +775,7 @@ blob_line_add_pixel (Blob *b,
} }
static void static void
blob_line (Blob *b, gimp_blob_line (GimpBlob *b,
gint x0, gint x0,
gint y0, gint y0,
gint x1, gint x1,
@ -818,7 +818,7 @@ blob_line (Blob *b,
incrE = 2 * dy; /* increment used for move to E */ incrE = 2 * dy; /* increment used for move to E */
incrNE = 2 * (dy - dx); /* increment used for move to NE */ incrNE = 2 * (dy - dx); /* increment used for move to NE */
blob_line_add_pixel (b, x, y); gimp_blob_line_add_pixel (b, x, y);
while (x != x1) while (x != x1)
{ {
@ -834,7 +834,7 @@ blob_line (Blob *b,
y += ystep; y += ystep;
} }
blob_line_add_pixel (b, x, y); gimp_blob_line_add_pixel (b, x, y);
} }
} }
else else
@ -843,7 +843,7 @@ blob_line (Blob *b,
incrE = 2 * dx; /* increment used for move to E */ incrE = 2 * dx; /* increment used for move to E */
incrNE = 2 * (dx - dy); /* increment used for move to NE */ incrNE = 2 * (dx - dy); /* increment used for move to NE */
blob_line_add_pixel (b, x, y); gimp_blob_line_add_pixel (b, x, y);
while (y != y1) while (y != y1)
{ {
@ -859,7 +859,7 @@ blob_line (Blob *b,
y += ystep; y += ystep;
} }
blob_line_add_pixel (b, x, y); gimp_blob_line_add_pixel (b, x, y);
} }
} }
} }

View File

@ -25,65 +25,65 @@
#define __GIMP_INK_BLOB_H__ #define __GIMP_INK_BLOB_H__
typedef struct _BlobPoint BlobPoint; typedef struct _GimpBlobPoint GimpBlobPoint;
typedef struct _BlobSpan BlobSpan; typedef struct _GimpBlobSpan GimpBlobSpan;
typedef struct _Blob Blob; typedef struct _GimpBlob GimpBlob;
typedef Blob * (* BlobFunc) (gdouble xc, typedef GimpBlob * (* GimpBlobFunc) (gdouble xc,
gdouble yc, gdouble yc,
gdouble xp, gdouble xp,
gdouble yp, gdouble yp,
gdouble xq, gdouble xq,
gdouble yq); gdouble yq);
struct _BlobPoint struct _GimpBlobPoint
{ {
gint x; gint x;
gint y; gint y;
}; };
struct _BlobSpan struct _GimpBlobSpan
{ {
gint left; gint left;
gint right; gint right;
}; };
struct _Blob struct _GimpBlob
{ {
gint y; gint y;
gint height; gint height;
BlobSpan data[1]; GimpBlobSpan data[1];
}; };
Blob * blob_polygon (BlobPoint *points, GimpBlob * gimp_blob_polygon (GimpBlobPoint *points,
gint npoints); gint n_points);
Blob * blob_square (gdouble xc, GimpBlob * gimp_blob_square (gdouble xc,
gdouble yc, gdouble yc,
gdouble xp, gdouble xp,
gdouble yp, gdouble yp,
gdouble xq, gdouble xq,
gdouble yq); gdouble yq);
Blob * blob_diamond (gdouble xc, GimpBlob * gimp_blob_diamond (gdouble xc,
gdouble yc, gdouble yc,
gdouble xp, gdouble xp,
gdouble yp, gdouble yp,
gdouble xq, gdouble xq,
gdouble yq); gdouble yq);
Blob * blob_ellipse (gdouble xc, GimpBlob * gimp_blob_ellipse (gdouble xc,
gdouble yc, gdouble yc,
gdouble xp, gdouble xp,
gdouble yp, gdouble yp,
gdouble xq, gdouble xq,
gdouble yq); gdouble yq);
void blob_bounds (Blob *b, void gimp_blob_bounds (GimpBlob *b,
gint *x, gint *x,
gint *y, gint *y,
gint *width, gint *width,
gint *height); gint *height);
Blob * blob_convex_union (Blob *b1, GimpBlob * gimp_blob_convex_union (GimpBlob *b1,
Blob *b2); GimpBlob *b2);
Blob * blob_duplicate (Blob *b); GimpBlob * gimp_blob_duplicate (GimpBlob *b);
#endif /* __GIMP_INK_BLOB_H__ */ #endif /* __GIMP_INK_BLOB_H__ */

View File

@ -59,7 +59,7 @@ static TempBuf * gimp_ink_get_paint_area (GimpPaintCore *paint_core,
GimpDrawable *drawable, GimpDrawable *drawable,
GimpPaintOptions *paint_options, GimpPaintOptions *paint_options,
const GimpCoords *coords); const GimpCoords *coords);
static GimpUndo* gimp_ink_push_undo (GimpPaintCore *core, static GimpUndo * gimp_ink_push_undo (GimpPaintCore *core,
GimpImage *image, GimpImage *image,
const gchar *undo_desc); const gchar *undo_desc);
@ -69,7 +69,7 @@ static void gimp_ink_motion (GimpPaintCore *paint_core,
const GimpCoords *coords, const GimpCoords *coords,
guint32 time); guint32 time);
static Blob * ink_pen_ellipse (GimpInkOptions *options, static GimpBlob * ink_pen_ellipse (GimpInkOptions *options,
gdouble x_center, gdouble x_center,
gdouble y_center, gdouble y_center,
gdouble pressure, gdouble pressure,
@ -77,7 +77,7 @@ static Blob * ink_pen_ellipse (GimpInkOptions *options,
gdouble ytilt, gdouble ytilt,
gdouble velocity); gdouble velocity);
static void render_blob (Blob *blob, static void render_blob (GimpBlob *blob,
PixelRegion *dest); PixelRegion *dest);
@ -177,7 +177,7 @@ gimp_ink_paint (GimpPaintCore *paint_core,
if (ink->start_blob) if (ink->start_blob)
g_free (ink->start_blob); g_free (ink->start_blob);
ink->start_blob = blob_duplicate (ink->last_blob); ink->start_blob = gimp_blob_duplicate (ink->last_blob);
} }
break; break;
@ -205,7 +205,7 @@ gimp_ink_get_paint_area (GimpPaintCore *paint_core,
bytes = gimp_drawable_bytes_with_alpha (drawable); bytes = gimp_drawable_bytes_with_alpha (drawable);
blob_bounds (ink->cur_blob, &x, &y, &width, &height); gimp_blob_bounds (ink->cur_blob, &x, &y, &width, &height);
dwidth = gimp_item_get_width (GIMP_ITEM (drawable)); dwidth = gimp_item_get_width (GIMP_ITEM (drawable));
dheight = gimp_item_get_height (GIMP_ITEM (drawable)); dheight = gimp_item_get_height (GIMP_ITEM (drawable));
@ -249,8 +249,8 @@ gimp_ink_motion (GimpPaintCore *paint_core,
GimpInkOptions *options = GIMP_INK_OPTIONS (paint_options); GimpInkOptions *options = GIMP_INK_OPTIONS (paint_options);
GimpContext *context = GIMP_CONTEXT (paint_options); GimpContext *context = GIMP_CONTEXT (paint_options);
GimpImage *image; GimpImage *image;
Blob *blob_union = NULL; GimpBlob *blob_union = NULL;
Blob *blob_to_render; GimpBlob *blob_to_render;
TempBuf *area; TempBuf *area;
guchar col[MAX_CHANNELS]; guchar col[MAX_CHANNELS];
PixelRegion blob_maskPR; PixelRegion blob_maskPR;
@ -270,13 +270,13 @@ gimp_ink_motion (GimpPaintCore *paint_core,
if (ink->start_blob) if (ink->start_blob)
g_free (ink->start_blob); g_free (ink->start_blob);
ink->start_blob = blob_duplicate (ink->last_blob); ink->start_blob = gimp_blob_duplicate (ink->last_blob);
blob_to_render = ink->last_blob; blob_to_render = ink->last_blob;
} }
else else
{ {
Blob *blob = ink_pen_ellipse (options, GimpBlob *blob = ink_pen_ellipse (options,
coords->x, coords->x,
coords->y, coords->y,
coords->pressure, coords->pressure,
@ -284,7 +284,7 @@ gimp_ink_motion (GimpPaintCore *paint_core,
coords->ytilt, coords->ytilt,
coords->velocity * 100); coords->velocity * 100);
blob_union = blob_convex_union (ink->last_blob, blob); blob_union = gimp_blob_convex_union (ink->last_blob, blob);
g_free (ink->last_blob); g_free (ink->last_blob);
ink->last_blob = blob; ink->last_blob = blob;
@ -345,7 +345,7 @@ gimp_ink_motion (GimpPaintCore *paint_core,
g_free (blob_union); g_free (blob_union);
} }
static Blob * static GimpBlob *
ink_pen_ellipse (GimpInkOptions *options, ink_pen_ellipse (GimpInkOptions *options,
gdouble x_center, gdouble x_center,
gdouble y_center, gdouble y_center,
@ -354,7 +354,7 @@ ink_pen_ellipse (GimpInkOptions *options,
gdouble ytilt, gdouble ytilt,
gdouble velocity) gdouble velocity)
{ {
BlobFunc blob_function; GimpBlobFunc blob_function;
gdouble size; gdouble size;
gdouble tsin, tcos; gdouble tsin, tcos;
gdouble aspect, radmin; gdouble aspect, radmin;
@ -439,15 +439,15 @@ ink_pen_ellipse (GimpInkOptions *options,
switch (options->blob_type) switch (options->blob_type)
{ {
case GIMP_INK_BLOB_TYPE_CIRCLE: case GIMP_INK_BLOB_TYPE_CIRCLE:
blob_function = blob_ellipse; blob_function = gimp_blob_ellipse;
break; break;
case GIMP_INK_BLOB_TYPE_SQUARE: case GIMP_INK_BLOB_TYPE_SQUARE:
blob_function = blob_square; blob_function = gimp_blob_square;
break; break;
case GIMP_INK_BLOB_TYPE_DIAMOND: case GIMP_INK_BLOB_TYPE_DIAMOND:
blob_function = blob_diamond; blob_function = gimp_blob_diamond;
break; break;
default: default:
@ -533,7 +533,7 @@ fill_run (guchar *dest,
} }
static void static void
render_blob_line (Blob *blob, render_blob_line (GimpBlob *blob,
guchar *dest, guchar *dest,
gint x, gint x,
gint y, gint y,
@ -640,7 +640,7 @@ render_blob_line (Blob *blob,
} }
static void static void
render_blob (Blob *blob, render_blob (GimpBlob *blob,
PixelRegion *dest) PixelRegion *dest)
{ {
gpointer pr; gpointer pr;

View File

@ -37,10 +37,10 @@ struct _GimpInk
{ {
GimpPaintCore parent_instance; GimpPaintCore parent_instance;
Blob *start_blob; /* starting blob (for undo) */ GimpBlob *start_blob; /* starting blob (for undo) */
Blob *cur_blob; /* current blob */ GimpBlob *cur_blob; /* current blob */
Blob *last_blob; /* blob for last cursor position */ GimpBlob *last_blob; /* blob for last cursor position */
}; };
struct _GimpInkClass struct _GimpInkClass

View File

@ -79,7 +79,7 @@ gimp_ink_undo_constructor (GType type,
ink = GIMP_INK (GIMP_PAINT_CORE_UNDO (ink_undo)->paint_core); ink = GIMP_INK (GIMP_PAINT_CORE_UNDO (ink_undo)->paint_core);
if (ink->start_blob) if (ink->start_blob)
ink_undo->last_blob = blob_duplicate (ink->start_blob); ink_undo->last_blob = gimp_blob_duplicate (ink->start_blob);
return object; return object;
} }
@ -96,7 +96,7 @@ gimp_ink_undo_pop (GimpUndo *undo,
if (GIMP_PAINT_CORE_UNDO (ink_undo)->paint_core) if (GIMP_PAINT_CORE_UNDO (ink_undo)->paint_core)
{ {
GimpInk *ink = GIMP_INK (GIMP_PAINT_CORE_UNDO (ink_undo)->paint_core); GimpInk *ink = GIMP_INK (GIMP_PAINT_CORE_UNDO (ink_undo)->paint_core);
Blob *tmp_blob; GimpBlob *tmp_blob;
tmp_blob = ink->last_blob; tmp_blob = ink->last_blob;
ink->last_blob = ink_undo->last_blob; ink->last_blob = ink_undo->last_blob;

View File

@ -36,7 +36,7 @@ struct _GimpInkUndo
{ {
GimpPaintCoreUndo parent_instance; GimpPaintCoreUndo parent_instance;
Blob *last_blob; GimpBlob *last_blob;
}; };
struct _GimpInkUndoClass struct _GimpInkUndoClass

View File

@ -330,22 +330,22 @@ gimp_blob_editor_draw_blob (GimpBlobEditor *editor,
{ {
GtkWidget *widget = GTK_WIDGET (editor); GtkWidget *widget = GTK_WIDGET (editor);
GtkStyle *style = gtk_widget_get_style (widget); GtkStyle *style = gtk_widget_get_style (widget);
Blob *blob; GimpBlob *blob;
BlobFunc function = blob_ellipse; GimpBlobFunc function = gimp_blob_ellipse;
gint i; gint i;
switch (editor->type) switch (editor->type)
{ {
case GIMP_INK_BLOB_TYPE_CIRCLE: case GIMP_INK_BLOB_TYPE_CIRCLE:
function = blob_ellipse; function = gimp_blob_ellipse;
break; break;
case GIMP_INK_BLOB_TYPE_SQUARE: case GIMP_INK_BLOB_TYPE_SQUARE:
function = blob_square; function = gimp_blob_square;
break; break;
case GIMP_INK_BLOB_TYPE_DIAMOND: case GIMP_INK_BLOB_TYPE_DIAMOND:
function = blob_diamond; function = gimp_blob_diamond;
break; break;
} }