From ff6a1b3990eddcdeeeefcf794111cf024cc57b5a Mon Sep 17 00:00:00 2001 From: deuce <> Date: Fri, 2 Feb 2018 06:40:13 +0000 Subject: [PATCH] Differentiate between updating the pixels, and forcing a redraw. A forced redraw redraws all the glyphs at all locations and is excessive the way it's used in SDL. We just need all the pixels refreshed, so we only do that now. --- src/conio/bitmap_con.c | 4 ++++ src/conio/bitmap_con.h | 1 + src/conio/sdl_con.c | 6 +++--- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/conio/bitmap_con.c b/src/conio/bitmap_con.c index 3b47f61f31..bb094595bb 100644 --- a/src/conio/bitmap_con.c +++ b/src/conio/bitmap_con.c @@ -45,6 +45,7 @@ static struct bitmap_callbacks callbacks; static unsigned char *font[4]; static unsigned char space=' '; int force_redraws=0; +int update_pixels = 0; struct rectangle { int x; @@ -115,6 +116,8 @@ static void blinker_thread(void *data) update_rect(0,0,0,0,force_redraws--); else update_rect(0,0,0,0,FALSE); + if (update_pixels) + send_rectangle(&vstat, 0, 0, screenwidth, screenheight, update_pixels--); callbacks.flush(); } } @@ -1170,6 +1173,7 @@ int bitmap_setpixel(uint32_t x, uint32_t y, uint32_t colour) pthread_mutex_lock(&screenlock); if (x < screenwidth && y < screenheight) screen[PIXEL_OFFSET(x, y)]=colour; + update_pixels++; pthread_mutex_unlock(&screenlock); return 1; } diff --git a/src/conio/bitmap_con.h b/src/conio/bitmap_con.h index 7e450d569e..bb84b245a4 100644 --- a/src/conio/bitmap_con.h +++ b/src/conio/bitmap_con.h @@ -8,6 +8,7 @@ extern struct video_stats vstat; extern pthread_mutex_t vstatlock; extern sem_t drawn_sem; extern int force_redraws; +extern int update_pixels; int bitmap_pgettext(int sx, int sy, int ex, int ey, void *fill, uint32_t *fg, uint32_t *bg); int bitmap_puttext(int sx, int sy, int ex, int ey, void *fill); diff --git a/src/conio/sdl_con.c b/src/conio/sdl_con.c index 483d5dcff1..dbbbeab7df 100644 --- a/src/conio/sdl_con.c +++ b/src/conio/sdl_con.c @@ -654,7 +654,7 @@ int sdl_setpalette(uint32_t index, uint16_t r, uint16_t g, uint16_t b) pal->g = g>>8; pal->b = b>>8; sdl_user_func(SDL_USEREVENT_SETPALETTE, pal); - force_redraws++; + update_pixels++; } } return 0; @@ -1073,7 +1073,7 @@ void setup_surfaces(void) sdl_setup_colours(new_rect); sdl.mutexV(newrect_mutex); sdl_setup_colours(win); - force_redraws++; + update_pixels++; } else if(sdl_init_good) { ev.type=SDL_QUIT; @@ -1729,7 +1729,7 @@ int sdl_video_event_thread(void *data) case SDL_VIDEOEXPOSE: { if(yuv.enabled) { - force_redraws=1; + update_pixels++; } else { if(upd_rects) { -- GitLab