changeset 16839:65dac61443f3 draft

(svn r21573) -Codechange: [OSX] Unify the naming of variables among different screen drivers a bit
author planetmaker <planetmaker@openttd.org>
date Tue, 21 Dec 2010 15:53:20 +0000
parents 76c0be9d2cb7
children ff18b4be8c8d
files src/video/cocoa/fullscreen.mm src/video/cocoa/wnd_quartz.mm src/video/cocoa/wnd_quickdraw.mm
diffstat 3 files changed, 93 insertions(+), 93 deletions(-) [+]
line wrap: on
line diff
--- a/src/video/cocoa/fullscreen.mm
+++ b/src/video/cocoa/fullscreen.mm
@@ -84,7 +84,7 @@
 	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 @@
 		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 @@
 }
 
 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 @@
 
 		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 @@
 
 		/* 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 @@
 
 		/* 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 @@
 			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 @@
 		 * 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_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 @@
 
 		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 @@
 
 		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 @@
 	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 @@
 			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 @@
 
 	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 @@
 
 	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 @@
 
 	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 @@
 	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()
--- a/src/video/cocoa/wnd_quartz.mm
+++ b/src/video/cocoa/wnd_quartz.mm
@@ -93,9 +93,9 @@
 	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 @@
 	bool active;
 	bool setup;
 
-	OTTD_QuartzView *qzview;
+	id cocoaview;
 	CGContextRef cgcontext;
 
 private:
@@ -141,7 +141,7 @@
 
 	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 @@
 	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 @@
 	driver->SetPortAlphaOpaque ();
 
 	/* save current visible surface */
-	[ self cacheImageInRect:[ driver->qzview frame ] ];
+	[ self cacheImageInRect:[ driver->cocoaview frame ] ];
 }
 
 - (void)appDidUnhide:(NSNotification*)note
@@ -473,9 +473,9 @@
 		/* 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 @@
 	[ 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 @@
 {
 	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 @@
 	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 @@
 
 	CGContextRelease(this->cgcontext);
 
-	free(this->image_buffer);
+	free(this->window_buffer);
 	free(this->pixel_buffer);
 }
 
@@ -589,8 +589,8 @@
 
 		/* 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 @@
 {
 
 	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 @@
 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 @@
 
 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 @@
  */
 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 @@
 
 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
--- a/src/video/cocoa/wnd_quickdraw.mm
+++ b/src/video/cocoa/wnd_quickdraw.mm
@@ -86,7 +86,7 @@
 	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 @@
 	bool active;
 	bool setup;
 
-	NSQuickDrawView *qdview;
+	id cocoaview;
 
 private:
 	void GetDeviceInfo();
@@ -203,7 +203,7 @@
 	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 @@
 	driver->SetPortAlphaOpaque ();
 
 	/* save current visible surface */
-	[ self cacheImageInRect:[ driver->qdview frame ] ];
+	[ self cacheImageInRect:[ driver->cocoaview frame ] ];
 }
 
 - (void)appDidUnhide:(NSNotification*)note
@@ -399,7 +399,7 @@
 		 * 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 @@
 	[ 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 @@
 	this->setup         = false;
 
 	this->window = nil;
-	this->qdview = nil;
+	this->cocoaview = nil;
 
 	this->num_dirty_rects = MAX_DIRTY_RECTS;
 }
@@ -579,7 +579,7 @@
 	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 @@
 /* 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 @@
 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 @@
 
 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 @@
 	 * 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;