----------------------------------------------------------------------
---------------------------------------------------------------------- Modified Files: ChangeLog app/pixel_region.c Optimized pixel_region_{get,set}_{row,col} ----------------------------------------------------------------------
This commit is contained in:
@ -1,3 +1,8 @@
|
|||||||
|
Sat Jul 25 04:11:31 PDT 1998 Jay Cox <jaycox@earthlink.net>
|
||||||
|
|
||||||
|
* app/pixel_region.c: optimized pixel_region_[gs]et_row,
|
||||||
|
minor optimization to pixel_region_[gs]et_col
|
||||||
|
|
||||||
Sat Jul 25 11:09:58 BST 1998 Adam D. Moss <adam@gimp.org>
|
Sat Jul 25 11:09:58 BST 1998 Adam D. Moss <adam@gimp.org>
|
||||||
|
|
||||||
* app/convert.c: Convert-to-indexed now remembers the last
|
* app/convert.c: Convert-to-indexed now remembers the last
|
||||||
|
@ -135,6 +135,7 @@ pixel_region_get_row (PR, x, y, w, data, subsample)
|
|||||||
int end;
|
int end;
|
||||||
int boundary;
|
int boundary;
|
||||||
int b;
|
int b;
|
||||||
|
int npixels;
|
||||||
|
|
||||||
end = x + w;
|
end = x + w;
|
||||||
|
|
||||||
@ -144,16 +145,28 @@ pixel_region_get_row (PR, x, y, w, data, subsample)
|
|||||||
{
|
{
|
||||||
tile = tile_manager_get_tile (PR->tiles, x, y, 0, TRUE, FALSE);
|
tile = tile_manager_get_tile (PR->tiles, x, y, 0, TRUE, FALSE);
|
||||||
tile_data = tile->data + tile->bpp * (tile->ewidth * (y % TILE_HEIGHT) + (x % TILE_WIDTH));
|
tile_data = tile->data + tile->bpp * (tile->ewidth * (y % TILE_HEIGHT) + (x % TILE_WIDTH));
|
||||||
boundary = x + (tile->ewidth - (x % TILE_WIDTH));
|
npixels = tile->ewidth - (x % TILE_WIDTH);
|
||||||
inc = subsample * tile->bpp;
|
|
||||||
|
|
||||||
for ( ; x < end && x < boundary; x += subsample)
|
if ((x + npixels) > end) /* make sure we don't write past the end */
|
||||||
|
npixels = end - x;
|
||||||
|
|
||||||
|
if (subsample == 1) /* optimize for the common case */
|
||||||
|
{
|
||||||
|
memcpy(data, tile_data, tile->bpp*npixels);
|
||||||
|
data += tile->bpp*npixels;
|
||||||
|
x += npixels;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
boundary = x + npixels;
|
||||||
|
inc = subsample * tile->bpp;
|
||||||
|
for ( ; x < boundary; x += subsample)
|
||||||
{
|
{
|
||||||
for (b = 0; b < tile->bpp; b++)
|
for (b = 0; b < tile->bpp; b++)
|
||||||
*data++ = tile_data[b];
|
*data++ = tile_data[b];
|
||||||
tile_data += inc;
|
tile_data += inc;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
tile_release (tile, FALSE);
|
tile_release (tile, FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -169,8 +182,7 @@ pixel_region_set_row (PR, x, y, w, data)
|
|||||||
Tile *tile;
|
Tile *tile;
|
||||||
unsigned char *tile_data;
|
unsigned char *tile_data;
|
||||||
int end;
|
int end;
|
||||||
int boundary;
|
int npixels;
|
||||||
int b;
|
|
||||||
|
|
||||||
end = x + w;
|
end = x + w;
|
||||||
|
|
||||||
@ -180,13 +192,16 @@ pixel_region_set_row (PR, x, y, w, data)
|
|||||||
{
|
{
|
||||||
tile = tile_manager_get_tile (PR->tiles, x, y, 0, TRUE, TRUE);
|
tile = tile_manager_get_tile (PR->tiles, x, y, 0, TRUE, TRUE);
|
||||||
tile_data = tile->data + tile->bpp * (tile->ewidth * (y % TILE_HEIGHT) + (x % TILE_WIDTH));
|
tile_data = tile->data + tile->bpp * (tile->ewidth * (y % TILE_HEIGHT) + (x % TILE_WIDTH));
|
||||||
boundary = x + (tile->ewidth - (x % TILE_WIDTH));
|
|
||||||
|
|
||||||
for ( ; x < end && x < boundary; x++)
|
npixels = tile->ewidth - (x % TILE_WIDTH);
|
||||||
{
|
|
||||||
for (b = 0; b < tile->bpp; b++)
|
if ((x + npixels) > end) /* make sure we don't write past the end */
|
||||||
*tile_data++ = *data++;
|
npixels = end - x;
|
||||||
}
|
|
||||||
|
memcpy(tile_data, data, tile->bpp*npixels);
|
||||||
|
|
||||||
|
data += tile->bpp*npixels;
|
||||||
|
x += npixels;
|
||||||
|
|
||||||
tile_release (tile, TRUE);
|
tile_release (tile, TRUE);
|
||||||
}
|
}
|
||||||
@ -217,9 +232,12 @@ pixel_region_get_col (PR, x, y, h, data, subsample)
|
|||||||
tile = tile_manager_get_tile (PR->tiles, x, y, 0, TRUE, FALSE);
|
tile = tile_manager_get_tile (PR->tiles, x, y, 0, TRUE, FALSE);
|
||||||
tile_data = tile->data + tile->bpp * (tile->ewidth * (y % TILE_HEIGHT) + (x % TILE_WIDTH));
|
tile_data = tile->data + tile->bpp * (tile->ewidth * (y % TILE_HEIGHT) + (x % TILE_WIDTH));
|
||||||
boundary = y + (tile->eheight - (y % TILE_HEIGHT));
|
boundary = y + (tile->eheight - (y % TILE_HEIGHT));
|
||||||
|
if (boundary > end) /* make sure we don't write past the end */
|
||||||
|
boundary = end;
|
||||||
|
|
||||||
inc = subsample * tile->bpp * tile->ewidth;
|
inc = subsample * tile->bpp * tile->ewidth;
|
||||||
|
|
||||||
for ( ; y < end && y < boundary; y += subsample)
|
for ( ; y < boundary; y += subsample)
|
||||||
{
|
{
|
||||||
for (b = 0; b < tile->bpp; b++)
|
for (b = 0; b < tile->bpp; b++)
|
||||||
*data++ = tile_data[b];
|
*data++ = tile_data[b];
|
||||||
@ -256,7 +274,10 @@ pixel_region_set_col (PR, x, y, h, data)
|
|||||||
boundary = y + (tile->eheight - (y % TILE_HEIGHT));
|
boundary = y + (tile->eheight - (y % TILE_HEIGHT));
|
||||||
inc = tile->bpp * tile->ewidth;
|
inc = tile->bpp * tile->ewidth;
|
||||||
|
|
||||||
for ( ; y < end && y < boundary; y++)
|
if (boundary > end) /* make sure we don't write past the end */
|
||||||
|
boundary = end;
|
||||||
|
|
||||||
|
for ( ; y < boundary; y++)
|
||||||
{
|
{
|
||||||
for (b = 0; b < tile->bpp; b++)
|
for (b = 0; b < tile->bpp; b++)
|
||||||
tile_data[b] = *data++;
|
tile_data[b] = *data++;
|
||||||
|
@ -135,6 +135,7 @@ pixel_region_get_row (PR, x, y, w, data, subsample)
|
|||||||
int end;
|
int end;
|
||||||
int boundary;
|
int boundary;
|
||||||
int b;
|
int b;
|
||||||
|
int npixels;
|
||||||
|
|
||||||
end = x + w;
|
end = x + w;
|
||||||
|
|
||||||
@ -144,16 +145,28 @@ pixel_region_get_row (PR, x, y, w, data, subsample)
|
|||||||
{
|
{
|
||||||
tile = tile_manager_get_tile (PR->tiles, x, y, 0, TRUE, FALSE);
|
tile = tile_manager_get_tile (PR->tiles, x, y, 0, TRUE, FALSE);
|
||||||
tile_data = tile->data + tile->bpp * (tile->ewidth * (y % TILE_HEIGHT) + (x % TILE_WIDTH));
|
tile_data = tile->data + tile->bpp * (tile->ewidth * (y % TILE_HEIGHT) + (x % TILE_WIDTH));
|
||||||
boundary = x + (tile->ewidth - (x % TILE_WIDTH));
|
npixels = tile->ewidth - (x % TILE_WIDTH);
|
||||||
inc = subsample * tile->bpp;
|
|
||||||
|
|
||||||
for ( ; x < end && x < boundary; x += subsample)
|
if ((x + npixels) > end) /* make sure we don't write past the end */
|
||||||
|
npixels = end - x;
|
||||||
|
|
||||||
|
if (subsample == 1) /* optimize for the common case */
|
||||||
|
{
|
||||||
|
memcpy(data, tile_data, tile->bpp*npixels);
|
||||||
|
data += tile->bpp*npixels;
|
||||||
|
x += npixels;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
boundary = x + npixels;
|
||||||
|
inc = subsample * tile->bpp;
|
||||||
|
for ( ; x < boundary; x += subsample)
|
||||||
{
|
{
|
||||||
for (b = 0; b < tile->bpp; b++)
|
for (b = 0; b < tile->bpp; b++)
|
||||||
*data++ = tile_data[b];
|
*data++ = tile_data[b];
|
||||||
tile_data += inc;
|
tile_data += inc;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
tile_release (tile, FALSE);
|
tile_release (tile, FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -169,8 +182,7 @@ pixel_region_set_row (PR, x, y, w, data)
|
|||||||
Tile *tile;
|
Tile *tile;
|
||||||
unsigned char *tile_data;
|
unsigned char *tile_data;
|
||||||
int end;
|
int end;
|
||||||
int boundary;
|
int npixels;
|
||||||
int b;
|
|
||||||
|
|
||||||
end = x + w;
|
end = x + w;
|
||||||
|
|
||||||
@ -180,13 +192,16 @@ pixel_region_set_row (PR, x, y, w, data)
|
|||||||
{
|
{
|
||||||
tile = tile_manager_get_tile (PR->tiles, x, y, 0, TRUE, TRUE);
|
tile = tile_manager_get_tile (PR->tiles, x, y, 0, TRUE, TRUE);
|
||||||
tile_data = tile->data + tile->bpp * (tile->ewidth * (y % TILE_HEIGHT) + (x % TILE_WIDTH));
|
tile_data = tile->data + tile->bpp * (tile->ewidth * (y % TILE_HEIGHT) + (x % TILE_WIDTH));
|
||||||
boundary = x + (tile->ewidth - (x % TILE_WIDTH));
|
|
||||||
|
|
||||||
for ( ; x < end && x < boundary; x++)
|
npixels = tile->ewidth - (x % TILE_WIDTH);
|
||||||
{
|
|
||||||
for (b = 0; b < tile->bpp; b++)
|
if ((x + npixels) > end) /* make sure we don't write past the end */
|
||||||
*tile_data++ = *data++;
|
npixels = end - x;
|
||||||
}
|
|
||||||
|
memcpy(tile_data, data, tile->bpp*npixels);
|
||||||
|
|
||||||
|
data += tile->bpp*npixels;
|
||||||
|
x += npixels;
|
||||||
|
|
||||||
tile_release (tile, TRUE);
|
tile_release (tile, TRUE);
|
||||||
}
|
}
|
||||||
@ -217,9 +232,12 @@ pixel_region_get_col (PR, x, y, h, data, subsample)
|
|||||||
tile = tile_manager_get_tile (PR->tiles, x, y, 0, TRUE, FALSE);
|
tile = tile_manager_get_tile (PR->tiles, x, y, 0, TRUE, FALSE);
|
||||||
tile_data = tile->data + tile->bpp * (tile->ewidth * (y % TILE_HEIGHT) + (x % TILE_WIDTH));
|
tile_data = tile->data + tile->bpp * (tile->ewidth * (y % TILE_HEIGHT) + (x % TILE_WIDTH));
|
||||||
boundary = y + (tile->eheight - (y % TILE_HEIGHT));
|
boundary = y + (tile->eheight - (y % TILE_HEIGHT));
|
||||||
|
if (boundary > end) /* make sure we don't write past the end */
|
||||||
|
boundary = end;
|
||||||
|
|
||||||
inc = subsample * tile->bpp * tile->ewidth;
|
inc = subsample * tile->bpp * tile->ewidth;
|
||||||
|
|
||||||
for ( ; y < end && y < boundary; y += subsample)
|
for ( ; y < boundary; y += subsample)
|
||||||
{
|
{
|
||||||
for (b = 0; b < tile->bpp; b++)
|
for (b = 0; b < tile->bpp; b++)
|
||||||
*data++ = tile_data[b];
|
*data++ = tile_data[b];
|
||||||
@ -256,7 +274,10 @@ pixel_region_set_col (PR, x, y, h, data)
|
|||||||
boundary = y + (tile->eheight - (y % TILE_HEIGHT));
|
boundary = y + (tile->eheight - (y % TILE_HEIGHT));
|
||||||
inc = tile->bpp * tile->ewidth;
|
inc = tile->bpp * tile->ewidth;
|
||||||
|
|
||||||
for ( ; y < end && y < boundary; y++)
|
if (boundary > end) /* make sure we don't write past the end */
|
||||||
|
boundary = end;
|
||||||
|
|
||||||
|
for ( ; y < boundary; y++)
|
||||||
{
|
{
|
||||||
for (b = 0; b < tile->bpp; b++)
|
for (b = 0; b < tile->bpp; b++)
|
||||||
tile_data[b] = *data++;
|
tile_data[b] = *data++;
|
||||||
|
Reference in New Issue
Block a user