From bcb77d0656ac933f4d317d94627a1951d1d2f117 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Thu, 25 Mar 2021 23:29:04 -0700 Subject: [PATCH] Qt: Move painter interrupting to main thread --- src/platform/qt/DisplayGL.cpp | 12 ++++++++---- src/platform/qt/DisplayGL.h | 5 ++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/platform/qt/DisplayGL.cpp b/src/platform/qt/DisplayGL.cpp index d00218340..2838992f9 100644 --- a/src/platform/qt/DisplayGL.cpp +++ b/src/platform/qt/DisplayGL.cpp @@ -7,8 +7,6 @@ #if defined(BUILD_GL) || defined(BUILD_GLES2) -#include "CoreController.h" - #include #include #include @@ -103,6 +101,7 @@ void DisplayGL::startDrawing(std::shared_ptr 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 proxy) { m_videoProxy = proxy; } +void PainterGL::interrupt() { + m_interrupter.interrupt(m_context); +} + void PainterGL::setShaders(struct VDir* dir) { if (!supportsShaders()) { return; diff --git a/src/platform/qt/DisplayGL.h b/src/platform/qt/DisplayGL.h index a5243a97a..a9ec10945 100644 --- a/src/platform/qt/DisplayGL.h +++ b/src/platform/qt/DisplayGL.h @@ -29,6 +29,7 @@ #include +#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); + void interrupt(); public slots: void create(); @@ -149,7 +151,8 @@ private: std::unique_ptr m_gl; bool m_active = false; bool m_started = false; - std::shared_ptr m_context = nullptr; + std::shared_ptr m_context; + CoreController::Interrupter m_interrupter; bool m_supportsShaders; bool m_showOSD; VideoShader m_shader{};