# HG changeset patch # User Matti Hamalainen # Date 1274204827 -10800 # Node ID e5049100f6ac92e1ec3d6667faaf5c1b319d31c3 # Parent 18e14722f58a292d97206ef76e18228d238f298f Optimize rasterization a bit. diff -r 18e14722f58a -r e5049100f6ac pwplib/sdl.c --- 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; }