mirror of https://github.com/OpenTTD/OpenTTD
Codechange: be consistent in what CheckPaletteAnim() does and when it is called
Additionally, make sure this is a class method. Later commits will make use of this.pull/8709/head
parent
790fa7102e
commit
ec1dd0bf61
|
@ -95,7 +95,7 @@ static void InitPalette()
|
||||||
UpdatePalette(0, 256);
|
UpdatePalette(0, 256);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CheckPaletteAnim()
|
void VideoDriver_Allegro::CheckPaletteAnim()
|
||||||
{
|
{
|
||||||
if (_cur_palette.count_dirty != 0) {
|
if (_cur_palette.count_dirty != 0) {
|
||||||
Blitter *blitter = BlitterFactory::GetCurrentBlitter();
|
Blitter *blitter = BlitterFactory::GetCurrentBlitter();
|
||||||
|
@ -484,8 +484,6 @@ void VideoDriver_Allegro::MainLoop()
|
||||||
auto next_game_tick = cur_ticks;
|
auto next_game_tick = cur_ticks;
|
||||||
auto next_draw_tick = cur_ticks;
|
auto next_draw_tick = cur_ticks;
|
||||||
|
|
||||||
CheckPaletteAnim();
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
InteractiveRandom(); // randomness
|
InteractiveRandom(); // randomness
|
||||||
|
|
||||||
|
@ -522,7 +520,7 @@ void VideoDriver_Allegro::MainLoop()
|
||||||
this->InputLoop();
|
this->InputLoop();
|
||||||
::InputLoop();
|
::InputLoop();
|
||||||
UpdateWindows();
|
UpdateWindows();
|
||||||
CheckPaletteAnim();
|
this->CheckPaletteAnim();
|
||||||
|
|
||||||
this->Paint();
|
this->Paint();
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
void InputLoop() override;
|
void InputLoop() override;
|
||||||
void Paint() override;
|
void Paint() override;
|
||||||
|
void CheckPaletteAnim() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Factory for the allegro video driver. */
|
/** Factory for the allegro video driver. */
|
||||||
|
|
|
@ -76,6 +76,7 @@ protected:
|
||||||
float GetDPIScale() override;
|
float GetDPIScale() override;
|
||||||
void InputLoop() override;
|
void InputLoop() override;
|
||||||
void Paint() override;
|
void Paint() override;
|
||||||
|
void CheckPaletteAnim() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool PollEvent();
|
bool PollEvent();
|
||||||
|
@ -88,7 +89,6 @@ private:
|
||||||
bool MakeWindow(int width, int height);
|
bool MakeWindow(int width, int height);
|
||||||
|
|
||||||
void UpdatePalette(uint first_color, uint num_colors);
|
void UpdatePalette(uint first_color, uint num_colors);
|
||||||
void CheckPaletteAnim();
|
|
||||||
|
|
||||||
void BlitIndexedToView32(int left, int top, int right, int bottom);
|
void BlitIndexedToView32(int left, int top, int right, int bottom);
|
||||||
};
|
};
|
||||||
|
|
|
@ -853,8 +853,6 @@ void VideoDriver_SDL::MainLoop()
|
||||||
last_realtime_tick = cur_ticks;
|
last_realtime_tick = cur_ticks;
|
||||||
next_game_tick = cur_ticks;
|
next_game_tick = cur_ticks;
|
||||||
|
|
||||||
this->CheckPaletteAnim();
|
|
||||||
|
|
||||||
if (_draw_threaded) {
|
if (_draw_threaded) {
|
||||||
/* Initialise the mutex first, because that's the thing we *need*
|
/* Initialise the mutex first, because that's the thing we *need*
|
||||||
* directly in the newly created thread. */
|
* directly in the newly created thread. */
|
||||||
|
|
|
@ -48,6 +48,7 @@ protected:
|
||||||
void UnlockVideoBuffer() override;
|
void UnlockVideoBuffer() override;
|
||||||
void Paint() override;
|
void Paint() override;
|
||||||
void PaintThread() override;
|
void PaintThread() override;
|
||||||
|
void CheckPaletteAnim();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int PollEvent();
|
int PollEvent();
|
||||||
|
@ -55,7 +56,6 @@ private:
|
||||||
void MainLoopCleanup();
|
void MainLoopCleanup();
|
||||||
bool CreateMainSurface(uint w, uint h, bool resize);
|
bool CreateMainSurface(uint w, uint h, bool resize);
|
||||||
bool CreateMainWindow(uint w, uint h);
|
bool CreateMainWindow(uint w, uint h);
|
||||||
void CheckPaletteAnim();
|
|
||||||
|
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
/* Convert a constant pointer back to a non-constant pointer to a member function. */
|
/* Convert a constant pointer back to a non-constant pointer to a member function. */
|
||||||
|
|
|
@ -123,8 +123,10 @@ static void InitPalette()
|
||||||
UpdatePalette(true);
|
UpdatePalette(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CheckPaletteAnim()
|
void VideoDriver_SDL::CheckPaletteAnim()
|
||||||
{
|
{
|
||||||
|
_local_palette = _cur_palette;
|
||||||
|
|
||||||
if (_cur_palette.count_dirty != 0) {
|
if (_cur_palette.count_dirty != 0) {
|
||||||
Blitter *blitter = BlitterFactory::GetCurrentBlitter();
|
Blitter *blitter = BlitterFactory::GetCurrentBlitter();
|
||||||
|
|
||||||
|
@ -183,7 +185,6 @@ void VideoDriver_SDL::PaintThread()
|
||||||
_draw_signal->wait(*_draw_mutex);
|
_draw_signal->wait(*_draw_mutex);
|
||||||
|
|
||||||
while (_draw_continue) {
|
while (_draw_continue) {
|
||||||
CheckPaletteAnim();
|
|
||||||
/* Then just draw and wait till we stop */
|
/* Then just draw and wait till we stop */
|
||||||
this->Paint();
|
this->Paint();
|
||||||
_draw_signal->wait(lock);
|
_draw_signal->wait(lock);
|
||||||
|
@ -708,8 +709,6 @@ void VideoDriver_SDL::MainLoop()
|
||||||
auto next_game_tick = cur_ticks;
|
auto next_game_tick = cur_ticks;
|
||||||
auto next_draw_tick = cur_ticks;
|
auto next_draw_tick = cur_ticks;
|
||||||
|
|
||||||
CheckPaletteAnim();
|
|
||||||
|
|
||||||
std::thread draw_thread;
|
std::thread draw_thread;
|
||||||
if (_draw_threaded) {
|
if (_draw_threaded) {
|
||||||
/* Initialise the mutex first, because that's the thing we *need*
|
/* Initialise the mutex first, because that's the thing we *need*
|
||||||
|
@ -781,12 +780,11 @@ void VideoDriver_SDL::MainLoop()
|
||||||
this->InputLoop();
|
this->InputLoop();
|
||||||
::InputLoop();
|
::InputLoop();
|
||||||
UpdateWindows();
|
UpdateWindows();
|
||||||
_local_palette = _cur_palette;
|
this->CheckPaletteAnim();
|
||||||
|
|
||||||
if (_draw_mutex != nullptr && !HasModalProgress()) {
|
if (_draw_mutex != nullptr && !HasModalProgress()) {
|
||||||
_draw_signal->notify_one();
|
_draw_signal->notify_one();
|
||||||
} else {
|
} else {
|
||||||
CheckPaletteAnim();
|
|
||||||
this->Paint();
|
this->Paint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ protected:
|
||||||
void UnlockVideoBuffer() override;
|
void UnlockVideoBuffer() override;
|
||||||
void Paint() override;
|
void Paint() override;
|
||||||
void PaintThread() override;
|
void PaintThread() override;
|
||||||
|
void CheckPaletteAnim();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_lock<std::recursive_mutex> draw_lock;
|
std::unique_lock<std::recursive_mutex> draw_lock;
|
||||||
|
|
|
@ -184,6 +184,11 @@ protected:
|
||||||
*/
|
*/
|
||||||
virtual void PaintThread() {}
|
virtual void PaintThread() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process any pending palette animation.
|
||||||
|
*/
|
||||||
|
virtual void CheckPaletteAnim() {}
|
||||||
|
|
||||||
std::chrono::steady_clock::duration GetGameInterval()
|
std::chrono::steady_clock::duration GetGameInterval()
|
||||||
{
|
{
|
||||||
return std::chrono::milliseconds(MILLISECONDS_PER_TICK);
|
return std::chrono::milliseconds(MILLISECONDS_PER_TICK);
|
||||||
|
|
|
@ -1201,7 +1201,6 @@ void VideoDriver_Win32::MainLoop()
|
||||||
|
|
||||||
_wnd.running = true;
|
_wnd.running = true;
|
||||||
|
|
||||||
CheckPaletteAnim();
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
InteractiveRandom(); // randomness
|
InteractiveRandom(); // randomness
|
||||||
|
|
||||||
|
|
|
@ -49,12 +49,11 @@ protected:
|
||||||
void UnlockVideoBuffer() override;
|
void UnlockVideoBuffer() override;
|
||||||
void Paint() override;
|
void Paint() override;
|
||||||
void PaintThread() override;
|
void PaintThread() override;
|
||||||
|
void CheckPaletteAnim() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_lock<std::recursive_mutex> draw_lock;
|
std::unique_lock<std::recursive_mutex> draw_lock;
|
||||||
|
|
||||||
void CheckPaletteAnim();
|
|
||||||
|
|
||||||
static void PaintThreadThunk(VideoDriver_Win32 *drv);
|
static void PaintThreadThunk(VideoDriver_Win32 *drv);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue