instead of iterating over tiles manually and using write_pixel_data_1() to

2008-08-24  Sven Neumann  <sven@gimp.org>

	* app/paint-funcs/scale-region.c: instead of iterating over 
tiles
	manually and using write_pixel_data_1() to write the data, use
	pixel_region_process() to iterate over the destination.


svn path=/trunk/; revision=26735
This commit is contained in:
Sven Neumann
2008-08-23 23:59:09 +00:00
committed by Sven Neumann
parent bb61099be5
commit 510e21219f
2 changed files with 78 additions and 77 deletions

View File

@ -1,3 +1,9 @@
2008-08-24 Sven Neumann <sven@gimp.org>
* app/paint-funcs/scale-region.c: instead of iterating over tiles
manually and using write_pixel_data_1() to write the data, use
pixel_region_process() to iterate over the destination.
2008-08-24 Sven Neumann <sven@gimp.org> 2008-08-24 Sven Neumann <sven@gimp.org>
* app/paint-funcs/scale-region.c: added more const qualifiers. * app/paint-funcs/scale-region.c: added more const qualifiers.

View File

@ -494,17 +494,14 @@ scale (TileManager *srcTM,
gint *progress, gint *progress,
gint max_progress) gint max_progress)
{ {
PixelRegion region;
const guint src_width = tile_manager_width (srcTM); const guint src_width = tile_manager_width (srcTM);
const guint src_height = tile_manager_height (srcTM); const guint src_height = tile_manager_height (srcTM);
const guint dst_width = tile_manager_width (dstTM); const guint dst_width = tile_manager_width (dstTM);
const guint dst_height = tile_manager_height (dstTM); const guint dst_height = tile_manager_height (dstTM);
const guint dst_tilerows = tile_manager_tiles_per_row (dstTM); /* the number of tiles in each row */
const guint dst_tilecols = tile_manager_tiles_per_col (dstTM); /* the number of tiles in each columns */
const gdouble scaley = (gdouble) dst_height / (gdouble) src_height; const gdouble scaley = (gdouble) dst_height / (gdouble) src_height;
const gdouble scalex = (gdouble) dst_width / (gdouble) src_width; const gdouble scalex = (gdouble) dst_width / (gdouble) src_width;
gint col, row; gpointer pr;
guchar pixel[4];
gfloat *kernel_lookup = NULL; gfloat *kernel_lookup = NULL;
/* fall back if not enough pixels available */ /* fall back if not enough pixels available */
@ -525,23 +522,20 @@ scale (TileManager *srcTM,
if (interpolation == GIMP_INTERPOLATION_LANCZOS) if (interpolation == GIMP_INTERPOLATION_LANCZOS)
kernel_lookup = create_lanczos3_lookup (); kernel_lookup = create_lanczos3_lookup ();
for (row = 0; row < dst_tilerows; row++) pixel_region_init (&region, dstTM, 0, 0, dst_width, dst_height, TRUE);
for (pr = pixel_regions_register (1, &region);
pr != NULL;
pr = pixel_regions_process (pr))
{ {
for (col = 0; col < dst_tilecols; col++) const gint x1 = region.x + region.w;
{ const gint y1 = region.y + region.h;
Tile *dst_tile = tile_manager_get_at (dstTM, guchar *row = region.data;
col, row,
FALSE, FALSE);
const guint dst_ewidth = tile_ewidth (dst_tile);
const guint dst_eheight = tile_eheight (dst_tile);
const gint x0 = col * TILE_WIDTH;
const gint y0 = row * TILE_HEIGHT;
const gint x1 = x0 + dst_ewidth;
const gint y1 = y0 + dst_eheight;
gint y; gint y;
for (y = y0; y < y1; y++) for (y = region.y; y < y1; y++)
{ {
guchar *pixel = row;
gdouble yfrac = y / scaley; gdouble yfrac = y / scaley;
gint sy0 = (gint) yfrac; gint sy0 = (gint) yfrac;
gint sy1 = sy0 + 1; gint sy1 = sy0 + 1;
@ -554,7 +548,7 @@ scale (TileManager *srcTM,
yfrac = yfrac - sy0; yfrac = yfrac - sy0;
for (x = x0; x < x1; x++) for (x = region.x; x < x1; x++)
{ {
gdouble xfrac = x / scalex; gdouble xfrac = x / scalex;
gint sx0 = (gint) xfrac; gint sx0 = (gint) xfrac;
@ -600,14 +594,15 @@ scale (TileManager *srcTM,
break; break;
} }
write_pixel_data_1 (dstTM, x, y, pixel); pixel += region.bytes;
} }
row += region.rowstride;
} }
if (progress_callback) if (progress_callback)
progress_callback (0, max_progress, ((*progress)++), progress_data); progress_callback (0, max_progress, ((*progress)++), progress_data);
} }
}
if (interpolation == GIMP_INTERPOLATION_LANCZOS) if (interpolation == GIMP_INTERPOLATION_LANCZOS)
g_free (kernel_lookup); g_free (kernel_lookup);