code cleanup; reduced number of progress updates.

2007-12-17  Sven Neumann  <sven@gimp.org>

	* libgimp/gimpregioniterator.c: code cleanup; reduced number of
	progress updates.

svn path=/trunk/; revision=24381
This commit is contained in:
Sven Neumann 2007-12-17 09:16:21 +00:00 committed by Sven Neumann
parent 12859122c6
commit 0c389448fa
2 changed files with 55 additions and 46 deletions

View File

@ -1,3 +1,8 @@
2007-12-17 Sven Neumann <sven@gimp.org>
* libgimp/gimpregioniterator.c: code cleanup; reduced number of
progress updates.
2007-12-16 Bill Skaggs <weskaggs@primate.udavis.edu>
* plug-ins/common/edge.c: name reverted to "Edge",

View File

@ -43,7 +43,7 @@ static void gimp_rgn_iterator_iter_single (GimpRgnIterator *iter,
GimpPixelRgn *srcPR,
GimpRgnFuncSrc func,
gpointer data);
static void gimp_rgn_render_row (guchar *src,
static void gimp_rgn_render_row (const guchar *src,
guchar *dest,
gint col,
gint bpp,
@ -123,6 +123,7 @@ gimp_rgn_iterator_src_dest (GimpRgnIterator *iter,
GimpPixelRgn srcPR, destPR;
gint x1, y1, x2, y2;
gint bpp;
gint count;
gpointer pr;
gint total_area;
gint area_so_far;
@ -144,23 +145,24 @@ gimp_rgn_iterator_src_dest (GimpRgnIterator *iter,
bpp = srcPR.bpp;
for (pr = gimp_pixel_rgns_register (2, &srcPR, &destPR);
for (pr = gimp_pixel_rgns_register (2, &srcPR, &destPR), count = 0;
pr != NULL;
pr = gimp_pixel_rgns_process (pr))
pr = gimp_pixel_rgns_process (pr), count++)
{
const guchar *src = srcPR.data;
guchar *dest = destPR.data;
gint y;
guchar* src = srcPR.data;
guchar* dest = destPR.data;
for (y = srcPR.y; y < srcPR.y + srcPR.h; y++)
{
gint x;
guchar *s = src;
const guchar *s = src;
guchar *d = dest;
gint x;
for (x = srcPR.x; x < srcPR.x + srcPR.w; x++)
{
func (x, y, s, d, bpp, data);
s += bpp;
d += bpp;
}
@ -170,6 +172,8 @@ gimp_rgn_iterator_src_dest (GimpRgnIterator *iter,
}
area_so_far += srcPR.w * srcPR.h;
if ((count % 8) == 0)
gimp_progress_update ((gdouble) area_so_far / (gdouble) total_area);
}
@ -214,33 +218,31 @@ gimp_rgn_iterate1 (GimpDrawable *drawable,
gpointer pr;
gint total_area;
gint area_so_far;
gint progress_skip;
gint count;
g_return_if_fail (drawable != NULL);
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
total_area = (x2 - x1) * (y2 - y1);
area_so_far = 0;
if (total_area <= 0)
return;
area_so_far = 0;
progress_skip = 0;
gimp_pixel_rgn_init (&srcPR, drawable,
x1, y1, (x2 - x1), (y2 - y1), FALSE, FALSE);
for (pr = gimp_pixel_rgns_register (1, &srcPR);
for (pr = gimp_pixel_rgns_register (1, &srcPR), count = 0;
pr != NULL;
pr = gimp_pixel_rgns_process (pr))
pr = gimp_pixel_rgns_process (pr), count++)
{
guchar *src = srcPR.data;
const guchar *src = srcPR.data;
gint y;
for (y = 0; y < srcPR.h; y++)
{
guchar *s = src;
const guchar *s = src;
gint x;
for (x = 0; x < srcPR.w; x++)
@ -254,7 +256,7 @@ gimp_rgn_iterate1 (GimpDrawable *drawable,
area_so_far += srcPR.w * srcPR.h;
if (((progress_skip++) % 10) == 0)
if ((count % 8) == 0)
gimp_progress_update ((gdouble) area_so_far / (gdouble) total_area);
}
}
@ -270,35 +272,33 @@ gimp_rgn_iterate2 (GimpDrawable *drawable,
gpointer pr;
gint total_area;
gint area_so_far;
gint progress_skip;
gint count;
g_return_if_fail (drawable != NULL);
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
total_area = (x2 - x1) * (y2 - y1);
area_so_far = 0;
if (total_area <= 0)
return;
area_so_far = 0;
progress_skip = 0;
/* Initialize the pixel regions. */
gimp_pixel_rgn_init (&srcPR, drawable, x1, y1, (x2 - x1), (y2 - y1),
FALSE, FALSE);
gimp_pixel_rgn_init (&destPR, drawable, x1, y1, (x2 - x1), (y2 - y1),
TRUE, TRUE);
for (pr = gimp_pixel_rgns_register (2, &srcPR, &destPR);
for (pr = gimp_pixel_rgns_register (2, &srcPR, &destPR), count = 0;
pr != NULL;
pr = gimp_pixel_rgns_process (pr))
pr = gimp_pixel_rgns_process (pr), count++)
{
gimp_rgn_render_region (&srcPR, &destPR, func, data);
area_so_far += srcPR.w * srcPR.h;
if (((progress_skip++) % 10) == 0)
if ((count % 8) == 0)
gimp_progress_update ((gdouble) area_so_far / (gdouble) total_area);
}
@ -317,20 +317,21 @@ gimp_rgn_iterator_iter_single (GimpRgnIterator *iter,
gpointer pr;
gint total_area;
gint area_so_far;
gint count;
total_area = (iter->x2 - iter->x1) * (iter->y2 - iter->y1);
area_so_far = 0;
for (pr = gimp_pixel_rgns_register (1, srcPR);
for (pr = gimp_pixel_rgns_register (1, srcPR), count = 0;
pr != NULL;
pr = gimp_pixel_rgns_process (pr))
pr = gimp_pixel_rgns_process (pr), count++)
{
guchar *src = srcPR->data;
const guchar *src = srcPR->data;
gint y;
for (y = srcPR->y; y < srcPR->y + srcPR->h; y++)
{
guchar *s = src;
const guchar *s = src;
gint x;
for (x = srcPR->x; x < srcPR->x + srcPR->w; x++)
@ -343,12 +344,14 @@ gimp_rgn_iterator_iter_single (GimpRgnIterator *iter,
}
area_so_far += srcPR->w * srcPR->h;
if ((count % 8) == 0)
gimp_progress_update ((gdouble) area_so_far / (gdouble) total_area);
}
}
static void
gimp_rgn_render_row (guchar *src,
gimp_rgn_render_row (const guchar *src,
guchar *dest,
gint col, /* row width in pixels */
gint bpp,
@ -358,6 +361,7 @@ gimp_rgn_render_row (guchar *src,
while (col--)
{
func (src, dest, bpp, data);
src += bpp;
dest += bpp;
}
@ -369,7 +373,7 @@ gimp_rgn_render_region (const GimpPixelRgn *srcPR,
GimpRgnFunc2 func,
gpointer data)
{
guchar *src = srcPR->data;
const guchar *src = srcPR->data;
guchar *dest = destPR->data;
gint row;