all repos — mgba @ d8687d32c49e75c5f665df10a92d1b0a9e10687f

mGBA Game Boy Advance Emulator

Qt: Fix timing issues on high refresh rate monitors
Jeffrey Pfau jeffrey@endrift.com
Fri, 20 Jan 2017 15:26:41 -0800
commit

d8687d32c49e75c5f665df10a92d1b0a9e10687f

parent

803b7c9859e2f6385bb1295f711a28e2b2c52599

3 files changed, 14 insertions(+), 1 deletions(-)

jump to
M CHANGESCHANGES

@@ -17,6 +17,7 @@ - GBA: Fix multiboot ROM loading

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

@@ -7,6 +7,7 @@ #include "DisplayGL.h"

#include <QApplication> #include <QResizeEvent> +#include <QTimer> #include <mgba/core/core.h> #include <mgba/core/thread.h>

@@ -317,6 +318,16 @@ void PainterGL::draw() {

if (m_queue.isEmpty() || !mCoreThreadIsActive(m_context)) { 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()) { dequeue(); mCoreSyncWaitFrameEnd(&m_context->sync);
M src/platform/qt/DisplayGL.hsrc/platform/qt/DisplayGL.h

@@ -15,12 +15,12 @@ #define GLdouble GLdouble

#endif #endif +#include <QElapsedTimer> #include <QGLWidget> #include <QList> #include <QMouseEvent> #include <QQueue> #include <QThread> -#include <QTimer> #include "platform/video-backend.h"

@@ -120,6 +120,7 @@ VideoShader m_shader;

VideoBackend* m_backend; QSize m_size; MessagePainter* m_messagePainter; + QElapsedTimer m_delayTimer; }; }