919 { |
918 { |
920 /* restore cached image, since it may not be current, post expose event too */ |
919 /* restore cached image, since it may not be current, post expose event too */ |
921 [ self restoreCachedImage ]; |
920 [ self restoreCachedImage ]; |
922 |
921 |
923 _cocoa_video_data.active = true; |
922 _cocoa_video_data.active = true; |
924 // DEBUG(driver, 1)("cocoa_v: appDidUnhide"); |
|
925 } |
923 } |
926 |
924 |
927 |
925 |
928 - (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)flag |
926 - (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)flag |
929 { |
927 { |
951 } |
949 } |
952 |
950 |
953 - (void)windowDidBecomeKey:(NSNotification *)aNotification |
951 - (void)windowDidBecomeKey:(NSNotification *)aNotification |
954 { |
952 { |
955 _cocoa_video_data.active = true; |
953 _cocoa_video_data.active = true; |
956 // DEBUG(driver, 1)("cocoa_v: windowDidBecomeKey"); |
|
957 } |
954 } |
958 |
955 |
959 - (void)windowDidResignKey:(NSNotification *)aNotification |
956 - (void)windowDidResignKey:(NSNotification *)aNotification |
960 { |
957 { |
961 _cocoa_video_data.active = false; |
958 _cocoa_video_data.active = false; |
962 // DEBUG(driver, 1)("cocoa_v: windowDidResignKey"); |
|
963 } |
959 } |
964 |
960 |
965 - (void)windowDidBecomeMain:(NSNotification *)aNotification |
961 - (void)windowDidBecomeMain:(NSNotification *)aNotification |
966 { |
962 { |
967 _cocoa_video_data.active = true; |
963 _cocoa_video_data.active = true; |
968 // DEBUG(driver, 1)("cocoa_v: windowDidBecomeMain"); |
|
969 } |
964 } |
970 |
965 |
971 - (void)windowDidResignMain:(NSNotification *)aNotification |
966 - (void)windowDidResignMain:(NSNotification *)aNotification |
972 { |
967 { |
973 _cocoa_video_data.active = false; |
968 _cocoa_video_data.active = false; |
974 // DEBUG(driver, 1)("cocoa_v: windowDidResignMain"); |
|
975 } |
969 } |
976 |
970 |
977 @end |
971 @end |
978 |
972 |
979 |
973 |
1505 CSleep((uint32) (adjustment * 1000)); |
1499 CSleep((uint32) (adjustment * 1000)); |
1506 } |
1500 } |
1507 |
1501 |
1508 static void QZ_DrawScreen(void) |
1502 static void QZ_DrawScreen(void) |
1509 { |
1503 { |
|
1504 const uint8* src; |
|
1505 uint8* dst; |
|
1506 uint height; |
|
1507 uint width; |
|
1508 uint pitch; |
1510 uint y; |
1509 uint y; |
1511 uint8 *src, *dst; |
1510 |
1512 |
1511 src = _cocoa_video_data.pixels; |
|
1512 dst = (uint8*)_cocoa_video_data.realpixels; |
|
1513 width = _cocoa_video_data.width; |
|
1514 pitch = _cocoa_video_data.pitch; |
|
1515 |
|
1516 #ifdef __POWERPC__ |
|
1517 // PPC appears to handle updating of rectangles right |
|
1518 { |
|
1519 uint num_dirty_rects; |
|
1520 uint length_drawn; |
|
1521 uint left; |
|
1522 uint i; |
|
1523 |
|
1524 num_dirty_rects = _cocoa_video_data.num_dirty_rects; |
|
1525 |
|
1526 /* Check if we need to do anything */ |
|
1527 if (num_dirty_rects == 0 ) return; |
|
1528 |
|
1529 if (num_dirty_rects >= MAX_DIRTY_RECTS) { |
|
1530 num_dirty_rects = 1; |
|
1531 _cocoa_video_data.dirty_rects[0].left = 0; |
|
1532 _cocoa_video_data.dirty_rects[0].top = 0; |
|
1533 _cocoa_video_data.dirty_rects[0].right = _cocoa_video_data.width; |
|
1534 _cocoa_video_data.dirty_rects[0].bottom = _cocoa_video_data.height; |
|
1535 } |
|
1536 |
|
1537 QZ_WaitForVerticalBlank(); |
|
1538 /* Build the region of dirty rectangles */ |
|
1539 for (i = 0; i < num_dirty_rects; i++) { |
|
1540 |
|
1541 y = _cocoa_video_data.dirty_rects[i].top; |
|
1542 left = _cocoa_video_data.dirty_rects[i].left; |
|
1543 length_drawn = _cocoa_video_data.dirty_rects[i].right - left + 1; |
|
1544 height = _cocoa_video_data.dirty_rects[i].bottom; |
|
1545 for (; y <= height; y++) memcpy(dst + y * pitch + left, src + y * width +left, length_drawn); |
|
1546 } |
|
1547 |
|
1548 _cocoa_video_data.num_dirty_rects = 0; |
|
1549 } |
|
1550 #else |
|
1551 // it appears that Intel based macs didn't like to only update parts of the screen at a time, so they still update everything at each frame |
|
1552 // we need to switch to use Quartz exclusively (no QuickDraw commands at all) to fix this |
|
1553 // to use Quartz exclusively, we should use 16 or 32 bit graphics since 8 bit coloured graphic support sucks |
|
1554 height = _cocoa_video_data.height; |
1513 QZ_WaitForVerticalBlank(); |
1555 QZ_WaitForVerticalBlank(); |
1514 |
1556 for (y = 0; y < height; y++) memcpy(dst + y * pitch, src + y * width, width); |
1515 for(y = 0; y < _cocoa_video_data.height; y++) { |
1557 #endif |
1516 src = _cocoa_video_data.pixels + y * _cocoa_video_data.width; |
|
1517 dst = ((uint8 *) _cocoa_video_data.realpixels) + y * _cocoa_video_data.pitch; |
|
1518 |
|
1519 memcpy(dst, src, _cocoa_video_data.width); |
|
1520 } |
|
1521 } |
1558 } |
1522 |
1559 |
1523 static int QZ_ListFullscreenModes (OTTDPoint *mode_list, int max_modes) { |
1560 static int QZ_ListFullscreenModes (OTTDPoint *mode_list, int max_modes) { |
1524 CFIndex num_modes; |
1561 CFIndex num_modes; |
1525 CFIndex i; |
1562 CFIndex i; |
1828 CGSetLocalEventsSuppressionInterval (0.0); |
1865 CGSetLocalEventsSuppressionInterval (0.0); |
1829 /* Do the actual warp */ |
1866 /* Do the actual warp */ |
1830 CGWarpMouseCursorPosition (cgp); |
1867 CGWarpMouseCursorPosition (cgp); |
1831 |
1868 |
1832 /* Generate the mouse moved event */ |
1869 /* Generate the mouse moved event */ |
1833 // SDL_PrivateMouseMotion (0, 0, x, y); |
|
1834 } |
1870 } |
1835 |
1871 |
1836 void QZ_ShowMouse (void) { |
1872 void QZ_ShowMouse (void) { |
1837 if (!_cocoa_video_data.cursor_visible) { |
1873 if (!_cocoa_video_data.cursor_visible) { |
1838 [ NSCursor unhide ]; |
1874 [ NSCursor unhide ]; |