Mercurial > hg > forks > pwpunix
changeset 13:e5049100f6ac
Optimize rasterization a bit.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 18 May 2010 20:47:07 +0300 |
parents | 18e14722f58a |
children | cf56b64a3c11 |
files | pwplib/sdl.c |
diffstat | 1 files changed, 14 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/pwplib/sdl.c Tue May 18 20:32:38 2010 +0300 +++ b/pwplib/sdl.c Tue May 18 20:47:07 2010 +0300 @@ -43,18 +43,23 @@ for (y = pwplib.videobuf.height; y; y--) { - int y2; - for (y2 = 4; y2; y2--) + int i; + Uint8 *dsrc = dst; + Uint32 *d = (Uint32 *)dst; + Uint8 *s = src; + + for (i = pwplib.videobuf.width; i; i--) + *d++ = pwp_SDL.lookup[*s++]; + + dst += pwp_SDL.screen->pitch; + + /* Optimization: memcpy the rasterized line 3 times below it */ + for (i = 3; i; i--) { - int x; - Uint32 *d = (Uint32 *)dst; - Uint8 *s = src; - - for (x = pwplib.videobuf.width; x; x--) - *d++ = pwp_SDL.lookup[*s++]; - + memcpy(dst, dsrc, pwp_SDL.screen->pitch); dst += pwp_SDL.screen->pitch; } + src += pwplib.videobuf.width; }