Added a framerate limiter.
Now it does not use all the CPU power while panning even on simple boards.
This commit is contained in:
parent
bb9ee216e8
commit
929a849b99
|
@ -88,6 +88,8 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
|
||||||
|
|
||||||
Connect( wxEVT_PAINT, wxPaintEventHandler( EDA_DRAW_PANEL_GAL::onPaint ), NULL, this );
|
Connect( wxEVT_PAINT, wxPaintEventHandler( EDA_DRAW_PANEL_GAL::onPaint ), NULL, this );
|
||||||
Connect( wxEVT_SIZE, wxSizeEventHandler( EDA_DRAW_PANEL_GAL::onSize ), NULL, this );
|
Connect( wxEVT_SIZE, wxSizeEventHandler( EDA_DRAW_PANEL_GAL::onSize ), NULL, this );
|
||||||
|
|
||||||
|
m_timeStamp = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -107,7 +109,7 @@ EDA_DRAW_PANEL_GAL::~EDA_DRAW_PANEL_GAL()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& aEvent )
|
void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
|
||||||
{
|
{
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
@ -121,6 +123,14 @@ void EDA_DRAW_PANEL_GAL::onSize( wxSizeEvent& aEvent )
|
||||||
|
|
||||||
void EDA_DRAW_PANEL_GAL::Refresh( bool eraseBackground, const wxRect* rect )
|
void EDA_DRAW_PANEL_GAL::Refresh( bool eraseBackground, const wxRect* rect )
|
||||||
{
|
{
|
||||||
|
const unsigned int FPS_LIMIT = 50;
|
||||||
|
|
||||||
|
// Framerate limiter
|
||||||
|
wxLongLong currentTimeStamp = wxGetLocalTimeMillis();
|
||||||
|
if( currentTimeStamp - m_timeStamp < ( 1 / FPS_LIMIT ) )
|
||||||
|
return;
|
||||||
|
m_timeStamp = currentTimeStamp;
|
||||||
|
|
||||||
#ifdef __WXDEBUG__
|
#ifdef __WXDEBUG__
|
||||||
prof_counter time;
|
prof_counter time;
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ public:
|
||||||
virtual void Refresh( bool eraseBackground = true, const wxRect* rect = NULL );
|
virtual void Refresh( bool eraseBackground = true, const wxRect* rect = NULL );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onPaint( wxPaintEvent& aEvent );
|
void onPaint( wxPaintEvent& WXUNUSED( aEvent ) );
|
||||||
void onSize( wxSizeEvent& aEvent );
|
void onSize( wxSizeEvent& aEvent );
|
||||||
|
|
||||||
KiGfx::GAL* m_gal; ///< Interface for drawing objects on a 2D-surface
|
KiGfx::GAL* m_gal; ///< Interface for drawing objects on a 2D-surface
|
||||||
|
@ -90,6 +90,7 @@ protected:
|
||||||
KiGfx::WX_VIEW_CONTROLS* m_viewControls; ///< Control for VIEW (moving, zooming, etc.)
|
KiGfx::WX_VIEW_CONTROLS* m_viewControls; ///< Control for VIEW (moving, zooming, etc.)
|
||||||
GalType m_currentGal; ///< Currently used GAL
|
GalType m_currentGal; ///< Currently used GAL
|
||||||
bool m_useShaders; ///< Are shaders used? (only for OpenGL GAL)
|
bool m_useShaders; ///< Are shaders used? (only for OpenGL GAL)
|
||||||
|
wxLongLong m_timeStamp;
|
||||||
|
|
||||||
std::string m_galShaderPath; ///< Path to shader files, used in OpenGL mode
|
std::string m_galShaderPath; ///< Path to shader files, used in OpenGL mode
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue