mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-16 08:52:40 +01:00
Change: Reflow Textfile window content incrementally.
This avoids a stall when reflowing a long text file with some truetype fonts.
This commit is contained in:
committed by
Peter Nelson
parent
46b745a06a
commit
7344dfe651
@@ -3042,11 +3042,20 @@ void InputLoop()
|
||||
HandleMouseEvents();
|
||||
}
|
||||
|
||||
static std::chrono::time_point<std::chrono::steady_clock> _realtime_tick_start;
|
||||
|
||||
bool CanContinueRealtimeTick()
|
||||
{
|
||||
auto now = std::chrono::steady_clock::now();
|
||||
return std::chrono::duration_cast<std::chrono::milliseconds>(now - _realtime_tick_start).count() < (MILLISECONDS_PER_TICK * 3 / 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch OnRealtimeTick event over all windows
|
||||
*/
|
||||
void CallWindowRealtimeTickEvent(uint delta_ms)
|
||||
{
|
||||
_realtime_tick_start = std::chrono::steady_clock::now();
|
||||
for (Window *w : Window::Iterate()) {
|
||||
w->OnRealtimeTick(delta_ms);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user