HostInterface: Refresh display on settings change/state load

This commit is contained in:
Connor McLaughlin 2021-07-11 14:01:04 +10:00
parent bf63be27c6
commit 05259bc851
4 changed files with 24 additions and 13 deletions

View file

@ -429,6 +429,7 @@ bool HostInterface::LoadState(const char* filename)
System::ResetPerformanceCounters(); System::ResetPerformanceCounters();
System::ResetThrottler(); System::ResetThrottler();
OnDisplayInvalidated();
return true; return true;
} }
@ -463,6 +464,8 @@ void HostInterface::OnSystemDestroyed() {}
void HostInterface::OnSystemPerformanceCountersUpdated() {} void HostInterface::OnSystemPerformanceCountersUpdated() {}
void HostInterface::OnDisplayInvalidated() {}
void HostInterface::OnSystemStateSaved(bool global, s32 slot) {} void HostInterface::OnSystemStateSaved(bool global, s32 slot) {}
void HostInterface::OnRunningGameChanged(const std::string& path, CDImage* image, const std::string& game_code, void HostInterface::OnRunningGameChanged(const std::string& path, CDImage* image, const std::string& game_code,
@ -817,6 +820,7 @@ void HostInterface::CheckForSettingsChanges(const Settings& old_settings)
g_settings.runahead_frames != old_settings.runahead_frames) g_settings.runahead_frames != old_settings.runahead_frames)
{ {
g_gpu->UpdateSettings(); g_gpu->UpdateSettings();
OnDisplayInvalidated();
} }
if (g_settings.gpu_widescreen_hack != old_settings.gpu_widescreen_hack || if (g_settings.gpu_widescreen_hack != old_settings.gpu_widescreen_hack ||
@ -906,16 +910,14 @@ void HostInterface::CheckForSettingsChanges(const Settings& old_settings)
if (g_settings.multitap_mode != old_settings.multitap_mode) if (g_settings.multitap_mode != old_settings.multitap_mode)
System::UpdateMultitaps(); System::UpdateMultitaps();
if (m_display) if (m_display && g_settings.display_linear_filtering != old_settings.display_linear_filtering ||
g_settings.display_integer_scaling != old_settings.display_integer_scaling ||
g_settings.display_stretch != old_settings.display_stretch)
{ {
if (g_settings.display_linear_filtering != old_settings.display_linear_filtering)
m_display->SetDisplayLinearFiltering(g_settings.display_linear_filtering); m_display->SetDisplayLinearFiltering(g_settings.display_linear_filtering);
if (g_settings.display_integer_scaling != old_settings.display_integer_scaling)
m_display->SetDisplayIntegerScaling(g_settings.display_integer_scaling); m_display->SetDisplayIntegerScaling(g_settings.display_integer_scaling);
if (g_settings.display_stretch != old_settings.display_stretch)
m_display->SetDisplayStretch(g_settings.display_stretch); m_display->SetDisplayStretch(g_settings.display_stretch);
OnDisplayInvalidated();
} }
} }
@ -1100,6 +1102,7 @@ void HostInterface::ToggleSoftwareRendering()
AddFormattedOSDMessage(5.0f, TranslateString("OSDMessage", "Switching to %s renderer..."), AddFormattedOSDMessage(5.0f, TranslateString("OSDMessage", "Switching to %s renderer..."),
Settings::GetRendererDisplayName(new_renderer)); Settings::GetRendererDisplayName(new_renderer));
System::RecreateGPU(new_renderer); System::RecreateGPU(new_renderer);
OnDisplayInvalidated();
} }
void HostInterface::ModifyResolutionScale(s32 increment) void HostInterface::ModifyResolutionScale(s32 increment)
@ -1117,6 +1120,7 @@ void HostInterface::ModifyResolutionScale(s32 increment)
g_gpu->UpdateSettings(); g_gpu->UpdateSettings();
g_gpu->ResetGraphicsAPIState(); g_gpu->ResetGraphicsAPIState();
System::ClearMemorySaveStates(); System::ClearMemorySaveStates();
OnDisplayInvalidated();
} }
} }
@ -1181,6 +1185,7 @@ void HostInterface::RecreateSystem()
System::ResetPerformanceCounters(); System::ResetPerformanceCounters();
System::ResetThrottler(); System::ResetThrottler();
OnDisplayInvalidated();
} }
void HostInterface::SetMouseMode(bool relative, bool hide_cursor) {} void HostInterface::SetMouseMode(bool relative, bool hide_cursor) {}

View file

@ -150,6 +150,9 @@ public:
const std::string& game_title); const std::string& game_title);
virtual void OnSystemPerformanceCountersUpdated(); virtual void OnSystemPerformanceCountersUpdated();
/// Called when the display is invalidated (e.g. a state is loaded).
virtual void OnDisplayInvalidated();
protected: protected:
virtual bool AcquireHostDisplay() = 0; virtual bool AcquireHostDisplay() = 0;
virtual void ReleaseHostDisplay() = 0; virtual void ReleaseHostDisplay() = 0;

View file

@ -1322,8 +1322,6 @@ void QtHostInterface::loadState(const QString& filename)
emit emulationStarting(); emit emulationStarting();
LoadState(filename.toStdString().c_str()); LoadState(filename.toStdString().c_str());
if (System::IsValid())
renderDisplay();
} }
void QtHostInterface::loadState(bool global, qint32 slot) void QtHostInterface::loadState(bool global, qint32 slot)
@ -1335,8 +1333,6 @@ void QtHostInterface::loadState(bool global, qint32 slot)
} }
LoadState(global, slot); LoadState(global, slot);
if (System::IsValid())
renderDisplay();
} }
void QtHostInterface::saveState(const QString& filename, bool block_until_done /* = false */) void QtHostInterface::saveState(const QString& filename, bool block_until_done /* = false */)
@ -1533,6 +1529,12 @@ void QtHostInterface::OnAchievementsRefreshed()
Cheevos::GetMaximumPointsForGame()); Cheevos::GetMaximumPointsForGame());
#endif #endif
} }
void QtHostInterface::OnDisplayInvalidated()
{
renderDisplay();
}
void QtHostInterface::doBackgroundControllerPoll() void QtHostInterface::doBackgroundControllerPoll()
{ {
PollAndUpdate(); PollAndUpdate();

View file

@ -185,6 +185,7 @@ public Q_SLOTS:
void requestRenderWindowScale(qreal scale); void requestRenderWindowScale(qreal scale);
void executeOnEmulationThread(std::function<void()> callback, bool wait = false); void executeOnEmulationThread(std::function<void()> callback, bool wait = false);
void OnAchievementsRefreshed() override; void OnAchievementsRefreshed() override;
void OnDisplayInvalidated() override;
private Q_SLOTS: private Q_SLOTS:
void doStopThread(); void doStopThread();