Fix refresh logic on MacOS to prevent excessive redraws
This new logic does not need to be MacOS-specific; it should account for timer inconsistencies on any platform. Thanks to Mark for the suggestions. Fixes https://gitlab.com/kicad/code/kicad/-/issues/6222 Fixes https://gitlab.com/kicad/code/kicad/-/issues/6332
This commit is contained in:
parent
f599185e2d
commit
d79aee3f78
|
@ -256,30 +256,21 @@ void EDA_DRAW_PANEL_GAL::onSize( wxSizeEvent& aEvent )
|
|||
|
||||
void EDA_DRAW_PANEL_GAL::Refresh( bool aEraseBackground, const wxRect* aRect )
|
||||
{
|
||||
if( m_pendingRefresh )
|
||||
return;
|
||||
|
||||
m_pendingRefresh = true;
|
||||
|
||||
#ifdef __WXMAC__
|
||||
// Timers on OS X may have a high latency (seen up to 500ms and more) which
|
||||
// makes repaints jerky. No negative impact seen without throttling, so just
|
||||
// do an unconditional refresh for OS X.
|
||||
ForceRefresh();
|
||||
#else
|
||||
wxLongLong t = wxGetLocalTimeMillis();
|
||||
wxLongLong delta = t - m_lastRefresh;
|
||||
|
||||
// If it has been too long since the last frame (possible depending on platform timer latency),
|
||||
// just do a refresh. Otherwise, start the refresh timer if it hasn't already been started.
|
||||
// This ensures that we will render often enough but not too often.
|
||||
if( delta >= MinRefreshPeriod )
|
||||
{
|
||||
ForceRefresh();
|
||||
m_refreshTimer.Start( MinRefreshPeriod, true );
|
||||
}
|
||||
else
|
||||
else if( !m_refreshTimer.IsRunning() )
|
||||
{
|
||||
// One shot timer
|
||||
m_refreshTimer.Start( ( MinRefreshPeriod - delta ).ToLong(), true );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue