diff options
author | Michael Lutz <michi@icosahedron.de> | 2021-02-07 20:50:41 +0100 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2021-02-22 22:16:07 +0100 |
commit | 2f25e9bdf8c8c2952ba7f8adb9bd73302fef37c2 (patch) | |
tree | 76d7216947a38a2dbea46b35a400a356a43970ed /src/video/cocoa/cocoa_v.h | |
parent | 421b599541069318817bd0e0768984a662a84753 (diff) | |
download | openttd-2f25e9bdf8c8c2952ba7f8adb9bd73302fef37c2.tar.xz |
Codechange: [OSX] Separate video driver into a base and a Quartz implementation.
Diffstat (limited to 'src/video/cocoa/cocoa_v.h')
-rw-r--r-- | src/video/cocoa/cocoa_v.h | 71 |
1 files changed, 45 insertions, 26 deletions
diff --git a/src/video/cocoa/cocoa_v.h b/src/video/cocoa/cocoa_v.h index f9f678157..4d683d622 100644 --- a/src/video/cocoa/cocoa_v.h +++ b/src/video/cocoa/cocoa_v.h @@ -24,32 +24,18 @@ class VideoDriver_Cocoa : public VideoDriver { private: Dimension orig_res; ///< Saved window size for non-fullscreen mode. - int window_width; ///< Current window width in pixel - int window_height; ///< Current window height in pixel - int window_pitch; - - 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 - - Rect dirty_rect; ///< Region of the screen that needs redrawing. - - uint32 palette[256]; ///< Colour Palette - public: bool setup; ///< Window is currently being created. OTTD_CocoaWindow *window; ///< Pointer to window object OTTD_CocoaView *cocoaview; ///< Pointer to view object CGColorSpaceRef color_space; ///< Window color space - CGContextRef cgcontext; ///< Context reference for Quartz subdriver OTTD_CocoaWindowDelegate *delegate; //!< Window delegate object public: VideoDriver_Cocoa(); - const char *Start(const StringList ¶m) override; void Stop() override; void MainLoop() override; @@ -61,40 +47,73 @@ public: void EditBoxLostFocus() override; - const char *GetName() const override { return "cocoa"; } - /* --- The following methods should be private, but can't be due to Obj-C limitations. --- */ void GameLoop(); - void AllocateBackingStore(); + virtual void AllocateBackingStore() = 0; protected: + Rect dirty_rect; ///< Region of the screen that needs redrawing. Dimension GetScreenSize() const override; float GetDPIScale() override; void InputLoop() override; - void Paint() override; - void CheckPaletteAnim() override; + + void GameSizeChanged(); + + const char *Initialize(); + + void UpdateVideoModes(); + + bool MakeWindow(int width, int height); + + virtual NSView* AllocateDrawView() = 0; private: bool PollEvent(); bool IsFullscreen(); - void GameSizeChanged(); +}; - void UpdateVideoModes(); +class VideoDriver_CocoaQuartz : public VideoDriver_Cocoa { +private: + 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 - bool MakeWindow(int width, int height); + int window_width; ///< Current window width in pixel + int window_height; ///< Current window height in pixel + int window_pitch; - void UpdatePalette(uint first_color, uint num_colors); + uint32 palette[256]; ///< Colour Palette void BlitIndexedToView32(int left, int top, int right, int bottom); + void UpdatePalette(uint first_color, uint num_colors); + +public: + CGContextRef cgcontext; ///< Context reference for Quartz subdriver + + VideoDriver_CocoaQuartz(); + + const char *Start(const StringList ¶m) override; + void Stop() override; + + /** Return driver name */ + const char *GetName() const override { return "cocoa"; } + + void AllocateBackingStore() override; + +protected: + void Paint() override; + void CheckPaletteAnim() override; + + NSView* AllocateDrawView() override; }; -class FVideoDriver_Cocoa : public DriverFactoryBase { +class FVideoDriver_CocoaQuartz : public DriverFactoryBase { public: - FVideoDriver_Cocoa() : DriverFactoryBase(Driver::DT_VIDEO, 10, "cocoa", "Cocoa Video Driver") {} - Driver *CreateInstance() const override { return new VideoDriver_Cocoa(); } + FVideoDriver_CocoaQuartz() : DriverFactoryBase(Driver::DT_VIDEO, 10, "cocoa", "Cocoa Video Driver") {} + Driver *CreateInstance() const override { return new VideoDriver_CocoaQuartz(); } }; #endif /* VIDEO_COCOA_H */ |