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

Add more vstatlock usage where needed, sync cvstat better.

parent 2a55ded2
No related branches found
No related tags found
No related merge requests found
......@@ -298,10 +298,12 @@ set_vmem_cell(struct vstat_vmem *vmem_ptr, size_t pos, uint16_t cell, uint32_t f
bitmap_attr2palette_locked(cell>>8, fg == 0xffffff ? &fg : NULL, bg == 0xffffff ? &bg : NULL);
altfont = (cell>>11 & 0x01) | ((cell>>14) & 0x02);
pthread_mutex_lock(&vstatlock);
if (!vstat.bright_altcharset)
altfont &= ~0x01;
if (!vstat.blink_altcharset)
altfont &= ~0x02;
pthread_mutex_unlock(&vstatlock);
font=current_font[altfont];
if (font == -99)
font = default_font;
......@@ -565,8 +567,9 @@ static int bitmap_draw_one_char(unsigned int xpos, unsigned int ypos)
}
}
}
if (this_font == NULL)
if (this_font == NULL) {
this_font = font[0];
}
fdw = charwidth - (flags & VIDMODES_FLAG_EXPAND) ? 1 : 0;
fontoffset=(sch) * (charheight * ((fdw + 7) / 8));
......
......@@ -454,11 +454,22 @@ int sdl_init(int mode)
return(-1);
}
static void
update_cvstat(struct video_stats *vs)
{
if (vs != NULL && vs != &vstat) {
pthread_mutex_lock(&vstatlock);
*vs = vstat;
pthread_mutex_unlock(&vstatlock);
}
}
static void internal_setwinsize(struct video_stats *vs, bool force)
{
int w, h;
bool changed = true;
update_cvstat(vs);
w = vs->winwidth;
h = vs->winheight;
if (w > 16384)
......@@ -671,7 +682,8 @@ static void setup_surfaces_locked(struct video_stats *vs)
}
if (vs != &vstat) {
pthread_mutex_lock(&vstatlock);
vstat = *vs;
vstat.winwidth = vs->winwidth;
vstat.winheight = vs->winheight;
pthread_mutex_unlock(&vstatlock);
}
sdl.SetWindowMinimumSize(win, idealmw, idealmh);
......@@ -694,6 +706,7 @@ static void sdl_add_key(unsigned int keyval, struct video_stats *vs)
fullscreen=!fullscreen;
cio_api.mode=fullscreen?CIOLIB_MODE_SDL_FULLSCREEN:CIOLIB_MODE_SDL;
sdl.SetWindowFullscreen(win, fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
update_cvstat(vs);
setup_surfaces_locked(vs);
return;
}
......@@ -885,6 +898,8 @@ void sdl_video_event_thread(void *data)
// Don't allow ALT-DIR to change size when maximized...
if ((sdl.GetWindowFlags(win) & SDL_WINDOW_MAXIMIZED) == 0) {
bool wc;
update_cvstat(&cvstat);
w = cvstat.winwidth;
h = cvstat.winheight;
aspect_fix(&w, &h, cvstat.aspect_width, cvstat.aspect_height);
......@@ -1061,6 +1076,7 @@ void sdl_video_event_thread(void *data)
sem_post(&sdl_ufunc_ret);
return;
case SDL_USEREVENT_FLUSH:
update_cvstat(&cvstat);
pthread_mutex_lock(&win_mutex);
if (win != NULL) {
pthread_mutex_unlock(&win_mutex);
......@@ -1200,9 +1216,6 @@ void sdl_video_event_thread(void *data)
sdl_mode = false;
pthread_mutex_unlock(&sdl_mode_mutex);
pthread_mutex_lock(&vstatlock);
cvstat = vstat;
pthread_mutex_unlock(&vstatlock);
internal_setwinsize(&cvstat, true);
sdl_ufunc_retval=0;
sem_post(&sdl_ufunc_ret);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment