Qt: Fix timing issues on high refresh rate monitors

This commit is contained in:
Jeffrey Pfau 2017-01-20 15:26:41 -08:00
parent 803b7c9859
commit d8687d32c4
3 changed files with 14 additions and 1 deletions

View File

@ -17,6 +17,7 @@ Bugfixes:
- Libretro: Fix saving in GB games (fixes mgba.io/i/486) - Libretro: Fix saving in GB games (fixes mgba.io/i/486)
- LR35902: Fix pc overflowing current region off-by-one - LR35902: Fix pc overflowing current region off-by-one
- GB MBC: Fix ROM bank overflows getting set to bank 0 - GB MBC: Fix ROM bank overflows getting set to bank 0
- Qt: Fix timing issues on high refresh rate monitors
Misc: Misc:
- SDL: Remove scancode key input - SDL: Remove scancode key input
- GBA Video: Clean up unused timers - GBA Video: Clean up unused timers

View File

@ -7,6 +7,7 @@
#include <QApplication> #include <QApplication>
#include <QResizeEvent> #include <QResizeEvent>
#include <QTimer>
#include <mgba/core/core.h> #include <mgba/core/core.h>
#include <mgba/core/thread.h> #include <mgba/core/thread.h>
@ -317,6 +318,16 @@ void PainterGL::draw() {
if (m_queue.isEmpty() || !mCoreThreadIsActive(m_context)) { if (m_queue.isEmpty() || !mCoreThreadIsActive(m_context)) {
return; return;
} }
if (!m_delayTimer.isValid()) {
m_delayTimer.start();
} else if (m_delayTimer.elapsed() < 16) {
QMetaObject::invokeMethod(this, "draw", Qt::QueuedConnection);
QThread::usleep(500);
return;
} else {
m_delayTimer.restart();
}
if (mCoreSyncWaitFrameStart(&m_context->sync) || !m_queue.isEmpty()) { if (mCoreSyncWaitFrameStart(&m_context->sync) || !m_queue.isEmpty()) {
dequeue(); dequeue();
mCoreSyncWaitFrameEnd(&m_context->sync); mCoreSyncWaitFrameEnd(&m_context->sync);

View File

@ -15,12 +15,12 @@
#endif #endif
#endif #endif
#include <QElapsedTimer>
#include <QGLWidget> #include <QGLWidget>
#include <QList> #include <QList>
#include <QMouseEvent> #include <QMouseEvent>
#include <QQueue> #include <QQueue>
#include <QThread> #include <QThread>
#include <QTimer>
#include "platform/video-backend.h" #include "platform/video-backend.h"
@ -120,6 +120,7 @@ private:
VideoBackend* m_backend; VideoBackend* m_backend;
QSize m_size; QSize m_size;
MessagePainter* m_messagePainter; MessagePainter* m_messagePainter;
QElapsedTimer m_delayTimer;
}; };
} }