87 |
|
static uint8 *the_buffer = NULL; // Mac frame buffer (where MacOS draws into) |
88 |
|
static uint8 *the_buffer_copy = NULL; // Copy of Mac frame buffer (for refreshed modes) |
89 |
|
|
90 |
– |
#ifdef HAVE_PTHREADS |
90 |
|
static bool redraw_thread_active = false; // Flag: Redraw thread installed |
91 |
+ |
#ifdef HAVE_PTHREADS |
92 |
|
static volatile bool redraw_thread_cancel; // Flag: Cancel Redraw thread |
93 |
|
static pthread_t redraw_thread; // Redraw thread |
94 |
|
#endif |
345 |
|
|
346 |
|
driver_base::~driver_base() |
347 |
|
{ |
348 |
– |
XFlush(x_display); |
349 |
– |
XSync(x_display, false); |
350 |
– |
|
348 |
|
if (w) { |
349 |
|
XUnmapWindow(x_display, w); |
350 |
|
wait_unmapped(w); |
351 |
|
XDestroyWindow(x_display, w); |
352 |
|
} |
353 |
|
|
354 |
+ |
XFlush(x_display); |
355 |
+ |
XSync(x_display, false); |
356 |
+ |
|
357 |
|
// Free frame buffer(s) |
358 |
|
if (!use_vosf) { |
359 |
|
if (the_buffer) { |
446 |
|
wait_mapped(w); |
447 |
|
|
448 |
|
// Try to create and attach SHM image |
449 |
< |
if (local_X11 && mode.depth != VDEPTH_1BIT && XShmQueryExtension(x_display)) { |
449 |
> |
if (local_X11 && XShmQueryExtension(x_display)) { |
450 |
|
|
451 |
|
// Create SHM image ("height + 2" for safety) |
452 |
|
img = XShmCreateImage(x_display, vis, mode.depth == VDEPTH_1BIT ? 1 : xdepth, mode.depth == VDEPTH_1BIT ? XYBitmap : ZPixmap, 0, &shminfo, width, height); |
659 |
|
* fbdev DGA display driver |
660 |
|
*/ |
661 |
|
|
662 |
+ |
const char FBDEVICES_FILE_NAME[] = DATADIR "/fbdevices"; |
663 |
+ |
const char FBDEVICE_FILE_NAME[] = "/dev/fb"; |
664 |
+ |
|
665 |
|
class driver_fbdev : public driver_dga { |
666 |
|
public: |
667 |
|
driver_fbdev(const video_mode &mode); |
668 |
|
~driver_fbdev(); |
666 |
– |
|
667 |
– |
private: |
668 |
– |
const char FBDEVICES_FILE_NAME[] = DATADIR "/fbdevices"; |
669 |
– |
const char FBDEVICE_FILE_NAME[] = "/dev/fb"; |
669 |
|
}; |
670 |
|
|
671 |
|
// Open display |
798 |
|
|
799 |
|
// Set VideoMonitor |
800 |
|
VideoModes[0].bytes_per_row = bytes_per_row; |
801 |
< |
VideoModes[0].depth = DepthModeForPixelDepth(); |
801 |
> |
VideoModes[0].depth = DepthModeForPixelDepth(fb_depth); |
802 |
|
VideoMonitor.mode = mode; |
803 |
|
set_mac_frame_buffer(mode.depth, true); |
804 |
|
|
1069 |
|
XSync(x_display, false); |
1070 |
|
LOCK_FRAME_BUFFER; |
1071 |
|
|
1073 |
– |
#ifdef HAVE_PTHREADS |
1072 |
|
// Start redraw/input thread |
1073 |
+ |
#ifdef HAVE_PTHREADS |
1074 |
|
redraw_thread_cancel = false; |
1075 |
|
redraw_thread_active = (pthread_create(&redraw_thread, NULL, redraw_func, NULL) == 0); |
1076 |
|
if (!redraw_thread_active) { |
1077 |
|
printf("FATAL: cannot create redraw thread\n"); |
1078 |
|
return false; |
1079 |
|
} |
1080 |
+ |
#else |
1081 |
+ |
redraw_thread_active = true; |
1082 |
|
#endif |
1083 |
|
|
1084 |
|
return true; |
1261 |
|
// Close display |
1262 |
|
static void video_close(void) |
1263 |
|
{ |
1263 |
– |
#ifdef HAVE_PTHREADS |
1264 |
|
// Stop redraw thread |
1265 |
+ |
#ifdef HAVE_PTHREADS |
1266 |
|
if (redraw_thread_active) { |
1267 |
|
redraw_thread_cancel = true; |
1268 |
|
#ifdef HAVE_PTHREAD_CANCEL |
1269 |
|
pthread_cancel(redraw_thread); |
1270 |
|
#endif |
1271 |
|
pthread_join(redraw_thread, NULL); |
1271 |
– |
redraw_thread_active = false; |
1272 |
|
} |
1273 |
|
#endif |
1274 |
+ |
redraw_thread_active = false; |
1275 |
|
|
1276 |
|
// Unlock frame buffer |
1277 |
|
UNLOCK_FRAME_BUFFER; |
2052 |
|
|
2053 |
|
void VideoRefresh(void) |
2054 |
|
{ |
2055 |
< |
// TODO: make main_unix/VideoRefresh call directly video_refresh() ? |
2056 |
< |
video_refresh(); |
2055 |
> |
// We need to check redraw_thread_active to inhibit refreshed during |
2056 |
> |
// mode changes on non-threaded platforms |
2057 |
> |
if (redraw_thread_active) |
2058 |
> |
video_refresh(); |
2059 |
|
} |
2060 |
|
|
2061 |
|
#ifdef HAVE_PTHREADS |