mirror of
https://github.com/VARCem/PDCurses.git
synced 2026-09-23 07:15:05 +00:00
Dirtying mechanism for SDL -- small but noticeable speedup.
This commit is contained in:
@@ -384,6 +384,8 @@ int PDC_color_content(short color, short *red, short *green, short *blue)
|
||||
|
||||
int PDC_init_color(short color, short red, short green, short blue)
|
||||
{
|
||||
pdc_dirty = TRUE;
|
||||
|
||||
pdc_color[color].r = DIVROUND(red * 255, 1000);
|
||||
pdc_color[color].g = DIVROUND(green * 255, 1000);
|
||||
pdc_color[color].b = DIVROUND(blue * 255, 1000);
|
||||
@@ -391,7 +393,5 @@ int PDC_init_color(short color, short red, short green, short blue)
|
||||
pdc_mapped[color] = SDL_MapRGB(pdc_screen->format, pdc_color[color].r,
|
||||
pdc_color[color].g, pdc_color[color].b);
|
||||
|
||||
wrefresh(curscr);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ extern bool pdc_own_screen; /* if pdc_screen was not set
|
||||
before initscr(), PDCurses is
|
||||
responsible for (owns) it */
|
||||
extern Uint32 pdc_lastupdate; /* time of last update, in ticks */
|
||||
extern bool pdc_dirty; /* redraw on napms() after init_color() */
|
||||
|
||||
PDCEX void PDC_update_rects(void);
|
||||
PDCEX void PDC_retile(void);
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "pdcsdl.h"
|
||||
|
||||
bool pdc_dirty = FALSE;
|
||||
|
||||
void PDC_beep(void)
|
||||
{
|
||||
PDC_LOG(("PDC_beep() - called\n"));
|
||||
@@ -11,6 +13,12 @@ void PDC_napms(int ms)
|
||||
{
|
||||
PDC_LOG(("PDC_napms() - called: ms=%d\n", ms));
|
||||
|
||||
if (pdc_dirty)
|
||||
{
|
||||
pdc_dirty = FALSE;
|
||||
wrefresh(curscr);
|
||||
}
|
||||
|
||||
PDC_update_rects();
|
||||
SDL_PumpEvents();
|
||||
SDL_Delay(ms);
|
||||
|
||||
@@ -418,6 +418,8 @@ int PDC_color_content(short color, short *red, short *green, short *blue)
|
||||
|
||||
int PDC_init_color(short color, short red, short green, short blue)
|
||||
{
|
||||
pdc_dirty = TRUE;
|
||||
|
||||
pdc_color[color].r = DIVROUND(red * 255, 1000);
|
||||
pdc_color[color].g = DIVROUND(green * 255, 1000);
|
||||
pdc_color[color].b = DIVROUND(blue * 255, 1000);
|
||||
@@ -425,7 +427,5 @@ int PDC_init_color(short color, short red, short green, short blue)
|
||||
pdc_mapped[color] = SDL_MapRGB(pdc_screen->format, pdc_color[color].r,
|
||||
pdc_color[color].g, pdc_color[color].b);
|
||||
|
||||
wrefresh(curscr);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ extern bool pdc_own_window; /* if pdc_window was not set
|
||||
before initscr(), PDCurses is
|
||||
responsible for (owns) it */
|
||||
extern Uint32 pdc_lastupdate; /* time of last update, in ticks */
|
||||
extern bool pdc_dirty; /* redraw on napms() after init_color() */
|
||||
|
||||
PDCEX void PDC_update_rects(void);
|
||||
PDCEX void PDC_retile(void);
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "pdcsdl.h"
|
||||
|
||||
bool pdc_dirty = FALSE;
|
||||
|
||||
void PDC_beep(void)
|
||||
{
|
||||
PDC_LOG(("PDC_beep() - called\n"));
|
||||
@@ -11,6 +13,12 @@ void PDC_napms(int ms)
|
||||
{
|
||||
PDC_LOG(("PDC_napms() - called: ms=%d\n", ms));
|
||||
|
||||
if (pdc_dirty)
|
||||
{
|
||||
pdc_dirty = FALSE;
|
||||
wrefresh(curscr);
|
||||
}
|
||||
|
||||
PDC_update_rects();
|
||||
SDL_PumpEvents();
|
||||
SDL_Delay(ms);
|
||||
|
||||
Reference in New Issue
Block a user