mirror of https://github.com/mgba-emu/mgba.git
Qt: Fix FPS counter on Windows
This commit is contained in:
parent
1247dec1ba
commit
da80c5a971
1
CHANGES
1
CHANGES
|
@ -113,6 +113,7 @@ Bugfixes:
|
|||
- Switch: Fix incorrect mapping for fast forward cap
|
||||
- GB, GBA: Fix broken opposing button filter (fixes mgba.io/i/1191)
|
||||
- Qt: Fix jumbled background when paused
|
||||
- Qt: Fix FPS counter on Windows
|
||||
Misc:
|
||||
- mGUI: Add SGB border configuration option
|
||||
- mGUI: Add support for different settings types
|
||||
|
|
|
@ -138,13 +138,11 @@ Window::Window(CoreManager* manager, ConfigController* config, int playerId, QWi
|
|||
|
||||
connect(this, &Window::shutdown, m_logView, &QWidget::hide);
|
||||
connect(&m_fpsTimer, &QTimer::timeout, this, &Window::showFPS);
|
||||
connect(&m_frameTimer, &QTimer::timeout, this, &Window::delimitFrames);
|
||||
connect(&m_focusCheck, &QTimer::timeout, this, &Window::focusCheck);
|
||||
connect(&m_inputController, &InputController::profileLoaded, m_shortcutController, &ShortcutController::loadProfile);
|
||||
|
||||
m_log.setLevels(mLOG_WARN | mLOG_ERROR | mLOG_FATAL);
|
||||
m_fpsTimer.setInterval(FPS_TIMER_INTERVAL);
|
||||
m_frameTimer.setInterval(FRAME_LIST_INTERVAL);
|
||||
m_focusCheck.setInterval(200);
|
||||
|
||||
m_shortcutController->setConfigController(m_config);
|
||||
|
@ -773,7 +771,6 @@ void Window::gameStopped() {
|
|||
m_audioChannels->clear();
|
||||
|
||||
m_fpsTimer.stop();
|
||||
m_frameTimer.stop();
|
||||
m_focusCheck.stop();
|
||||
|
||||
emit paused(false);
|
||||
|
@ -903,19 +900,8 @@ void Window::mustRestart() {
|
|||
}
|
||||
|
||||
void Window::recordFrame() {
|
||||
if (m_frameList.isEmpty()) {
|
||||
m_frameList.append(1);
|
||||
} else {
|
||||
++m_frameList.back();
|
||||
}
|
||||
}
|
||||
|
||||
void Window::delimitFrames() {
|
||||
if (m_frameList.size() >= FRAME_LIST_SIZE) {
|
||||
m_frameCounter -= m_frameList.takeAt(0);
|
||||
}
|
||||
m_frameCounter += m_frameList.back();
|
||||
m_frameList.append(0);
|
||||
m_frameList.append(m_frameTimer.nsecsElapsed());
|
||||
m_frameTimer.restart();
|
||||
}
|
||||
|
||||
void Window::showFPS() {
|
||||
|
@ -923,7 +909,12 @@ void Window::showFPS() {
|
|||
updateTitle();
|
||||
return;
|
||||
}
|
||||
float fps = m_frameCounter * 10000.f / (FRAME_LIST_INTERVAL * (m_frameList.size() - 1));
|
||||
qint64 total = 0;
|
||||
for (qint64 t : m_frameList) {
|
||||
total += t;
|
||||
}
|
||||
double fps = (m_frameList.size() * 1e10) / total;
|
||||
m_frameList.clear();
|
||||
fps = round(fps) / 10.f;
|
||||
updateTitle(fps);
|
||||
}
|
||||
|
@ -1655,7 +1646,6 @@ void Window::setupMenu(QMenuBar* menubar) {
|
|||
showFps->connect([this](const QVariant& value) {
|
||||
if (!value.toInt()) {
|
||||
m_fpsTimer.stop();
|
||||
m_frameTimer.stop();
|
||||
updateTitle();
|
||||
} else if (m_controller) {
|
||||
m_fpsTimer.start();
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <QAction>
|
||||
#include <QDateTime>
|
||||
#include <QElapsedTimer>
|
||||
#include <QList>
|
||||
#include <QMainWindow>
|
||||
#include <QTimer>
|
||||
|
@ -132,7 +133,6 @@ private slots:
|
|||
void mustRestart();
|
||||
|
||||
void recordFrame();
|
||||
void delimitFrames();
|
||||
void showFPS();
|
||||
void focusCheck();
|
||||
|
||||
|
@ -140,8 +140,6 @@ private slots:
|
|||
|
||||
private:
|
||||
static const int FPS_TIMER_INTERVAL = 2000;
|
||||
static const int FRAME_LIST_INTERVAL = 100;
|
||||
static const int FRAME_LIST_SIZE = 40;
|
||||
|
||||
void setupMenu(QMenuBar*);
|
||||
void openStateWindow(LoadSave);
|
||||
|
@ -189,10 +187,9 @@ private:
|
|||
QPixmap m_logo{":/res/mgba-1024.png"};
|
||||
ConfigController* m_config;
|
||||
InputController m_inputController;
|
||||
QList<int> m_frameList;
|
||||
int m_frameCounter = 0;
|
||||
QList<qint64> m_frameList;
|
||||
QElapsedTimer m_frameTimer;
|
||||
QTimer m_fpsTimer;
|
||||
QTimer m_frameTimer;
|
||||
QList<QString> m_mruFiles;
|
||||
QMenu* m_mruMenu = nullptr;
|
||||
QMenu* m_videoLayers;
|
||||
|
|
Loading…
Reference in New Issue