mirror of https://github.com/mgba-emu/mgba.git
Qt: Prevent flicker upon pausing the emulator
This commit is contained in:
parent
81b85d1843
commit
cade03e10d
|
@ -66,6 +66,34 @@ void Display::stopDrawing() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Display::pauseDrawing() {
|
||||||
|
if (m_drawThread) {
|
||||||
|
if (GBAThreadIsActive(m_context)) {
|
||||||
|
GBAThreadInterrupt(m_context);
|
||||||
|
GBASyncSuspendDrawing(&m_context->sync);
|
||||||
|
}
|
||||||
|
QMetaObject::invokeMethod(m_painter, "pause", Qt::BlockingQueuedConnection);
|
||||||
|
if (GBAThreadIsActive(m_context)) {
|
||||||
|
GBASyncResumeDrawing(&m_context->sync);
|
||||||
|
GBAThreadContinue(m_context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Display::unpauseDrawing() {
|
||||||
|
if (m_drawThread) {
|
||||||
|
if (GBAThreadIsActive(m_context)) {
|
||||||
|
GBAThreadInterrupt(m_context);
|
||||||
|
GBASyncSuspendDrawing(&m_context->sync);
|
||||||
|
}
|
||||||
|
QMetaObject::invokeMethod(m_painter, "unpause", Qt::BlockingQueuedConnection);
|
||||||
|
if (GBAThreadIsActive(m_context)) {
|
||||||
|
GBASyncResumeDrawing(&m_context->sync);
|
||||||
|
GBAThreadContinue(m_context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Display::forceDraw() {
|
void Display::forceDraw() {
|
||||||
if (m_drawThread) {
|
if (m_drawThread) {
|
||||||
QMetaObject::invokeMethod(m_painter, "forceDraw", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(m_painter, "forceDraw", Qt::QueuedConnection);
|
||||||
|
@ -182,3 +210,14 @@ void Painter::stop() {
|
||||||
m_gl->doneCurrent();
|
m_gl->doneCurrent();
|
||||||
m_gl->context()->moveToThread(QApplication::instance()->thread());
|
m_gl->context()->moveToThread(QApplication::instance()->thread());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Painter::pause() {
|
||||||
|
m_drawTimer->stop();
|
||||||
|
// Make sure both buffers are filled
|
||||||
|
forceDraw();
|
||||||
|
forceDraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Painter::unpause() {
|
||||||
|
m_drawTimer->start();
|
||||||
|
}
|
||||||
|
|
|
@ -19,6 +19,8 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
void startDrawing(const uint32_t* buffer, GBAThread* context);
|
void startDrawing(const uint32_t* buffer, GBAThread* context);
|
||||||
void stopDrawing();
|
void stopDrawing();
|
||||||
|
void pauseDrawing();
|
||||||
|
void unpauseDrawing();
|
||||||
void forceDraw();
|
void forceDraw();
|
||||||
#ifdef USE_PNG
|
#ifdef USE_PNG
|
||||||
void screenshot();
|
void screenshot();
|
||||||
|
@ -49,6 +51,8 @@ public slots:
|
||||||
void draw();
|
void draw();
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
|
void pause();
|
||||||
|
void unpause();
|
||||||
void resize(const QSize& size);
|
void resize(const QSize& size);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -52,6 +52,8 @@ Window::Window(ConfigController* config, QWidget* parent)
|
||||||
connect(m_controller, SIGNAL(gameStopped(GBAThread*)), m_display, SLOT(stopDrawing()));
|
connect(m_controller, SIGNAL(gameStopped(GBAThread*)), m_display, SLOT(stopDrawing()));
|
||||||
connect(m_controller, SIGNAL(gameStopped(GBAThread*)), this, SLOT(gameStopped()));
|
connect(m_controller, SIGNAL(gameStopped(GBAThread*)), this, SLOT(gameStopped()));
|
||||||
connect(m_controller, SIGNAL(stateLoaded(GBAThread*)), m_display, SLOT(forceDraw()));
|
connect(m_controller, SIGNAL(stateLoaded(GBAThread*)), m_display, SLOT(forceDraw()));
|
||||||
|
connect(m_controller, SIGNAL(gamePaused(GBAThread*)), m_display, SLOT(pauseDrawing()));
|
||||||
|
connect(m_controller, SIGNAL(gameUnpaused(GBAThread*)), m_display, SLOT(unpauseDrawing()));
|
||||||
connect(m_controller, SIGNAL(postLog(int, const QString&)), m_logView, SLOT(postLog(int, const QString&)));
|
connect(m_controller, SIGNAL(postLog(int, const QString&)), m_logView, SLOT(postLog(int, const QString&)));
|
||||||
connect(this, SIGNAL(startDrawing(const uint32_t*, GBAThread*)), m_display, SLOT(startDrawing(const uint32_t*, GBAThread*)), Qt::QueuedConnection);
|
connect(this, SIGNAL(startDrawing(const uint32_t*, GBAThread*)), m_display, SLOT(startDrawing(const uint32_t*, GBAThread*)), Qt::QueuedConnection);
|
||||||
connect(this, SIGNAL(shutdown()), m_display, SLOT(stopDrawing()));
|
connect(this, SIGNAL(shutdown()), m_display, SLOT(stopDrawing()));
|
||||||
|
|
Loading…
Reference in New Issue