32 |
|
#include <algorithm> |
33 |
|
|
34 |
|
#ifdef ENABLE_XF86_DGA |
35 |
< |
#include <X11/extensions/xf86dga.h> |
35 |
> |
# include <X11/extensions/xf86dga.h> |
36 |
|
#endif |
37 |
|
|
38 |
|
#ifdef ENABLE_XF86_VIDMODE |
57 |
|
|
58 |
|
// Constants |
59 |
|
const char KEYCODE_FILE_NAME[] = DATADIR "/keycodes"; |
60 |
+ |
static const bool hw_mac_cursor_accl = true; // Flag: Enable MacOS to X11 copy of cursor? |
61 |
|
|
62 |
|
// Global variables |
63 |
|
static int32 frame_skip; |
64 |
|
static int16 mouse_wheel_mode; |
65 |
|
static int16 mouse_wheel_lines; |
66 |
|
static bool redraw_thread_active = false; // Flag: Redraw thread installed |
67 |
+ |
static pthread_attr_t redraw_thread_attr; // Redraw thread attributes |
68 |
|
static pthread_t redraw_thread; // Redraw thread |
69 |
|
|
70 |
|
static bool local_X11; // Flag: X server running on local machine? |
127 |
|
static uint32 the_buffer_size; // Size of allocated the_buffer |
128 |
|
|
129 |
|
// Variables for DGA mode |
128 |
– |
static char *dga_screen_base; |
129 |
– |
static int dga_fb_width; |
130 |
|
static int current_dga_cmap; |
131 |
|
|
132 |
|
#ifdef ENABLE_XF86_VIDMODE |
196 |
|
} |
197 |
|
} |
198 |
|
|
199 |
+ |
// Return bits per pixel for requested depth |
200 |
+ |
static inline int bytes_per_pixel(int depth) |
201 |
+ |
{ |
202 |
+ |
int bpp; |
203 |
+ |
switch (depth) { |
204 |
+ |
case 8: |
205 |
+ |
bpp = 1; |
206 |
+ |
break; |
207 |
+ |
case 15: case 16: |
208 |
+ |
bpp = 2; |
209 |
+ |
break; |
210 |
+ |
case 24: case 32: |
211 |
+ |
bpp = 4; |
212 |
+ |
break; |
213 |
+ |
default: |
214 |
+ |
abort(); |
215 |
+ |
} |
216 |
+ |
return bpp; |
217 |
+ |
} |
218 |
+ |
|
219 |
|
// Map video_mode depth ID to numerical depth value |
220 |
|
static inline int depth_of_video_mode(int mode) |
221 |
|
{ |
222 |
< |
int depth = -1; |
222 |
> |
int depth; |
223 |
|
switch (mode) { |
224 |
|
case APPLE_1_BIT: |
225 |
|
depth = 1; |
369 |
|
} |
370 |
|
|
371 |
|
// Wait until window is mapped/unmapped |
372 |
< |
void wait_mapped(Window w) |
372 |
> |
static void wait_mapped(Window w) |
373 |
|
{ |
374 |
|
XEvent e; |
375 |
|
do { |
377 |
|
} while ((e.type != MapNotify) || (e.xmap.event != w)); |
378 |
|
} |
379 |
|
|
380 |
< |
void wait_unmapped(Window w) |
380 |
> |
static void wait_unmapped(Window w) |
381 |
|
{ |
382 |
|
XEvent e; |
383 |
|
do { |
506 |
|
XSetState(x_display, the_gc, black_pixel, white_pixel, GXcopy, AllPlanes); |
507 |
|
|
508 |
|
// Create cursor |
509 |
< |
cursor_image = XCreateImage(x_display, vis, 1, XYPixmap, 0, (char *)MacCursor + 4, 16, 16, 16, 2); |
510 |
< |
cursor_image->byte_order = MSBFirst; |
511 |
< |
cursor_image->bitmap_bit_order = MSBFirst; |
512 |
< |
cursor_mask_image = XCreateImage(x_display, vis, 1, XYPixmap, 0, (char *)MacCursor + 36, 16, 16, 16, 2); |
513 |
< |
cursor_mask_image->byte_order = MSBFirst; |
514 |
< |
cursor_mask_image->bitmap_bit_order = MSBFirst; |
515 |
< |
cursor_map = XCreatePixmap(x_display, the_win, 16, 16, 1); |
516 |
< |
cursor_mask_map = XCreatePixmap(x_display, the_win, 16, 16, 1); |
517 |
< |
cursor_gc = XCreateGC(x_display, cursor_map, 0, 0); |
518 |
< |
cursor_mask_gc = XCreateGC(x_display, cursor_mask_map, 0, 0); |
519 |
< |
mac_cursor = XCreatePixmapCursor(x_display, cursor_map, cursor_mask_map, &black, &white, 0, 0); |
520 |
< |
cursor_changed = false; |
509 |
> |
if (hw_mac_cursor_accl) { |
510 |
> |
cursor_image = XCreateImage(x_display, vis, 1, XYPixmap, 0, (char *)MacCursor + 4, 16, 16, 16, 2); |
511 |
> |
cursor_image->byte_order = MSBFirst; |
512 |
> |
cursor_image->bitmap_bit_order = MSBFirst; |
513 |
> |
cursor_mask_image = XCreateImage(x_display, vis, 1, XYPixmap, 0, (char *)MacCursor + 36, 16, 16, 16, 2); |
514 |
> |
cursor_mask_image->byte_order = MSBFirst; |
515 |
> |
cursor_mask_image->bitmap_bit_order = MSBFirst; |
516 |
> |
cursor_map = XCreatePixmap(x_display, the_win, 16, 16, 1); |
517 |
> |
cursor_mask_map = XCreatePixmap(x_display, the_win, 16, 16, 1); |
518 |
> |
cursor_gc = XCreateGC(x_display, cursor_map, 0, 0); |
519 |
> |
cursor_mask_gc = XCreateGC(x_display, cursor_mask_map, 0, 0); |
520 |
> |
mac_cursor = XCreatePixmapCursor(x_display, cursor_map, cursor_mask_map, &black, &white, 0, 0); |
521 |
> |
cursor_changed = false; |
522 |
> |
} |
523 |
> |
|
524 |
> |
// Create no_cursor |
525 |
> |
else { |
526 |
> |
mac_cursor = XCreatePixmapCursor(x_display, |
527 |
> |
XCreatePixmap(x_display, the_win, 1, 1, 1), |
528 |
> |
XCreatePixmap(x_display, the_win, 1, 1, 1), |
529 |
> |
&black, &white, 0, 0); |
530 |
> |
XDefineCursor(x_display, the_win, mac_cursor); |
531 |
> |
} |
532 |
|
|
533 |
|
// Init blitting routines |
534 |
|
bool native_byte_order; |
553 |
|
// Set relative mouse mode |
554 |
|
ADBSetRelMouseMode(true); |
555 |
|
|
556 |
+ |
// Create window |
557 |
+ |
XSetWindowAttributes wattr; |
558 |
+ |
wattr.event_mask = eventmask = dga_eventmask; |
559 |
+ |
wattr.override_redirect = True; |
560 |
+ |
wattr.colormap = (depth == 1 ? DefaultColormap(x_display, screen) : cmap[0]); |
561 |
+ |
the_win = XCreateWindow(x_display, rootwin, 0, 0, width, height, 0, xdepth, |
562 |
+ |
InputOutput, vis, CWEventMask | CWOverrideRedirect | |
563 |
+ |
(color_class == DirectColor ? CWColormap : 0), &wattr); |
564 |
+ |
|
565 |
+ |
// Show window |
566 |
+ |
XMapRaised(x_display, the_win); |
567 |
+ |
wait_mapped(the_win); |
568 |
+ |
|
569 |
|
#ifdef ENABLE_XF86_VIDMODE |
570 |
|
// Switch to best mode |
571 |
|
if (has_vidmode) { |
582 |
|
#endif |
583 |
|
|
584 |
|
// Establish direct screen connection |
585 |
+ |
XMoveResizeWindow(x_display, the_win, 0, 0, width, height); |
586 |
+ |
XWarpPointer(x_display, None, rootwin, 0, 0, 0, 0, 0, 0); |
587 |
|
XGrabKeyboard(x_display, rootwin, True, GrabModeAsync, GrabModeAsync, CurrentTime); |
588 |
|
XGrabPointer(x_display, rootwin, True, PointerMotionMask | ButtonPressMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None, CurrentTime); |
589 |
+ |
|
590 |
+ |
int v_width, v_bank, v_size; |
591 |
+ |
XF86DGAGetVideo(x_display, screen, (char **)&the_buffer, &v_width, &v_bank, &v_size); |
592 |
|
XF86DGADirectVideo(x_display, screen, XF86DGADirectGraphics | XF86DGADirectKeyb | XF86DGADirectMouse); |
593 |
|
XF86DGASetViewPort(x_display, screen, 0, 0); |
594 |
|
XF86DGASetVidPage(x_display, screen, 0); |
595 |
|
|
596 |
|
// Set colormap |
597 |
< |
if (depth == 8) |
597 |
> |
if (!IsDirectMode(get_current_mode())) { |
598 |
> |
XSetWindowColormap(x_display, the_win, cmap[current_dga_cmap = 0]); |
599 |
|
XF86DGAInstallColormap(x_display, screen, cmap[current_dga_cmap]); |
600 |
+ |
} |
601 |
+ |
XSync(x_display, false); |
602 |
|
|
603 |
< |
// Set bytes per row |
604 |
< |
int bytes_per_row = TrivialBytesPerRow((dga_fb_width + 7) & ~7, DepthModeForPixelDepth(depth)); |
553 |
< |
|
603 |
> |
// Init blitting routines |
604 |
> |
int bytes_per_row = TrivialBytesPerRow((v_width + 7) & ~7, DepthModeForPixelDepth(depth)); |
605 |
|
#if ENABLE_VOSF |
606 |
|
bool native_byte_order; |
607 |
|
#ifdef WORDS_BIGENDIAN |
620 |
|
the_buffer_size = page_extend((height + 2) * bytes_per_row); |
621 |
|
the_buffer_copy = (uint8 *)malloc(the_buffer_size); |
622 |
|
the_buffer = (uint8 *)vm_acquire(the_buffer_size); |
623 |
+ |
D(bug("the_buffer = %p, the_buffer_copy = %p, the_host_buffer = %p\n", the_buffer, the_buffer_copy, the_host_buffer)); |
624 |
|
} |
625 |
|
#else |
626 |
|
use_vosf = false; |
575 |
– |
the_buffer = dga_screen_base; |
627 |
|
#endif |
628 |
|
#endif |
578 |
– |
screen_base = (uint32)the_buffer; |
629 |
|
|
630 |
+ |
// Set frame buffer base |
631 |
+ |
D(bug("the_buffer = %p, use_vosf = %d\n", the_buffer, use_vosf)); |
632 |
+ |
screen_base = (uint32)the_buffer; |
633 |
|
VModes[cur_mode].viRowBytes = bytes_per_row; |
581 |
– |
XSync(x_display, false); |
634 |
|
return true; |
635 |
|
#else |
636 |
|
ErrorAlert("SheepShaver has been compiled with DGA support disabled."); |
763 |
|
if (the_gc) |
764 |
|
XFreeGC(x_display, the_gc); |
765 |
|
|
714 |
– |
// Close window |
715 |
– |
if (the_win) { |
716 |
– |
XUnmapWindow(x_display, the_win); |
717 |
– |
wait_unmapped(the_win); |
718 |
– |
XDestroyWindow(x_display, the_win); |
719 |
– |
} |
720 |
– |
|
766 |
|
XFlush(x_display); |
767 |
|
XSync(x_display, false); |
768 |
|
} |
800 |
|
else if (display_type == DIS_WINDOW) |
801 |
|
close_window(); |
802 |
|
|
803 |
+ |
// Close window |
804 |
+ |
if (the_win) { |
805 |
+ |
XUnmapWindow(x_display, the_win); |
806 |
+ |
wait_unmapped(the_win); |
807 |
+ |
XDestroyWindow(x_display, the_win); |
808 |
+ |
} |
809 |
+ |
|
810 |
|
// Free colormaps |
811 |
|
if (cmap[0]) { |
812 |
|
XFreeColormap(x_display, cmap[0]); |
923 |
|
} |
924 |
|
} |
925 |
|
|
926 |
+ |
// Find Apple mode matching best specified dimensions |
927 |
+ |
static int find_apple_resolution(int xsize, int ysize) |
928 |
+ |
{ |
929 |
+ |
int apple_id; |
930 |
+ |
if (xsize < 800) |
931 |
+ |
apple_id = APPLE_640x480; |
932 |
+ |
else if (xsize < 1024) |
933 |
+ |
apple_id = APPLE_800x600; |
934 |
+ |
else if (xsize < 1152) |
935 |
+ |
apple_id = APPLE_1024x768; |
936 |
+ |
else if (xsize < 1280) { |
937 |
+ |
if (ysize < 900) |
938 |
+ |
apple_id = APPLE_1152x768; |
939 |
+ |
else |
940 |
+ |
apple_id = APPLE_1152x900; |
941 |
+ |
} |
942 |
+ |
else if (xsize < 1600) |
943 |
+ |
apple_id = APPLE_1280x1024; |
944 |
+ |
else |
945 |
+ |
apple_id = APPLE_1600x1200; |
946 |
+ |
return apple_id; |
947 |
+ |
} |
948 |
+ |
|
949 |
+ |
// Find mode in list of supported modes |
950 |
+ |
static int find_mode(int apple_mode, int apple_id, int type) |
951 |
+ |
{ |
952 |
+ |
for (VideoInfo *p = VModes; p->viType != DIS_INVALID; p++) { |
953 |
+ |
if (p->viType == type && p->viAppleID == apple_id && p->viAppleMode == apple_mode) |
954 |
+ |
return p - VModes; |
955 |
+ |
} |
956 |
+ |
return -1; |
957 |
+ |
} |
958 |
+ |
|
959 |
|
// Add mode to list of supported modes |
960 |
|
static void add_mode(VideoInfo *&p, uint32 allow, uint32 test, int apple_mode, int apple_id, int type) |
961 |
|
{ |
976 |
|
p->viXsize = 1024; |
977 |
|
p->viYsize = 768; |
978 |
|
break; |
979 |
+ |
case APPLE_1152x768: |
980 |
+ |
p->viXsize = 1152; |
981 |
+ |
p->viYsize = 768; |
982 |
+ |
break; |
983 |
|
case APPLE_1152x900: |
984 |
|
p->viXsize = 1152; |
985 |
|
p->viYsize = 900; |
1126 |
|
add_mode(p, screen_modes, 2, default_mode, APPLE_800x600, DIS_SCREEN); |
1127 |
|
if (has_mode(1024, 768)) |
1128 |
|
add_mode(p, screen_modes, 4, default_mode, APPLE_1024x768, DIS_SCREEN); |
1129 |
+ |
if (has_mode(1152, 768)) |
1130 |
+ |
add_mode(p, screen_modes, 64, default_mode, APPLE_1152x768, DIS_SCREEN); |
1131 |
|
if (has_mode(1152, 900)) |
1132 |
|
add_mode(p, screen_modes, 8, default_mode, APPLE_1152x900, DIS_SCREEN); |
1133 |
|
if (has_mode(1280, 1024)) |
1137 |
|
} else if (screen_modes) { |
1138 |
|
int xsize = DisplayWidth(x_display, screen); |
1139 |
|
int ysize = DisplayHeight(x_display, screen); |
1140 |
< |
int apple_id; |
1050 |
< |
if (xsize < 800) |
1051 |
< |
apple_id = APPLE_640x480; |
1052 |
< |
else if (xsize < 1024) |
1053 |
< |
apple_id = APPLE_800x600; |
1054 |
< |
else if (xsize < 1152) |
1055 |
< |
apple_id = APPLE_1024x768; |
1056 |
< |
else if (xsize < 1280) |
1057 |
< |
apple_id = APPLE_1152x900; |
1058 |
< |
else if (xsize < 1600) |
1059 |
< |
apple_id = APPLE_1280x1024; |
1060 |
< |
else |
1061 |
< |
apple_id = APPLE_1600x1200; |
1140 |
> |
int apple_id = find_apple_resolution(xsize, ysize); |
1141 |
|
p->viType = DIS_SCREEN; |
1142 |
|
p->viRowBytes = 0; |
1143 |
|
p->viXsize = xsize; |
1154 |
|
|
1155 |
|
// Find default mode (window 640x480) |
1156 |
|
cur_mode = -1; |
1157 |
< |
for (p = VModes; p->viType != DIS_INVALID; p++) { |
1158 |
< |
if (p->viType == DIS_WINDOW |
1159 |
< |
&& p->viAppleID == APPLE_W_640x480 |
1160 |
< |
&& p->viAppleMode == default_mode) { |
1161 |
< |
cur_mode = p - VModes; |
1162 |
< |
break; |
1157 |
> |
if (has_dga && screen_modes) { |
1158 |
> |
int screen_width = DisplayWidth(x_display, screen); |
1159 |
> |
int screen_height = DisplayHeight(x_display, screen); |
1160 |
> |
int apple_id = find_apple_resolution(screen_width, screen_height); |
1161 |
> |
if (apple_id != -1) |
1162 |
> |
cur_mode = find_mode(default_mode, apple_id, DIS_SCREEN); |
1163 |
> |
} |
1164 |
> |
if (cur_mode == -1) { |
1165 |
> |
// pick up first windowed mode available |
1166 |
> |
for (VideoInfo *p = VModes; p->viType != DIS_INVALID; p++) { |
1167 |
> |
if (p->viType == DIS_WINDOW && p->viAppleMode == default_mode) { |
1168 |
> |
cur_mode = p - VModes; |
1169 |
> |
break; |
1170 |
> |
} |
1171 |
|
} |
1172 |
|
} |
1173 |
|
assert(cur_mode != -1); |
1180 |
|
} |
1181 |
|
#endif |
1182 |
|
|
1096 |
– |
#ifdef ENABLE_XF86_DGA |
1097 |
– |
if (has_dga && screen_modes) { |
1098 |
– |
int v_bank, v_size; |
1099 |
– |
XF86DGAGetVideo(x_display, screen, &dga_screen_base, &dga_fb_width, &v_bank, &v_size); |
1100 |
– |
D(bug("DGA screen_base %p, v_width %d\n", dga_screen_base, dga_fb_width)); |
1101 |
– |
} |
1102 |
– |
#endif |
1103 |
– |
|
1183 |
|
// Open window/screen |
1184 |
|
if (!open_display()) |
1185 |
|
return false; |
1191 |
|
|
1192 |
|
// Start periodic thread |
1193 |
|
XSync(x_display, false); |
1194 |
< |
redraw_thread_active = (pthread_create(&redraw_thread, NULL, redraw_func, NULL) == 0); |
1194 |
> |
Set_pthread_attr(&redraw_thread_attr, 0); |
1195 |
> |
redraw_thread_active = (pthread_create(&redraw_thread, &redraw_thread_attr, redraw_func, NULL) == 0); |
1196 |
|
D(bug("Redraw thread installed (%ld)\n", redraw_thread)); |
1197 |
|
return true; |
1198 |
|
} |
1555 |
|
break; |
1556 |
|
} |
1557 |
|
|
1558 |
< |
// Mouse moved |
1558 |
> |
// Mouse entered window |
1559 |
|
case EnterNotify: |
1560 |
< |
ADBMouseMoved(((XMotionEvent *)&event)->x, ((XMotionEvent *)&event)->y); |
1560 |
> |
if (event.xcrossing.mode != NotifyGrab && event.xcrossing.mode != NotifyUngrab) |
1561 |
> |
ADBMouseMoved(event.xmotion.x, event.xmotion.y); |
1562 |
|
break; |
1563 |
+ |
|
1564 |
+ |
// Mouse moved |
1565 |
|
case MotionNotify: |
1566 |
< |
ADBMouseMoved(((XMotionEvent *)&event)->x, ((XMotionEvent *)&event)->y); |
1566 |
> |
ADBMouseMoved(event.xmotion.x, event.xmotion.y); |
1567 |
|
break; |
1568 |
|
|
1569 |
|
// Keyboard |
1630 |
|
* Install graphics acceleration |
1631 |
|
*/ |
1632 |
|
|
1633 |
< |
#if 0 |
1634 |
< |
// Rectangle blitting |
1635 |
< |
static void accl_bitblt(accl_params *p) |
1633 |
> |
// Rectangle inversion |
1634 |
> |
template< int bpp > |
1635 |
> |
static inline void do_invrect(uint8 *dest, uint32 length) |
1636 |
|
{ |
1637 |
< |
D(bug("accl_bitblt\n")); |
1637 |
> |
#define INVERT_1(PTR, OFS) ((uint8 *)(PTR))[OFS] = ~((uint8 *)(PTR))[OFS] |
1638 |
> |
#define INVERT_2(PTR, OFS) ((uint16 *)(PTR))[OFS] = ~((uint16 *)(PTR))[OFS] |
1639 |
> |
#define INVERT_4(PTR, OFS) ((uint32 *)(PTR))[OFS] = ~((uint32 *)(PTR))[OFS] |
1640 |
> |
#define INVERT_8(PTR, OFS) ((uint64 *)(PTR))[OFS] = ~((uint64 *)(PTR))[OFS] |
1641 |
|
|
1642 |
< |
// Get blitting parameters |
1643 |
< |
int16 src_X = p->src_rect[1] - p->src_bounds[1]; |
1644 |
< |
int16 src_Y = p->src_rect[0] - p->src_bounds[0]; |
1645 |
< |
int16 dest_X = p->dest_rect[1] - p->dest_bounds[1]; |
1646 |
< |
int16 dest_Y = p->dest_rect[0] - p->dest_bounds[0]; |
1647 |
< |
int16 width = p->dest_rect[3] - p->dest_rect[1] - 1; |
1562 |
< |
int16 height = p->dest_rect[2] - p->dest_rect[0] - 1; |
1563 |
< |
D(bug(" src X %d, src Y %d, dest X %d, dest Y %d\n", src_X, src_Y, dest_X, dest_Y)); |
1564 |
< |
D(bug(" width %d, height %d\n", width, height)); |
1642 |
> |
#ifndef UNALIGNED_PROFITABLE |
1643 |
> |
// Align on 16-bit boundaries |
1644 |
> |
if (bpp < 16 && (((uintptr)dest) & 1)) { |
1645 |
> |
INVERT_1(dest, 0); |
1646 |
> |
dest += 1; length -= 1; |
1647 |
> |
} |
1648 |
|
|
1649 |
< |
// And perform the blit |
1650 |
< |
bitblt_hook(src_X, src_Y, dest_X, dest_Y, width, height); |
1651 |
< |
} |
1649 |
> |
// Align on 32-bit boundaries |
1650 |
> |
if (bpp < 32 && (((uintptr)dest) & 2)) { |
1651 |
> |
INVERT_2(dest, 0); |
1652 |
> |
dest += 2; length -= 2; |
1653 |
> |
} |
1654 |
> |
#endif |
1655 |
|
|
1656 |
< |
static bool accl_bitblt_hook(accl_params *p) |
1657 |
< |
{ |
1658 |
< |
D(bug("accl_draw_hook %p\n", p)); |
1656 |
> |
// Invert 8-byte words |
1657 |
> |
if (length >= 8) { |
1658 |
> |
const int r = (length / 8) % 8; |
1659 |
> |
dest += r * 8; |
1660 |
|
|
1661 |
< |
// Check if we can accelerate this bitblt |
1662 |
< |
if (p->src_base_addr == screen_base && p->dest_base_addr == screen_base && |
1663 |
< |
display_type == DIS_SCREEN && bitblt_hook != NULL && |
1664 |
< |
((uint32 *)p)[0x18 >> 2] + ((uint32 *)p)[0x128 >> 2] == 0 && |
1665 |
< |
((uint32 *)p)[0x130 >> 2] == 0 && |
1666 |
< |
p->transfer_mode == 0 && |
1667 |
< |
p->src_row_bytes > 0 && ((uint32 *)p)[0x15c >> 2] > 0) { |
1661 |
> |
int n = ((length / 8) + 7) / 8; |
1662 |
> |
switch (r) { |
1663 |
> |
case 0: do { |
1664 |
> |
dest += 64; |
1665 |
> |
INVERT_8(dest, -8); |
1666 |
> |
case 7: INVERT_8(dest, -7); |
1667 |
> |
case 6: INVERT_8(dest, -6); |
1668 |
> |
case 5: INVERT_8(dest, -5); |
1669 |
> |
case 4: INVERT_8(dest, -4); |
1670 |
> |
case 3: INVERT_8(dest, -3); |
1671 |
> |
case 2: INVERT_8(dest, -2); |
1672 |
> |
case 1: INVERT_8(dest, -1); |
1673 |
> |
} while (--n > 0); |
1674 |
> |
} |
1675 |
> |
} |
1676 |
|
|
1677 |
< |
// Yes, set function pointer |
1678 |
< |
p->draw_proc = accl_bitblt; |
1679 |
< |
return true; |
1677 |
> |
// 32-bit cell to invert? |
1678 |
> |
if (length & 4) { |
1679 |
> |
INVERT_4(dest, 0); |
1680 |
> |
if (bpp <= 16) |
1681 |
> |
dest += 4; |
1682 |
|
} |
1683 |
< |
return false; |
1683 |
> |
|
1684 |
> |
// 16-bit cell to invert? |
1685 |
> |
if (bpp <= 16 && (length & 2)) { |
1686 |
> |
INVERT_2(dest, 0); |
1687 |
> |
if (bpp <= 8) |
1688 |
> |
dest += 2; |
1689 |
> |
} |
1690 |
> |
|
1691 |
> |
// 8-bit cell to invert? |
1692 |
> |
if (bpp <= 8 && (length & 1)) |
1693 |
> |
INVERT_1(dest, 0); |
1694 |
> |
|
1695 |
> |
#undef INVERT_1 |
1696 |
> |
#undef INVERT_2 |
1697 |
> |
#undef INVERT_4 |
1698 |
> |
#undef INVERT_8 |
1699 |
|
} |
1700 |
|
|
1701 |
< |
// Rectangle filling/inversion |
1590 |
< |
static void accl_fillrect8(accl_params *p) |
1701 |
> |
void NQD_invrect(uint32 p) |
1702 |
|
{ |
1703 |
< |
D(bug("accl_fillrect8\n")); |
1703 |
> |
D(bug("accl_invrect %08x\n", p)); |
1704 |
|
|
1705 |
< |
// Get filling parameters |
1706 |
< |
int16 dest_X = p->dest_rect[1] - p->dest_bounds[1]; |
1707 |
< |
int16 dest_Y = p->dest_rect[0] - p->dest_bounds[0]; |
1708 |
< |
int16 dest_X_max = p->dest_rect[3] - p->dest_bounds[1] - 1; |
1709 |
< |
int16 dest_Y_max = p->dest_rect[2] - p->dest_bounds[0] - 1; |
1599 |
< |
uint8 color = p->pen_mode == 8 ? p->fore_pen : p->back_pen; |
1705 |
> |
// Get inversion parameters |
1706 |
> |
int16 dest_X = (int16)ReadMacInt16(p + acclDestRect + 2) - (int16)ReadMacInt16(p + acclDestBoundsRect + 2); |
1707 |
> |
int16 dest_Y = (int16)ReadMacInt16(p + acclDestRect + 0) - (int16)ReadMacInt16(p + acclDestBoundsRect + 0); |
1708 |
> |
int16 width = (int16)ReadMacInt16(p + acclDestRect + 6) - (int16)ReadMacInt16(p + acclDestRect + 2); |
1709 |
> |
int16 height = (int16)ReadMacInt16(p + acclDestRect + 4) - (int16)ReadMacInt16(p + acclDestRect + 0); |
1710 |
|
D(bug(" dest X %d, dest Y %d\n", dest_X, dest_Y)); |
1711 |
< |
D(bug(" dest X max %d, dest Y max %d\n", dest_X_max, dest_Y_max)); |
1711 |
> |
D(bug(" width %d, height %d, bytes_per_row %d\n", width, height, (int32)ReadMacInt32(p + acclDestRowBytes))); |
1712 |
|
|
1713 |
< |
// And perform the fill |
1714 |
< |
fillrect8_hook(dest_X, dest_Y, dest_X_max, dest_Y_max, color); |
1713 |
> |
//!!?? pen_mode == 14 |
1714 |
> |
|
1715 |
> |
// And perform the inversion |
1716 |
> |
const int bpp = bytes_per_pixel(ReadMacInt32(p + acclDestPixelSize)); |
1717 |
> |
const int dest_row_bytes = (int32)ReadMacInt32(p + acclDestRowBytes); |
1718 |
> |
uint8 *dest = Mac2HostAddr(ReadMacInt32(p + acclDestBaseAddr) + (dest_Y * dest_row_bytes) + (dest_X * bpp)); |
1719 |
> |
width *= bpp; |
1720 |
> |
switch (bpp) { |
1721 |
> |
case 1: |
1722 |
> |
for (int i = 0; i < height; i++) { |
1723 |
> |
do_invrect<8>(dest, width); |
1724 |
> |
dest += dest_row_bytes; |
1725 |
> |
} |
1726 |
> |
break; |
1727 |
> |
case 2: |
1728 |
> |
for (int i = 0; i < height; i++) { |
1729 |
> |
do_invrect<16>(dest, width); |
1730 |
> |
dest += dest_row_bytes; |
1731 |
> |
} |
1732 |
> |
break; |
1733 |
> |
case 4: |
1734 |
> |
for (int i = 0; i < height; i++) { |
1735 |
> |
do_invrect<32>(dest, width); |
1736 |
> |
dest += dest_row_bytes; |
1737 |
> |
} |
1738 |
> |
break; |
1739 |
> |
} |
1740 |
|
} |
1741 |
|
|
1742 |
< |
static void accl_fillrect32(accl_params *p) |
1742 |
> |
// Rectangle filling |
1743 |
> |
template< int bpp > |
1744 |
> |
static inline void do_fillrect(uint8 *dest, uint32 color, uint32 length) |
1745 |
|
{ |
1746 |
< |
D(bug("accl_fillrect32\n")); |
1746 |
> |
#define FILL_1(PTR, OFS, VAL) ((uint8 *)(PTR))[OFS] = (VAL) |
1747 |
> |
#define FILL_2(PTR, OFS, VAL) ((uint16 *)(PTR))[OFS] = (VAL) |
1748 |
> |
#define FILL_4(PTR, OFS, VAL) ((uint32 *)(PTR))[OFS] = (VAL) |
1749 |
> |
#define FILL_8(PTR, OFS, VAL) ((uint64 *)(PTR))[OFS] = (VAL) |
1750 |
|
|
1751 |
< |
// Get filling parameters |
1752 |
< |
int16 dest_X = p->dest_rect[1] - p->dest_bounds[1]; |
1753 |
< |
int16 dest_Y = p->dest_rect[0] - p->dest_bounds[0]; |
1754 |
< |
int16 dest_X_max = p->dest_rect[3] - p->dest_bounds[1] - 1; |
1755 |
< |
int16 dest_Y_max = p->dest_rect[2] - p->dest_bounds[0] - 1; |
1756 |
< |
uint32 color = p->pen_mode == 8 ? p->fore_pen : p->back_pen; |
1617 |
< |
D(bug(" dest X %d, dest Y %d\n", dest_X, dest_Y)); |
1618 |
< |
D(bug(" dest X max %d, dest Y max %d\n", dest_X_max, dest_Y_max)); |
1751 |
> |
#ifndef UNALIGNED_PROFITABLE |
1752 |
> |
// Align on 16-bit boundaries |
1753 |
> |
if (bpp < 16 && (((uintptr)dest) & 1)) { |
1754 |
> |
FILL_1(dest, 0, color); |
1755 |
> |
dest += 1; length -= 1; |
1756 |
> |
} |
1757 |
|
|
1758 |
< |
// And perform the fill |
1759 |
< |
fillrect32_hook(dest_X, dest_Y, dest_X_max, dest_Y_max, color); |
1758 |
> |
// Align on 32-bit boundaries |
1759 |
> |
if (bpp < 32 && (((uintptr)dest) & 2)) { |
1760 |
> |
FILL_2(dest, 0, color); |
1761 |
> |
dest += 2; length -= 2; |
1762 |
> |
} |
1763 |
> |
#endif |
1764 |
> |
|
1765 |
> |
// Fill 8-byte words |
1766 |
> |
if (length >= 8) { |
1767 |
> |
const uint64 c = (((uint64)color) << 32) | color; |
1768 |
> |
const int r = (length / 8) % 8; |
1769 |
> |
dest += r * 8; |
1770 |
> |
|
1771 |
> |
int n = ((length / 8) + 7) / 8; |
1772 |
> |
switch (r) { |
1773 |
> |
case 0: do { |
1774 |
> |
dest += 64; |
1775 |
> |
FILL_8(dest, -8, c); |
1776 |
> |
case 7: FILL_8(dest, -7, c); |
1777 |
> |
case 6: FILL_8(dest, -6, c); |
1778 |
> |
case 5: FILL_8(dest, -5, c); |
1779 |
> |
case 4: FILL_8(dest, -4, c); |
1780 |
> |
case 3: FILL_8(dest, -3, c); |
1781 |
> |
case 2: FILL_8(dest, -2, c); |
1782 |
> |
case 1: FILL_8(dest, -1, c); |
1783 |
> |
} while (--n > 0); |
1784 |
> |
} |
1785 |
> |
} |
1786 |
> |
|
1787 |
> |
// 32-bit cell to fill? |
1788 |
> |
if (length & 4) { |
1789 |
> |
FILL_4(dest, 0, color); |
1790 |
> |
if (bpp <= 16) |
1791 |
> |
dest += 4; |
1792 |
> |
} |
1793 |
> |
|
1794 |
> |
// 16-bit cell to fill? |
1795 |
> |
if (bpp <= 16 && (length & 2)) { |
1796 |
> |
FILL_2(dest, 0, color); |
1797 |
> |
if (bpp <= 8) |
1798 |
> |
dest += 2; |
1799 |
> |
} |
1800 |
> |
|
1801 |
> |
// 8-bit cell to fill? |
1802 |
> |
if (bpp <= 8 && (length & 1)) |
1803 |
> |
FILL_1(dest, 0, color); |
1804 |
> |
|
1805 |
> |
#undef FILL_1 |
1806 |
> |
#undef FILL_2 |
1807 |
> |
#undef FILL_4 |
1808 |
> |
#undef FILL_8 |
1809 |
|
} |
1810 |
|
|
1811 |
< |
static void accl_invrect(accl_params *p) |
1811 |
> |
void NQD_fillrect(uint32 p) |
1812 |
|
{ |
1813 |
< |
D(bug("accl_invrect\n")); |
1813 |
> |
D(bug("accl_fillrect %08x\n", p)); |
1814 |
|
|
1815 |
< |
// Get inversion parameters |
1816 |
< |
int16 dest_X = p->dest_rect[1] - p->dest_bounds[1]; |
1817 |
< |
int16 dest_Y = p->dest_rect[0] - p->dest_bounds[0]; |
1818 |
< |
int16 dest_X_max = p->dest_rect[3] - p->dest_bounds[1] - 1; |
1819 |
< |
int16 dest_Y_max = p->dest_rect[2] - p->dest_bounds[0] - 1; |
1815 |
> |
// Get filling parameters |
1816 |
> |
int16 dest_X = (int16)ReadMacInt16(p + acclDestRect + 2) - (int16)ReadMacInt16(p + acclDestBoundsRect + 2); |
1817 |
> |
int16 dest_Y = (int16)ReadMacInt16(p + acclDestRect + 0) - (int16)ReadMacInt16(p + acclDestBoundsRect + 0); |
1818 |
> |
int16 width = (int16)ReadMacInt16(p + acclDestRect + 6) - (int16)ReadMacInt16(p + acclDestRect + 2); |
1819 |
> |
int16 height = (int16)ReadMacInt16(p + acclDestRect + 4) - (int16)ReadMacInt16(p + acclDestRect + 0); |
1820 |
> |
uint32 color = htonl(ReadMacInt32(p + acclPenMode) == 8 ? ReadMacInt32(p + acclForePen) : ReadMacInt32(p + acclBackPen)); |
1821 |
|
D(bug(" dest X %d, dest Y %d\n", dest_X, dest_Y)); |
1822 |
< |
D(bug(" dest X max %d, dest Y max %d\n", dest_X_max, dest_Y_max)); |
1823 |
< |
|
1636 |
< |
//!!?? pen_mode == 14 |
1822 |
> |
D(bug(" width %d, height %d\n", width, height)); |
1823 |
> |
D(bug(" bytes_per_row %d color %08x\n", (int32)ReadMacInt32(p + acclDestRowBytes), color)); |
1824 |
|
|
1825 |
< |
// And perform the inversion |
1826 |
< |
invrect_hook(dest_X, dest_Y, dest_X_max, dest_Y_max); |
1825 |
> |
// And perform the fill |
1826 |
> |
const int bpp = bytes_per_pixel(ReadMacInt32(p + acclDestPixelSize)); |
1827 |
> |
const int dest_row_bytes = (int32)ReadMacInt32(p + acclDestRowBytes); |
1828 |
> |
uint8 *dest = Mac2HostAddr(ReadMacInt32(p + acclDestBaseAddr) + (dest_Y * dest_row_bytes) + (dest_X * bpp)); |
1829 |
> |
width *= bpp; |
1830 |
> |
switch (bpp) { |
1831 |
> |
case 1: |
1832 |
> |
for (int i = 0; i < height; i++) { |
1833 |
> |
memset(dest, color, width); |
1834 |
> |
dest += dest_row_bytes; |
1835 |
> |
} |
1836 |
> |
break; |
1837 |
> |
case 2: |
1838 |
> |
for (int i = 0; i < height; i++) { |
1839 |
> |
do_fillrect<16>(dest, color, width); |
1840 |
> |
dest += dest_row_bytes; |
1841 |
> |
} |
1842 |
> |
break; |
1843 |
> |
case 4: |
1844 |
> |
for (int i = 0; i < height; i++) { |
1845 |
> |
do_fillrect<32>(dest, color, width); |
1846 |
> |
dest += dest_row_bytes; |
1847 |
> |
} |
1848 |
> |
break; |
1849 |
> |
} |
1850 |
|
} |
1851 |
|
|
1852 |
< |
static bool accl_fillrect_hook(accl_params *p) |
1852 |
> |
bool NQD_fillrect_hook(uint32 p) |
1853 |
|
{ |
1854 |
< |
D(bug("accl_fillrect_hook %p\n", p)); |
1854 |
> |
D(bug("accl_fillrect_hook %08x\n", p)); |
1855 |
|
|
1856 |
|
// Check if we can accelerate this fillrect |
1857 |
< |
if (p->dest_base_addr == screen_base && ((uint32 *)p)[0x284 >> 2] != 0 && display_type == DIS_SCREEN) { |
1858 |
< |
if (p->transfer_mode == 8) { |
1857 |
> |
if (ReadMacInt32(p + 0x284) != 0 && ReadMacInt32(p + acclDestPixelSize) >= 8) { |
1858 |
> |
const int transfer_mode = ReadMacInt32(p + acclTransferMode); |
1859 |
> |
if (transfer_mode == 8) { |
1860 |
|
// Fill |
1861 |
< |
if (p->dest_pixel_size == 8 && fillrect8_hook != NULL) { |
1862 |
< |
p->draw_proc = accl_fillrect8; |
1863 |
< |
return true; |
1864 |
< |
} else if (p->dest_pixel_size == 32 && fillrect32_hook != NULL) { |
1654 |
< |
p->draw_proc = accl_fillrect32; |
1655 |
< |
return true; |
1656 |
< |
} |
1657 |
< |
} else if (p->transfer_mode == 10 && invrect_hook != NULL) { |
1861 |
> |
WriteMacInt32(p + acclDrawProc, NativeTVECT(NATIVE_FILLRECT)); |
1862 |
> |
return true; |
1863 |
> |
} |
1864 |
> |
else if (transfer_mode == 10) { |
1865 |
|
// Invert |
1866 |
< |
p->draw_proc = accl_invrect; |
1866 |
> |
WriteMacInt32(p + acclDrawProc, NativeTVECT(NATIVE_INVRECT)); |
1867 |
|
return true; |
1868 |
|
} |
1869 |
|
} |
1870 |
|
return false; |
1871 |
|
} |
1872 |
|
|
1873 |
+ |
// Rectangle blitting |
1874 |
+ |
// TODO: optimize for VOSF and target pixmap == screen |
1875 |
+ |
void NQD_bitblt(uint32 p) |
1876 |
+ |
{ |
1877 |
+ |
D(bug("accl_bitblt %08x\n", p)); |
1878 |
+ |
|
1879 |
+ |
// Get blitting parameters |
1880 |
+ |
int16 src_X = (int16)ReadMacInt16(p + acclSrcRect + 2) - (int16)ReadMacInt16(p + acclSrcBoundsRect + 2); |
1881 |
+ |
int16 src_Y = (int16)ReadMacInt16(p + acclSrcRect + 0) - (int16)ReadMacInt16(p + acclSrcBoundsRect + 0); |
1882 |
+ |
int16 dest_X = (int16)ReadMacInt16(p + acclDestRect + 2) - (int16)ReadMacInt16(p + acclDestBoundsRect + 2); |
1883 |
+ |
int16 dest_Y = (int16)ReadMacInt16(p + acclDestRect + 0) - (int16)ReadMacInt16(p + acclDestBoundsRect + 0); |
1884 |
+ |
int16 width = (int16)ReadMacInt16(p + acclDestRect + 6) - (int16)ReadMacInt16(p + acclDestRect + 2); |
1885 |
+ |
int16 height = (int16)ReadMacInt16(p + acclDestRect + 4) - (int16)ReadMacInt16(p + acclDestRect + 0); |
1886 |
+ |
D(bug(" src addr %08x, dest addr %08x\n", ReadMacInt32(p + acclSrcBaseAddr), ReadMacInt32(p + acclDestBaseAddr))); |
1887 |
+ |
D(bug(" src X %d, src Y %d, dest X %d, dest Y %d\n", src_X, src_Y, dest_X, dest_Y)); |
1888 |
+ |
D(bug(" width %d, height %d\n", width, height)); |
1889 |
+ |
|
1890 |
+ |
// And perform the blit |
1891 |
+ |
const int bpp = bytes_per_pixel(ReadMacInt32(p + acclSrcPixelSize)); |
1892 |
+ |
width *= bpp; |
1893 |
+ |
if ((int32)ReadMacInt32(p + acclSrcRowBytes) > 0) { |
1894 |
+ |
const int src_row_bytes = (int32)ReadMacInt32(p + acclSrcRowBytes); |
1895 |
+ |
const int dst_row_bytes = (int32)ReadMacInt32(p + acclDestRowBytes); |
1896 |
+ |
uint8 *src = Mac2HostAddr(ReadMacInt32(p + acclSrcBaseAddr) + (src_Y * src_row_bytes) + (src_X * bpp)); |
1897 |
+ |
uint8 *dst = Mac2HostAddr(ReadMacInt32(p + acclDestBaseAddr) + (dest_Y * dst_row_bytes) + (dest_X * bpp)); |
1898 |
+ |
for (int i = 0; i < height; i++) { |
1899 |
+ |
memmove(dst, src, width); |
1900 |
+ |
src += src_row_bytes; |
1901 |
+ |
dst += dst_row_bytes; |
1902 |
+ |
} |
1903 |
+ |
} |
1904 |
+ |
else { |
1905 |
+ |
const int src_row_bytes = -(int32)ReadMacInt32(p + acclSrcRowBytes); |
1906 |
+ |
const int dst_row_bytes = -(int32)ReadMacInt32(p + acclDestRowBytes); |
1907 |
+ |
uint8 *src = Mac2HostAddr(ReadMacInt32(p + acclSrcBaseAddr) + ((src_Y + height - 1) * src_row_bytes) + (src_X * bpp)); |
1908 |
+ |
uint8 *dst = Mac2HostAddr(ReadMacInt32(p + acclDestBaseAddr) + ((dest_Y + height - 1) * dst_row_bytes) + (dest_X * bpp)); |
1909 |
+ |
for (int i = height - 1; i >= 0; i--) { |
1910 |
+ |
memmove(dst, src, width); |
1911 |
+ |
src -= src_row_bytes; |
1912 |
+ |
dst -= dst_row_bytes; |
1913 |
+ |
} |
1914 |
+ |
} |
1915 |
+ |
} |
1916 |
+ |
|
1917 |
+ |
/* |
1918 |
+ |
BitBlt transfer modes: |
1919 |
+ |
0 : srcCopy |
1920 |
+ |
1 : srcOr |
1921 |
+ |
2 : srcXor |
1922 |
+ |
3 : srcBic |
1923 |
+ |
4 : notSrcCopy |
1924 |
+ |
5 : notSrcOr |
1925 |
+ |
6 : notSrcXor |
1926 |
+ |
7 : notSrcBic |
1927 |
+ |
32 : blend |
1928 |
+ |
33 : addPin |
1929 |
+ |
34 : addOver |
1930 |
+ |
35 : subPin |
1931 |
+ |
36 : transparent |
1932 |
+ |
37 : adMax |
1933 |
+ |
38 : subOver |
1934 |
+ |
39 : adMin |
1935 |
+ |
50 : hilite |
1936 |
+ |
*/ |
1937 |
+ |
|
1938 |
+ |
bool NQD_bitblt_hook(uint32 p) |
1939 |
+ |
{ |
1940 |
+ |
D(bug("accl_draw_hook %08x\n", p)); |
1941 |
+ |
|
1942 |
+ |
// Check if we can accelerate this bitblt |
1943 |
+ |
if (ReadMacInt32(p + 0x018) + ReadMacInt32(p + 0x128) == 0 && |
1944 |
+ |
ReadMacInt32(p + 0x130) == 0 && |
1945 |
+ |
ReadMacInt32(p + acclSrcPixelSize) >= 8 && |
1946 |
+ |
ReadMacInt32(p + acclSrcPixelSize) == ReadMacInt32(p + acclDestPixelSize) && |
1947 |
+ |
(ReadMacInt32(p + acclSrcRowBytes) ^ ReadMacInt32(p + acclDestRowBytes)) >= 0 && // same sign? |
1948 |
+ |
ReadMacInt32(p + acclTransferMode) == 0 && // srcCopy? |
1949 |
+ |
ReadMacInt32(p + 0x15c) > 0) { |
1950 |
+ |
|
1951 |
+ |
// Yes, set function pointer |
1952 |
+ |
WriteMacInt32(p + acclDrawProc, NativeTVECT(NATIVE_BITBLT)); |
1953 |
+ |
return true; |
1954 |
+ |
} |
1955 |
+ |
return false; |
1956 |
+ |
} |
1957 |
+ |
|
1958 |
|
// Wait for graphics operation to finish |
1959 |
< |
static bool accl_sync_hook(void *arg) |
1959 |
> |
bool NQD_sync_hook(uint32 arg) |
1960 |
|
{ |
1961 |
< |
D(bug("accl_sync_hook %p\n", arg)); |
1670 |
< |
if (sync_hook != NULL) |
1671 |
< |
sync_hook(); |
1961 |
> |
D(bug("accl_sync_hook %08x\n", arg)); |
1962 |
|
return true; |
1963 |
|
} |
1964 |
|
|
1675 |
– |
static struct accl_hook_info bitblt_hook_info = {accl_bitblt_hook, accl_sync_hook, ACCL_BITBLT}; |
1676 |
– |
static struct accl_hook_info fillrect_hook_info = {accl_fillrect_hook, accl_sync_hook, ACCL_FILLRECT}; |
1677 |
– |
#endif |
1678 |
– |
|
1965 |
|
void VideoInstallAccel(void) |
1966 |
|
{ |
1967 |
|
// Install acceleration hooks |
1968 |
|
if (PrefsFindBool("gfxaccel")) { |
1969 |
|
D(bug("Video: Installing acceleration hooks\n")); |
1970 |
< |
//!! NQDMisc(6, &bitblt_hook_info); |
1971 |
< |
// NQDMisc(6, &fillrect_hook_info); |
1970 |
> |
uint32 base; |
1971 |
> |
|
1972 |
> |
SheepVar bitblt_hook_info(sizeof(accl_hook_info)); |
1973 |
> |
base = bitblt_hook_info.addr(); |
1974 |
> |
WriteMacInt32(base + 0, NativeTVECT(NATIVE_BITBLT_HOOK)); |
1975 |
> |
WriteMacInt32(base + 4, NativeTVECT(NATIVE_SYNC_HOOK)); |
1976 |
> |
WriteMacInt32(base + 8, ACCL_BITBLT); |
1977 |
> |
NQDMisc(6, bitblt_hook_info.ptr()); |
1978 |
> |
|
1979 |
> |
SheepVar fillrect_hook_info(sizeof(accl_hook_info)); |
1980 |
> |
base = fillrect_hook_info.addr(); |
1981 |
> |
WriteMacInt32(base + 0, NativeTVECT(NATIVE_FILLRECT_HOOK)); |
1982 |
> |
WriteMacInt32(base + 4, NativeTVECT(NATIVE_SYNC_HOOK)); |
1983 |
> |
WriteMacInt32(base + 8, ACCL_FILLRECT); |
1984 |
> |
NQDMisc(6, fillrect_hook_info.ptr()); |
1985 |
|
} |
1986 |
|
} |
1987 |
|
|
2089 |
|
|
2090 |
|
|
2091 |
|
/* |
2092 |
+ |
* Can we set the MacOS cursor image into the window? |
2093 |
+ |
*/ |
2094 |
+ |
|
2095 |
+ |
bool video_can_change_cursor(void) |
2096 |
+ |
{ |
2097 |
+ |
return hw_mac_cursor_accl && (display_type != DIS_SCREEN); |
2098 |
+ |
} |
2099 |
+ |
|
2100 |
+ |
|
2101 |
+ |
/* |
2102 |
|
* Set cursor image for window |
2103 |
|
*/ |
2104 |
|
|
2308 |
|
XF86DGADirectVideo(x_display, screen, 0); |
2309 |
|
XUngrabPointer(x_display, CurrentTime); |
2310 |
|
XUngrabKeyboard(x_display, CurrentTime); |
2311 |
+ |
XUnmapWindow(x_display, the_win); |
2312 |
+ |
wait_unmapped(the_win); |
2313 |
+ |
XDestroyWindow(x_display, the_win); |
2314 |
|
#endif |
2315 |
|
XSync(x_display, false); |
2316 |
|
XDisplayUnlock(); |
2343 |
|
update_display(); |
2344 |
|
|
2345 |
|
// Set new cursor image if it was changed |
2346 |
< |
if (cursor_changed) { |
2346 |
> |
if (hw_mac_cursor_accl && cursor_changed) { |
2347 |
|
cursor_changed = false; |
2348 |
|
memcpy(cursor_image->data, MacCursor + 4, 32); |
2349 |
|
memcpy(cursor_mask_image->data, MacCursor + 36, 32); |