Skip to content
Snippets Groups Projects
Commit c25141c9 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Move video flags out from under vstatlock.

This is a heavily accessed value that is rarely changed and was
causing a lot of contention on vstatlock.

Down to 2.9 seconds.
parent cf67458b
No related branches found
No related tags found
No related merge requests found
Pipeline #7745 passed
...@@ -107,6 +107,7 @@ static struct vmem_cell *bitmap_drawn; ...@@ -107,6 +107,7 @@ static struct vmem_cell *bitmap_drawn;
static int outstanding_rects; static int outstanding_rects;
// win32gdi requires two rects... // win32gdi requires two rects...
#define MAX_OUTSTANDING 2 #define MAX_OUTSTANDING 2
static protected_int32_t videoflags;
/* Exported globals */ /* Exported globals */
...@@ -914,6 +915,7 @@ static int check_redraw(void) ...@@ -914,6 +915,7 @@ static int check_redraw(void)
return ret; return ret;
} }
pthread_t bpid;
/* Blinker Thread */ /* Blinker Thread */
static void blinker_thread(void *data) static void blinker_thread(void *data)
{ {
...@@ -926,6 +928,7 @@ static void blinker_thread(void *data) ...@@ -926,6 +928,7 @@ static void blinker_thread(void *data)
int lfc; int lfc;
int blink; int blink;
bpid = pthread_self();
SetThreadName("Blinker"); SetThreadName("Blinker");
while(1) { while(1) {
curs_changed = 0; curs_changed = 0;
...@@ -1675,11 +1678,11 @@ void bitmap_setcustomcursor(int s, int e, int r, int b, int v) ...@@ -1675,11 +1678,11 @@ void bitmap_setcustomcursor(int s, int e, int r, int b, int v)
rwlock_unlock(&vstatlock); rwlock_unlock(&vstatlock);
} }
int bitmap_getvideoflags(void) static void
setvideoflags_from_vstat(void)
{ {
int flags=0; int flags = 0;
rwlock_rdlock(&vstatlock);
if(vstat.bright_background) if(vstat.bright_background)
flags |= CIOLIB_VIDEO_BGBRIGHT; flags |= CIOLIB_VIDEO_BGBRIGHT;
if(vstat.no_bright) if(vstat.no_bright)
...@@ -1690,13 +1693,20 @@ int bitmap_getvideoflags(void) ...@@ -1690,13 +1693,20 @@ int bitmap_getvideoflags(void)
flags |= CIOLIB_VIDEO_NOBLINK; flags |= CIOLIB_VIDEO_NOBLINK;
if(vstat.blink_altcharset) if(vstat.blink_altcharset)
flags |= CIOLIB_VIDEO_BLINKALTCHARS; flags |= CIOLIB_VIDEO_BLINKALTCHARS;
rwlock_unlock(&vstatlock); protected_int32_set(&videoflags, flags);
return(flags); }
int bitmap_getvideoflags(void)
{
int flags=0;
return protected_int32_value(videoflags);
} }
void bitmap_setvideoflags(int flags) void bitmap_setvideoflags(int flags)
{ {
rwlock_wrlock(&vstatlock); rwlock_wrlock(&vstatlock);
protected_int32_set(&videoflags, flags);
if(flags & CIOLIB_VIDEO_BGBRIGHT) if(flags & CIOLIB_VIDEO_BGBRIGHT)
vstat.bright_background=1; vstat.bright_background=1;
else else
...@@ -2205,6 +2215,7 @@ int bitmap_drv_init_mode(int mode, int *width, int *height, int maxwidth, int ma ...@@ -2205,6 +2215,7 @@ int bitmap_drv_init_mode(int mode, int *width, int *height, int maxwidth, int ma
if(load_vmode(&vstat, mode)) { if(load_vmode(&vstat, mode)) {
return(-1); return(-1);
} }
setvideoflags_from_vstat();
// Save the old diagonal (no point is sqrting here) // Save the old diagonal (no point is sqrting here)
os = ((int64_t)vstat.winwidth * vstat.winwidth) + ((int64_t)vstat.winheight * vstat.winheight); os = ((int64_t)vstat.winwidth * vstat.winwidth) + ((int64_t)vstat.winheight * vstat.winheight);
...@@ -2304,6 +2315,7 @@ int bitmap_drv_init(void (*drawrect_cb) (struct rectlist *data) ...@@ -2304,6 +2315,7 @@ int bitmap_drv_init(void (*drawrect_cb) (struct rectlist *data)
| CONIO_OPT_SET_PIXEL | CONIO_OPT_CUSTOM_CURSOR | CONIO_OPT_SET_PIXEL | CONIO_OPT_CUSTOM_CURSOR
| CONIO_OPT_FONT_SELECT | CONIO_OPT_EXTENDED_PALETTE | CONIO_OPT_PALETTE_SETTING | CONIO_OPT_FONT_SELECT | CONIO_OPT_EXTENDED_PALETTE | CONIO_OPT_PALETTE_SETTING
| CONIO_OPT_BLOCKY_SCALING; | CONIO_OPT_BLOCKY_SCALING;
protected_int32_init(&videoflags, 0);
pthread_mutex_init(&callbacks.lock, NULL); pthread_mutex_init(&callbacks.lock, NULL);
rwlock_init(&vstatlock); rwlock_init(&vstatlock);
pthread_mutex_init(&screenlock, NULL); pthread_mutex_init(&screenlock, NULL);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment