Commit b9211077 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

added progress callback.

2004-06-13  Sven Neumann  <sven@gimp.org>

	* app/paint-funcs/paint-funcs.[ch] (shapeburst_region): added
	progress callback.

	* app/core/gimpdrawable-blend.c: show a progress while calculating
	the Shapeburst. Not perfect but better than not showing any
	progress at all.
parent 2498adc5
2004-06-13 Sven Neumann <sven@gimp.org>
* app/paint-funcs/paint-funcs.[ch] (shapeburst_region): added
progress callback.
* app/core/gimpdrawable-blend.c: show a progress while calculating
the Shapeburst. Not perfect but better than not showing any
progress at all.
2004-06-13 Michael Natterer <mitch@gimp.org>
* app/widgets/widgets-enums.[ch]: added enum GimpCursorFormat
......
......@@ -113,10 +113,12 @@ static gdouble gradient_calc_shapeburst_spherical_factor (gdouble x,
static gdouble gradient_calc_shapeburst_dimpled_factor (gdouble x,
gdouble y);
static void gradient_precalc_shapeburst (GimpImage *gimage,
GimpDrawable *drawable,
PixelRegion *PR,
gdouble dist);
static void gradient_precalc_shapeburst (GimpImage *gimage,
GimpDrawable *drawable,
PixelRegion *PR,
gdouble dist,
GimpProgressFunc progress_callback,
gpointer progress_data);
static void gradient_render_pixel (gdouble x,
gdouble y,
......@@ -570,10 +572,12 @@ gradient_calc_shapeburst_dimpled_factor (gdouble x,
}
static void
gradient_precalc_shapeburst (GimpImage *gimage,
GimpDrawable *drawable,
PixelRegion *PR,
gdouble dist)
gradient_precalc_shapeburst (GimpImage *gimage,
GimpDrawable *drawable,
PixelRegion *PR,
gdouble dist,
GimpProgressFunc progress_callback,
gpointer progress_data)
{
GimpChannel *mask;
PixelRegion tempR;
......@@ -630,7 +634,7 @@ gradient_precalc_shapeburst (GimpImage *gimage,
pixel_region_init (&tempR, tempR.tiles, 0, 0, PR->w, PR->h, TRUE);
pixel_region_init (&distR, distR.tiles, 0, 0, PR->w, PR->h, TRUE);
max_iteration = shapeburst_region (&tempR, &distR);
max_iteration = shapeburst_region (&tempR, &distR, progress_callback, progress_data);
/* normalize the shapeburst with the max iteration */
if (max_iteration > 0)
......@@ -982,7 +986,8 @@ gradient_fill_region (GimpImage *gimage,
case GIMP_GRADIENT_SHAPEBURST_SPHERICAL:
case GIMP_GRADIENT_SHAPEBURST_DIMPLED:
rbd.dist = sqrt (SQR (ex - sx) + SQR (ey - sy));
gradient_precalc_shapeburst (gimage, drawable, PR, rbd.dist);
gradient_precalc_shapeburst (gimage, drawable, PR, rbd.dist,
progress_callback, progress_data);
break;
default:
......
......@@ -3502,36 +3502,37 @@ subsample_region (PixelRegion *srcPR,
gfloat
shapeburst_region (PixelRegion *srcPR,
PixelRegion *distPR)
shapeburst_region (PixelRegion *srcPR,
PixelRegion *distPR,
GimpProgressFunc progress_callback,
gpointer progress_data)
{
Tile *tile;
Tile *tile;
guchar *tile_data;
gfloat max_iterations;
gfloat max_iterations = 0.0;
gfloat *distp_cur;
gfloat *distp_prev;
gfloat *memory;
gfloat *tmp;
gfloat min_prev;
gfloat float_tmp;
gint min;
gint min_left;
gint length;
gint i, j, k;
gint src;
gint fraction;
gint prev_frac;
gint x, y;
gint end;
gint boundary;
gint inc;
src = 0;
max_iterations = 0.0;
gfloat min_prev;
gfloat float_tmp;
gint min;
gint min_left;
gint length;
gint i, j, k;
gint fraction;
gint prev_frac;
gint x, y;
gint end;
gint boundary;
gint inc;
gint src = 0;
gint max_progress = srcPR->w * srcPR->h;
gint progress = 0;
length = distPR->w + 1;
memory = g_new (gfloat, length * 2);
distp_prev = memory;
for (i = 0; i < length; i++)
distp_prev[i] = 0.0;
......@@ -3542,13 +3543,13 @@ shapeburst_region (PixelRegion *srcPR,
for (i = 0; i < srcPR->h; i++)
{
/* set the current dist row to 0's */
memset(distp_cur - 1, 0, sizeof (gfloat) * (length - 1));
memset (distp_cur - 1, 0, sizeof (gfloat) * (length - 1));
for (j = 0; j < srcPR->w; j++)
{
min_prev = MIN (distp_cur[j-1], distp_prev[j]);
min_left = MIN ((srcPR->w - j - 1), (srcPR->h - i - 1));
min = (int) MIN (min_left, min_prev);
min = (gint) MIN (min_left, min_prev);
fraction = 255;
/* This might need to be changed to 0 instead of k = (min) ? (min - 1) : 0 */
......@@ -3619,9 +3620,16 @@ shapeburst_region (PixelRegion *srcPR,
tmp = distp_prev;
distp_prev = distp_cur;
distp_cur = tmp;
if (progress_callback)
{
progress += srcPR->h;
(* progress_callback) (0, max_progress, progress, progress_data);
}
}
g_free (memory);
return max_iterations;
}
......
......@@ -377,8 +377,10 @@ void subsample_region (PixelRegion *srcPR,
PixelRegion *destPR,
gint subsample);
gfloat shapeburst_region (PixelRegion *srcPR,
PixelRegion *distPR);
gfloat shapeburst_region (PixelRegion *srcPR,
PixelRegion *distPR,
GimpProgressFunc progress_callback,
gpointer progress_data);
void thin_region (PixelRegion *src,
gint16 xradius,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment