mirror of https://github.com/OpenTTD/OpenTTD
(svn r4100) -Backported 4082 and 4099
the cocoa driver no longer crashes when going to fullscreen (this one depended on the resolution) teh cocoa driver speedup of around 1000% applies to Intel macs, so the driver is now just as fast as the PPC onerelease/0.4
parent
37835e9158
commit
b320aa40fa
|
@ -1507,54 +1507,41 @@ static void QZ_DrawScreen(void)
|
||||||
uint width;
|
uint width;
|
||||||
uint pitch;
|
uint pitch;
|
||||||
uint y;
|
uint y;
|
||||||
|
uint num_dirty_rects;
|
||||||
|
uint length_drawn;
|
||||||
|
uint left;
|
||||||
|
uint i;
|
||||||
|
|
||||||
src = _cocoa_video_data.pixels;
|
src = _cocoa_video_data.pixels;
|
||||||
dst = (uint8*)_cocoa_video_data.realpixels;
|
dst = (uint8*)_cocoa_video_data.realpixels;
|
||||||
width = _cocoa_video_data.width;
|
width = _cocoa_video_data.width;
|
||||||
pitch = _cocoa_video_data.pitch;
|
pitch = _cocoa_video_data.pitch;
|
||||||
|
num_dirty_rects = _cocoa_video_data.num_dirty_rects;
|
||||||
|
|
||||||
#ifdef __POWERPC__
|
/* Check if we need to do anything */
|
||||||
// PPC appears to handle updating of rectangles right
|
if (num_dirty_rects == 0 ) return;
|
||||||
{
|
|
||||||
uint num_dirty_rects;
|
|
||||||
uint length_drawn;
|
|
||||||
uint left;
|
|
||||||
uint i;
|
|
||||||
|
|
||||||
num_dirty_rects = _cocoa_video_data.num_dirty_rects;
|
if (num_dirty_rects >= MAX_DIRTY_RECTS) {
|
||||||
|
num_dirty_rects = 1;
|
||||||
/* Check if we need to do anything */
|
_cocoa_video_data.dirty_rects[0].left = 0;
|
||||||
if (num_dirty_rects == 0 ) return;
|
_cocoa_video_data.dirty_rects[0].top = 0;
|
||||||
|
_cocoa_video_data.dirty_rects[0].right = _cocoa_video_data.width;
|
||||||
if (num_dirty_rects >= MAX_DIRTY_RECTS) {
|
_cocoa_video_data.dirty_rects[0].bottom = _cocoa_video_data.height;
|
||||||
num_dirty_rects = 1;
|
|
||||||
_cocoa_video_data.dirty_rects[0].left = 0;
|
|
||||||
_cocoa_video_data.dirty_rects[0].top = 0;
|
|
||||||
_cocoa_video_data.dirty_rects[0].right = _cocoa_video_data.width;
|
|
||||||
_cocoa_video_data.dirty_rects[0].bottom = _cocoa_video_data.height;
|
|
||||||
}
|
|
||||||
|
|
||||||
QZ_WaitForVerticalBlank();
|
|
||||||
/* Build the region of dirty rectangles */
|
|
||||||
for (i = 0; i < num_dirty_rects; i++) {
|
|
||||||
|
|
||||||
y = _cocoa_video_data.dirty_rects[i].top;
|
|
||||||
left = _cocoa_video_data.dirty_rects[i].left;
|
|
||||||
length_drawn = _cocoa_video_data.dirty_rects[i].right - left + 1;
|
|
||||||
height = _cocoa_video_data.dirty_rects[i].bottom;
|
|
||||||
for (; y <= height; y++) memcpy(dst + y * pitch + left, src + y * width +left, length_drawn);
|
|
||||||
}
|
|
||||||
|
|
||||||
_cocoa_video_data.num_dirty_rects = 0;
|
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
// 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
|
|
||||||
// we need to switch to use Quartz exclusively (no QuickDraw commands at all) to fix this
|
|
||||||
// to use Quartz exclusively, we should use 16 or 32 bit graphics since 8 bit coloured graphic support sucks
|
|
||||||
height = _cocoa_video_data.height;
|
|
||||||
QZ_WaitForVerticalBlank();
|
QZ_WaitForVerticalBlank();
|
||||||
for (y = 0; y < height; y++) memcpy(dst + y * pitch, src + y * width, width);
|
/* Build the region of dirty rectangles */
|
||||||
#endif
|
for (i = 0; i < num_dirty_rects; i++) {
|
||||||
|
|
||||||
|
y = _cocoa_video_data.dirty_rects[i].top;
|
||||||
|
left = _cocoa_video_data.dirty_rects[i].left;
|
||||||
|
length_drawn = _cocoa_video_data.dirty_rects[i].right - left;
|
||||||
|
height = _cocoa_video_data.dirty_rects[i].bottom;
|
||||||
|
for (; y < height; y++) memcpy(dst + y * pitch + left, src + y * width +left, length_drawn);
|
||||||
|
}
|
||||||
|
|
||||||
|
_cocoa_video_data.num_dirty_rects = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int QZ_ListFullscreenModes (OTTDPoint *mode_list, int max_modes) {
|
static int QZ_ListFullscreenModes (OTTDPoint *mode_list, int max_modes) {
|
||||||
|
@ -1701,9 +1688,11 @@ static void QZ_UpdateVideoModes(void)
|
||||||
current_modes = _default_resolutions;
|
current_modes = _default_resolutions;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0, j = 0; j < lengthof(_resolutions) && i < count; i++) {
|
for (i = 0, j = 0; j < lengthof(_resolutions) && i < count; i++) {
|
||||||
if (_cocoa_video_data.fullscreen || ((uint) current_modes[i].x <= _cocoa_video_data.device_width &&
|
if (_cocoa_video_data.fullscreen || (
|
||||||
(uint) current_modes[i].y <= _cocoa_video_data.device_height)) {
|
(uint)current_modes[i].x < _cocoa_video_data.device_width &&
|
||||||
|
(uint)current_modes[i].y < _cocoa_video_data.device_height)
|
||||||
|
) {
|
||||||
_resolutions[j][0] = current_modes[i].x;
|
_resolutions[j][0] = current_modes[i].x;
|
||||||
_resolutions[j][1] = current_modes[i].y;
|
_resolutions[j][1] = current_modes[i].y;
|
||||||
j++;
|
j++;
|
||||||
|
|
Loading…
Reference in New Issue