135 |
|
static bool sdl_palette_changed = false; // Flag: Palette changed, redraw thread must set new colors |
136 |
|
static const int sdl_eventmask = SDL_MOUSEBUTTONDOWNMASK | SDL_MOUSEBUTTONUPMASK | SDL_MOUSEMOTIONMASK | SDL_KEYUPMASK | SDL_KEYDOWNMASK | SDL_VIDEOEXPOSEMASK | SDL_QUITMASK; |
137 |
|
|
138 |
+ |
// Mutex to protect SDL events |
139 |
+ |
static SDL_mutex *sdl_events_lock = NULL; |
140 |
+ |
#define LOCK_EVENTS SDL_LockMutex(sdl_events_lock) |
141 |
+ |
#define UNLOCK_EVENTS SDL_UnlockMutex(sdl_events_lock) |
142 |
+ |
|
143 |
|
// Mutex to protect palette |
144 |
|
static SDL_mutex *sdl_palette_lock = NULL; |
145 |
|
#define LOCK_PALETTE SDL_LockMutex(sdl_palette_lock) |
163 |
|
|
164 |
|
|
165 |
|
/* |
166 |
+ |
* SDL surface locking glue |
167 |
+ |
*/ |
168 |
+ |
|
169 |
+ |
#ifdef ENABLE_VOSF |
170 |
+ |
#define SDL_VIDEO_LOCK_VOSF_SURFACE(SURFACE) do { \ |
171 |
+ |
if ((SURFACE)->flags & (SDL_HWSURFACE | SDL_FULLSCREEN)) \ |
172 |
+ |
the_host_buffer = (uint8 *)(SURFACE)->pixels; \ |
173 |
+ |
} while (0) |
174 |
+ |
#else |
175 |
+ |
#define SDL_VIDEO_LOCK_VOSF_SURFACE(SURFACE) |
176 |
+ |
#endif |
177 |
+ |
|
178 |
+ |
#define SDL_VIDEO_LOCK_SURFACE(SURFACE) do { \ |
179 |
+ |
if (SDL_MUSTLOCK(SURFACE)) { \ |
180 |
+ |
SDL_LockSurface(SURFACE); \ |
181 |
+ |
SDL_VIDEO_LOCK_VOSF_SURFACE(SURFACE); \ |
182 |
+ |
} \ |
183 |
+ |
} while (0) |
184 |
+ |
|
185 |
+ |
#define SDL_VIDEO_UNLOCK_SURFACE(SURFACE) do { \ |
186 |
+ |
if (SDL_MUSTLOCK(SURFACE)) \ |
187 |
+ |
SDL_UnlockSurface(SURFACE); \ |
188 |
+ |
} while (0) |
189 |
+ |
|
190 |
+ |
|
191 |
+ |
/* |
192 |
|
* Framebuffer allocation routines |
193 |
|
*/ |
194 |
|
|
195 |
|
static void *vm_acquire_framebuffer(uint32 size) |
196 |
|
{ |
166 |
– |
#ifdef SHEEPSHAVER |
167 |
– |
#ifdef DIRECT_ADDRESSING_HACK |
168 |
– |
const uint32 FRAME_BUFFER_BASE = 0x61000000; |
169 |
– |
uint8 *fb = Mac2HostAddr(FRAME_BUFFER_BASE); |
170 |
– |
if (vm_acquire_fixed(fb, size) < 0) |
171 |
– |
fb = VM_MAP_FAILED; |
172 |
– |
return fb; |
173 |
– |
#endif |
174 |
– |
#endif |
197 |
|
return vm_acquire(size); |
198 |
|
} |
199 |
|
|
1062 |
|
#endif |
1063 |
|
|
1064 |
|
// Create Mutexes |
1065 |
+ |
if ((sdl_events_lock = SDL_CreateMutex()) == NULL) |
1066 |
+ |
return false; |
1067 |
|
if ((sdl_palette_lock = SDL_CreateMutex()) == NULL) |
1068 |
|
return false; |
1069 |
|
if ((frame_buffer_lock = SDL_CreateMutex()) == NULL) |
1289 |
|
SDL_DestroyMutex(frame_buffer_lock); |
1290 |
|
if (sdl_palette_lock) |
1291 |
|
SDL_DestroyMutex(sdl_palette_lock); |
1292 |
+ |
if (sdl_events_lock) |
1293 |
+ |
SDL_DestroyMutex(sdl_events_lock); |
1294 |
|
} |
1295 |
|
|
1296 |
|
|
1460 |
|
void SDL_monitor_desc::switch_to_current_mode(void) |
1461 |
|
{ |
1462 |
|
// Close and reopen display |
1463 |
+ |
LOCK_EVENTS; |
1464 |
|
video_close(); |
1465 |
|
video_open(); |
1466 |
+ |
UNLOCK_EVENTS; |
1467 |
|
|
1468 |
|
if (drv == NULL) { |
1469 |
|
ErrorAlert(STR_OPEN_WINDOW_ERR); |
2085 |
|
// Set new cursor image if it was changed |
2086 |
|
if (cursor_changed && sdl_cursor) { |
2087 |
|
cursor_changed = false; |
2088 |
+ |
LOCK_EVENTS; |
2089 |
|
SDL_FreeCursor(sdl_cursor); |
2090 |
|
sdl_cursor = SDL_CreateCursor(MacCursor + 4, MacCursor + 36, 16, 16, MacCursor[2], MacCursor[3]); |
2091 |
|
if (sdl_cursor) |
2092 |
|
SDL_SetCursor(sdl_cursor); |
2093 |
+ |
UNLOCK_EVENTS; |
2094 |
|
} |
2095 |
|
#endif |
2096 |
|
|