From afe2f96474a256ccb366d8272bd87911020a00a7 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Wed, 18 Mar 2020 22:27:45 +1000 Subject: [PATCH] Qt: Fix display not updating after resize when paused Fixes #104. --- src/duckstation-qt/qtdisplaywidget.h | 2 -- src/duckstation-qt/qthostinterface.cpp | 31 +++++++++++++++++--------- src/duckstation-qt/qthostinterface.h | 1 + 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/duckstation-qt/qtdisplaywidget.h b/src/duckstation-qt/qtdisplaywidget.h index f3f9a80f1..b900f1445 100644 --- a/src/duckstation-qt/qtdisplaywidget.h +++ b/src/duckstation-qt/qtdisplaywidget.h @@ -24,8 +24,6 @@ public: virtual bool initializeDeviceContext(bool debug_device); virtual void destroyDeviceContext(); - virtual void Render() = 0; - // this comes back on the emu thread virtual void windowResized(s32 new_window_width, s32 new_window_height); diff --git a/src/duckstation-qt/qthostinterface.cpp b/src/duckstation-qt/qthostinterface.cpp index 75ee59e5f..51095b5b1 100644 --- a/src/duckstation-qt/qthostinterface.cpp +++ b/src/duckstation-qt/qthostinterface.cpp @@ -214,8 +214,14 @@ void QtHostInterface::handleKeyEvent(int key, bool pressed) void QtHostInterface::onDisplayWidgetResized(int width, int height) { // this can be null if it was destroyed and the main thread is late catching up - if (m_display_widget) - m_display_widget->windowResized(width, height); + if (!m_display_widget) + return; + + m_display_widget->windowResized(width, height); + + // re-render the display, since otherwise it will be out of date and stretched if paused + if (m_system) + renderDisplay(); } bool QtHostInterface::AcquireHostDisplay() @@ -699,14 +705,7 @@ void QtHostInterface::threadEntryPoint() m_system->RunFrame(); - m_system->GetGPU()->ResetGraphicsAPIState(); - - DrawDebugWindows(); - DrawOSDMessages(); - - m_display->Render(); - - m_system->GetGPU()->RestoreGraphicsAPIState(); + renderDisplay(); if (m_speed_limiter_enabled) m_system->Throttle(); @@ -727,6 +726,18 @@ void QtHostInterface::threadEntryPoint() moveToThread(m_original_thread); } +void QtHostInterface::renderDisplay() +{ + m_system->GetGPU()->ResetGraphicsAPIState(); + + DrawDebugWindows(); + DrawOSDMessages(); + + m_display->Render(); + + m_system->GetGPU()->RestoreGraphicsAPIState(); +} + void QtHostInterface::wakeThread() { if (isOnWorkerThread()) diff --git a/src/duckstation-qt/qthostinterface.h b/src/duckstation-qt/qthostinterface.h index 3502aa525..d0c4b92fa 100644 --- a/src/duckstation-qt/qthostinterface.h +++ b/src/duckstation-qt/qthostinterface.h @@ -157,6 +157,7 @@ private: void createThread(); void stopThread(); void threadEntryPoint(); + void renderDisplay(); void wakeThread(); QSettings m_qsettings;