Fix data race during palette animation with threaded blitters

This commit is contained in:
Jonathan G Rennison
2020-04-11 23:56:13 +01:00
parent c061675001
commit 4c59dfb6b1
10 changed files with 20 additions and 4 deletions

View File

@@ -1238,6 +1238,11 @@ void DoPaletteAnimations()
}
}
void GameLoopPaletteAnimations()
{
if (!_pause_mode && HasBit(_display_opt, DO_FULL_ANIMATION)) DoPaletteAnimations();
}
/**
* Determine a contrasty text colour for a coloured background.
* @param background Background colour.

View File

@@ -44,6 +44,7 @@
#include "string_type.h"
void GameLoop();
void GameLoopPaletteAnimations();
void CreateConsole();

View File

@@ -88,7 +88,6 @@
void CallLandscapeTick();
void IncreaseDate();
void DoPaletteAnimations();
void MusicLoop();
void ResetMusic();
void CallWindowGameTickEvent();
@@ -1911,8 +1910,6 @@ void GameLoop()
StateGameLoop();
}
if (!_pause_mode && HasBit(_display_opt, DO_FULL_ANIMATION)) DoPaletteAnimations();
InputLoop();
SoundDriver::GetInstance()->MainLoop();

View File

@@ -513,6 +513,7 @@ void VideoDriver_Allegro::MainLoop()
if (old_shift_pressed != _shift_pressed) HandleShiftChanged();
GameLoop();
GameLoopPaletteAnimations();
UpdateWindows();
CheckPaletteAnim();

View File

@@ -654,7 +654,10 @@ void QZ_GameLoop()
_cocoa_subdriver->Draw(true);
CSleep(1);
for (int i = 0; i < 2; i++) GameLoop();
for (int i = 0; i < 2; i++) {
GameLoop();
GameLoopPaletteAnimations();
}
UpdateWindows();
QZ_CheckPaletteAnim();
@@ -702,6 +705,7 @@ void QZ_GameLoop()
if (old_shift_pressed != _shift_pressed) HandleShiftChanged();
GameLoop();
GameLoopPaletteAnimations();
UpdateWindows();
QZ_CheckPaletteAnim();

View File

@@ -299,6 +299,7 @@ void VideoDriver_Dedicated::MainLoop()
next_tick = cur_ticks + MILLISECONDS_PER_TICK;
GameLoop();
GameLoopPaletteAnimations();
UpdateWindows();
}

View File

@@ -48,11 +48,13 @@ void VideoDriver_Null::MainLoop()
if (this->until_exit) {
while (!_exit_game) {
GameLoop();
GameLoopPaletteAnimations();
UpdateWindows();
}
} else {
for (int i = 0; i < this->ticks; i++) {
GameLoop();
GameLoopPaletteAnimations();
UpdateWindows();
}
}

View File

@@ -1087,6 +1087,8 @@ void VideoDriver_SDL::MainLoop()
if (_draw_mutex != nullptr) draw_lock.lock();
GameLoopPaletteAnimations();
UpdateWindows();
_local_palette = _cur_palette;
} else {

View File

@@ -755,6 +755,8 @@ void VideoDriver_SDL::MainLoop()
if (_draw_mutex != nullptr) draw_lock.lock();
GameLoopPaletteAnimations();
UpdateWindows();
_local_palette = _cur_palette;
} else {

View File

@@ -1268,6 +1268,7 @@ void VideoDriver_Win32::MainLoop()
if (_draw_threaded) draw_lock.unlock();
GameLoop();
if (_draw_threaded) draw_lock.lock();
GameLoopPaletteAnimations();
if (_force_full_redraw) MarkWholeScreenDirty();