summaryrefslogtreecommitdiff
path: root/src/video/cocoa/cocoa_v.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/video/cocoa/cocoa_v.h')
-rw-r--r--src/video/cocoa/cocoa_v.h76
1 files changed, 39 insertions, 37 deletions
diff --git a/src/video/cocoa/cocoa_v.h b/src/video/cocoa/cocoa_v.h
index 54ff53d15..2aca2034e 100644
--- a/src/video/cocoa/cocoa_v.h
+++ b/src/video/cocoa/cocoa_v.h
@@ -86,12 +86,22 @@ 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 {
+
+class WindowQuartzSubdriver {
+private:
+ /**
+ * This function copies 8bpp pixels from the screen buffer in 32bpp windowed mode.
+ *
+ * @param left The x coord for the left edge of the box to blit.
+ * @param top The y coord for the top edge of the box to blit.
+ * @param right The x coord for the right edge of the box to blit.
+ * @param bottom The y coord for the bottom edge of the box to blit.
+ */
+ void BlitIndexedToView32(int left, int top, int right, int bottom);
+
+ void GetDeviceInfo();
+ bool SetVideoMode(int width, int height, int bpp);
+
public:
int device_width; ///< Width of device in pixel
int device_height; ///< Height of device in pixel
@@ -104,8 +114,6 @@ public:
int buffer_depth; ///< Colour depth of used frame buffer
void *pixel_buffer; ///< used for direct pixel access
void *window_buffer; ///< Colour translation from palette to screen
- CGColorSpaceRef color_space; //< Window color space
- id window; ///< Pointer to window object
# define MAX_DIRTY_RECTS 100
Rect dirty_rects[MAX_DIRTY_RECTS]; ///< dirty rectangles
@@ -115,20 +123,18 @@ public:
bool active; ///< Whether the window is visible
bool setup;
+ id window; ///< Pointer to window object
id cocoaview; ///< Pointer to view object
+ CGColorSpaceRef color_space; ///< Window color space
+ CGContextRef cgcontext; ///< Context reference for Quartz subdriver
- /* Separate driver vars for Quarz
- * Needed here in order to avoid much code duplication */
- CGContextRef cgcontext; ///< Context reference for Quartz subdriver
-
- /* Driver methods */
- /** Initialize driver */
- virtual ~CocoaSubdriver() {}
+ WindowQuartzSubdriver();
+ ~WindowQuartzSubdriver();
/** Draw window
* @param force_update Whether to redraw unconditionally
*/
- virtual void Draw(bool force_update = false) = 0;
+ void Draw(bool force_update = false);
/** Mark dirty a screen region
* @param left x-coordinate of left border
@@ -136,77 +142,73 @@ public:
* @param width width or dirty rectangle
* @param height height of dirty rectangle
*/
- virtual void MakeDirty(int left, int top, int width, int height) = 0;
+ void MakeDirty(int left, int top, int width, int height);
/** Update the palette */
- virtual void UpdatePalette(uint first_color, uint num_colors) = 0;
+ void UpdatePalette(uint first_color, uint num_colors);
- virtual uint ListModes(OTTD_Point *modes, uint max_modes) = 0;
+ uint ListModes(OTTD_Point *modes, uint max_modes);
/** Change window resolution
* @param w New window width
* @param h New window height
* @return Whether change was successful
*/
- virtual bool ChangeResolution(int w, int h, int bpp) = 0;
+ bool ChangeResolution(int w, int h, int bpp);
/** Are we in fullscreen mode
* @return whether fullscreen mode is currently used
*/
- virtual bool IsFullscreen() = 0;
+ bool IsFullscreen();
/** Toggle between fullscreen and windowed mode
* @return whether switch was successful
*/
- virtual bool ToggleFullscreen(bool fullscreen) { return false; };
+ bool ToggleFullscreen(bool fullscreen);
/** Return the width of the current view
* @return width of the current view
*/
- virtual int GetWidth() = 0;
+ int GetWidth() { return window_width; }
/** Return the height of the current view
* @return height of the current view
*/
- virtual int GetHeight() = 0;
+ int GetHeight() { return window_height; }
/** Return the current pixel buffer
* @return pixelbuffer
*/
- virtual void *GetPixelBuffer() = 0;
+ void *GetPixelBuffer() { return buffer_depth == 8 ? pixel_buffer : window_buffer; }
/** Convert local coordinate to window server (CoreGraphics) coordinate
* @param p local coordinates
* @return window driver coordinates
*/
- virtual CGPoint PrivateLocalToCG(NSPoint *p) = 0;
+ CGPoint PrivateLocalToCG(NSPoint *p);
/** Return the mouse location
* @param event UI event
* @return mouse location as NSPoint
*/
- virtual NSPoint GetMouseLocation(NSEvent *event) = 0;
+ NSPoint GetMouseLocation(NSEvent *event);
/** Return whether the mouse is within our view
* @param pt Mouse coordinates
* @return Whether mouse coordinates are within view
*/
- virtual bool MouseIsInsideView(NSPoint *pt) = 0;
+ bool MouseIsInsideView(NSPoint *pt);
- /** Return whether the window is active (visible)
- * @return whether the window is visible or not
- */
- virtual bool IsActive() = 0;
+ /** Return whether the window is active (visible) */
+ bool IsActive() { return active; }
- /** Whether the window was successfully resized
+ /** Resize the window.
* @return whether the window was successfully resized
*/
- virtual bool WindowResized() { return false; };
+ bool WindowResized();
};
-extern CocoaSubdriver *_cocoa_subdriver;
-
-CocoaSubdriver *QZ_CreateWindowQuartzSubdriver(int width, int height, int bpp);
+extern WindowQuartzSubdriver *_cocoa_subdriver;
uint QZ_ListModes(OTTD_Point *modes, uint max_modes, CGDirectDisplayID display_id, int display_depth);