summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/video/cocoa/fullscreen.mm86
-rw-r--r--src/video/cocoa/wnd_quartz.mm60
-rw-r--r--src/video/cocoa/wnd_quickdraw.mm40
3 files changed, 93 insertions, 93 deletions
diff --git a/src/video/cocoa/fullscreen.mm b/src/video/cocoa/fullscreen.mm
index 1f35d2c59..9816176eb 100644
--- a/src/video/cocoa/fullscreen.mm
+++ b/src/video/cocoa/fullscreen.mm
@@ -84,7 +84,7 @@ static int CDECL ModeSorter(const OTTD_Point *p1, const OTTD_Point *p2)
return 0;
}
-uint QZ_ListModes(OTTD_Point *modes, uint max_modes, CGDirectDisplayID display_id, int display_depth)
+uint QZ_ListModes(OTTD_Point *modes, uint max_modes, CGDirectDisplayID display_id, int device_depth)
{
CFArrayRef mode_list = CGDisplayAvailableModes(display_id);
CFIndex num_modes = CFArrayGetCount(mode_list);
@@ -99,7 +99,7 @@ uint QZ_ListModes(OTTD_Point *modes, uint max_modes, CGDirectDisplayID display_i
CFNumberRef number = (const __CFNumber*)CFDictionaryGetValue(onemode, kCGDisplayBitsPerPixel);
CFNumberGetValue(number, kCFNumberSInt32Type, &bpp);
- if (bpp != display_depth) continue;
+ if (bpp != device_depth) continue;
number = (const __CFNumber*)CFDictionaryGetValue(onemode, kCGDisplayWidth);
CFNumberGetValue(number, kCFNumberSInt32Type, &intvalue);
@@ -149,11 +149,11 @@ bool QZ_CanDisplay8bpp()
}
class FullscreenSubdriver: public CocoaSubdriver {
- int display_width;
- int display_height;
- int display_depth;
- int screen_pitch;
- void *screen_buffer;
+ int device_width;
+ int device_height;
+ int device_depth;
+ int window_pitch;
+ void *window_buffer;
void *pixel_buffer;
CGDirectDisplayID display_id; ///< 0 == main display (only support single display)
@@ -248,8 +248,8 @@ class FullscreenSubdriver: public CocoaSubdriver {
if (refreshRate == 0) return;
- double linesPerSecond = refreshRate * this->display_height;
- double target = this->display_height;
+ double linesPerSecond = refreshRate * this->device_height;
+ double target = this->device_height;
/* Figure out the first delay so we start off about right */
double position = CGDisplayBeamPosition(this->display_id);
@@ -277,14 +277,14 @@ class FullscreenSubdriver: public CocoaSubdriver {
/* See if requested mode exists */
boolean_t exact_match;
- this->cur_mode = CGDisplayBestModeForParameters(this->display_id, this->display_depth, w, h, &exact_match);
+ this->cur_mode = CGDisplayBestModeForParameters(this->display_id, this->device_depth, w, h, &exact_match);
/* If the mode wasn't an exact match, check if it has the right bpp, and update width and height */
if (!exact_match) {
int bpp;
CFNumberRef number = (const __CFNumber*) CFDictionaryGetValue(this->cur_mode, kCGDisplayBitsPerPixel);
CFNumberGetValue(number, kCFNumberSInt32Type, &bpp);
- if (bpp != this->display_depth) {
+ if (bpp != this->device_depth) {
DEBUG(driver, 0, "Failed to find display resolution");
goto ERR_NO_MATCH;
}
@@ -301,8 +301,8 @@ class FullscreenSubdriver: public CocoaSubdriver {
/* Store the mouse coordinates relative to the total screen */
mouseLocation = [ NSEvent mouseLocation ];
- mouseLocation.x /= this->display_width;
- mouseLocation.y /= this->display_height;
+ mouseLocation.x /= this->device_width;
+ mouseLocation.y /= this->device_height;
/* Hide mouse in order to avoid glitch in 8bpp */
QZ_HideMouse();
@@ -323,20 +323,20 @@ class FullscreenSubdriver: public CocoaSubdriver {
goto ERR_NO_SWITCH;
}
- this->screen_buffer = CGDisplayBaseAddress(this->display_id);
- this->screen_pitch = CGDisplayBytesPerRow(this->display_id);
+ this->window_buffer = CGDisplayBaseAddress(this->display_id);
+ this->window_pitch = CGDisplayBytesPerRow(this->display_id);
- this->display_width = CGDisplayPixelsWide(this->display_id);
- this->display_height = CGDisplayPixelsHigh(this->display_id);
+ this->device_width = CGDisplayPixelsWide(this->display_id);
+ this->device_height = CGDisplayPixelsHigh(this->display_id);
/* Setup double-buffer emulation */
- this->pixel_buffer = malloc(this->display_width * this->display_height * this->display_depth / 8);
+ this->pixel_buffer = malloc(this->device_width * this->device_height * this->device_depth / 8);
if (this->pixel_buffer == NULL) {
DEBUG(driver, 0, "Failed to allocate memory for double buffering");
goto ERR_DOUBLEBUF;
}
- if (this->display_depth == 8 && !CGDisplayCanSetPalette(this->display_id)) {
+ if (this->device_depth == 8 && !CGDisplayCanSetPalette(this->display_id)) {
DEBUG(driver, 0, "Not an indexed display mode.");
goto ERR_NOT_INDEXED;
}
@@ -353,15 +353,15 @@ class FullscreenSubdriver: public CocoaSubdriver {
* We can hack around this bug by setting the screen rect ourselves.
* This hack should be removed if/when the bug is fixed.
*/
- screen_rect = NSMakeRect(0, 0, this->display_width, this->display_height);
+ screen_rect = NSMakeRect(0, 0, this->device_width, this->device_height);
[ [ NSScreen mainScreen ] setFrame:screen_rect ];
this->UpdatePalette(0, 256);
/* Move the mouse cursor to approx the same location */
CGPoint display_mouseLocation;
- display_mouseLocation.x = mouseLocation.x * this->display_width;
- display_mouseLocation.y = this->display_height - (mouseLocation.y * this->display_height);
+ display_mouseLocation.x = mouseLocation.x * this->device_width;
+ display_mouseLocation.y = this->device_height - (mouseLocation.y * this->device_height);
CGDisplayMoveCursorToPoint(this->display_id, display_mouseLocation);
@@ -378,8 +378,8 @@ ERR_NO_SWITCH:
ERR_NO_CAPTURE:
if (!gamma_error) this->FadeGammaIn(&gamma_table);
ERR_NO_MATCH:
- this->display_width = 0;
- this->display_height = 0;
+ this->device_width = 0;
+ this->device_height = 0;
return false;
}
@@ -412,8 +412,8 @@ ERR_NO_MATCH:
if (!gamma_error) this->FadeGammaIn(&gamma_table);
- this->display_width = CGDisplayPixelsWide(this->display_id);
- this->display_height = CGDisplayPixelsHigh(this->display_id);
+ this->device_width = CGDisplayPixelsWide(this->display_id);
+ this->device_height = CGDisplayPixelsHigh(this->display_id);
}
public:
@@ -429,9 +429,9 @@ public:
if (bpp == 8) this->palette = CGPaletteCreateDefaultColorPalette();
- this->display_width = CGDisplayPixelsWide(this->display_id);
- this->display_height = CGDisplayPixelsHigh(this->display_id);
- this->display_depth = bpp;
+ this->device_width = CGDisplayPixelsWide(this->display_id);
+ this->device_height = CGDisplayPixelsHigh(this->display_id);
+ this->device_depth = bpp;
this->pixel_buffer = NULL;
this->num_dirty_rects = MAX_DIRTY_RECTS;
@@ -445,11 +445,11 @@ public:
virtual void Draw(bool force_update)
{
const uint8 *src = (uint8 *)this->pixel_buffer;
- uint8 *dst = (uint8 *)this->screen_buffer;
- uint pitch = this->screen_pitch;
- uint width = this->display_width;
+ uint8 *dst = (uint8 *)this->window_buffer;
+ uint pitch = this->window_pitch;
+ uint width = this->device_width;
uint num_dirty = this->num_dirty_rects;
- uint bytesperpixel = this->display_depth / 8;
+ uint bytesperpixel = this->device_depth / 8;
/* Check if we need to do anything */
if (num_dirty == 0) return;
@@ -458,8 +458,8 @@ public:
num_dirty = 1;
this->dirty_rects[0].left = 0;
this->dirty_rects[0].top = 0;
- this->dirty_rects[0].right = this->display_width;
- this->dirty_rects[0].bottom = this->display_height;
+ this->dirty_rects[0].right = this->device_width;
+ this->dirty_rects[0].bottom = this->device_height;
}
WaitForVerticalBlank();
@@ -491,7 +491,7 @@ public:
virtual void UpdatePalette(uint first_color, uint num_colors)
{
- if (this->display_depth != 8) return;
+ if (this->device_depth != 8) return;
for (uint32_t index = first_color; index < first_color + num_colors; index++) {
/* Clamp colors between 0.0 and 1.0 */
@@ -508,13 +508,13 @@ public:
virtual uint ListModes(OTTD_Point *modes, uint max_modes)
{
- return QZ_ListModes(modes, max_modes, this->display_id, this->display_depth);
+ return QZ_ListModes(modes, max_modes, this->display_id, this->device_depth);
}
virtual bool ChangeResolution(int w, int h)
{
- int old_width = this->display_width;
- int old_height = this->display_height;
+ int old_width = this->device_width;
+ int old_height = this->device_height;
if (SetVideoMode(w, h)) return true;
@@ -530,12 +530,12 @@ public:
virtual int GetWidth()
{
- return this->display_width;
+ return this->device_width;
}
virtual int GetHeight()
{
- return this->display_height;
+ return this->device_height;
}
virtual void *GetPixelBuffer()
@@ -555,14 +555,14 @@ public:
virtual NSPoint GetMouseLocation(NSEvent *event)
{
NSPoint pt = [ NSEvent mouseLocation ];
- pt.y = this->display_height - pt.y;
+ pt.y = this->device_height - pt.y;
return pt;
}
virtual bool MouseIsInsideView(NSPoint *pt)
{
- return pt->x >= 0 && pt->y >= 0 && pt->x < this->display_width && pt->y < this->display_height;
+ return pt->x >= 0 && pt->y >= 0 && pt->x < this->device_width && pt->y < this->device_height;
}
virtual bool IsActive()
diff --git a/src/video/cocoa/wnd_quartz.mm b/src/video/cocoa/wnd_quartz.mm
index 949575b77..6180c138e 100644
--- a/src/video/cocoa/wnd_quartz.mm
+++ b/src/video/cocoa/wnd_quartz.mm
@@ -93,9 +93,9 @@ class WindowQuartzSubdriver: public CocoaSubdriver {
int buffer_depth;
void *pixel_buffer;
- void *image_buffer;
+ void *window_buffer;
- OTTD_QuartzWindow *window;
+ id window;
#define MAX_DIRTY_RECTS 100
Rect dirty_rects[MAX_DIRTY_RECTS];
@@ -107,7 +107,7 @@ public:
bool active;
bool setup;
- OTTD_QuartzView *qzview;
+ id cocoaview;
CGContextRef cgcontext;
private:
@@ -141,7 +141,7 @@ public:
virtual int GetWidth() { return window_width; }
virtual int GetHeight() { return window_height; }
- virtual void *GetPixelBuffer() { return buffer_depth == 8 ? pixel_buffer : image_buffer; }
+ virtual void *GetPixelBuffer() { return buffer_depth == 8 ? pixel_buffer : window_buffer; }
/* Convert local coordinate to window server (CoreGraphics) coordinate */
virtual CGPoint PrivateLocalToCG(NSPoint *p);
@@ -211,7 +211,7 @@ static CGColorSpaceRef QZ_GetCorrectColorSpace()
driver->SetPortAlphaOpaque();
/* save current visible surface */
- [ self cacheImageInRect:[ driver->qzview frame ] ];
+ [ self cacheImageInRect:[ driver->cocoaview frame ] ];
/* let the window manager redraw controls, border, etc */
[ super display ];
@@ -244,7 +244,7 @@ static CGColorSpaceRef QZ_GetCorrectColorSpace()
driver->SetPortAlphaOpaque ();
/* save current visible surface */
- [ self cacheImageInRect:[ driver->qzview frame ] ];
+ [ self cacheImageInRect:[ driver->cocoaview frame ] ];
}
- (void)appDidUnhide:(NSNotification*)note
@@ -473,9 +473,9 @@ bool WindowQuartzSubdriver::SetVideoMode(int width, int height)
/* Ensure frame height - title bar height >= view height */
contentRect.size.height = Clamp(height, 0, [ this->window frame ].size.height - 22 /* 22 is the height of title bar of window*/);
- if (this->qzview != nil) {
+ if (this->cocoaview != nil) {
height = contentRect.size.height;
- [ this->qzview setFrameSize:contentRect.size ];
+ [ this->cocoaview setFrameSize:contentRect.size ];
}
}
@@ -485,19 +485,19 @@ bool WindowQuartzSubdriver::SetVideoMode(int width, int height)
[ this->window center ];
/* Only recreate the view if it doesn't already exist */
- if (this->qzview == nil) {
- this->qzview = [ [ OTTD_QuartzView alloc ] initWithFrame:contentRect ];
- if (this->qzview == nil) {
+ if (this->cocoaview == nil) {
+ this->cocoaview = [ [ OTTD_QuartzView alloc ] initWithFrame:contentRect ];
+ if (this->cocoaview == nil) {
DEBUG(driver, 0, "Could not create the Quickdraw view.");
this->setup = false;
return false;
}
- [ this->qzview setDriver:this ];
+ [ this->cocoaview setDriver:this ];
- [ this->qzview setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable ];
- [ this->window setContentView:qzview ];
- [ this->qzview release ];
+ [ this->cocoaview setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable ];
+ [ this->window setContentView:cocoaview ];
+ [ this->cocoaview release ];
[ this->window makeKeyAndOrderFront:nil ];
}
@@ -513,7 +513,7 @@ void WindowQuartzSubdriver::BlitIndexedToView32(int left, int top, int right, in
{
const uint32 *pal = this->palette;
const uint8 *src = (uint8*)this->pixel_buffer;
- uint32 *dst = (uint32*)this->image_buffer;
+ uint32 *dst = (uint32*)this->window_buffer;
uint width = this->window_width;
uint pitch = this->window_width;
@@ -530,13 +530,13 @@ WindowQuartzSubdriver::WindowQuartzSubdriver(int bpp)
this->window_width = 0;
this->window_height = 0;
this->buffer_depth = bpp;
- this->image_buffer = NULL;
+ this->window_buffer = NULL;
this->pixel_buffer = NULL;
this->active = false;
this->setup = false;
this->window = nil;
- this->qzview = nil;
+ this->cocoaview = nil;
this->cgcontext = NULL;
@@ -552,7 +552,7 @@ WindowQuartzSubdriver::~WindowQuartzSubdriver()
CGContextRelease(this->cgcontext);
- free(this->image_buffer);
+ free(this->window_buffer);
free(this->pixel_buffer);
}
@@ -589,8 +589,8 @@ void WindowQuartzSubdriver::Draw(bool force_update)
/* Normally drawRect will be automatically called by Mac OS X during next update cycle,
* and then blitting will occur. If force_update is true, it will be done right now. */
- [ this->qzview setNeedsDisplayInRect:dirtyrect ];
- if (force_update) [ this->qzview displayIfNeeded ];
+ [ this->cocoaview setNeedsDisplayInRect:dirtyrect ];
+ if (force_update) [ this->cocoaview displayIfNeeded ];
}
this->num_dirty_rects = 0;
@@ -643,7 +643,7 @@ CGPoint WindowQuartzSubdriver::PrivateLocalToCG(NSPoint *p)
{
p->y = this->window_height - p->y;
- *p = [ this->qzview convertPoint:*p toView:nil ];
+ *p = [ this->cocoaview convertPoint:*p toView:nil ];
*p = [ this->window convertBaseToScreen:*p ];
p->y = this->device_height - p->y;
@@ -658,7 +658,7 @@ CGPoint WindowQuartzSubdriver::PrivateLocalToCG(NSPoint *p)
NSPoint WindowQuartzSubdriver::GetMouseLocation(NSEvent *event)
{
NSPoint pt = [ event locationInWindow ];
- pt = [ this->qzview convertPoint:pt fromView:nil ];
+ pt = [ this->cocoaview convertPoint:pt fromView:nil ];
pt.y = this->window_height - pt.y;
@@ -667,7 +667,7 @@ NSPoint WindowQuartzSubdriver::GetMouseLocation(NSEvent *event)
bool WindowQuartzSubdriver::MouseIsInsideView(NSPoint *pt)
{
- return [ qzview mouse:*pt inRect:[ this->qzview bounds ] ];
+ return [ cocoaview mouse:*pt inRect:[ this->cocoaview bounds ] ];
}
@@ -677,7 +677,7 @@ bool WindowQuartzSubdriver::MouseIsInsideView(NSPoint *pt)
*/
void WindowQuartzSubdriver::SetPortAlphaOpaque()
{
- uint32 *pixels = (uint32*)this->image_buffer;
+ uint32 *pixels = (uint32*)this->window_buffer;
uint32 pitch = this->window_width;
for (int y = 0; y < this->window_height; y++)
@@ -688,20 +688,20 @@ void WindowQuartzSubdriver::SetPortAlphaOpaque()
bool WindowQuartzSubdriver::WindowResized()
{
- if (this->window == nil || this->qzview == nil) return true;
+ if (this->window == nil || this->cocoaview == nil) return true;
- NSRect newframe = [ this->qzview frame ];
+ NSRect newframe = [ this->cocoaview frame ];
this->window_width = newframe.size.width;
this->window_height = newframe.size.height;
/* Create Core Graphics Context */
- free(this->image_buffer);
- this->image_buffer = (uint32*)malloc(this->window_width * this->window_height * 4);
+ free(this->window_buffer);
+ this->window_buffer = (uint32*)malloc(this->window_width * this->window_height * 4);
CGContextRelease(this->cgcontext);
this->cgcontext = CGBitmapContextCreate(
- this->image_buffer, // data
+ this->window_buffer, // data
this->window_width, // width
this->window_height, // height
8, // bits per component
diff --git a/src/video/cocoa/wnd_quickdraw.mm b/src/video/cocoa/wnd_quickdraw.mm
index abf38599f..15c15fabb 100644
--- a/src/video/cocoa/wnd_quickdraw.mm
+++ b/src/video/cocoa/wnd_quickdraw.mm
@@ -86,7 +86,7 @@ class WindowQuickdrawSubdriver: public CocoaSubdriver {
void *pixel_buffer;
void *window_buffer;
- OTTD_QuickdrawWindow *window;
+ id window;
#define MAX_DIRTY_RECTS 100
Rect dirty_rects[MAX_DIRTY_RECTS];
@@ -98,7 +98,7 @@ public:
bool active;
bool setup;
- NSQuickDrawView *qdview;
+ id cocoaview;
private:
void GetDeviceInfo();
@@ -203,7 +203,7 @@ public:
driver->SetPortAlphaOpaque();
/* save current visible surface */
- [ self cacheImageInRect:[ driver->qdview frame ] ];
+ [ self cacheImageInRect:[ driver->cocoaview frame ] ];
/* let the window manager redraw controls, border, etc */
[ super display ];
@@ -236,7 +236,7 @@ public:
driver->SetPortAlphaOpaque ();
/* save current visible surface */
- [ self cacheImageInRect:[ driver->qdview frame ] ];
+ [ self cacheImageInRect:[ driver->cocoaview frame ] ];
}
- (void)appDidUnhide:(NSNotification*)note
@@ -399,7 +399,7 @@ bool WindowQuickdrawSubdriver::SetVideoMode(int width, int height)
* The height of title bar of the window is 22 pixels */
contentRect.size.height = Clamp(height, 0, [ this->window frame ].size.height - 22);
height = contentRect.size.height;
- [ this->qdview setFrameSize:contentRect.size ];
+ [ this->cocoaview setFrameSize:contentRect.size ];
}
/* Update again */
@@ -409,17 +409,17 @@ bool WindowQuickdrawSubdriver::SetVideoMode(int width, int height)
[ this->window center ];
/* Only recreate the view if it doesn't already exist */
- if (this->qdview == nil) {
- this->qdview = [ [ NSQuickDrawView alloc ] initWithFrame:contentRect ];
- if (this->qdview == nil) {
+ if (this->cocoaview == nil) {
+ this->cocoaview = [ [ NSQuickDrawView alloc ] initWithFrame:contentRect ];
+ if (this->cocoaview == nil) {
DEBUG(driver, 0, "Could not create the Quickdraw view.");
this->setup = false;
return false;
}
- [ this->qdview setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable ];
- [ [ this->window contentView ] addSubview:this->qdview ];
- [ this->qdview release ];
+ [ this->cocoaview setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable ];
+ [ [ this->window contentView ] addSubview:this->cocoaview ];
+ [ this->cocoaview release ];
[ this->window makeKeyAndOrderFront:nil ];
}
@@ -533,7 +533,7 @@ WindowQuickdrawSubdriver::WindowQuickdrawSubdriver(int bpp)
this->setup = false;
this->window = nil;
- this->qdview = nil;
+ this->cocoaview = nil;
this->num_dirty_rects = MAX_DIRTY_RECTS;
}
@@ -579,7 +579,7 @@ void WindowQuickdrawSubdriver::Draw(bool force_update)
this->DrawResizeIcon();
/* Flush the dirty region */
- QDFlushPortBuffer( (OpaqueGrafPtr*) [ this->qdview qdPort ], dirty);
+ QDFlushPortBuffer( (OpaqueGrafPtr*) [ this->cocoaview qdPort ], dirty);
DisposeRgn(dirty);
DisposeRgn(temp);
@@ -645,7 +645,7 @@ bool WindowQuickdrawSubdriver::ChangeResolution(int w, int h)
/* Convert local coordinate to window server (CoreGraphics) coordinate */
CGPoint WindowQuickdrawSubdriver::PrivateLocalToCG(NSPoint *p)
{
- *p = [ this->qdview convertPoint:*p toView: nil ];
+ *p = [ this->cocoaview convertPoint:*p toView: nil ];
*p = [ this->window convertBaseToScreen:*p ];
p->y = this->device_height - p->y;
@@ -655,14 +655,14 @@ CGPoint WindowQuickdrawSubdriver::PrivateLocalToCG(NSPoint *p)
NSPoint WindowQuickdrawSubdriver::GetMouseLocation(NSEvent *event)
{
NSPoint pt = [ event locationInWindow ];
- pt = [ this->qdview convertPoint:pt fromView:nil ];
+ pt = [ this->cocoaview convertPoint:pt fromView:nil ];
return pt;
}
bool WindowQuickdrawSubdriver::MouseIsInsideView(NSPoint *pt)
{
- return [ this->qdview mouse:*pt inRect:[ this->qdview bounds ] ];
+ return [ this->cocoaview mouse:*pt inRect:[ this->cocoaview bounds ] ];
}
@@ -685,10 +685,10 @@ void WindowQuickdrawSubdriver::SetPortAlphaOpaque()
bool WindowQuickdrawSubdriver::WindowResized()
{
- if (this->window == nil || this->qdview == nil) return true;
+ if (this->window == nil || this->cocoaview == nil) return true;
- NSRect newframe = [ this->qdview frame ];
- CGrafPtr thePort = (OpaqueGrafPtr*) [ this->qdview qdPort ];
+ NSRect newframe = [ this->cocoaview frame ];
+ CGrafPtr thePort = (OpaqueGrafPtr*) [ this->cocoaview qdPort ];
LockPortBits(thePort);
this->window_buffer = GetPixBaseAddr(GetPortPixMap(thePort));
@@ -699,7 +699,7 @@ bool WindowQuickdrawSubdriver::WindowResized()
* We want it to point to the *view's* pixels
*/
int voff = [ this->window frame ].size.height - newframe.size.height - newframe.origin.y;
- int hoff = [ this->qdview frame ].origin.x;
+ int hoff = [ this->cocoaview frame ].origin.x;
this->window_buffer = (uint8*)this->window_buffer + (voff * this->window_pitch) + hoff * (this->device_depth / 8);
this->window_width = newframe.size.width;