93 |
|
static bool local_X11; // Flag: X server running on local machine? |
94 |
|
static uint8 *the_buffer = NULL; // Mac frame buffer (where MacOS draws into) |
95 |
|
static uint8 *the_buffer_copy = NULL; // Copy of Mac frame buffer (for refreshed modes) |
96 |
+ |
static uint32 the_buffer_size; // Size of allocated the_buffer |
97 |
|
|
98 |
|
static bool redraw_thread_active = false; // Flag: Redraw thread installed |
99 |
|
#ifdef HAVE_PTHREADS |
510 |
|
free(the_host_buffer); |
511 |
|
the_host_buffer = NULL; |
512 |
|
} |
513 |
< |
if (the_buffer != (uint8 *)VM_MAP_FAILED) { |
514 |
< |
vm_release(the_buffer, the_buffer_size); |
513 |
> |
if (the_buffer) { |
514 |
> |
free(the_buffer); |
515 |
|
the_buffer = NULL; |
516 |
|
} |
517 |
< |
if (the_buffer_copy != (uint8 *)VM_MAP_FAILED) { |
518 |
< |
vm_release(the_buffer_copy, the_buffer_size); |
517 |
> |
if (the_buffer_copy) { |
518 |
> |
free(the_buffer_copy); |
519 |
|
the_buffer_copy = NULL; |
520 |
|
} |
521 |
|
} |
630 |
|
} |
631 |
|
|
632 |
|
#ifdef ENABLE_VOSF |
633 |
+ |
use_vosf = true; |
634 |
|
// Allocate memory for frame buffer (SIZE is extended to page-boundary) |
635 |
|
the_host_buffer = the_buffer_copy; |
636 |
|
the_buffer_size = page_extend((aligned_height + 2) * img->bytes_per_line); |
684 |
|
the_buffer_copy = NULL; // don't free() in driver_base dtor |
685 |
|
#endif |
686 |
|
} |
687 |
+ |
#ifdef ENABLE_VOSF |
688 |
+ |
if (use_vosf) { |
689 |
+ |
// don't free() memory mapped buffers in driver_base dtor |
690 |
+ |
if (the_buffer != VM_MAP_FAILED) { |
691 |
+ |
vm_release(the_buffer, the_buffer_size); |
692 |
+ |
the_buffer = NULL; |
693 |
+ |
} |
694 |
+ |
if (the_buffer_copy != VM_MAP_FAILED) { |
695 |
+ |
vm_release(the_buffer_copy, the_buffer_size); |
696 |
+ |
the_buffer_copy = NULL; |
697 |
+ |
} |
698 |
+ |
} |
699 |
+ |
#endif |
700 |
|
if (img) |
701 |
|
XDestroyImage(img); |
702 |
|
if (have_shm) { |
1016 |
|
int bytes_per_row = TrivialBytesPerRow(mode.x, mode.depth); |
1017 |
|
|
1018 |
|
// Map frame buffer |
1019 |
< |
if ((the_buffer = (uint8 *) mmap(NULL, height * bytes_per_row, PROT_READ | PROT_WRITE, MAP_PRIVATE, fbdev_fd, fb_offset)) == MAP_FAILED) { |
1020 |
< |
if ((the_buffer = (uint8 *) mmap(NULL, height * bytes_per_row, PROT_READ | PROT_WRITE, MAP_SHARED, fbdev_fd, fb_offset)) == MAP_FAILED) { |
1019 |
> |
the_buffer_size = height * bytes_per_row; |
1020 |
> |
if ((the_buffer = (uint8 *) mmap(NULL, the_buffer_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fbdev_fd, fb_offset)) == MAP_FAILED) { |
1021 |
> |
if ((the_buffer = (uint8 *) mmap(NULL, the_buffer_size, PROT_READ | PROT_WRITE, MAP_SHARED, fbdev_fd, fb_offset)) == MAP_FAILED) { |
1022 |
|
char str[256]; |
1023 |
|
sprintf(str, GetString(STR_FBDEV_MMAP_ERR), strerror(errno)); |
1024 |
|
ErrorAlert(str); |
1057 |
|
// Close display |
1058 |
|
driver_fbdev::~driver_fbdev() |
1059 |
|
{ |
1060 |
+ |
if (!use_vosf) { |
1061 |
+ |
if (the_buffer != MAP_FAILED) { |
1062 |
+ |
// don't free() the screen buffer in driver_base dtor |
1063 |
+ |
munmap(the_buffer, the_buffer_size); |
1064 |
+ |
the_buffer = NULL; |
1065 |
+ |
} |
1066 |
+ |
} |
1067 |
+ |
#ifdef ENABLE_VOSF |
1068 |
+ |
else { |
1069 |
+ |
if (the_host_buffer != MAP_FAILED) { |
1070 |
+ |
// don't free() the screen buffer in driver_base dtor |
1071 |
+ |
munmap(the_host_buffer, the_buffer_size); |
1072 |
+ |
the_host_buffer = NULL; |
1073 |
+ |
} |
1074 |
+ |
if (the_buffer_copy != VM_MAP_FAILED) { |
1075 |
+ |
vm_release(the_buffer_copy, the_buffer_size); |
1076 |
+ |
the_buffer_copy = NULL; |
1077 |
+ |
} |
1078 |
+ |
if (the_buffer != VM_MAP_FAILED) { |
1079 |
+ |
vm_release(the_buffer, the_buffer_size); |
1080 |
+ |
the_buffer = NULL; |
1081 |
+ |
} |
1082 |
+ |
} |
1083 |
+ |
#endif |
1084 |
|
} |
1085 |
|
#endif |
1086 |
|
|
1166 |
|
|
1167 |
|
// Init blitting routines |
1168 |
|
int bytes_per_row = TrivialBytesPerRow((v_width + 7) & ~7, mode.depth); |
1169 |
< |
#ifdef VIDEO_VOSF |
1169 |
> |
#if VIDEO_VOSF |
1170 |
|
#if REAL_ADDRESSING || DIRECT_ADDRESSING |
1171 |
|
// Screen_blitter_init() returns TRUE if VOSF is mandatory |
1172 |
|
// i.e. the framebuffer update function is not Blit_Copy_Raw |
1197 |
|
driver_xf86dga::~driver_xf86dga() |
1198 |
|
{ |
1199 |
|
XF86DGADirectVideo(x_display, screen, 0); |
1200 |
+ |
if (!use_vosf) { |
1201 |
+ |
// don't free() the screen buffer in driver_base dtor |
1202 |
+ |
the_buffer = NULL; |
1203 |
+ |
} |
1204 |
+ |
#ifdef ENABLE_VOSF |
1205 |
+ |
else { |
1206 |
+ |
// don't free() the screen buffer in driver_base dtor |
1207 |
+ |
the_host_buffer = NULL; |
1208 |
+ |
|
1209 |
+ |
if (the_buffer_copy != VM_MAP_FAILED) { |
1210 |
+ |
vm_release(the_buffer_copy, the_buffer_size); |
1211 |
+ |
the_buffer_copy = NULL; |
1212 |
+ |
} |
1213 |
+ |
if (the_buffer != VM_MAP_FAILED) { |
1214 |
+ |
vm_release(the_buffer, the_buffer_size); |
1215 |
+ |
the_buffer = NULL; |
1216 |
+ |
} |
1217 |
+ |
} |
1218 |
+ |
#endif |
1219 |
|
#ifdef ENABLE_XF86_VIDMODE |
1220 |
|
if (has_vidmode) |
1221 |
|
XF86VidModeSwitchToMode(x_display, screen, x_video_modes[0]); |
1402 |
|
|
1403 |
|
#ifdef ENABLE_VOSF |
1404 |
|
if (use_vosf) { |
1405 |
< |
// Initialize the mainBuffer structure |
1406 |
< |
if (!video_init_buffer()) { |
1405 |
> |
// Initialize the VOSF system |
1406 |
> |
if (!video_vosf_init()) { |
1407 |
|
ErrorAlert(STR_VOSF_INIT_ERR); |
1408 |
|
return false; |
1409 |
|
} |
1351 |
– |
|
1352 |
– |
// Initialize the handler for SIGSEGV |
1353 |
– |
if (!sigsegv_install_handler(screen_fault_handler)) { |
1354 |
– |
ErrorAlert("Could not initialize Video on SEGV signals"); |
1355 |
– |
return false; |
1356 |
– |
} |
1410 |
|
} |
1411 |
|
#endif |
1412 |
|
|
1622 |
|
XSync(x_display, false); |
1623 |
|
|
1624 |
|
#ifdef ENABLE_VOSF |
1572 |
– |
// Deinitialize VOSF |
1625 |
|
if (use_vosf) { |
1626 |
< |
if (mainBuffer.pageInfo) { |
1627 |
< |
free(mainBuffer.pageInfo); |
1576 |
< |
mainBuffer.pageInfo = NULL; |
1577 |
< |
} |
1578 |
< |
if (mainBuffer.dirtyPages) { |
1579 |
< |
free(mainBuffer.dirtyPages); |
1580 |
< |
mainBuffer.dirtyPages = NULL; |
1581 |
< |
} |
1626 |
> |
// Deinitialize VOSF |
1627 |
> |
video_vosf_exit(); |
1628 |
|
} |
1629 |
|
#endif |
1630 |
|
|