From ee2bb56d385fc92c4a152bf81ef7c91dae5429d8 Mon Sep 17 00:00:00 2001 From: William McBrine Date: Sat, 16 Jun 2007 05:16:44 +0000 Subject: [PATCH] To get around the Mac performance problem (which turns out to be due to a change in the way QDFlushPortBuffer() is handled -- it only updates every 60th of a second, and blocks until then), here's a version that builds a list of SDL_Rects, and calls SDL_UpdateRects() only when the list is full, or from PDC_napms(). Of course it's (even) faster on other platforms, too. However, in the degenerate case where PDC_napms() is never called (no keyboard checks, no intentional pauses), the screen will not be updated. I could get around that, too, but it's much more hairy... --- sdl1/pdcdisp.c | 29 ++++++++++++++++++++++++++--- sdl1/pdcsdl.h | 4 +++- sdl1/pdcutil.c | 3 ++- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/sdl1/pdcdisp.c b/sdl1/pdcdisp.c index 86ca2f16..4e77cc07 100644 --- a/sdl1/pdcdisp.c +++ b/sdl1/pdcdisp.c @@ -13,7 +13,7 @@ #include "pdcsdl.h" -RCSID("$Id: pdcdisp.c,v 1.11 2007/06/14 14:43:53 wmcbrine Exp $") +RCSID("$Id: pdcdisp.c,v 1.12 2007/06/16 05:16:44 wmcbrine Exp $") #include #include @@ -56,6 +56,22 @@ chtype acs_map[128] = #endif +#define MAXRECT 200 + +static SDL_Rect uprect[MAXRECT]; +static int rectcount = 0; + +/* do the real updates on a delay */ + +void PDC_update_rects(void) +{ + if (rectcount) + { + SDL_UpdateRects(pdc_screen, rectcount, uprect); + rectcount = 0; + } +} + /* set the font colors to match the chtype's attribute */ static void _set_attr(chtype ch) @@ -184,6 +200,9 @@ void PDC_transform_line(int lineno, int x, int len, const chtype *srcp) PDC_LOG(("PDC_transform_line() - called: lineno=%d\n", lineno)); + if (rectcount == MAXRECT) + PDC_update_rects(); + src.w = pdc_fwidth; src.h = pdc_fheight; dest.y = pdc_fheight * lineno; @@ -214,6 +233,10 @@ void PDC_transform_line(int lineno, int x, int len, const chtype *srcp) dest.x += pdc_fwidth; } - SDL_UpdateRect(pdc_screen, x * pdc_fwidth, lineno * pdc_fheight, - len * pdc_fwidth, pdc_fheight); + uprect[rectcount].x = x * pdc_fwidth; + uprect[rectcount].y = lineno * pdc_fheight; + uprect[rectcount].w = len * pdc_fwidth; + uprect[rectcount].h = pdc_fheight; + + rectcount++; } diff --git a/sdl1/pdcsdl.h b/sdl1/pdcsdl.h index 90f02f5b..7d00acdf 100644 --- a/sdl1/pdcsdl.h +++ b/sdl1/pdcsdl.h @@ -11,7 +11,7 @@ * See the file maintain.er for details of the current maintainer. * ************************************************************************/ -/* $Id: pdcsdl.h,v 1.4 2007/06/14 15:58:20 wmcbrine Exp $ */ +/* $Id: pdcsdl.h,v 1.5 2007/06/16 05:16:44 wmcbrine Exp $ */ #include @@ -22,3 +22,5 @@ extern SDL_Color pdc_color[16]; extern Uint32 pdc_mapped[16]; extern int pdc_fheight, pdc_fwidth, pdc_sheight, pdc_swidth; extern bool pdc_own_screen; + +void PDC_update_rects(void); diff --git a/sdl1/pdcutil.c b/sdl1/pdcutil.c index f0f50fe4..45012d76 100644 --- a/sdl1/pdcutil.c +++ b/sdl1/pdcutil.c @@ -13,7 +13,7 @@ #include "pdcsdl.h" -RCSID("$Id: pdcutil.c,v 1.3 2007/06/14 13:50:27 wmcbrine Exp $") +RCSID("$Id: pdcutil.c,v 1.4 2007/06/16 05:16:44 wmcbrine Exp $") void PDC_beep(void) { @@ -24,6 +24,7 @@ void PDC_napms(int ms) { PDC_LOG(("PDC_napms() - called: ms=%d\n", ms)); + PDC_update_rects(); SDL_Delay(ms); }