diff options
author | Michael Lutz <michi@icosahedron.de> | 2021-02-11 00:10:27 +0100 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2021-02-22 22:16:07 +0100 |
commit | 7f55f0a264aa6070865ac311942c3bbf7f1e1319 (patch) | |
tree | e5eb854c8eeb8091ab0c0bc875f0467d8d57f924 /src/video/cocoa/cocoa_v.h | |
parent | 2f25e9bdf8c8c2952ba7f8adb9bd73302fef37c2 (diff) | |
download | openttd-7f55f0a264aa6070865ac311942c3bbf7f1e1319.tar.xz |
Codechange: [OSX] Add support for (un)locking the video buffer.
Diffstat (limited to 'src/video/cocoa/cocoa_v.h')
-rw-r--r-- | src/video/cocoa/cocoa_v.h | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/video/cocoa/cocoa_v.h b/src/video/cocoa/cocoa_v.h index 4d683d622..c1a645245 100644 --- a/src/video/cocoa/cocoa_v.h +++ b/src/video/cocoa/cocoa_v.h @@ -51,13 +51,17 @@ public: void GameLoop(); - virtual void AllocateBackingStore() = 0; + virtual void AllocateBackingStore(bool force = false) = 0; protected: Rect dirty_rect; ///< Region of the screen that needs redrawing. + bool buffer_locked; ///< Video buffer was locked by the main thread. + Dimension GetScreenSize() const override; float GetDPIScale() override; void InputLoop() override; + bool LockVideoBuffer() override; + void UnlockVideoBuffer() override; void GameSizeChanged(); @@ -69,6 +73,11 @@ protected: virtual NSView* AllocateDrawView() = 0; + /** Get a pointer to the video buffer. */ + virtual void *GetVideoPointer() = 0; + /** Hand video buffer back to the drawing backend. */ + virtual void ReleaseVideoPointer() {} + private: bool PollEvent(); @@ -101,13 +110,15 @@ public: /** Return driver name */ const char *GetName() const override { return "cocoa"; } - void AllocateBackingStore() override; + void AllocateBackingStore(bool force = false) override; protected: void Paint() override; void CheckPaletteAnim() override; NSView* AllocateDrawView() override; + + void *GetVideoPointer() override { return this->buffer_depth == 8 ? this->pixel_buffer : this->window_buffer; } }; class FVideoDriver_CocoaQuartz : public DriverFactoryBase { |