Commit dc564954 authored by Michael Natterer's avatar Michael Natterer 😴

app: namespace the ink blob

Blob -> GimpBlob, blob_foo() -> gimp_blob_foo() etc.
parent c4cd420e
......@@ -41,22 +41,22 @@ typedef enum
/* local function prototypes */
static Blob * blob_new (gint y,
gint height);
static void blob_fill (Blob *b,
EdgeType *present);
static void blob_make_convex (Blob *b,
EdgeType *present);
static GimpBlob * gimp_blob_new (gint y,
gint height);
static void gimp_blob_fill (GimpBlob *b,
EdgeType *present);
static void gimp_blob_make_convex (GimpBlob *b,
EdgeType *present);
#if 0
static void blob_line_add_pixel (Blob *b,
gint x,
gint y);
static void blob_line (Blob *b,
gint x0,
gint y0,
gint x1,
gint y1);
static void gimp_blob_line_add_pixel (GimpBlob *b,
gint x,
gint y);
static void gimp_blob_line (GimpBlob *b,
gint x0,
gint y0,
gint x1,
gint y1);
#endif
......@@ -64,11 +64,11 @@ static void blob_line (Blob *b,
/* Return blob for the given (convex) polygon
*/
Blob *
blob_polygon (BlobPoint *points,
gint npoints)
GimpBlob *
gimp_blob_polygon (GimpBlobPoint *points,
gint n_points)
{
Blob *result;
GimpBlob *result;
EdgeType *present;
gint i;
gint im1;
......@@ -78,7 +78,7 @@ blob_polygon (BlobPoint *points,
ymax = 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)
ymax = points[i].y;
......@@ -86,14 +86,14 @@ blob_polygon (BlobPoint *points,
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);
im1 = npoints - 1;
im1 = n_points - 1;
i = 0;
ip1 = 1;
for (; i < npoints ; i++)
for (; i < n_points ; i++)
{
gint sides = 0;
gint j = points[i].y - ymin;
......@@ -136,11 +136,11 @@ blob_polygon (BlobPoint *points,
im1 = i;
ip1++;
if (ip1 == npoints)
if (ip1 == n_points)
ip1 = 0;
}
blob_fill (result, present);
gimp_blob_fill (result, present);
g_free (present);
return result;
......@@ -149,15 +149,15 @@ blob_polygon (BlobPoint *points,
/* Scan convert a square specified by _offsets_ of major and minor
* axes, and by center into a blob
*/
Blob *
blob_square (gdouble xc,
gdouble yc,
gdouble xp,
gdouble yp,
gdouble xq,
gdouble yq)
GimpBlob *
gimp_blob_square (gdouble xc,
gdouble yc,
gdouble xp,
gdouble yp,
gdouble xq,
gdouble yq)
{
BlobPoint points[4];
GimpBlobPoint points[4];
/* Make sure we order points ccw */
......@@ -176,21 +176,21 @@ blob_square (gdouble xc,
points[3].x = xc - xp + xq;
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
* axes, and by center into a blob
*/
Blob *
blob_diamond (gdouble xc,
gdouble yc,
gdouble xp,
gdouble yp,
gdouble xq,
gdouble yq)
GimpBlob *
gimp_blob_diamond (gdouble xc,
gdouble yc,
gdouble xp,
gdouble yp,
gdouble xq,
gdouble yq)
{
BlobPoint points[4];
GimpBlobPoint points[4];
/* Make sure we order points ccw */
......@@ -209,7 +209,7 @@ blob_diamond (gdouble xc,
points[3].x = xc + xq;
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
* minor axes, and by center into a blob
*/
Blob *
blob_ellipse (gdouble xc,
gdouble yc,
gdouble xp,
gdouble yp,
gdouble xq,
gdouble yq)
GimpBlob *
gimp_blob_ellipse (gdouble xc,
gdouble yc,
gdouble xp,
gdouble yp,
gdouble xq,
gdouble yq)
{
Blob *result;
GimpBlob *result;
EdgeType *present;
gint i;
gdouble r1, r2;
......@@ -282,7 +282,7 @@ blob_ellipse (gdouble xc,
maxy = ceil (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);
/* Figure out a step that will draw most of the points */
......@@ -345,18 +345,18 @@ blob_ellipse (gdouble xc,
/* Now fill in missing points */
blob_fill (result, present);
gimp_blob_fill (result, present);
g_free (present);
return result;
}
void
blob_bounds (Blob *b,
gint *x,
gint *y,
gint *width,
gint *height)
gimp_blob_bounds (GimpBlob *b,
gint *x,
gint *y,
gint *width,
gint *height)
{
gint i;
gint x0, x1, y0, y1;
......@@ -392,11 +392,11 @@ blob_bounds (Blob *b,
*height = y1 - y0;
}
Blob *
blob_convex_union (Blob *b1,
Blob *b2)
GimpBlob *
gimp_blob_convex_union (GimpBlob *b1,
GimpBlob *b2)
{
Blob *result;
GimpBlob *result;
gint y;
gint i, j;
EdgeType *present;
......@@ -404,7 +404,7 @@ blob_convex_union (Blob *b1,
/* Create the storage for the result */
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)
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);
return result;
}
Blob *
blob_duplicate (Blob *b)
GimpBlob *
gimp_blob_duplicate (GimpBlob *b)
{
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
void
blob_dump (Blob *b)
gimp_blob_dump (GimpBlob *b)
{
gint i,j;
......@@ -480,13 +480,13 @@ blob_dump (Blob *b)
/* private functions */
static Blob *
blob_new (gint y,
gint height)
static GimpBlob *
gimp_blob_new (gint y,
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->height = height;
......@@ -495,8 +495,8 @@ blob_new (gint y,
}
static void
blob_fill (Blob *b,
EdgeType *present)
gimp_blob_fill (GimpBlob *b,
EdgeType *present)
{
gint start;
gint x1, x2, i1, i2;
......@@ -656,8 +656,8 @@ blob_fill (Blob *b,
}
static void
blob_make_convex (Blob *b,
EdgeType *present)
gimp_blob_make_convex (GimpBlob *b,
EdgeType *present)
{
gint x1, x2, y1, y2, i1, i2;
gint i;
......@@ -752,16 +752,16 @@ blob_make_convex (Blob *b,
i2 = i;
}
blob_fill (b, present);
gimp_blob_fill (b, present);
}
#if 0
static void
blob_line_add_pixel (Blob *b,
gint x,
gint y)
gimp_blob_line_add_pixel (GimpBlob *b,
gint x,
gint y)
{
if (b->data[y - b->y].left > b->data[y - b->y].right)
{
......@@ -775,11 +775,11 @@ blob_line_add_pixel (Blob *b,
}
static void
blob_line (Blob *b,
gint x0,
gint y0,
gint x1,
gint y1)
gimp_blob_line (GimpBlob *b,
gint x0,
gint y0,
gint x1,
gint y1)
{
gint dx, dy, d;
gint incrE, incrNE;
......@@ -818,7 +818,7 @@ blob_line (Blob *b,
incrE = 2 * dy; /* increment used for move to E */
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)
{
......@@ -834,7 +834,7 @@ blob_line (Blob *b,
y += ystep;
}
blob_line_add_pixel (b, x, y);
gimp_blob_line_add_pixel (b, x, y);
}
}
else
......@@ -843,7 +843,7 @@ blob_line (Blob *b,
incrE = 2 * dx; /* increment used for move to E */
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)
{
......@@ -859,7 +859,7 @@ blob_line (Blob *b,
y += ystep;
}
blob_line_add_pixel (b, x, y);
gimp_blob_line_add_pixel (b, x, y);
}
}
}
......
......@@ -25,65 +25,65 @@
#define __GIMP_INK_BLOB_H__
typedef struct _BlobPoint BlobPoint;
typedef struct _BlobSpan BlobSpan;
typedef struct _Blob Blob;
typedef struct _GimpBlobPoint GimpBlobPoint;
typedef struct _GimpBlobSpan GimpBlobSpan;
typedef struct _GimpBlob GimpBlob;
typedef Blob * (* BlobFunc) (gdouble xc,
gdouble yc,
gdouble xp,
gdouble yp,
gdouble xq,
gdouble yq);
typedef GimpBlob * (* GimpBlobFunc) (gdouble xc,
gdouble yc,
gdouble xp,
gdouble yp,
gdouble xq,
gdouble yq);
struct _BlobPoint
struct _GimpBlobPoint
{
gint x;
gint y;
};
struct _BlobSpan
struct _GimpBlobSpan
{
gint left;
gint right;
};
struct _Blob
struct _GimpBlob
{
gint y;
gint height;
BlobSpan data[1];
GimpBlobSpan data[1];
};
Blob * blob_polygon (BlobPoint *points,
gint npoints);
Blob * blob_square (gdouble xc,
gdouble yc,
gdouble xp,
gdouble yp,
gdouble xq,
gdouble yq);
Blob * blob_diamond (gdouble xc,
gdouble yc,
gdouble xp,
gdouble yp,
gdouble xq,
gdouble yq);
Blob * blob_ellipse (gdouble xc,
gdouble yc,
gdouble xp,
gdouble yp,
gdouble xq,
gdouble yq);
void blob_bounds (Blob *b,
gint *x,
gint *y,
gint *width,
gint *height);
Blob * blob_convex_union (Blob *b1,
Blob *b2);
Blob * blob_duplicate (Blob *b);
GimpBlob * gimp_blob_polygon (GimpBlobPoint *points,
gint n_points);
GimpBlob * gimp_blob_square (gdouble xc,
gdouble yc,
gdouble xp,
gdouble yp,
gdouble xq,
gdouble yq);
GimpBlob * gimp_blob_diamond (gdouble xc,
gdouble yc,
gdouble xp,
gdouble yp,
gdouble xq,
gdouble yq);
GimpBlob * gimp_blob_ellipse (gdouble xc,
gdouble yc,
gdouble xp,
gdouble yp,
gdouble xq,
gdouble yq);
void gimp_blob_bounds (GimpBlob *b,
gint *x,
gint *y,
gint *width,
gint *height);
GimpBlob * gimp_blob_convex_union (GimpBlob *b1,
GimpBlob *b2);
GimpBlob * gimp_blob_duplicate (GimpBlob *b);
#endif /* __GIMP_INK_BLOB_H__ */
......@@ -47,38 +47,38 @@
/* local function prototypes */
static void gimp_ink_finalize (GObject *object);
static void gimp_ink_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
const GimpCoords *coords,
GimpPaintState paint_state,
guint32 time);
static TempBuf * gimp_ink_get_paint_area (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
const GimpCoords *coords);
static GimpUndo* gimp_ink_push_undo (GimpPaintCore *core,
GimpImage *image,
const gchar *undo_desc);
static void gimp_ink_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
const GimpCoords *coords,
guint32 time);
static Blob * ink_pen_ellipse (GimpInkOptions *options,
gdouble x_center,
gdouble y_center,
gdouble pressure,
gdouble xtilt,
gdouble ytilt,
gdouble velocity);
static void render_blob (Blob *blob,
PixelRegion *dest);
static void gimp_ink_finalize (GObject *object);
static void gimp_ink_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
const GimpCoords *coords,
GimpPaintState paint_state,
guint32 time);
static TempBuf * gimp_ink_get_paint_area (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
const GimpCoords *coords);
static GimpUndo * gimp_ink_push_undo (GimpPaintCore *core,
GimpImage *image,
const gchar *undo_desc);
static void gimp_ink_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
const GimpCoords *coords,
guint32 time);
static GimpBlob * ink_pen_ellipse (GimpInkOptions *options,
gdouble x_center,
gdouble y_center,
gdouble pressure,
gdouble xtilt,
gdouble ytilt,
gdouble velocity);
static void render_blob (GimpBlob *blob,
PixelRegion *dest);
G_DEFINE_TYPE (GimpInk, gimp_ink, GIMP_TYPE_PAINT_CORE)
......@@ -177,7 +177,7 @@ gimp_ink_paint (GimpPaintCore *paint_core,
if (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;
......@@ -205,7 +205,7 @@ gimp_ink_get_paint_area (GimpPaintCore *paint_core,
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));
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);
GimpContext *context = GIMP_CONTEXT (paint_options);
GimpImage *image;
Blob *blob_union = NULL;
Blob *blob_to_render;
GimpBlob *blob_union = NULL;
GimpBlob *blob_to_render;
TempBuf *area;
guchar col[MAX_CHANNELS];
PixelRegion blob_maskPR;
......@@ -270,21 +270,21 @@ gimp_ink_motion (GimpPaintCore *paint_core,
if (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;
}
else
{
Blob *blob = ink_pen_ellipse (options,
coords->x,
coords->y,
coords->pressure,
coords->xtilt,
coords->ytilt,
coords->velocity * 100);
GimpBlob *blob = ink_pen_ellipse (options,
coords->x,
coords->y,
coords->pressure,
coords->xtilt,
coords->ytilt,
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);
ink->last_blob = blob;
......@@ -345,7 +345,7 @@ gimp_ink_motion (GimpPaintCore *paint_core,
g_free (blob_union);
}
static Blob *
static GimpBlob *
ink_pen_ellipse (GimpInkOptions *options,
gdouble x_center,
gdouble y_center,
......@@ -354,14 +354,14 @@ ink_pen_ellipse (GimpInkOptions *options,
gdouble ytilt,
gdouble velocity)
{
BlobFunc blob_function;
gdouble size;
gdouble tsin, tcos;
gdouble aspect, radmin;
gdouble x,y;
gdouble tscale;
gdouble tscale_c;
gdouble tscale_s;
GimpBlobFunc blob_function;
gdouble size;
gdouble tsin, tcos;
gdouble aspect, radmin;
gdouble x,y;
gdouble tscale;
gdouble tscale_c;
gdouble tscale_s;
/* Adjust the size depending on pressure. */
......@@ -439,15 +439,15 @@ ink_pen_ellipse (GimpInkOptions *options,
switch (options->blob_type)
{
case GIMP_INK_BLOB_TYPE_CIRCLE:
blob_function = blob_ellipse;
blob_function = gimp_blob_ellipse;
break;
case GIMP_INK_BLOB_TYPE_SQUARE:
blob_function = blob_square;
blob_function = gimp_blob_square;
break;
case GIMP_INK_BLOB_TYPE_DIAMOND:
blob_function = blob_diamond;
blob_function = gimp_blob_diamond;
break;
default:
......@@ -533,11 +533,11 @@ fill_run (guchar *dest,
}
static void
render_blob_line (Blob *blob,
guchar *dest,
gint x,
gint y,
gint width)
render_blob_line (GimpBlob *blob,
guchar *dest,
gint x,
gint y,
gint width)
{
gint buf[4 * SUBSAMPLE];
gint *data = buf;
......@@ -640,7 +640,7 @@ render_blob_line (Blob *blob,
}
static void
render_blob (Blob *blob,
render_blob (GimpBlob *blob,
PixelRegion *dest)
{
gpointer pr;
......
......@@ -37,10 +37,10 @@ struct _GimpInk
{
GimpPaintCore parent_instance;
Blob *start_blob; /* starting blob (for undo) */
GimpBlob *start_blob; /* starting blob (for undo) */
Blob *cur_blob; /* current blob */
Blob *last_blob; /* blob for last cursor position */
GimpBlob *cur_blob; /* current blob */
GimpBlob *last_blob; /* blob for last cursor position */
};
struct _GimpInkClass
......
......@@ -79,7 +79,7 @@ gimp_ink_undo_constructor (GType type,
ink = GIMP_INK (GIMP_PAINT_CORE_UNDO (ink_undo)->paint_core);
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;
}
......@@ -95,8 +95,8 @@ gimp_ink_undo_pop (GimpUndo *undo,
if (GIMP_PAINT_CORE_UNDO (ink_undo)->paint_core)
{
GimpInk *ink = GIMP_INK (GIMP_PAINT_CORE_UNDO (ink_undo)->paint_core);
Blob *tmp_blob;
GimpInk *ink = GIMP_INK (GIMP_PAINT_CORE_UNDO (ink_undo)->paint_core);
GimpBlob *tmp_blob;
tmp_blob = ink->last_blob;
ink->last_blob = ink_undo->last_blob;
......
......@@ -36,7 +36,7 @@ struct _GimpInkUndo
{
GimpPaintCoreUndo parent_instance;
Blob *last_blob;
GimpBlob *last_blob;
};
struct _GimpInkUndoClass
......
......@@ -328,24 +328,24 @@ gimp_blob_editor_draw_blob (GimpBlobEditor *editor,
gdouble yc,
gdouble radius)
{
GtkWidget *widget = GTK_WIDGET (editor);
GtkStyle *style = gtk_widget_get_style (widget);
Blob *blob;
BlobFunc function = blob_ellipse;
gint i;
GtkWidget *widget = GTK_WIDGET (editor);
GtkStyle *style = gtk_widget_get_style (widget);
GimpBlob *blob;
GimpBlobFunc function = gimp_blob_ellipse;
gint i;