Qt: Move painter interrupting to main thread
Vicki Pfau vi@endrift.com
Thu, 25 Mar 2021 23:29:04 -0700
2 files changed,
12 insertions(+),
5 deletions(-)
M
src/platform/qt/DisplayGL.cpp
→
src/platform/qt/DisplayGL.cpp
@@ -7,8 +7,6 @@ #include "DisplayGL.h"
#if defined(BUILD_GL) || defined(BUILD_GLES2) -#include "CoreController.h" - #include <QApplication> #include <QMutexLocker> #include <QOffscreenSurface>@@ -103,6 +101,7 @@ messagePainter()->resize(size(), isAspectRatioLocked(), devicePixelRatioF());
#else messagePainter()->resize(size(), isAspectRatioLocked(), devicePixelRatio()); #endif + CoreController::Interrupter interrupter(controller); QMetaObject::invokeMethod(m_painter.get(), "start"); setUpdatesEnabled(false); }@@ -223,12 +222,13 @@ QMetaObject::invokeMethod(m_painter.get(), "clearShaders", Qt::BlockingQueuedConnection);
} 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 @@ return;
} 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());@@ -572,6 +572,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) {
M
src/platform/qt/DisplayGL.h
→
src/platform/qt/DisplayGL.h
@@ -29,6 +29,7 @@ #include <QTimer>
#include <array> +#include "CoreController.h" #include "VideoProxy.h" #include "platform/video-backend.h"@@ -102,6 +103,7 @@
bool supportsShaders() const { return m_supportsShaders; } void setVideoProxy(std::shared_ptr<VideoProxy>); + void interrupt(); public slots: void create();@@ -149,7 +151,8 @@ std::unique_ptr<QOpenGLPaintDevice> m_window;
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{};