mirror of https://github.com/mgba-emu/mgba.git
Qt: Move painter interrupting to main thread
This commit is contained in:
parent
4af5238a3b
commit
bcb77d0656
|
@ -7,8 +7,6 @@
|
|||
|
||||
#if defined(BUILD_GL) || defined(BUILD_GLES2)
|
||||
|
||||
#include "CoreController.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QMutexLocker>
|
||||
#include <QOffscreenSurface>
|
||||
|
@ -103,6 +101,7 @@ void DisplayGL::startDrawing(std::shared_ptr<CoreController> controller) {
|
|||
#else
|
||||
messagePainter()->resize(size(), isAspectRatioLocked(), devicePixelRatio());
|
||||
#endif
|
||||
CoreController::Interrupter interrupter(controller);
|
||||
QMetaObject::invokeMethod(m_painter.get(), "start");
|
||||
setUpdatesEnabled(false);
|
||||
}
|
||||
|
@ -223,12 +222,13 @@ void DisplayGL::clearShaders() {
|
|||
}
|
||||
|
||||
void DisplayGL::resizeContext() {
|
||||
m_painter->interrupt();
|
||||
QMetaObject::invokeMethod(m_painter.get(), "resizeContext");
|
||||
}
|
||||
|
||||
void DisplayGL::setVideoScale(int scale) {
|
||||
if (m_context) {
|
||||
CoreController::Interrupter interrupter(m_context);
|
||||
m_painter->interrupt();
|
||||
mCoreConfigSetIntValue(&m_context->thread()->core->config, "videoScale", scale);
|
||||
}
|
||||
QMetaObject::invokeMethod(m_painter.get(), "resizeContext");
|
||||
|
@ -362,10 +362,10 @@ void PainterGL::resizeContext() {
|
|||
}
|
||||
|
||||
if (m_started) {
|
||||
CoreController::Interrupter interrupter(m_context);
|
||||
mCore* core = m_context->thread()->core;
|
||||
core->reloadConfigOption(core, "videoScale", NULL);
|
||||
}
|
||||
m_interrupter.resume();
|
||||
|
||||
QSize size = m_context->screenDimensions();
|
||||
m_backend->setDimensions(m_backend, size.width(), size.height());
|
||||
|
@ -574,6 +574,10 @@ void PainterGL::setVideoProxy(std::shared_ptr<VideoProxy> proxy) {
|
|||
m_videoProxy = proxy;
|
||||
}
|
||||
|
||||
void PainterGL::interrupt() {
|
||||
m_interrupter.interrupt(m_context);
|
||||
}
|
||||
|
||||
void PainterGL::setShaders(struct VDir* dir) {
|
||||
if (!supportsShaders()) {
|
||||
return;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include <array>
|
||||
|
||||
#include "CoreController.h"
|
||||
#include "VideoProxy.h"
|
||||
|
||||
#include "platform/video-backend.h"
|
||||
|
@ -102,6 +103,7 @@ public:
|
|||
bool supportsShaders() const { return m_supportsShaders; }
|
||||
|
||||
void setVideoProxy(std::shared_ptr<VideoProxy>);
|
||||
void interrupt();
|
||||
|
||||
public slots:
|
||||
void create();
|
||||
|
@ -149,7 +151,8 @@ private:
|
|||
std::unique_ptr<QOpenGLContext> m_gl;
|
||||
bool m_active = false;
|
||||
bool m_started = false;
|
||||
std::shared_ptr<CoreController> m_context = nullptr;
|
||||
std::shared_ptr<CoreController> m_context;
|
||||
CoreController::Interrupter m_interrupter;
|
||||
bool m_supportsShaders;
|
||||
bool m_showOSD;
|
||||
VideoShader m_shader{};
|
||||
|
|
Loading…
Reference in New Issue