summaryrefslogtreecommitdiff
path: root/src/video/cocoa
diff options
context:
space:
mode:
authorplanetmaker <planetmaker@openttd.org>2010-12-21 15:56:02 +0000
committerplanetmaker <planetmaker@openttd.org>2010-12-21 15:56:02 +0000
commit7ab04792c501fcc605eff92d79eab5a66707e28f (patch)
treef23fb8f1f548e3130f4f05cbb0e28b597c4216b7 /src/video/cocoa
parent574e0830f19080f668c0e358656213b64b63af4e (diff)
downloadopenttd-7ab04792c501fcc605eff92d79eab5a66707e28f.tar.xz
(svn r21574) -Codechange: [OSX] Move the variable declaration of the screen drivers to the generic class, deduplicating code
Diffstat (limited to 'src/video/cocoa')
-rw-r--r--src/video/cocoa/cocoa_v.h34
-rw-r--r--src/video/cocoa/fullscreen.mm11
-rw-r--r--src/video/cocoa/wnd_quartz.mm33
-rw-r--r--src/video/cocoa/wnd_quickdraw.mm33
4 files changed, 38 insertions, 73 deletions
diff --git a/src/video/cocoa/cocoa_v.h b/src/video/cocoa/cocoa_v.h
index 66818dddb..2d789d89e 100644
--- a/src/video/cocoa/cocoa_v.h
+++ b/src/video/cocoa/cocoa_v.h
@@ -42,9 +42,41 @@ public:
};
-
+/**
+ * Generic display driver for cocoa
+ * On grounds to not duplicate some code, it contains a few variables
+ * which are not used by all device drivers.
+ */
class CocoaSubdriver {
public:
+ int device_width;
+ int device_height;
+ int device_depth;
+
+ int window_width;
+ int window_height;
+ int window_pitch;
+
+ int buffer_depth;
+ void *pixel_buffer; // used for direct pixel access
+ void *window_buffer; // has colour translation from palette to screen
+ id window; // pointer to window object
+
+# define MAX_DIRTY_RECTS 100
+ Rect dirty_rects[MAX_DIRTY_RECTS];
+ int num_dirty_rects;
+ uint32 palette[256];
+
+ bool active;
+ bool setup;
+
+ id cocoaview; // pointer to view object
+
+ /* Separate driver vars for Quarz
+ * Needed here in order to avoid much code duplication */
+ CGContextRef cgcontext;
+
+ /* Driver methods */
virtual ~CocoaSubdriver() {}
virtual void Draw(bool force_update = false) = 0;
diff --git a/src/video/cocoa/fullscreen.mm b/src/video/cocoa/fullscreen.mm
index 9816176eb..e41849c70 100644
--- a/src/video/cocoa/fullscreen.mm
+++ b/src/video/cocoa/fullscreen.mm
@@ -149,22 +149,11 @@ bool QZ_CanDisplay8bpp()
}
class FullscreenSubdriver: public CocoaSubdriver {
- 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)
CFDictionaryRef cur_mode; ///< current mode of the display
CFDictionaryRef save_mode; ///< original mode of the display
CGDirectPaletteRef palette; ///< palette of an 8-bit display
- #define MAX_DIRTY_RECTS 100
- Rect dirty_rects[MAX_DIRTY_RECTS];
- int num_dirty_rects;
-
/* Gamma functions to try to hide the flash from a res switch
* Fade the display from normal to black
diff --git a/src/video/cocoa/wnd_quartz.mm b/src/video/cocoa/wnd_quartz.mm
index 6180c138e..b9a84160f 100644
--- a/src/video/cocoa/wnd_quartz.mm
+++ b/src/video/cocoa/wnd_quartz.mm
@@ -84,37 +84,7 @@ class WindowQuartzSubdriver;
@end
class WindowQuartzSubdriver: public CocoaSubdriver {
- int device_width;
- int device_height;
-
- int window_width;
- int window_height;
-
- int buffer_depth;
-
- void *pixel_buffer;
- void *window_buffer;
-
- id window;
-
- #define MAX_DIRTY_RECTS 100
- Rect dirty_rects[MAX_DIRTY_RECTS];
- int num_dirty_rects;
-
- uint32 palette[256];
-
-public:
- bool active;
- bool setup;
-
- id cocoaview;
- CGContextRef cgcontext;
-
private:
- void GetDeviceInfo();
-
- bool SetVideoMode(int width, int height);
-
/**
* This function copies 8bpp pixels from the screen buffer in 32bpp windowed mode.
*
@@ -125,6 +95,9 @@ private:
*/
void BlitIndexedToView32(int left, int top, int right, int bottom);
+ virtual void GetDeviceInfo();
+ virtual bool SetVideoMode(int width, int height);
+
public:
WindowQuartzSubdriver(int bpp);
virtual ~WindowQuartzSubdriver();
diff --git a/src/video/cocoa/wnd_quickdraw.mm b/src/video/cocoa/wnd_quickdraw.mm
index 15c15fabb..de38e26c0 100644
--- a/src/video/cocoa/wnd_quickdraw.mm
+++ b/src/video/cocoa/wnd_quickdraw.mm
@@ -73,38 +73,7 @@ class WindowQuickdrawSubdriver;
@end
class WindowQuickdrawSubdriver: public CocoaSubdriver {
- int device_width;
- int device_height;
- int device_depth;
-
- int window_width;
- int window_height;
- int window_pitch;
-
- int buffer_depth;
-
- void *pixel_buffer;
- void *window_buffer;
-
- id window;
-
- #define MAX_DIRTY_RECTS 100
- Rect dirty_rects[MAX_DIRTY_RECTS];
- int num_dirty_rects;
-
- uint32 palette[256];
-
-public:
- bool active;
- bool setup;
-
- id cocoaview;
-
private:
- void GetDeviceInfo();
-
- bool SetVideoMode(int width, int height);
-
/**
* This function copies 32bpp pixels from the screen buffer in 16bpp windowed mode.
*
@@ -138,6 +107,8 @@ private:
inline void BlitToView(int left, int top, int right, int bottom);
void DrawResizeIcon();
+ virtual void GetDeviceInfo();
+ virtual bool SetVideoMode(int width, int height);
public:
WindowQuickdrawSubdriver(int bpp);