mirror of
https://github.com/holub/mame
synced 2025-04-20 23:42:22 +03:00
From: Christophe Jaillet [mailto:christophe.jaillet@wanadoo.fr]
Sent: Wed 9/24/2008 2:00 PM To: submit@mamedev.org Subject: Speed up fillbitmap Hi, there are many places in mame which make use of "fill_bitmap" or the equivalent "fillbitmap" An optimisation is done when the depth of the bitmap is 16 or 32 bpp and when the UINT16 or UINT32 corresponding to the color is composed of same bytes (i.e 0xffff for example). This is usefull because most of the calls are for color 0 (black). In all other cases, the bitmap is filled one pixel at a time using a loop with a code like : ================ for (y = fill.min_y; y <= fill.max_y; y++) { UINT16 *destrow = BITMAP_ADDR16(dest, y, 0); for (x = fill.min_x; x <= fill.max_x; x++) destrow[x] = (UINT16)color; } ================ However, each rows of the final bitmap will be the same. So I modified this simple assigned to work as follow : 1) fill the first row one pixel at a time 2) fill all the other rows by copying the first one. This makes us use memcpy instead of a hard coded loop for most of the filling process.
This commit is contained in:
parent
07d208cbbd
commit
0f775dc84e
@ -198,11 +198,19 @@ void bitmap_fill(bitmap_t *dest, const rectangle *cliprect, UINT32 color)
|
||||
}
|
||||
else
|
||||
{
|
||||
for (y = fill.min_y; y <= fill.max_y; y++)
|
||||
UINT16 *destrow, *destrow0;
|
||||
|
||||
/* Fill the first line the hard way */
|
||||
destrow = BITMAP_ADDR16(dest, fill.min_y, 0);
|
||||
for (x = fill.min_x; x <= fill.max_x; x++)
|
||||
destrow[x] = (UINT16)color;
|
||||
|
||||
/* For the other lines, just copy the first one */
|
||||
destrow0 = BITMAP_ADDR16(dest, fill.min_y, fill.min_x);
|
||||
for (y = fill.min_y + 1; y <= fill.max_y; y++)
|
||||
{
|
||||
UINT16 *destrow = BITMAP_ADDR16(dest, y, 0);
|
||||
for (x = fill.min_x; x <= fill.max_x; x++)
|
||||
destrow[x] = (UINT16)color;
|
||||
destrow = BITMAP_ADDR16(dest, y, fill.min_x);
|
||||
memcpy(destrow, destrow0, (fill.max_x + 1 - fill.min_x) * 2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -216,11 +224,19 @@ void bitmap_fill(bitmap_t *dest, const rectangle *cliprect, UINT32 color)
|
||||
}
|
||||
else
|
||||
{
|
||||
for (y = fill.min_y; y <= fill.max_y; y++)
|
||||
UINT32 *destrow, *destrow0;
|
||||
|
||||
/* Fill the first line the hard way */
|
||||
destrow = BITMAP_ADDR32(dest, fill.min_y, 0);
|
||||
for (x = fill.min_x; x <= fill.max_x; x++)
|
||||
destrow[x] = (UINT32)color;
|
||||
|
||||
/* For the other lines, just copy the first one */
|
||||
destrow0 = BITMAP_ADDR32(dest, fill.min_y, fill.min_x);
|
||||
for (y = fill.min_y + 1; y <= fill.max_y; y++)
|
||||
{
|
||||
UINT32 *destrow = BITMAP_ADDR32(dest, y, 0);
|
||||
for (x = fill.min_x; x <= fill.max_x; x++)
|
||||
destrow[x] = (UINT32)color;
|
||||
destrow = BITMAP_ADDR32(dest, y, fill.min_x);
|
||||
memcpy(destrow, destrow0, (fill.max_x + 1 - fill.min_x) * 4);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user