mirror of https://github.com/mgba-emu/mgba.git
Qt: Fix OSD on modern macOS (fixes #2736)
This commit is contained in:
parent
fc35395ab8
commit
eb7b90e5d9
1
CHANGES
1
CHANGES
|
@ -25,6 +25,7 @@ Other fixes:
|
||||||
- Qt: Fix full-buffer rewind
|
- Qt: Fix full-buffer rewind
|
||||||
- Qt: Fix crash if loading a shader fails
|
- Qt: Fix crash if loading a shader fails
|
||||||
- Qt: Fix black screen when starting with a game (fixes mgba.io/i/2781)
|
- Qt: Fix black screen when starting with a game (fixes mgba.io/i/2781)
|
||||||
|
- Qt: Fix OSD on modern macOS (fixes mgba.io/i/2736)
|
||||||
- Scripting: Fix receiving packets for client sockets
|
- Scripting: Fix receiving packets for client sockets
|
||||||
- Scripting: Fix empty receive calls returning unknown error on Windows
|
- Scripting: Fix empty receive calls returning unknown error on Windows
|
||||||
Misc:
|
Misc:
|
||||||
|
|
|
@ -70,6 +70,10 @@ mGLWidget::mGLWidget(QWidget* parent)
|
||||||
connect(&m_refresh, &QTimer::timeout, this, static_cast<void (QWidget::*)()>(&QWidget::update));
|
connect(&m_refresh, &QTimer::timeout, this, static_cast<void (QWidget::*)()>(&QWidget::update));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mGLWidget::~mGLWidget() {
|
||||||
|
// This is needed for unique_ptr<QOpenGLPaintDevice> to work
|
||||||
|
}
|
||||||
|
|
||||||
void mGLWidget::initializeGL() {
|
void mGLWidget::initializeGL() {
|
||||||
m_vao = std::make_unique<QOpenGLVertexArrayObject>();
|
m_vao = std::make_unique<QOpenGLVertexArrayObject>();
|
||||||
m_vao->create();
|
m_vao->create();
|
||||||
|
@ -99,6 +103,8 @@ void mGLWidget::initializeGL() {
|
||||||
|
|
||||||
m_vaoDone = false;
|
m_vaoDone = false;
|
||||||
m_tex = 0;
|
m_tex = 0;
|
||||||
|
|
||||||
|
m_paintDev = std::make_unique<QOpenGLPaintDevice>();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mGLWidget::finalizeVAO() {
|
bool mGLWidget::finalizeVAO() {
|
||||||
|
@ -150,6 +156,23 @@ void mGLWidget::paintGL() {
|
||||||
} else {
|
} else {
|
||||||
m_refresh.start(17);
|
m_refresh.start(17);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_showOSD && m_messagePainter) {
|
||||||
|
qreal r = window()->devicePixelRatio();
|
||||||
|
m_paintDev->setDevicePixelRatio(r);
|
||||||
|
m_paintDev->setSize(size() * r);
|
||||||
|
QPainter painter(m_paintDev.get());
|
||||||
|
m_messagePainter->paint(&painter);
|
||||||
|
painter.end();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void mGLWidget::setMessagePainter(MessagePainter* messagePainter) {
|
||||||
|
m_messagePainter = messagePainter;
|
||||||
|
}
|
||||||
|
|
||||||
|
void mGLWidget::setShowOSD(bool showOSD) {
|
||||||
|
m_showOSD = showOSD;
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplayGL::DisplayGL(const QSurfaceFormat& format, QWidget* parent)
|
DisplayGL::DisplayGL(const QSurfaceFormat& format, QWidget* parent)
|
||||||
|
@ -170,6 +193,7 @@ DisplayGL::DisplayGL(const QSurfaceFormat& format, QWidget* parent)
|
||||||
m_gl = new mGLWidget;
|
m_gl = new mGLWidget;
|
||||||
m_gl->setAttribute(Qt::WA_NativeWindow);
|
m_gl->setAttribute(Qt::WA_NativeWindow);
|
||||||
m_gl->setFormat(format);
|
m_gl->setFormat(format);
|
||||||
|
m_gl->setMessagePainter(messagePainter());
|
||||||
QBoxLayout* layout = new QVBoxLayout;
|
QBoxLayout* layout = new QVBoxLayout;
|
||||||
layout->addWidget(m_gl);
|
layout->addWidget(m_gl);
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
@ -372,6 +396,9 @@ void DisplayGL::interframeBlending(bool enable) {
|
||||||
|
|
||||||
void DisplayGL::showOSDMessages(bool enable) {
|
void DisplayGL::showOSDMessages(bool enable) {
|
||||||
Display::showOSDMessages(enable);
|
Display::showOSDMessages(enable);
|
||||||
|
if (m_gl) {
|
||||||
|
m_gl->setShowOSD(enable);
|
||||||
|
}
|
||||||
QMetaObject::invokeMethod(m_painter.get(), "showOSD", Q_ARG(bool, enable));
|
QMetaObject::invokeMethod(m_painter.get(), "showOSD", Q_ARG(bool, enable));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -525,7 +552,9 @@ void PainterGL::create() {
|
||||||
mGLES2Context* gl2Backend;
|
mGLES2Context* gl2Backend;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (!m_widget) {
|
||||||
m_paintDev = std::make_unique<QOpenGLPaintDevice>();
|
m_paintDev = std::make_unique<QOpenGLPaintDevice>();
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(BUILD_GLES2) || defined(BUILD_GLES3)
|
#if defined(BUILD_GLES2) || defined(BUILD_GLES3)
|
||||||
if (m_supportsShaders) {
|
if (m_supportsShaders) {
|
||||||
|
@ -650,8 +679,10 @@ void PainterGL::setMessagePainter(MessagePainter* messagePainter) {
|
||||||
void PainterGL::resize(const QSize& size) {
|
void PainterGL::resize(const QSize& size) {
|
||||||
qreal r = m_window->devicePixelRatio();
|
qreal r = m_window->devicePixelRatio();
|
||||||
m_size = size;
|
m_size = size;
|
||||||
|
if (m_paintDev) {
|
||||||
m_paintDev->setSize(m_size * r);
|
m_paintDev->setSize(m_size * r);
|
||||||
m_paintDev->setDevicePixelRatio(r);
|
m_paintDev->setDevicePixelRatio(r);
|
||||||
|
}
|
||||||
if (m_started && !m_active) {
|
if (m_started && !m_active) {
|
||||||
forceDraw();
|
forceDraw();
|
||||||
}
|
}
|
||||||
|
@ -818,7 +849,7 @@ void PainterGL::performDraw() {
|
||||||
m_backend->postFrame(m_backend, m_buffer);
|
m_backend->postFrame(m_backend, m_buffer);
|
||||||
}
|
}
|
||||||
m_backend->drawFrame(m_backend);
|
m_backend->drawFrame(m_backend);
|
||||||
if (m_showOSD && m_messagePainter && !glContextHasBug(OpenGLBug::IG4ICD_CRASH)) {
|
if (m_showOSD && m_messagePainter && m_paintDev && !glContextHasBug(OpenGLBug::IG4ICD_CRASH)) {
|
||||||
m_painter.begin(m_paintDev.get());
|
m_painter.begin(m_paintDev.get());
|
||||||
m_messagePainter->paint(&m_painter);
|
m_messagePainter->paint(&m_painter);
|
||||||
m_painter.end();
|
m_painter.end();
|
||||||
|
|
|
@ -51,9 +51,12 @@ Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
mGLWidget(QWidget* parent = nullptr);
|
mGLWidget(QWidget* parent = nullptr);
|
||||||
|
~mGLWidget();
|
||||||
|
|
||||||
void setTex(GLuint tex) { m_tex = tex; }
|
void setTex(GLuint tex) { m_tex = tex; }
|
||||||
void setVBO(GLuint vbo) { m_vbo = vbo; }
|
void setVBO(GLuint vbo) { m_vbo = vbo; }
|
||||||
|
void setMessagePainter(MessagePainter*);
|
||||||
|
void setShowOSD(bool showOSD);
|
||||||
bool finalizeVAO();
|
bool finalizeVAO();
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
|
@ -72,6 +75,9 @@ private:
|
||||||
|
|
||||||
QTimer m_refresh;
|
QTimer m_refresh;
|
||||||
int m_refreshResidue = 0;
|
int m_refreshResidue = 0;
|
||||||
|
std::unique_ptr<QOpenGLPaintDevice> m_paintDev;
|
||||||
|
MessagePainter* m_messagePainter = nullptr;
|
||||||
|
bool m_showOSD = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PainterGL;
|
class PainterGL;
|
||||||
|
|
Loading…
Reference in New Issue