summaryrefslogtreecommitdiff
path: root/src/video/win32_v.cpp
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-02-20 11:22:06 +0100
committerPatric Stout <github@truebrain.nl>2021-02-20 17:08:44 +0100
commit23d6f4eac9c85b050bf9efa8f0e94e333d969244 (patch)
tree2256ad1ec81e038d74da170c114a5ef754ade98d /src/video/win32_v.cpp
parentec1dd0bf618f2c4fe17c62db9eec3b5e056574a0 (diff)
downloadopenttd-23d6f4eac9c85b050bf9efa8f0e94e333d969244.tar.xz
Codechange: [Win32] simplify when/where GdiFlush() is called
Diffstat (limited to 'src/video/win32_v.cpp')
-rw-r--r--src/video/win32_v.cpp12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp
index 2024aec18..e3728a646 100644
--- a/src/video/win32_v.cpp
+++ b/src/video/win32_v.cpp
@@ -1211,6 +1211,9 @@ void VideoDriver_Win32::MainLoop()
}
if (_exit_game) break;
+ /* Flush GDI buffer to ensure we don't conflict with the drawing thread. */
+ GdiFlush();
+
cur_ticks = std::chrono::steady_clock::now();
/* If more than a millisecond has passed, increase the _realtime_tick. */
@@ -1229,9 +1232,6 @@ void VideoDriver_Win32::MainLoop()
if (next_game_tick < cur_ticks - ALLOWED_DRIFT * this->GetGameInterval()) next_game_tick = cur_ticks;
}
- /* Flush GDI buffer to ensure we don't conflict with the drawing thread. */
- GdiFlush();
-
/* The game loop is the part that can run asynchronously.
* The rest except sleeping can't. */
this->UnlockVideoBuffer();
@@ -1247,9 +1247,6 @@ void VideoDriver_Win32::MainLoop()
if (_force_full_redraw) MarkWholeScreenDirty();
- /* Flush GDI buffer to ensure we don't conflict with the drawing thread. */
- GdiFlush();
-
this->InputLoop();
::InputLoop();
UpdateWindows();
@@ -1269,9 +1266,6 @@ void VideoDriver_Win32::MainLoop()
auto now = std::chrono::steady_clock::now();
if (next_tick > now) {
- /* Flush GDI buffer to ensure we don't conflict with the drawing thread. */
- GdiFlush();
-
this->UnlockVideoBuffer();
std::this_thread::sleep_for(next_tick - now);
this->LockVideoBuffer();