File diff r18159:2c94e9268b2c → r18160:133e96e28508
src/video/cocoa/wnd_quickdraw.mm
Show inline comments
 
@@ -78,25 +78,25 @@ private:
 
	void BlitIndexedToView16(int left, int top, int right, int bottom);
 

	
 
	inline void BlitToView(int left, int top, int right, int bottom);
 
	void DrawResizeIcon();
 

	
 
	virtual void GetDeviceInfo();
 
	virtual bool SetVideoMode(int width, int height);
 
	virtual bool SetVideoMode(int width, int height, int bpp);
 

	
 
public:
 
	WindowQuickdrawSubdriver(int bpp);
 
	WindowQuickdrawSubdriver();
 
	virtual ~WindowQuickdrawSubdriver();
 

	
 
	virtual void Draw(bool force_update);
 
	virtual void MakeDirty(int left, int top, int width, int height);
 
	virtual void UpdatePalette(uint first_color, uint num_colors);
 

	
 
	virtual uint ListModes(OTTD_Point *modes, uint max_modes);
 

	
 
	virtual bool ChangeResolution(int w, int h);
 
	virtual bool ChangeResolution(int w, int h, int bpp);
 

	
 
	virtual bool IsFullscreen() { return false; }
 

	
 
	virtual int GetWidth() { return window_width; }
 
	virtual int GetHeight() { return window_height; }
 
	virtual void *GetPixelBuffer() { return pixel_buffer; }
 
@@ -149,18 +149,18 @@ void WindowQuickdrawSubdriver::GetDevice
 
		kCFNumberSInt32Type, &this->device_width);
 

	
 
	CFNumberGetValue((const __CFNumber*)CFDictionaryGetValue(cur_mode, kCGDisplayHeight),
 
		kCFNumberSInt32Type, &this->device_height);
 
}
 

	
 
bool WindowQuickdrawSubdriver::SetVideoMode(int width, int height)
 
bool WindowQuickdrawSubdriver::SetVideoMode(int width, int height, int bpp)
 
{
 
	this->setup = true;
 
	this->GetDeviceInfo();
 

	
 
	if (this->buffer_depth > this->device_depth) {
 
	if (bpp > this->device_depth) {
 
		DEBUG(driver, 0, "Cannot use a blitter with a higer screen depth than the display when running in windowed mode.");
 
		this->setup = false;
 
		return false;
 
	}
 

	
 
	if (width > this->device_width) width = this->device_width;
 
@@ -214,12 +214,13 @@ bool WindowQuickdrawSubdriver::SetVideoM
 
		[ this->cocoaview setFrameSize:contentRect.size ];
 
	}
 

	
 
	/* Update again */
 
	this->window_width = width;
 
	this->window_height = height;
 
	this->buffer_depth = bpp;
 

	
 
	[ this->window center ];
 

	
 
	/* Only recreate the view if it doesn't already exist */
 
	if (this->cocoaview == nil) {
 
		this->cocoaview = [ [ NSQuickDrawView alloc ] initWithFrame:contentRect ];
 
@@ -332,17 +333,17 @@ void WindowQuickdrawSubdriver::DrawResiz
 
			}
 
			break;
 
	}
 
}
 

	
 

	
 
WindowQuickdrawSubdriver::WindowQuickdrawSubdriver(int bpp)
 
WindowQuickdrawSubdriver::WindowQuickdrawSubdriver()
 
{
 
	this->window_width  = 0;
 
	this->window_height = 0;
 
	this->buffer_depth  = bpp;
 
	this->buffer_depth  = 0;
 
	this->pixel_buffer  = NULL;
 
	this->active        = false;
 
	this->setup         = false;
 

	
 
	this->window = nil;
 
	this->cocoaview = nil;
 
@@ -437,20 +438,21 @@ void WindowQuickdrawSubdriver::UpdatePal
 

	
 
uint WindowQuickdrawSubdriver::ListModes(OTTD_Point *modes, uint max_modes)
 
{
 
	return QZ_ListModes(modes, max_modes, kCGDirectMainDisplay, this->buffer_depth);
 
}
 

	
 
bool WindowQuickdrawSubdriver::ChangeResolution(int w, int h)
 
bool WindowQuickdrawSubdriver::ChangeResolution(int w, int h, int bpp)
 
{
 
	int old_width  = this->window_width;
 
	int old_height = this->window_height;
 
	int old_bpp    = this->buffer_depth;
 

	
 
	if (this->SetVideoMode(w, h)) return true;
 
	if (this->SetVideoMode(w, h, bpp)) return true;
 

	
 
	if (old_width != 0 && old_height != 0) this->SetVideoMode(old_width, old_height);
 
	if (old_width != 0 && old_height != 0) this->SetVideoMode(old_width, old_height, old_bpp);
 

	
 
	return false;
 
}
 

	
 
/* Convert local coordinate to window server (CoreGraphics) coordinate */
 
CGPoint WindowQuickdrawSubdriver::PrivateLocalToCG(NSPoint *p)
 
@@ -541,15 +543,15 @@ CocoaSubdriver *QZ_CreateWindowQuickdraw
 

	
 
	if (bpp != 8 && bpp != 32) {
 
		DEBUG(driver, 0, "The cocoa quickdraw subdriver only supports 8 and 32 bpp.");
 
		return NULL;
 
	}
 

	
 
	ret = new WindowQuickdrawSubdriver(bpp);
 
	ret = new WindowQuickdrawSubdriver();
 

	
 
	if (!ret->ChangeResolution(width, height)) {
 
	if (!ret->ChangeResolution(width, height, bpp)) {
 
		delete ret;
 
		return NULL;
 
	}
 

	
 
	return ret;
 
}