Commit 929a849b authored by Maciej Suminski's avatar Maciej Suminski
Browse files

Added a framerate limiter.

Now it does not use all the CPU power while panning even on simple boards.
parent bb9ee216
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -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_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();
}
@@ -121,6 +123,14 @@ void EDA_DRAW_PANEL_GAL::onSize( wxSizeEvent& aEvent )

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__
    prof_counter time;

+2 −1
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@ public:
    virtual void Refresh( bool eraseBackground = true, const wxRect* rect = NULL );

protected:
    void onPaint( wxPaintEvent& aEvent );
    void onPaint( wxPaintEvent& WXUNUSED( aEvent ) );
    void onSize( wxSizeEvent& aEvent );

    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.)
    GalType                  m_currentGal;       ///< Currently used 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
};