Add: make modal windows update more smooth
Basically, modal windows had their own thread-locking for what drawing was possible. This is a bit nonsense now we have a game-thread. And it makes much more sense to do things like NewGRFScan and GenerateWorld in the game-thread, and not in a thread next to the game-thread. This commit changes that: it removes the threads for NewGRFScan and GenerateWorld, and just runs the code in the game-thread. On regular intervals it allows the draw-thread to do a tick, which gives a much smoother look and feel. It does slow down NewGRFScan and GenerateWorld ever so slightly as it spends more time on drawing. But the slowdown is not measureable on my machines (with 700+ NewGRFs / 4kx4k map and a Debug build). Running without a game-thread means NewGRFScan and GenerateWorld are now blocking.
This commit is contained in:

committed by
Patric Stout

parent
098d5b2239
commit
970fedd78c
20
src/gfx.cpp
20
src/gfx.cpp
@@ -1470,26 +1470,6 @@ void DrawDirtyBlocks()
|
||||
int x;
|
||||
int y;
|
||||
|
||||
if (HasModalProgress()) {
|
||||
/* We are generating the world, so release our rights to the map and
|
||||
* painting while we are waiting a bit. */
|
||||
_modal_progress_paint_mutex.unlock();
|
||||
_modal_progress_work_mutex.unlock();
|
||||
|
||||
/* Wait a while and hope the modal gives us a bit of time to draw the GUI. */
|
||||
if (!IsFirstModalProgressLoop()) CSleep(MODAL_PROGRESS_REDRAW_TIMEOUT);
|
||||
|
||||
/* Modal progress thread may need blitter access while we are waiting for it. */
|
||||
_modal_progress_paint_mutex.lock();
|
||||
_modal_progress_work_mutex.lock();
|
||||
|
||||
/* When we ended with the modal progress, do not draw the blocks.
|
||||
* Simply let the next run do so, otherwise we would be loading
|
||||
* the new state (and possibly change the blitter) when we hold
|
||||
* the drawing lock, which we must not do. */
|
||||
if (_switch_mode != SM_NONE && !HasModalProgress()) return;
|
||||
}
|
||||
|
||||
y = 0;
|
||||
do {
|
||||
x = 0;
|
||||
|
Reference in New Issue
Block a user