mirror of
https://github.com/VARCem/PDCurses.git
synced 2026-09-24 07:45:21 +00:00
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...
This commit is contained in:
@@ -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 <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -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++;
|
||||
}
|
||||
|
||||
@@ -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 <curspriv.h>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user