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::ResetThrottler();
OnDisplayInvalidated();
return true;
}
@ -463,6 +464,8 @@ void HostInterface::OnSystemDestroyed() {}
void HostInterface::OnSystemPerformanceCountersUpdated() {}
void HostInterface::OnDisplayInvalidated() {}
void HostInterface::OnSystemStateSaved(bool global, s32 slot) {}
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_gpu->UpdateSettings();
OnDisplayInvalidated();
}
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)
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);
if (g_settings.display_integer_scaling != old_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->SetDisplayLinearFiltering(g_settings.display_linear_filtering);
m_display->SetDisplayIntegerScaling(g_settings.display_integer_scaling);
m_display->SetDisplayStretch(g_settings.display_stretch);
OnDisplayInvalidated();
}
}
@ -1100,6 +1102,7 @@ void HostInterface::ToggleSoftwareRendering()
AddFormattedOSDMessage(5.0f, TranslateString("OSDMessage", "Switching to %s renderer..."),
Settings::GetRendererDisplayName(new_renderer));
System::RecreateGPU(new_renderer);
OnDisplayInvalidated();
}
void HostInterface::ModifyResolutionScale(s32 increment)
@ -1117,6 +1120,7 @@ void HostInterface::ModifyResolutionScale(s32 increment)
g_gpu->UpdateSettings();
g_gpu->ResetGraphicsAPIState();
System::ClearMemorySaveStates();
OnDisplayInvalidated();
}
}
@ -1181,6 +1185,7 @@ void HostInterface::RecreateSystem()
System::ResetPerformanceCounters();
System::ResetThrottler();
OnDisplayInvalidated();
}
void HostInterface::SetMouseMode(bool relative, bool hide_cursor) {}

View File

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

View File

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

View File

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