Qt: Move painter interrupting to main thread

This commit is contained in:
Vicki Pfau 2021-03-25 23:29:04 -07:00
parent 4af5238a3b
commit bcb77d0656
2 changed files with 12 additions and 5 deletions

View File

@ -7,8 +7,6 @@
#if defined(BUILD_GL) || defined(BUILD_GLES2) #if defined(BUILD_GL) || defined(BUILD_GLES2)
#include "CoreController.h"
#include <QApplication> #include <QApplication>
#include <QMutexLocker> #include <QMutexLocker>
#include <QOffscreenSurface> #include <QOffscreenSurface>
@ -103,6 +101,7 @@ void DisplayGL::startDrawing(std::shared_ptr<CoreController> controller) {
#else #else
messagePainter()->resize(size(), isAspectRatioLocked(), devicePixelRatio()); messagePainter()->resize(size(), isAspectRatioLocked(), devicePixelRatio());
#endif #endif
CoreController::Interrupter interrupter(controller);
QMetaObject::invokeMethod(m_painter.get(), "start"); QMetaObject::invokeMethod(m_painter.get(), "start");
setUpdatesEnabled(false); setUpdatesEnabled(false);
} }
@ -223,12 +222,13 @@ void DisplayGL::clearShaders() {
} }
void DisplayGL::resizeContext() { void DisplayGL::resizeContext() {
m_painter->interrupt();
QMetaObject::invokeMethod(m_painter.get(), "resizeContext"); QMetaObject::invokeMethod(m_painter.get(), "resizeContext");
} }
void DisplayGL::setVideoScale(int scale) { void DisplayGL::setVideoScale(int scale) {
if (m_context) { if (m_context) {
CoreController::Interrupter interrupter(m_context); m_painter->interrupt();
mCoreConfigSetIntValue(&m_context->thread()->core->config, "videoScale", scale); mCoreConfigSetIntValue(&m_context->thread()->core->config, "videoScale", scale);
} }
QMetaObject::invokeMethod(m_painter.get(), "resizeContext"); QMetaObject::invokeMethod(m_painter.get(), "resizeContext");
@ -362,10 +362,10 @@ void PainterGL::resizeContext() {
} }
if (m_started) { if (m_started) {
CoreController::Interrupter interrupter(m_context);
mCore* core = m_context->thread()->core; mCore* core = m_context->thread()->core;
core->reloadConfigOption(core, "videoScale", NULL); core->reloadConfigOption(core, "videoScale", NULL);
} }
m_interrupter.resume();
QSize size = m_context->screenDimensions(); QSize size = m_context->screenDimensions();
m_backend->setDimensions(m_backend, size.width(), size.height()); m_backend->setDimensions(m_backend, size.width(), size.height());
@ -574,6 +574,10 @@ void PainterGL::setVideoProxy(std::shared_ptr<VideoProxy> proxy) {
m_videoProxy = proxy; m_videoProxy = proxy;
} }
void PainterGL::interrupt() {
m_interrupter.interrupt(m_context);
}
void PainterGL::setShaders(struct VDir* dir) { void PainterGL::setShaders(struct VDir* dir) {
if (!supportsShaders()) { if (!supportsShaders()) {
return; return;

View File

@ -29,6 +29,7 @@
#include <array> #include <array>
#include "CoreController.h"
#include "VideoProxy.h" #include "VideoProxy.h"
#include "platform/video-backend.h" #include "platform/video-backend.h"
@ -102,6 +103,7 @@ public:
bool supportsShaders() const { return m_supportsShaders; } bool supportsShaders() const { return m_supportsShaders; }
void setVideoProxy(std::shared_ptr<VideoProxy>); void setVideoProxy(std::shared_ptr<VideoProxy>);
void interrupt();
public slots: public slots:
void create(); void create();
@ -149,7 +151,8 @@ private:
std::unique_ptr<QOpenGLContext> m_gl; std::unique_ptr<QOpenGLContext> m_gl;
bool m_active = false; bool m_active = false;
bool m_started = 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_supportsShaders;
bool m_showOSD; bool m_showOSD;
VideoShader m_shader{}; VideoShader m_shader{};