summaryrefslogtreecommitdiff
path: root/src/video/video_driver.hpp
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-03-08 14:50:06 +0100
committerPatric Stout <github@truebrain.nl>2021-03-08 19:18:55 +0100
commit8946b41d20d6be59da23b98add273955b43450fd (patch)
tree59efe6e340339a68f4355a0c19cda5695755e49c /src/video/video_driver.hpp
parente56d2c63c306dd087de26088729d09233b1122c2 (diff)
downloadopenttd-8946b41d20d6be59da23b98add273955b43450fd.tar.xz
Fix: ensure switching blitter happens in the main thread
This because video-drivers might need to make changes to their context, which for most video-drivers has to be done in the same thread as the window was created; main thread in our case.
Diffstat (limited to 'src/video/video_driver.hpp')
-rw-r--r--src/video/video_driver.hpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/video/video_driver.hpp b/src/video/video_driver.hpp
index 423e46436..4b2de253a 100644
--- a/src/video/video_driver.hpp
+++ b/src/video/video_driver.hpp
@@ -35,7 +35,7 @@ class VideoDriver : public Driver {
const uint DEFAULT_WINDOW_HEIGHT = 480u; ///< Default window height.
public:
- VideoDriver() : is_game_threaded(true) {}
+ VideoDriver() : is_game_threaded(true), change_blitter(nullptr) {}
/**
* Mark a particular area dirty.
@@ -162,6 +162,15 @@ public:
}
/**
+ * Queue a request to change the blitter. This is not executed immediately,
+ * but instead on the next draw-tick.
+ */
+ void ChangeBlitter(const char *new_blitter)
+ {
+ this->change_blitter = new_blitter;
+ }
+
+ /**
* Get the currently active instance of the video driver.
*/
static VideoDriver *GetInstance() {
@@ -303,6 +312,9 @@ protected:
private:
void GameLoop();
void GameThread();
+ void RealChangeBlitter(const char *repl_blitter);
+
+ const char *change_blitter; ///< Request to change the blitter. nullptr if no pending request.
};
#endif /* VIDEO_VIDEO_DRIVER_HPP */